author | Nikita Kozlov <nikita@beem-project.com> |
Fri, 15 Apr 2011 03:01:09 +0200 | |
changeset 938 | b2e1b45382a4 |
parent 882 | d1b0d878eac9 |
parent 931 | bcafceecd837 |
child 940 | 98d8df89c3d2 |
permissions | -rwxr-xr-x |
577 | 1 |
/* |
567 | 2 |
BEEM is a videoconference application on the Android Platform. |
3 |
||
4 |
Copyright (C) 2009 by Frederic-Charles Barthelery, |
|
5 |
Jean-Manuel Da Silva, |
|
6 |
Nikita Kozlov, |
|
7 |
Philippe Lago, |
|
8 |
Jean Baptiste Vergely, |
|
577 | 9 |
Vincent Veronis. |
567 | 10 |
|
11 |
This file is part of BEEM. |
|
12 |
||
13 |
BEEM is free software: you can redistribute it and/or modify |
|
14 |
it under the terms of the GNU General Public License as published by |
|
15 |
the Free Software Foundation, either version 3 of the License, or |
|
16 |
(at your option) any later version. |
|
17 |
||
18 |
BEEM is distributed in the hope that it will be useful, |
|
19 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21 |
GNU General Public License for more details. |
|
22 |
||
23 |
You should have received a copy of the GNU General Public License |
|
24 |
along with BEEM. If not, see <http://www.gnu.org/licenses/>. |
|
25 |
||
26 |
Please send bug reports with examples or suggestions to |
|
27 |
contact@beem-project.com or http://dev.beem-project.com/ |
|
28 |
||
577 | 29 |
Epitech, hereby disclaims all copyright interest in the program "Beem" |
567 | 30 |
written by Frederic-Charles Barthelery, |
31 |
Jean-Manuel Da Silva, |
|
32 |
Nikita Kozlov, |
|
33 |
Philippe Lago, |
|
34 |
Jean Baptiste Vergely, |
|
35 |
Vincent Veronis. |
|
36 |
||
37 |
Nicolas Sadirac, November 26, 2009 |
|
38 |
President of Epitech. |
|
39 |
||
40 |
Flavien Astraud, November 26, 2009 |
|
41 |
Head of the EIP Laboratory. |
|
42 |
||
708
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
43 |
*/ |
55
66732dd2cb77
Add an interface for sending im message.
Da Risk <darisk972@gmail.com>
parents:
diff
changeset
|
44 |
package com.beem.project.beem.service; |
66732dd2cb77
Add an interface for sending im message.
Da Risk <darisk972@gmail.com>
parents:
diff
changeset
|
45 |
|
882 | 46 |
import java.io.File; |
508
7d8da3df2907
Ajout d'un chat switcher dans l'activite Chat.
Jean-Manuel Da Silva <dasilvj at gmail dot com>
parents:
503
diff
changeset
|
47 |
import java.util.ArrayList; |
55
66732dd2cb77
Add an interface for sending im message.
Da Risk <darisk972@gmail.com>
parents:
diff
changeset
|
48 |
import java.util.HashMap; |
508
7d8da3df2907
Ajout d'un chat switcher dans l'activite Chat.
Jean-Manuel Da Silva <dasilvj at gmail dot com>
parents:
503
diff
changeset
|
49 |
import java.util.List; |
55
66732dd2cb77
Add an interface for sending im message.
Da Risk <darisk972@gmail.com>
parents:
diff
changeset
|
50 |
import java.util.Map; |
66732dd2cb77
Add an interface for sending im message.
Da Risk <darisk972@gmail.com>
parents:
diff
changeset
|
51 |
|
66732dd2cb77
Add an interface for sending im message.
Da Risk <darisk972@gmail.com>
parents:
diff
changeset
|
52 |
import org.jivesoftware.smack.Chat; |
66732dd2cb77
Add an interface for sending im message.
Da Risk <darisk972@gmail.com>
parents:
diff
changeset
|
53 |
import org.jivesoftware.smack.ChatManager; |
66732dd2cb77
Add an interface for sending im message.
Da Risk <darisk972@gmail.com>
parents:
diff
changeset
|
54 |
import org.jivesoftware.smack.ChatManagerListener; |
66732dd2cb77
Add an interface for sending im message.
Da Risk <darisk972@gmail.com>
parents:
diff
changeset
|
55 |
|
118
8bbe46055004
fix some bugs. When you receive a new chat, a notification appears.
Da Risk <darisk972@gmail.com>
parents:
108
diff
changeset
|
56 |
import android.app.Notification; |
8bbe46055004
fix some bugs. When you receive a new chat, a notification appears.
Da Risk <darisk972@gmail.com>
parents:
108
diff
changeset
|
57 |
import android.app.PendingIntent; |
8bbe46055004
fix some bugs. When you receive a new chat, a notification appears.
Da Risk <darisk972@gmail.com>
parents:
108
diff
changeset
|
58 |
import android.content.Intent; |
706
bc47c8518bfd
some notification preferences
Nikita Kozlov <nikita@beem-project.com>
parents:
685
diff
changeset
|
59 |
import android.content.SharedPreferences; |
882 | 60 |
import android.os.Environment; |
55
66732dd2cb77
Add an interface for sending im message.
Da Risk <darisk972@gmail.com>
parents:
diff
changeset
|
61 |
import android.os.RemoteCallbackList; |
66732dd2cb77
Add an interface for sending im message.
Da Risk <darisk972@gmail.com>
parents:
diff
changeset
|
62 |
import android.os.RemoteException; |
706
bc47c8518bfd
some notification preferences
Nikita Kozlov <nikita@beem-project.com>
parents:
685
diff
changeset
|
63 |
import android.preference.PreferenceManager; |
55
66732dd2cb77
Add an interface for sending im message.
Da Risk <darisk972@gmail.com>
parents:
diff
changeset
|
64 |
import android.util.Log; |
66732dd2cb77
Add an interface for sending im message.
Da Risk <darisk972@gmail.com>
parents:
diff
changeset
|
65 |
|
853 | 66 |
import com.beem.project.beem.BeemApplication; |
118
8bbe46055004
fix some bugs. When you receive a new chat, a notification appears.
Da Risk <darisk972@gmail.com>
parents:
108
diff
changeset
|
67 |
import com.beem.project.beem.BeemService; |
178 | 68 |
import com.beem.project.beem.R; |
55
66732dd2cb77
Add an interface for sending im message.
Da Risk <darisk972@gmail.com>
parents:
diff
changeset
|
69 |
import com.beem.project.beem.service.aidl.IChat; |
66732dd2cb77
Add an interface for sending im message.
Da Risk <darisk972@gmail.com>
parents:
diff
changeset
|
70 |
import com.beem.project.beem.service.aidl.IChatManager; |
66732dd2cb77
Add an interface for sending im message.
Da Risk <darisk972@gmail.com>
parents:
diff
changeset
|
71 |
import com.beem.project.beem.service.aidl.IChatManagerListener; |
66732dd2cb77
Add an interface for sending im message.
Da Risk <darisk972@gmail.com>
parents:
diff
changeset
|
72 |
import com.beem.project.beem.service.aidl.IMessageListener; |
508
7d8da3df2907
Ajout d'un chat switcher dans l'activite Chat.
Jean-Manuel Da Silva <dasilvj at gmail dot com>
parents:
503
diff
changeset
|
73 |
import com.beem.project.beem.service.aidl.IRoster; |
55
66732dd2cb77
Add an interface for sending im message.
Da Risk <darisk972@gmail.com>
parents:
diff
changeset
|
74 |
|
66732dd2cb77
Add an interface for sending im message.
Da Risk <darisk972@gmail.com>
parents:
diff
changeset
|
75 |
/** |
503
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
76 |
* An adapter for smack's ChatManager. This class provides functionnality to handle chats. |
55
66732dd2cb77
Add an interface for sending im message.
Da Risk <darisk972@gmail.com>
parents:
diff
changeset
|
77 |
* @author darisk |
66732dd2cb77
Add an interface for sending im message.
Da Risk <darisk972@gmail.com>
parents:
diff
changeset
|
78 |
*/ |
66732dd2cb77
Add an interface for sending im message.
Da Risk <darisk972@gmail.com>
parents:
diff
changeset
|
79 |
public class BeemChatManager extends IChatManager.Stub { |
740
a91db9ddc46f
Fixes a little bug in contactlist activity.
Da Risk <darisk972@gmail.com>
parents:
714
diff
changeset
|
80 |
|
a91db9ddc46f
Fixes a little bug in contactlist activity.
Da Risk <darisk972@gmail.com>
parents:
714
diff
changeset
|
81 |
private static final String TAG = "BeemChatManager"; |
503
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
82 |
private final ChatManager mAdaptee; |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
83 |
private final Map<String, ChatAdapter> mChats = new HashMap<String, ChatAdapter>(); |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
84 |
private final ChatListener mChatListener = new ChatListener(); |
708
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
85 |
private final RemoteCallbackList<IChatManagerListener> mRemoteChatCreationListeners = |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
86 |
new RemoteCallbackList<IChatManagerListener>(); |
503
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
87 |
private final BeemService mService; |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
88 |
|
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
89 |
/** |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
90 |
* Constructor. |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
91 |
* @param chatManager the smack ChatManager to adapt |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
92 |
* @param service the service which runs the chat manager |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
93 |
*/ |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
94 |
public BeemChatManager(final ChatManager chatManager, final BeemService service) { |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
95 |
mService = service; |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
96 |
mAdaptee = chatManager; |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
97 |
mAdaptee.addChatListener(mChatListener); |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
98 |
} |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
99 |
|
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
100 |
@Override |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
101 |
public void addChatCreationListener(IChatManagerListener listener) throws RemoteException { |
584
72d9d76900af
Fix many bugs and memory leak
Da Risk <darisk972@gmail.com>
parents:
577
diff
changeset
|
102 |
if (listener != null) |
72d9d76900af
Fix many bugs and memory leak
Da Risk <darisk972@gmail.com>
parents:
577
diff
changeset
|
103 |
mRemoteChatCreationListeners.register(listener); |
503
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
104 |
} |
212 | 105 |
|
503
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
106 |
/** |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
107 |
* Create a chat session. |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
108 |
* @param contact the contact you want to chat with |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
109 |
* @param listener listener to use for chat events on this chat session |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
110 |
* @return the chat session |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
111 |
*/ |
584
72d9d76900af
Fix many bugs and memory leak
Da Risk <darisk972@gmail.com>
parents:
577
diff
changeset
|
112 |
@Override |
503
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
113 |
public IChat createChat(Contact contact, IMessageListener listener) { |
714
40190c2be90b
some improvement in resource management, ready to test
Nikita Kozlov <nikita@beem-project.com>
parents:
713
diff
changeset
|
114 |
String jid = contact.getJIDWithRes(); |
40190c2be90b
some improvement in resource management, ready to test
Nikita Kozlov <nikita@beem-project.com>
parents:
713
diff
changeset
|
115 |
Log.d(TAG, "Get chat key1 = "); |
40190c2be90b
some improvement in resource management, ready to test
Nikita Kozlov <nikita@beem-project.com>
parents:
713
diff
changeset
|
116 |
|
503
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
117 |
return createChat(jid, listener); |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
118 |
} |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
119 |
|
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
120 |
/** |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
121 |
* Create a chat session. |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
122 |
* @param jid the jid of the contact you want to chat with |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
123 |
* @param listener listener to use for chat events on this chat session |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
124 |
* @return the chat session |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
125 |
*/ |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
126 |
public IChat createChat(String jid, IMessageListener listener) { |
713
b4333628a4a3
beginning on chat by resource integration and a small fix for the TrustStore
Nikita Kozlov <nikita@beem-project.com>
parents:
708
diff
changeset
|
127 |
String key = jid; |
584
72d9d76900af
Fix many bugs and memory leak
Da Risk <darisk972@gmail.com>
parents:
577
diff
changeset
|
128 |
ChatAdapter result; |
714
40190c2be90b
some improvement in resource management, ready to test
Nikita Kozlov <nikita@beem-project.com>
parents:
713
diff
changeset
|
129 |
Log.d(TAG, "Get chat key2 = "); |
503
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
130 |
if (mChats.containsKey(key)) { |
584
72d9d76900af
Fix many bugs and memory leak
Da Risk <darisk972@gmail.com>
parents:
577
diff
changeset
|
131 |
result = mChats.get(key); |
72d9d76900af
Fix many bugs and memory leak
Da Risk <darisk972@gmail.com>
parents:
577
diff
changeset
|
132 |
result.addMessageListener(listener); |
72d9d76900af
Fix many bugs and memory leak
Da Risk <darisk972@gmail.com>
parents:
577
diff
changeset
|
133 |
return result; |
501
d52918cfaba7
Corrections des problèmes de l´activité Chat.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
500
diff
changeset
|
134 |
} |
584
72d9d76900af
Fix many bugs and memory leak
Da Risk <darisk972@gmail.com>
parents:
577
diff
changeset
|
135 |
Chat c = mAdaptee.createChat(key, null); |
660
2cec95b3068f
Fix a little bug with chat notifications
Da Risk <darisk972@gmail.com>
parents:
622
diff
changeset
|
136 |
// maybe a little probleme of thread synchronization |
2cec95b3068f
Fix a little bug with chat notifications
Da Risk <darisk972@gmail.com>
parents:
622
diff
changeset
|
137 |
// if so use an HashTable instead of a HashMap for mChats |
2cec95b3068f
Fix a little bug with chat notifications
Da Risk <darisk972@gmail.com>
parents:
622
diff
changeset
|
138 |
result = getChat(c); |
584
72d9d76900af
Fix many bugs and memory leak
Da Risk <darisk972@gmail.com>
parents:
577
diff
changeset
|
139 |
result.addMessageListener(listener); |
72d9d76900af
Fix many bugs and memory leak
Da Risk <darisk972@gmail.com>
parents:
577
diff
changeset
|
140 |
return result; |
503
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
141 |
} |
212 | 142 |
|
503
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
143 |
/** |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
144 |
* {@inheritDoc} |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
145 |
*/ |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
146 |
@Override |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
147 |
public void destroyChat(IChat chat) throws RemoteException { |
592
1a929f74b5e0
Fix little bug with chat notification
Da Risk <darisk972@gmail.com>
parents:
588
diff
changeset
|
148 |
// Can't remove it. otherwise we will lose all futur message in this chat |
1a929f74b5e0
Fix little bug with chat notification
Da Risk <darisk972@gmail.com>
parents:
588
diff
changeset
|
149 |
// chat.removeMessageListener(mChatListener); |
674
af23f43cf6e3
Create the Chat only when we send or receive a message
Da Risk <darisk972@gmail.com>
parents:
660
diff
changeset
|
150 |
if (chat == null) |
af23f43cf6e3
Create the Chat only when we send or receive a message
Da Risk <darisk972@gmail.com>
parents:
660
diff
changeset
|
151 |
return; |
592
1a929f74b5e0
Fix little bug with chat notification
Da Risk <darisk972@gmail.com>
parents:
588
diff
changeset
|
152 |
deleteChatNotification(chat); |
584
72d9d76900af
Fix many bugs and memory leak
Da Risk <darisk972@gmail.com>
parents:
577
diff
changeset
|
153 |
mChats.remove(chat.getParticipant().getJID()); |
503
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
154 |
} |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
155 |
|
586 | 156 |
/** |
157 |
* {@inheritDoc} |
|
567 | 158 |
*/ |
503
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
159 |
@Override |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
160 |
public void deleteChatNotification(IChat chat) { |
592
1a929f74b5e0
Fix little bug with chat notification
Da Risk <darisk972@gmail.com>
parents:
588
diff
changeset
|
161 |
try { |
1a929f74b5e0
Fix little bug with chat notification
Da Risk <darisk972@gmail.com>
parents:
588
diff
changeset
|
162 |
mService.deleteNotification(chat.getParticipant().getJID().hashCode()); |
1a929f74b5e0
Fix little bug with chat notification
Da Risk <darisk972@gmail.com>
parents:
588
diff
changeset
|
163 |
} catch (RemoteException e) { |
1a929f74b5e0
Fix little bug with chat notification
Da Risk <darisk972@gmail.com>
parents:
588
diff
changeset
|
164 |
Log.v(TAG, "Remote exception ", e); |
1a929f74b5e0
Fix little bug with chat notification
Da Risk <darisk972@gmail.com>
parents:
588
diff
changeset
|
165 |
} |
503
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
166 |
} |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
167 |
|
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
168 |
/** |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
169 |
* Get an existing ChatAdapter or create it if necessary. |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
170 |
* @param chat The real instance of smack chat |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
171 |
* @return a chat adapter register in the manager |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
172 |
*/ |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
173 |
private ChatAdapter getChat(Chat chat) { |
713
b4333628a4a3
beginning on chat by resource integration and a small fix for the TrustStore
Nikita Kozlov <nikita@beem-project.com>
parents:
708
diff
changeset
|
174 |
String key = chat.getParticipant(); |
503
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
175 |
if (mChats.containsKey(key)) { |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
176 |
return mChats.get(key); |
501
d52918cfaba7
Corrections des problèmes de l´activité Chat.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
500
diff
changeset
|
177 |
} |
503
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
178 |
ChatAdapter res = new ChatAdapter(chat); |
853 | 179 |
boolean history = PreferenceManager.getDefaultSharedPreferences(mService.getBaseContext()).getBoolean( |
180 |
"settings_key_history", false); |
|
181 |
String accountUser = PreferenceManager.getDefaultSharedPreferences(mService.getBaseContext()).getString( |
|
182 |
BeemApplication.ACCOUNT_USERNAME_KEY, ""); |
|
882 | 183 |
String historyPath = PreferenceManager.getDefaultSharedPreferences(mService.getBaseContext()).getString( |
184 |
BeemApplication.CHAT_HISTORY_KEY, ""); |
|
185 |
if ("".equals(historyPath)) historyPath = "/Android/data/com.beem.project.beem/chat/"; |
|
186 |
res.setHistory(history); |
|
853 | 187 |
res.setAccountUser(accountUser); |
882 | 188 |
res.setHistoryPath(new File(Environment.getExternalStorageDirectory(), historyPath)); |
772 | 189 |
Log.d(TAG, "getChat put " + key); |
503
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
190 |
mChats.put(key, res); |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
191 |
return res; |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
192 |
} |
419
88e1a96ee8da
Retrait des notifications quand on ouvre le chat d'une personne qui vient
Da Risk <darisk972@gmail.com>
parents:
360
diff
changeset
|
193 |
|
674
af23f43cf6e3
Create the Chat only when we send or receive a message
Da Risk <darisk972@gmail.com>
parents:
660
diff
changeset
|
194 |
@Override |
af23f43cf6e3
Create the Chat only when we send or receive a message
Da Risk <darisk972@gmail.com>
parents:
660
diff
changeset
|
195 |
public ChatAdapter getChat(Contact contact) { |
714
40190c2be90b
some improvement in resource management, ready to test
Nikita Kozlov <nikita@beem-project.com>
parents:
713
diff
changeset
|
196 |
String key = contact.getJIDWithRes(); |
674
af23f43cf6e3
Create the Chat only when we send or receive a message
Da Risk <darisk972@gmail.com>
parents:
660
diff
changeset
|
197 |
return mChats.get(key); |
af23f43cf6e3
Create the Chat only when we send or receive a message
Da Risk <darisk972@gmail.com>
parents:
660
diff
changeset
|
198 |
} |
af23f43cf6e3
Create the Chat only when we send or receive a message
Da Risk <darisk972@gmail.com>
parents:
660
diff
changeset
|
199 |
|
514
c5d0b38dd35f
Mise a jour de la JavaDoc et corrections des erreurs de CheckStyle.
Jean-Manuel Da Silva <dasilvj@gmail.com>
parents:
511
diff
changeset
|
200 |
/** |
c5d0b38dd35f
Mise a jour de la JavaDoc et corrections des erreurs de CheckStyle.
Jean-Manuel Da Silva <dasilvj@gmail.com>
parents:
511
diff
changeset
|
201 |
* This methods permits to retrieve the list of contacts who have an opened chat session with us. |
c5d0b38dd35f
Mise a jour de la JavaDoc et corrections des erreurs de CheckStyle.
Jean-Manuel Da Silva <dasilvj@gmail.com>
parents:
511
diff
changeset
|
202 |
* @return An List containing Contact instances. |
c5d0b38dd35f
Mise a jour de la JavaDoc et corrections des erreurs de CheckStyle.
Jean-Manuel Da Silva <dasilvj@gmail.com>
parents:
511
diff
changeset
|
203 |
* @throws RemoteException If a Binder remote-invocation error occurred. |
c5d0b38dd35f
Mise a jour de la JavaDoc et corrections des erreurs de CheckStyle.
Jean-Manuel Da Silva <dasilvj@gmail.com>
parents:
511
diff
changeset
|
204 |
*/ |
508
7d8da3df2907
Ajout d'un chat switcher dans l'activite Chat.
Jean-Manuel Da Silva <dasilvj at gmail dot com>
parents:
503
diff
changeset
|
205 |
public List<Contact> getOpenedChatList() throws RemoteException { |
7d8da3df2907
Ajout d'un chat switcher dans l'activite Chat.
Jean-Manuel Da Silva <dasilvj at gmail dot com>
parents:
503
diff
changeset
|
206 |
List<Contact> openedChats = new ArrayList<Contact>(); |
7d8da3df2907
Ajout d'un chat switcher dans l'activite Chat.
Jean-Manuel Da Silva <dasilvj at gmail dot com>
parents:
503
diff
changeset
|
207 |
IRoster mRoster = mService.getBind().getRoster(); |
514
c5d0b38dd35f
Mise a jour de la JavaDoc et corrections des erreurs de CheckStyle.
Jean-Manuel Da Silva <dasilvj@gmail.com>
parents:
511
diff
changeset
|
208 |
|
508
7d8da3df2907
Ajout d'un chat switcher dans l'activite Chat.
Jean-Manuel Da Silva <dasilvj at gmail dot com>
parents:
503
diff
changeset
|
209 |
for (ChatAdapter chat : mChats.values()) { |
622
b3e1e7e1fddd
The priority can be negative. Fix a little bug with the switch dialog
Da Risk <darisk972@gmail.com>
parents:
599
diff
changeset
|
210 |
if (chat.getMessages().size() > 0) { |
b3e1e7e1fddd
The priority can be negative. Fix a little bug with the switch dialog
Da Risk <darisk972@gmail.com>
parents:
599
diff
changeset
|
211 |
Contact t = mRoster.getContact(chat.getParticipant().getJID()); |
b3e1e7e1fddd
The priority can be negative. Fix a little bug with the switch dialog
Da Risk <darisk972@gmail.com>
parents:
599
diff
changeset
|
212 |
if (t == null) |
b3e1e7e1fddd
The priority can be negative. Fix a little bug with the switch dialog
Da Risk <darisk972@gmail.com>
parents:
599
diff
changeset
|
213 |
t = new Contact(chat.getParticipant().getJID()); |
b3e1e7e1fddd
The priority can be negative. Fix a little bug with the switch dialog
Da Risk <darisk972@gmail.com>
parents:
599
diff
changeset
|
214 |
openedChats.add(t); |
b3e1e7e1fddd
The priority can be negative. Fix a little bug with the switch dialog
Da Risk <darisk972@gmail.com>
parents:
599
diff
changeset
|
215 |
} |
508
7d8da3df2907
Ajout d'un chat switcher dans l'activite Chat.
Jean-Manuel Da Silva <dasilvj at gmail dot com>
parents:
503
diff
changeset
|
216 |
} |
514
c5d0b38dd35f
Mise a jour de la JavaDoc et corrections des erreurs de CheckStyle.
Jean-Manuel Da Silva <dasilvj@gmail.com>
parents:
511
diff
changeset
|
217 |
return openedChats; |
508
7d8da3df2907
Ajout d'un chat switcher dans l'activite Chat.
Jean-Manuel Da Silva <dasilvj at gmail dot com>
parents:
503
diff
changeset
|
218 |
} |
7d8da3df2907
Ajout d'un chat switcher dans l'activite Chat.
Jean-Manuel Da Silva <dasilvj at gmail dot com>
parents:
503
diff
changeset
|
219 |
|
503
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
220 |
/** |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
221 |
* {@inheritDoc} |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
222 |
*/ |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
223 |
@Override |
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
224 |
public void removeChatCreationListener(IChatManagerListener listener) throws RemoteException { |
584
72d9d76900af
Fix many bugs and memory leak
Da Risk <darisk972@gmail.com>
parents:
577
diff
changeset
|
225 |
if (listener != null) |
72d9d76900af
Fix many bugs and memory leak
Da Risk <darisk972@gmail.com>
parents:
577
diff
changeset
|
226 |
mRemoteChatCreationListeners.unregister(listener); |
503
93e5d2d9953f
Le formatter a encore frappé.
Jean-Manuel ¨dasilvj¨ Da Silva
parents:
502
diff
changeset
|
227 |
} |
55
66732dd2cb77
Add an interface for sending im message.
Da Risk <darisk972@gmail.com>
parents:
diff
changeset
|
228 |
|
708
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
229 |
/** |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
230 |
* A listener for all the chat creation event that happens on the connection. |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
231 |
* @author darisk |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
232 |
*/ |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
233 |
private class ChatListener extends IMessageListener.Stub implements ChatManagerListener { |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
234 |
|
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
235 |
/** |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
236 |
* Constructor. |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
237 |
*/ |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
238 |
public ChatListener() { |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
239 |
} |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
240 |
|
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
241 |
/** |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
242 |
* {@inheritDoc} |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
243 |
*/ |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
244 |
@Override |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
245 |
public void chatCreated(Chat chat, boolean locally) { |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
246 |
IChat newchat = getChat(chat); |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
247 |
Log.d(TAG, "Chat" + chat.toString() + " created locally " + locally + "with " + chat.getParticipant()); |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
248 |
try { |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
249 |
newchat.addMessageListener(mChatListener); |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
250 |
final int n = mRemoteChatCreationListeners.beginBroadcast(); |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
251 |
|
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
252 |
for (int i = 0; i < n; i++) { |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
253 |
IChatManagerListener listener = mRemoteChatCreationListeners.getBroadcastItem(i); |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
254 |
listener.chatCreated(newchat, locally); |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
255 |
} |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
256 |
mRemoteChatCreationListeners.finishBroadcast(); |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
257 |
} catch (RemoteException e) { |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
258 |
// The RemoteCallbackList will take care of removing the |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
259 |
// dead listeners. |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
260 |
Log.w(TAG, " Error while triggering remote connection listeners in chat creation", e); |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
261 |
} |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
262 |
} |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
263 |
|
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
264 |
/** |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
265 |
* Create the PendingIntent to launch our activity if the user select this chat notification. |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
266 |
* @param chat A ChatAdapter instance |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
267 |
* @return A Chat activity PendingIntent |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
268 |
*/ |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
269 |
private PendingIntent makeChatIntent(IChat chat) { |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
270 |
Intent chatIntent = new Intent(mService, com.beem.project.beem.ui.Chat.class); |
747 | 271 |
chatIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP |
272 |
| Intent.FLAG_ACTIVITY_NEW_TASK); |
|
708
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
273 |
try { |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
274 |
chatIntent.setData(chat.getParticipant().toUri()); |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
275 |
} catch (RemoteException e) { |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
276 |
Log.e(TAG, e.getMessage()); |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
277 |
} |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
278 |
PendingIntent contentIntent = PendingIntent.getActivity(mService, 0, chatIntent, |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
279 |
PendingIntent.FLAG_UPDATE_CURRENT); |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
280 |
return contentIntent; |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
281 |
} |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
282 |
|
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
283 |
/** |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
284 |
* Set a notification of a new chat. |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
285 |
* @param chat The chat to access by the notification |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
286 |
*/ |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
287 |
private void notifyNewChat(IChat chat) { |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
288 |
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(mService); |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
289 |
try { |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
290 |
CharSequence tickerText = mService.getBind().getRoster().getContact(chat.getParticipant().getJID()) |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
291 |
.getName(); |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
292 |
Notification notification = new Notification(android.R.drawable.stat_notify_chat, tickerText, System |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
293 |
.currentTimeMillis()); |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
294 |
notification.flags = Notification.FLAG_AUTO_CANCEL; |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
295 |
notification.setLatestEventInfo(mService, tickerText, mService |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
296 |
.getString(R.string.BeemChatManagerNewMessage), makeChatIntent(chat)); |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
297 |
mService.sendNotification(chat.getParticipant().getJID().hashCode(), notification); |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
298 |
} catch (RemoteException e) { |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
299 |
Log.e(TAG, e.getMessage()); |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
300 |
} |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
301 |
} |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
302 |
|
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
303 |
/** |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
304 |
* {@inheritDoc} |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
305 |
*/ |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
306 |
@Override |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
307 |
public void processMessage(final IChat chat, Message message) { |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
308 |
try { |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
309 |
if (!chat.isOpen() && message.getBody() != null) { |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
310 |
if (chat instanceof ChatAdapter) { |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
311 |
mChats.put(chat.getParticipant().getJID(), (ChatAdapter) chat); |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
312 |
} |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
313 |
notifyNewChat(chat); |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
314 |
} |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
315 |
} catch (RemoteException e) { |
714
40190c2be90b
some improvement in resource management, ready to test
Nikita Kozlov <nikita@beem-project.com>
parents:
713
diff
changeset
|
316 |
Log.e(TAG, e.getMessage()); |
708
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
317 |
} |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
318 |
} |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
319 |
|
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
320 |
@Override |
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
321 |
public void stateChanged(final IChat chat) { } |
928
0ff0059f2ec3
initial commit adding otr to beem, it's based on http://bitbucket.org/romanzadov/beem, with a better beem integration
Nikita Kozlov <nikita@mbdsys.com>
parents:
774
diff
changeset
|
322 |
|
0ff0059f2ec3
initial commit adding otr to beem, it's based on http://bitbucket.org/romanzadov/beem, with a better beem integration
Nikita Kozlov <nikita@mbdsys.com>
parents:
774
diff
changeset
|
323 |
@Override |
0ff0059f2ec3
initial commit adding otr to beem, it's based on http://bitbucket.org/romanzadov/beem, with a better beem integration
Nikita Kozlov <nikita@mbdsys.com>
parents:
774
diff
changeset
|
324 |
public void otrStateChanged(String otrState) throws RemoteException { |
931
bcafceecd837
adding otr status listener
Nikita Kozlov <nikita@mbdsys.com>
parents:
928
diff
changeset
|
325 |
// TODO Auto-generated method stub |
bcafceecd837
adding otr status listener
Nikita Kozlov <nikita@mbdsys.com>
parents:
928
diff
changeset
|
326 |
|
928
0ff0059f2ec3
initial commit adding otr to beem, it's based on http://bitbucket.org/romanzadov/beem, with a better beem integration
Nikita Kozlov <nikita@mbdsys.com>
parents:
774
diff
changeset
|
327 |
} |
708
915b3dde9851
adding notification preference for invite notifications
Nikita Kozlov <nikita@beem-project.com>
parents:
706
diff
changeset
|
328 |
} |
55
66732dd2cb77
Add an interface for sending im message.
Da Risk <darisk972@gmail.com>
parents:
diff
changeset
|
329 |
} |