Feature #216 » beem_muc_for_r969.patch
| /dev/null Thu Jan 01 00:00:00 1970 +0000 → res/layout/joinmucdialog.xml Tue Apr 10 14:23:32 2012 -0500 | ||
|---|---|---|
| 1 |
<?xml version="1.0" encoding="utf-8"?> |
|
| 2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
| 3 |
android:orientation="vertical" android:layout_width="fill_parent" |
|
| 4 |
android:layout_height="fill_parent"> |
|
| 5 |
<TextView android:id="@+id/CDRoomDialogLabel" |
|
| 6 |
android:layout_height="wrap_content" android:layout_width="wrap_content" |
|
| 7 |
android:layout_marginLeft="20dip" android:layout_marginRight="20dip" |
|
| 8 |
android:text="@string/Room" |
|
| 9 |
android:gravity="left" style="@style/Label" /> |
|
| 10 |
<EditText android:id="@+id/CDRoomDialogName" |
|
| 11 |
android:layout_height="wrap_content" android:layout_width="fill_parent" |
|
| 12 |
android:layout_marginLeft="20dip" android:layout_marginRight="20dip" |
|
| 13 |
android:scrollHorizontally="true" android:autoText="false" |
|
| 14 |
android:capitalize="none" android:gravity="fill_horizontal" |
|
| 15 |
android:contentDescription="@string/Room" android:text="room@server"/> |
|
| 16 |
<TextView android:id="@+id/CDNickDialogLabel" |
|
| 17 |
android:layout_height="wrap_content" android:layout_width="wrap_content" |
|
| 18 |
android:layout_marginLeft="20dip" android:layout_marginRight="20dip" |
|
| 19 |
android:text="@string/Nick" |
|
| 20 |
android:gravity="left" style="@style/Label" /> |
|
| 21 |
<EditText android:id="@+id/CDNickDialogName" |
|
| 22 |
android:layout_height="wrap_content" android:layout_width="fill_parent" |
|
| 23 |
android:layout_marginLeft="20dip" android:layout_marginRight="20dip" |
|
| 24 |
android:scrollHorizontally="true" android:autoText="false" |
|
| 25 |
android:capitalize="none" android:gravity="fill_horizontal" |
|
| 26 |
android:contentDescription="@string/Nick"/> |
|
| 27 | ||
| 28 |
</LinearLayout> |
|
| res/layout/preferences.xml Fri Apr 06 17:43:01 2012 +0200 → res/layout/preferences.xml Tue Apr 10 14:23:32 2012 -0500 | ||
|---|---|---|
| 48 | 48 |
<RingtonePreference android:title="@string/notification_snd_title" |
| 49 | 49 |
android:key="notification_sound" android:summary="@string/notification_snd_sum" |
| 50 | 50 |
android:ringtoneType="notification" android:showDefault="true" /> |
| 51 |
<CheckBoxPreference android:title="@string/notification_hl_title" |
|
| 52 |
android:defaultValue="false" android:summary="@string/notification_hl_sum" |
|
| 53 |
android:key="notification_hls" /> |
|
| 51 | 54 |
</PreferenceScreen> |
| 52 | 55 |
</PreferenceCategory> |
| 53 | 56 |
<PreferenceCategory android:title="@string/user_preferences"> |
| ... | ... | |
| 67 | 70 |
android:title="@string/SettingsPriorityTitle" android:summary="@string/SettingsPrioritySummary" |
| 68 | 71 |
android:numeric="signed" android:defaultValue="0" /> |
| 69 | 72 |
</PreferenceCategory> |
| 73 |
<PreferenceCategory android:title="@string/muc_preferences"> |
|
| 74 |
<EditTextPreference android:key="settings_key_nickname" |
|
| 75 |
android:title="@string/SettingsNicknameTitle" android:summary="@string/SettingsNicknameSummary" |
|
| 76 |
android:defaultValue="BeemGuest" /> |
|
| 77 |
<EditTextPreference android:key="settings_key_hls" android:title="@string/SettingsHLSTitle" android:summary="@string/SettingsHLSSummary" /> |
|
| 78 |
</PreferenceCategory> |
|
| 70 | 79 |
<PreferenceCategory android:title="@string/network_preferences"> |
| 71 | 80 |
<PreferenceScreen android:key="proxy" android:title="@string/SettingsProxy" |
| 72 | 81 |
android:summary="@string/settings_proxy_sum"> |
| res/menu/contact_list.xml Fri Apr 06 17:43:01 2012 +0200 → res/menu/contact_list.xml Tue Apr 10 14:23:32 2012 -0500 | ||
|---|---|---|
| 6 | 6 |
<item android:id="@+id/menu_change_status" |
| 7 | 7 |
android:visible="true" |
| 8 | 8 |
android:title="@string/contact_list_menu_status"/> |
| 9 |
<item android:id="@+id/muc" |
|
| 10 |
android:visible="true" |
|
| 11 |
android:title="MUC" /> |
|
| 9 | 12 |
<item android:id="@+id/contact_list_menu_chatlist" |
| 10 |
android:visible="true" android:icon="@drawable/ic_menu_chat_dashboard" |
|
| 11 |
android:title="@string/chat_menu_change_chat"/> |
|
| 13 |
android:visible="true" |
|
| 14 |
android:title="@string/chat_menu_change_chat" |
|
| 15 |
android:icon="@drawable/ic_menu_chat_dashboard" /> |
|
| 12 | 16 |
<item android:id="@+id/contact_list_menu_settings" |
| 13 | 17 |
android:visible="true" |
| 14 | 18 |
android:title="@string/contact_list_menu_settings" |
| res/menu/contactlist_context.xml Fri Apr 06 17:43:01 2012 +0200 → res/menu/contactlist_context.xml Tue Apr 10 14:23:32 2012 -0500 | ||
|---|---|---|
| 4 | 4 |
<menu> |
| 5 | 5 |
</menu> |
| 6 | 6 |
</item> |
| 7 |
<item android:id="@+id/contact_list_context_menu_joinasmuc_item" |
|
| 8 |
android:title="@string/CDJoinMUC" /> |
|
| 7 | 9 |
<item android:id="@+id/contact_list_context_menu_call_item" |
| 8 | 10 |
android:title="@string/CDCall" android:visible="false" /> |
| 9 | 11 |
<item android:id="@+id/contact_list_context_menu_user_info" |
| res/values-fr/strings.xml Fri Apr 06 17:43:01 2012 +0200 → res/values-fr/strings.xml Tue Apr 10 14:23:32 2012 -0500 | ||
|---|---|---|
| 313 | 313 |
<string name="privacy_list_delete_dialog_no">Non</string> |
| 314 | 314 | |
| 315 | 315 |
<string name="UpdateButton">Mettre à jour</string> |
| 316 |
|
|
| 317 |
<string name="Room">Salon</string> |
|
| 318 |
<string name="Nick">Pseudo</string> |
|
| 316 | 319 | |
| 317 | 320 |
<!-- MemorizingTrustManager library --> |
| 318 | 321 |
<string name="mtm_accept_cert">Accepter un certificat de sécurité invalide ?</string> |
| res/values/strings.xml Fri Apr 06 17:43:01 2012 +0200 → res/values/strings.xml Tue Apr 10 14:23:32 2012 -0500 | ||
|---|---|---|
| 27 | 27 | |
| 28 | 28 |
<!-- ContactDialog class --> |
| 29 | 29 |
<string name="CDChat">Chat</string> |
| 30 |
<string name="CDJoinMUC">Join MUC</string> |
|
| 30 | 31 |
<string name="CDCall">Call</string> |
| 31 | 32 |
<string name="CDInfos">Manage User</string> |
| 32 | 33 | |
| ... | ... | |
| 83 | 84 |
<string name="SettingsAdvancedPortOpt">Edit the server port</string> |
| 84 | 85 |
<string name="SettingsResourceTitle">Resource</string> |
| 85 | 86 |
<string name="SettingsPriorityTitle">Priority</string> |
| 87 |
<string name="SettingsNicknameTitle">Default nickname for MUC</string> |
|
| 88 |
<string name="SettingsHLSTitle">Highlights</string> |
|
| 86 | 89 |
<string name="SettingsResourceSummary">Set the XMPP resource of your client </string> |
| 87 | 90 |
<string name="SettingsPrioritySummary">Set the priority of your client</string> |
| 91 |
<string name="SettingsNicknameSummary">Set the default nickname when joining MUC</string> |
|
| 92 |
<string name="SettingsHLSSummary">Comma-separated list of words (other than your nickname) that will highlight you</string> |
|
| 88 | 93 |
<string name="contact_list_preferences">Buddy list</string> |
| 89 | 94 |
<string name="contact_list_preferences_sum">A set of display options for your buddy list |
| 90 | 95 |
</string> |
| ... | ... | |
| 124 | 129 |
<string name="notification_enable_vibrate_sum">Enable vibrate on incoming messages</string> |
| 125 | 130 |
<string name="notification_snd_title">Message ringtone</string> |
| 126 | 131 |
<string name="notification_snd_sum">Set your incoming message ringtone</string> |
| 132 |
<string name="notification_hl_title">Notify only highlights</string> |
|
| 133 |
<string name="notification_hl_sum">Check if you want to be notified only when you are highlited in MUC</string> |
|
| 127 | 134 |
<string name="settings_chat_compact">Chat compact</string> |
| 128 | 135 |
<string name="settings_chat_compact_sum">Set the chat windows compact</string> |
| 129 | 136 |
<string name="history">History</string> |
| ... | ... | |
| 209 | 216 |
<string name="general_preferences">General preferences</string> |
| 210 | 217 |
<string name="user_preferences">User settings (required)</string> |
| 211 | 218 |
<string name="user_preferences_advanced">User settings advanced (optional)</string> |
| 219 |
<string name="muc_preferences">MUC settings (optional)</string> |
|
| 212 | 220 |
<string name="network_preferences">Network options</string> |
| 213 | 221 |
<string name="proxy_proxy_settings">Proxy settings</string> |
| 214 | 222 |
<string name="proxy_user_settings">Proxy settings</string> |
| ... | ... | |
| 321 | 329 |
<string name="mtm_decision_abort">Abort</string> |
| 322 | 330 | |
| 323 | 331 |
<string name="mtm_notification">Certificate Verification</string> |
| 332 |
|
|
| 333 |
<string name="Room">Room</string> |
|
| 334 |
<string name="Nick">Nickname</string> |
|
| 324 | 335 | |
| 325 | 336 |
<!-- Error messages --> |
| 326 | 337 |
|
| src/com/beem/project/beem/BeemService.java Fri Apr 06 17:43:01 2012 +0200 → src/com/beem/project/beem/BeemService.java Tue Apr 10 14:23:32 2012 -0500 | ||
|---|---|---|
| 328 | 328 |
public IXmppFacade getBind() {
|
| 329 | 329 |
return mBind; |
| 330 | 330 |
} |
| 331 |
|
|
| 332 |
public XmppConnectionAdapter getmConnection() {
|
|
| 333 |
return mConnection; |
|
| 334 |
} |
|
| 331 | 335 | |
| 332 | 336 |
/** |
| 333 | 337 |
* Get the preference of the service. |
| src/com/beem/project/beem/service/BeemChatManager.java Fri Apr 06 17:43:01 2012 +0200 → src/com/beem/project/beem/service/BeemChatManager.java Tue Apr 10 14:23:32 2012 -0500 | ||
|---|---|---|
| 59 | 59 |
import org.jivesoftware.smack.RosterListener; |
| 60 | 60 |
import org.jivesoftware.smack.packet.Presence; |
| 61 | 61 |
import org.jivesoftware.smack.util.StringUtils; |
| 62 |
import org.jivesoftware.smack.XMPPException; |
|
| 63 |
import org.jivesoftware.smack.util.StringUtils; |
|
| 64 |
import org.jivesoftware.smackx.muc.MultiUserChat; |
|
| 62 | 65 | |
| 63 | 66 |
import android.app.Notification; |
| 64 | 67 |
import android.app.PendingIntent; |
| ... | ... | |
| 73 | 76 |
import com.beem.project.beem.BeemApplication; |
| 74 | 77 |
import com.beem.project.beem.BeemService; |
| 75 | 78 |
import com.beem.project.beem.service.aidl.IChat; |
| 79 |
import com.beem.project.beem.service.aidl.IChatMUC; |
|
| 76 | 80 |
import com.beem.project.beem.service.aidl.IChatManager; |
| 77 | 81 |
import com.beem.project.beem.service.aidl.IChatManagerListener; |
| 78 | 82 |
import com.beem.project.beem.service.aidl.IMessageListener; |
| ... | ... | |
| 88 | 92 |
private static final String TAG = "BeemChatManager"; |
| 89 | 93 |
private final ChatManager mAdaptee; |
| 90 | 94 |
private final Map<String, ChatAdapter> mChats = new HashMap<String, ChatAdapter>(); |
| 95 |
private final Map<String, ChatMUCAdapter> mMUCChats = new HashMap<String, ChatMUCAdapter>(); |
|
| 91 | 96 |
private final ChatListener mChatListener = new ChatListener(); |
| 92 | 97 |
private final RemoteCallbackList<IChatManagerListener> mRemoteChatCreationListeners = |
| 93 | 98 |
new RemoteCallbackList<IChatManagerListener>(); |
| ... | ... | |
| 147 | 152 |
return result; |
| 148 | 153 |
} |
| 149 | 154 | |
| 155 |
|
|
| 156 |
/** |
|
| 157 |
* Create a MUC chat session. |
|
| 158 |
* @param jid the jid of the MUC |
|
| 159 |
* @param listener listener to use for chat events on this chat session |
|
| 160 |
* @return the chat session |
|
| 161 |
*/ |
|
| 162 |
public IChatMUC createMUCChat(Contact contact, IMessageListener listener) {
|
|
| 163 |
String jid = contact.getJIDWithRes(); |
|
| 164 |
Log.d(TAG, "Get chat key1 = "); |
|
| 165 | ||
| 166 |
return createMUCChat(jid, listener); |
|
| 167 |
} |
|
| 168 |
|
|
| 169 |
public IChatMUC createMUCChat(String jid, IMessageListener listener) {
|
|
| 170 |
String key = StringUtils.parseBareAddress(jid); |
|
| 171 |
String nick = StringUtils.parseResource(jid); |
|
| 172 |
ChatMUCAdapter result; |
|
| 173 |
Log.d(TAG, "Get chat key2 = "+jid); |
|
| 174 |
if (mMUCChats.containsKey(key)) {
|
|
| 175 |
result = mMUCChats.get(key); |
|
| 176 |
result.addMessageListener(listener); |
|
| 177 |
return result; |
|
| 178 |
} |
|
| 179 |
MultiUserChat c = new MultiUserChat(mService.getmConnection().getAdaptee(),key); |
|
| 180 |
result = new ChatMUCAdapter(c, mService, nick); |
|
| 181 |
mMUCChats.put(key, result); |
|
| 182 |
result.addMessageListener(listener); |
|
| 183 |
result.addMessageListener(mChatListener); |
|
| 184 |
return result; |
|
| 185 |
} |
|
| 186 | ||
| 150 | 187 |
/** |
| 151 | 188 |
* {@inheritDoc}
|
| 152 | 189 |
*/ |
| ... | ... | |
| 160 | 197 |
mChats.remove(chat.getParticipant().getJID()); |
| 161 | 198 |
} |
| 162 | 199 | |
| 200 |
@Override |
|
| 201 |
public void destroyMUCChat(IChatMUC chat) throws RemoteException {
|
|
| 202 |
if (chat == null) |
|
| 203 |
return; |
|
| 204 |
((ChatMUCAdapter)chat).getAdaptee().leave() ; |
|
| 205 |
mMUCChats.remove(chat.getRoom().getJID()); |
|
| 206 |
|
|
| 207 |
} |
|
| 208 | ||
| 163 | 209 |
/** |
| 164 | 210 |
* {@inheritDoc}
|
| 165 | 211 |
*/ |
| ... | ... | |
| 205 | 251 |
return mChats.get(key); |
| 206 | 252 |
} |
| 207 | 253 | |
| 254 |
@Override |
|
| 255 |
public ChatMUCAdapter getMUCChat(Contact contact) {
|
|
| 256 |
String key = contact.getJID(); |
|
| 257 |
return mMUCChats.get(key); |
|
| 258 |
} |
|
| 259 | ||
| 208 | 260 |
/** |
| 209 | 261 |
* This methods permits to retrieve the list of contacts who have an opened chat session with us. |
| 210 | 262 |
* @return An List containing Contact instances. |
| ... | ... | |
| 216 | 268 | |
| 217 | 269 |
for (ChatAdapter chat : mChats.values()) {
|
| 218 | 270 |
if (chat.getMessages().size() > 0) {
|
| 219 |
Contact t = mRoster.getContact(chat.getParticipant().getJID()); |
|
| 271 |
Contact t = mRoster.getContact(chat.getParticipant().getJIDWithRes());
|
|
| 220 | 272 |
if (t == null) |
| 221 |
t = new Contact(chat.getParticipant().getJID()); |
|
| 273 |
t = new Contact(chat.getParticipant().getJIDWithRes());
|
|
| 222 | 274 |
openedChats.add(t); |
| 223 | 275 |
} |
| 224 | 276 |
} |
| 277 |
for (ChatMUCAdapter chat : mMUCChats.values()) {
|
|
| 278 |
Contact t = new Contact(chat.getRoom().getJID(), true); |
|
| 279 |
openedChats.add(t); |
|
| 280 |
} |
|
| 225 | 281 |
return openedChats; |
| 226 | 282 |
} |
| 227 | 283 | |
| ... | ... | |
| 274 | 330 |
* @param chat A ChatAdapter instance |
| 275 | 331 |
* @return A Chat activity PendingIntent |
| 276 | 332 |
*/ |
| 277 |
private PendingIntent makeChatIntent(IChat chat) {
|
|
| 333 |
private PendingIntent makeChatIntent(Contact c) {
|
|
| 278 | 334 |
Intent chatIntent = new Intent(mService, com.beem.project.beem.ui.Chat.class); |
| 279 | 335 |
chatIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP |
| 280 | 336 |
| Intent.FLAG_ACTIVITY_NEW_TASK); |
| 281 |
try {
|
|
| 282 |
chatIntent.setData(chat.getParticipant().toUri()); |
|
| 283 |
} catch (RemoteException e) {
|
|
| 284 |
Log.e(TAG, e.getMessage()); |
|
| 285 |
} |
|
| 337 |
chatIntent.setData(c.toUri()); |
|
| 286 | 338 |
PendingIntent contentIntent = PendingIntent.getActivity(mService, 0, chatIntent, |
| 287 | 339 |
PendingIntent.FLAG_UPDATE_CURRENT); |
| 288 | 340 |
return contentIntent; |
| ... | ... | |
| 293 | 345 |
* @param chat The chat to access by the notification |
| 294 | 346 |
* @param msgBody the body of the new message |
| 295 | 347 |
*/ |
| 296 |
private void notifyNewChat(IChat chat, String msgBody) {
|
|
| 297 |
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(mService); |
|
| 298 |
try {
|
|
| 299 |
CharSequence tickerText = mService.getBind().getRoster().getContact(chat.getParticipant().getJID()) |
|
| 300 |
.getName(); |
|
| 348 |
private void notifyNewChat(Contact c, String msgBody) {
|
|
| 349 |
CharSequence tickerText = c.getName(); |
|
| 301 | 350 |
Notification notification = new Notification(android.R.drawable.stat_notify_chat, tickerText, System |
| 302 | 351 |
.currentTimeMillis()); |
| 303 | 352 |
notification.flags = Notification.FLAG_AUTO_CANCEL | Notification.FLAG_SHOW_LIGHTS; |
| 304 |
notification.setLatestEventInfo(mService, tickerText, msgBody, makeChatIntent(chat)); |
|
| 305 |
mService.sendNotification(chat.getParticipant().getJID().hashCode(), notification); |
|
| 306 |
} catch (RemoteException e) {
|
|
| 307 |
Log.e(TAG, e.getMessage()); |
|
| 308 |
} |
|
| 353 |
notification.setLatestEventInfo(mService, tickerText, msgBody, makeChatIntent(c)); |
|
| 354 |
mService.sendNotification(c.getJID().hashCode(), notification); |
|
| 309 | 355 |
} |
| 310 | 356 | |
| 357 | ||
| 358 |
/** |
|
| 359 |
* Set a notification of a new chat. |
|
| 360 |
* @param chat The chat to access by the notification |
|
| 361 |
*/ |
|
| 362 |
private void notifyNewChat(IChat chat, String msgBody) {
|
|
| 363 |
try {
|
|
| 364 |
notifyNewChat(chat.getParticipant(), msgBody); |
|
| 365 |
} catch (RemoteException e) {
|
|
| 366 |
// TODO Auto-generated catch block |
|
| 367 |
e.printStackTrace(); |
|
| 368 |
} |
|
| 369 |
} |
|
| 370 |
/** |
|
| 371 |
* Set a notification of a MUC chat. |
|
| 372 |
* @param chat The chat to access by the notification |
|
| 373 |
*/ |
|
| 374 |
private void notifyMUCChat(IChatMUC chat, String msgBody) {
|
|
| 375 |
Log.d(TAG,"poeuet") ; |
|
| 376 |
try {
|
|
| 377 |
notifyNewChat(chat.getRoom(), msgBody) ; |
|
| 378 |
} catch (RemoteException e) {
|
|
| 379 |
// TODO Auto-generated catch block |
|
| 380 |
e.printStackTrace(); |
|
| 381 |
} |
|
| 382 |
} |
|
| 383 | ||
| 311 | 384 |
/** |
| 312 | 385 |
* {@inheritDoc}
|
| 313 | 386 |
*/ |
| ... | ... | |
| 326 | 399 |
} |
| 327 | 400 |
} |
| 328 | 401 | |
| 402 |
@Override |
|
| 403 |
public void processMUCMessage(IChatMUC chat, Message message) |
|
| 404 |
throws RemoteException {
|
|
| 405 |
String body = message.getBody(); |
|
| 406 |
boolean onlyhl = PreferenceManager.getDefaultSharedPreferences(mService).getBoolean("notification_hls", false) ;
|
|
| 407 |
if (!chat.isOpen() && message.getBody() != null && ( message.isHL() || !onlyhl)) {
|
|
| 408 |
notifyMUCChat(chat, body) ; |
|
| 409 |
} |
|
| 410 |
} |
|
| 411 | ||
| 329 | 412 |
@Override |
| 330 | 413 |
public void stateChanged(final IChat chat) {
|
| 331 | 414 |
} |
| /dev/null Thu Jan 01 00:00:00 1970 +0000 → src/com/beem/project/beem/service/ChatMUCAdapter.java Tue Apr 10 14:23:32 2012 -0500 | ||
|---|---|---|
| 1 |
/* |
|
| 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, |
|
| 9 |
Vincent Veronis. |
|
| 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 | ||
| 29 |
Epitech, hereby disclaims all copyright interest in the program "Beem" |
|
| 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 | ||
| 43 |
*/ |
|
| 44 |
package com.beem.project.beem.service; |
|
| 45 | ||
| 46 |
import java.util.Collections; |
|
| 47 |
import java.util.LinkedList; |
|
| 48 |
import java.util.List; |
|
| 49 | ||
| 50 |
import org.jivesoftware.smackx.muc.MultiUserChat; |
|
| 51 |
import org.jivesoftware.smack.PacketListener; |
|
| 52 |
import org.jivesoftware.smack.XMPPException; |
|
| 53 |
import org.jivesoftware.smack.packet.Packet; |
|
| 54 |
import org.jivesoftware.smack.util.StringUtils; |
|
| 55 |
import org.jivesoftware.smackx.ChatStateListener; |
|
| 56 |
import org.jivesoftware.smackx.ChatState; |
|
| 57 | ||
| 58 |
import android.os.RemoteCallbackList; |
|
| 59 |
import android.os.RemoteException; |
|
| 60 |
import android.preference.PreferenceManager; |
|
| 61 |
import android.util.Log; |
|
| 62 | ||
| 63 |
import com.beem.project.beem.BeemService; |
|
| 64 |
import com.beem.project.beem.service.aidl.IChatMUC; |
|
| 65 |
import com.beem.project.beem.service.aidl.IMessageListener; |
|
| 66 | ||
| 67 |
/** |
|
| 68 |
* An adapter for smack's Chat class. |
|
| 69 |
* @author darisk |
|
| 70 |
*/ |
|
| 71 |
public class ChatMUCAdapter extends IChatMUC.Stub {
|
|
| 72 |
private static final int HISTORY_MAX_SIZE = 50; |
|
| 73 |
private static final String TAG = "ChatMUCAdapter"; |
|
| 74 |
private final MultiUserChat mAdaptee; |
|
| 75 |
private final Contact mParticipant; |
|
| 76 |
private String mState; |
|
| 77 |
private boolean mIsOpen; |
|
| 78 |
private String mNick ; |
|
| 79 |
private final BeemService mService; |
|
| 80 |
private final List<Message> mMessages; |
|
| 81 |
private final RemoteCallbackList<IMessageListener> mRemoteListeners = new RemoteCallbackList<IMessageListener>(); |
|
| 82 |
private final MsgMUCListener mMsgListener = new MsgMUCListener(); |
|
| 83 |
|
|
| 84 |
/** |
|
| 85 |
* Constructor. |
|
| 86 |
* @param chat The chat to adapt |
|
| 87 |
*/ |
|
| 88 |
public ChatMUCAdapter(final MultiUserChat chat, final BeemService service, String nick) {
|
|
| 89 |
mAdaptee = chat; |
|
| 90 |
mParticipant = new Contact(chat.getRoom(),true); |
|
| 91 |
mMessages = new LinkedList<Message>(); |
|
| 92 |
mAdaptee.addMessageListener(mMsgListener); |
|
| 93 |
mNick = nick ; |
|
| 94 |
mService = service; |
|
| 95 |
// Join the MUC |
|
| 96 |
try {
|
|
| 97 |
chat.join(nick) ; |
|
| 98 |
} catch (XMPPException e) {
|
|
| 99 |
// TODO Auto-generated catch block |
|
| 100 |
e.printStackTrace(); |
|
| 101 |
} |
|
| 102 |
} |
|
| 103 | ||
| 104 |
/** |
|
| 105 |
* {@inheritDoc}
|
|
| 106 |
*/ |
|
| 107 |
@Override |
|
| 108 |
public Contact getRoom() throws RemoteException {
|
|
| 109 |
return mParticipant; |
|
| 110 |
} |
|
| 111 |
|
|
| 112 |
/** |
|
| 113 |
* {@inheritDoc}
|
|
| 114 |
*/ |
|
| 115 |
@Override |
|
| 116 |
public void sendMessage(com.beem.project.beem.service.Message message) throws RemoteException {
|
|
| 117 |
org.jivesoftware.smack.packet.Message send = new org.jivesoftware.smack.packet.Message(); |
|
| 118 |
send.setTo(message.getTo()); |
|
| 119 |
Log.w(TAG, "message to " + message.getTo()); |
|
| 120 |
send.setBody(message.getBody()); |
|
| 121 |
send.setType(org.jivesoftware.smack.packet.Message.Type.groupchat); |
|
| 122 |
// TODO gerer les messages contenant des XMPPError |
|
| 123 |
// send.set |
|
| 124 |
try {
|
|
| 125 |
mAdaptee.sendMessage(send); |
|
| 126 |
} catch (XMPPException e) {
|
|
| 127 |
// TODO Auto-generated catch block |
|
| 128 |
e.printStackTrace(); |
|
| 129 |
} |
|
| 130 |
} |
|
| 131 | ||
| 132 |
/** |
|
| 133 |
* {@inheritDoc}
|
|
| 134 |
*/ |
|
| 135 |
@Override |
|
| 136 |
public void addMessageListener(IMessageListener listen) {
|
|
| 137 |
Log.d(TAG, "Un ecouteur de plus"); |
|
| 138 |
if (listen != null) |
|
| 139 |
mRemoteListeners.register(listen); |
|
| 140 |
} |
|
| 141 | ||
| 142 |
/** |
|
| 143 |
* {@inheritDoc}
|
|
| 144 |
*/ |
|
| 145 |
@Override |
|
| 146 |
public void removeMessageListener(IMessageListener listen) {
|
|
| 147 |
Log.d(TAG, "Un ecouteur de moins"); |
|
| 148 |
if (listen != null) {
|
|
| 149 |
mRemoteListeners.unregister(listen); |
|
| 150 |
} |
|
| 151 |
} |
|
| 152 | ||
| 153 |
/** |
|
| 154 |
* {@inheritDoc}
|
|
| 155 |
*/ |
|
| 156 |
@Override |
|
| 157 |
public String getState() throws RemoteException {
|
|
| 158 |
return mState; |
|
| 159 |
} |
|
| 160 | ||
| 161 |
/** |
|
| 162 |
* {@inheritDoc}
|
|
| 163 |
*/ |
|
| 164 |
@Override |
|
| 165 |
public void setState(String state) throws RemoteException {
|
|
| 166 |
mState = state; |
|
| 167 |
} |
|
| 168 | ||
| 169 |
/** |
|
| 170 |
* Get the adaptee for the Chat. |
|
| 171 |
* @return The real chat object |
|
| 172 |
*/ |
|
| 173 |
public MultiUserChat getAdaptee() {
|
|
| 174 |
return mAdaptee; |
|
| 175 |
} |
|
| 176 | ||
| 177 |
/** |
|
| 178 |
* {@inheritDoc}
|
|
| 179 |
*/ |
|
| 180 |
@Override |
|
| 181 |
public void setOpen(boolean isOpen) {
|
|
| 182 |
this.mIsOpen = isOpen; |
|
| 183 |
} |
|
| 184 | ||
| 185 |
/** |
|
| 186 |
* {@inheritDoc}
|
|
| 187 |
*/ |
|
| 188 |
@Override |
|
| 189 |
public boolean isOpen() {
|
|
| 190 |
return mIsOpen; |
|
| 191 |
} |
|
| 192 | ||
| 193 |
/** |
|
| 194 |
* {@inheritDoc}
|
|
| 195 |
*/ |
|
| 196 |
@Override |
|
| 197 |
public List<Message> getMessages() throws RemoteException {
|
|
| 198 |
return Collections.unmodifiableList(mMessages); |
|
| 199 |
} |
|
| 200 | ||
| 201 |
/** |
|
| 202 |
* Add a message in the chat history. |
|
| 203 |
* @param msg the message to add |
|
| 204 |
*/ |
|
| 205 |
void addMessage(Message msg) {
|
|
| 206 |
if (mMessages.size() == HISTORY_MAX_SIZE) |
|
| 207 |
mMessages.remove(0); |
|
| 208 |
mMessages.add(msg); |
|
| 209 |
} |
|
| 210 | ||
| 211 |
/** |
|
| 212 |
* Listener. |
|
| 213 |
*/ |
|
| 214 |
private class MsgMUCListener implements PacketListener {
|
|
| 215 |
/** |
|
| 216 |
* Constructor. |
|
| 217 |
*/ |
|
| 218 |
public MsgMUCListener() { }
|
|
| 219 | ||
| 220 |
public void processPacket(Packet p) {
|
|
| 221 |
org.jivesoftware.smack.packet.Message message = (org.jivesoftware.smack.packet.Message) p ; |
|
| 222 |
Message msg = new Message(message); |
|
| 223 |
//TODO add que les message pas de type errors |
|
| 224 |
ChatMUCAdapter.this.addMessage(msg); |
|
| 225 |
final int n = mRemoteListeners.beginBroadcast(); |
|
| 226 |
for (int i = 0; i < n; i++) {
|
|
| 227 |
IMessageListener listener = mRemoteListeners.getBroadcastItem(i); |
|
| 228 |
try {
|
|
| 229 |
if (listener != null) {
|
|
| 230 |
//HL detection |
|
| 231 |
//If the pseudo |
|
| 232 |
String bodylow = msg.getBody().toLowerCase() ; |
|
| 233 |
if (bodylow.contains(mNick.toLowerCase())) {
|
|
| 234 |
msg.setHL(true) ; |
|
| 235 |
} |
|
| 236 |
//If in the hl list |
|
| 237 |
String hls = PreferenceManager.getDefaultSharedPreferences(mService).getString("settings_key_hls", "") ;
|
|
| 238 |
if (! hls.equalsIgnoreCase("")) {
|
|
| 239 |
for (String hl : hls.split(",")) {
|
|
| 240 |
if (bodylow.contains(hl.toLowerCase())) {
|
|
| 241 |
msg.setHL(true) ; |
|
| 242 |
} |
|
| 243 |
} |
|
| 244 |
} |
|
| 245 |
listener.processMUCMessage(ChatMUCAdapter.this, msg); |
|
| 246 |
} |
|
| 247 |
} catch (RemoteException e) {
|
|
| 248 |
Log.w(TAG, "Error while diffusing message to listener", e); |
|
| 249 |
} |
|
| 250 |
} |
|
| 251 |
mRemoteListeners.finishBroadcast(); |
|
| 252 |
} |
|
| 253 | ||
| 254 |
} |
|
| 255 | ||
| 256 |
@Override |
|
| 257 |
public List<Contact> getMembers() throws RemoteException {
|
|
| 258 |
// TODO Auto-generated method stub |
|
| 259 |
return null; |
|
| 260 |
} |
|
| 261 | ||
| 262 |
} |
|
| src/com/beem/project/beem/service/Contact.java Fri Apr 06 17:43:01 2012 +0200 → src/com/beem/project/beem/service/Contact.java Tue Apr 10 14:23:32 2012 -0500 | ||
|---|---|---|
| 86 | 86 |
private final List<String> mGroups = new ArrayList<String>(); |
| 87 | 87 |
private String mName; |
| 88 | 88 |
private String mAvatarId; |
| 89 |
private boolean mIsMUC; |
|
| 89 | 90 | |
| 90 | 91 |
/** |
| 91 | 92 |
* Construct a contact from a parcel. |
| ... | ... | |
| 129 | 130 |
if (!"xmpp".equals(uri.getScheme())) |
| 130 | 131 |
throw new IllegalArgumentException(); |
| 131 | 132 |
String enduri = uri.getEncodedSchemeSpecificPart(); |
| 132 |
mJID = StringUtils.parseBareAddress(enduri); |
|
| 133 |
String fjid = StringUtils.parseBareAddress(enduri); |
|
| 134 |
if (fjid.charAt(0) == '$') {
|
|
| 135 |
mJID = fjid.substring(1) ; |
|
| 136 |
mIsMUC = true ; |
|
| 137 |
} else {
|
|
| 138 |
mJID = fjid ; |
|
| 139 |
mIsMUC = false ; |
|
| 140 |
} |
|
| 133 | 141 |
mName = mJID; |
| 134 | 142 |
mStatus = Status.CONTACT_STATUS_DISCONNECT; |
| 135 | 143 |
mMsgState = null; |
| ... | ... | |
| 138 | 146 |
mSelectedRes = res; |
| 139 | 147 |
mRes.add(res); |
| 140 | 148 |
} |
| 149 |
|
|
| 150 |
public Contact(final String jid, boolean isMuc) {
|
|
| 151 |
this(jid) ; |
|
| 152 |
this.mIsMUC = true ; |
|
| 153 |
} |
|
| 141 | 154 | |
| 142 | 155 |
/** |
| 143 | 156 |
* Make an xmpp uri for a spcific jid. |
| ... | ... | |
| 282 | 295 |
public int getStatus() {
|
| 283 | 296 |
return mStatus; |
| 284 | 297 |
} |
| 298 |
|
|
| 299 |
/** |
|
| 300 |
* Return whether the contact is a MUC room or not |
|
| 301 |
*/ |
|
| 302 |
public boolean isMUC() {
|
|
| 303 |
return mIsMUC ; |
|
| 304 |
} |
|
| 285 | 305 | |
| 286 | 306 |
/** |
| 287 | 307 |
* Get the avatar id of the contact. |
| ... | ... | |
| 419 | 439 |
*/ |
| 420 | 440 |
public Uri toUri(String resource) {
|
| 421 | 441 |
StringBuilder build = new StringBuilder("xmpp:");
|
| 442 |
if (this.isMUC()) {
|
|
| 443 |
build.append("$") ;
|
|
| 444 |
} |
|
| 422 | 445 |
String name = StringUtils.parseName(mJID); |
| 423 | 446 |
build.append(name); |
| 424 | 447 |
if (!"".equals(name)) |
| src/com/beem/project/beem/service/Message.java Fri Apr 06 17:43:01 2012 +0200 → src/com/beem/project/beem/service/Message.java Tue Apr 10 14:23:32 2012 -0500 | ||
|---|---|---|
| 93 | 93 |
private String mFrom; |
| 94 | 94 |
private String mThread; |
| 95 | 95 |
private Date mTimestamp; |
| 96 |
private boolean mHL; |
|
| 96 | 97 | |
| 97 | 98 |
// TODO ajouter l'erreur |
| 98 | 99 | |
| ... | ... | |
| 109 | 110 |
mThread = ""; |
| 110 | 111 |
mFrom = null; |
| 111 | 112 |
mTimestamp = new Date(); |
| 113 |
mHL = false; |
|
| 112 | 114 |
} |
| 113 | 115 | |
| 114 | 116 |
/** |
| ... | ... | |
| 146 | 148 |
break; |
| 147 | 149 |
} |
| 148 | 150 |
this.mFrom = smackMsg.getFrom(); |
| 151 |
mHL = false; |
|
| 149 | 152 |
//TODO better handling of error messages |
| 150 | 153 |
if (mType == MSG_TYPE_ERROR) {
|
| 151 | 154 |
XMPPError er = smackMsg.getError(); |
| ... | ... | |
| 179 | 182 |
mThread = in.readString(); |
| 180 | 183 |
mFrom = in.readString(); |
| 181 | 184 |
mTimestamp = new Date(in.readLong()); |
| 185 |
mHL = false; |
|
| 182 | 186 |
} |
| 183 | 187 | |
| 184 | 188 |
/** |
| ... | ... | |
| 319 | 323 |
return 0; |
| 320 | 324 |
} |
| 321 | 325 | |
| 326 |
public void setHL(boolean mHL) {
|
|
| 327 |
this.mHL = mHL; |
|
| 328 |
} |
|
| 329 | ||
| 330 |
public boolean isHL() {
|
|
| 331 |
return mHL; |
|
| 332 |
} |
|
| 333 | ||
| 334 | ||
| 322 | 335 |
} |
| src/com/beem/project/beem/service/XmppConnectionAdapter.java Fri Apr 06 17:43:01 2012 +0200 → src/com/beem/project/beem/service/XmppConnectionAdapter.java Tue Apr 10 14:23:32 2012 -0500 | ||
|---|---|---|
| 87 | 87 |
import org.jivesoftware.smack.util.StringUtils; |
| 88 | 88 |
import org.jivesoftware.smackx.ChatStateManager; |
| 89 | 89 |
import org.jivesoftware.smackx.ServiceDiscoveryManager; |
| 90 |
import org.jivesoftware.smackx.bookmark.BookmarkManager; |
|
| 90 | 91 |
import org.jivesoftware.smackx.packet.DiscoverInfo; |
| 91 | 92 | |
| 92 | 93 |
/** |
| ... | ... | |
| 107 | 108 |
private final String mLogin; |
| 108 | 109 |
private final String mPassword; |
| 109 | 110 |
private String mResource; |
| 111 |
private String mDefaultNickname; |
|
| 110 | 112 |
private String mErrorMsg; |
| 111 | 113 |
private RosterAdapter mRoster; |
| 112 | 114 |
private int mPreviousPriority; |
| /dev/null Thu Jan 01 00:00:00 1970 +0000 → src/com/beem/project/beem/service/aidl/IChatMUC.aidl Tue Apr 10 14:23:32 2012 -0500 | ||
|---|---|---|
| 1 |
/* |
|
| 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, |
|
| 9 |
Vincent Veronis. |
|
| 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 | ||
| 29 |
Epitech, hereby disclaims all copyright interest in the program "Beem" |
|
| 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 | ||
| 43 |
*/ |
|
| 44 |
package com.beem.project.beem.service.aidl; |
|
| 45 | ||
| 46 |
import com.beem.project.beem.service.Contact; |
|
| 47 |
import com.beem.project.beem.service.Message; |
|
| 48 |
import com.beem.project.beem.service.aidl.IMessageListener; |
|
| 49 | ||
| 50 |
/** |
|
| 51 |
* An aidl interface for ChatMUC session. |
|
| 52 |
*/ |
|
| 53 |
interface IChatMUC {
|
|
| 54 |
/** |
|
| 55 |
* Send a message. |
|
| 56 |
* @param message the message to send |
|
| 57 |
*/ |
|
| 58 |
void sendMessage(in Message message); |
|
| 59 |
|
|
| 60 |
Contact getRoom() ; |
|
| 61 |
/** |
|
| 62 |
* Add a message listener. |
|
| 63 |
* @param listener the listener to add. |
|
| 64 |
*/ |
|
| 65 |
void addMessageListener(in IMessageListener listener); |
|
| 66 | ||
| 67 |
/** |
|
| 68 |
* Remove a message listener. |
|
| 69 |
* @param listener the listener to remove. |
|
| 70 |
*/ |
|
| 71 |
void removeMessageListener(in IMessageListener listener); |
|
| 72 | ||
| 73 |
String getState(); |
|
| 74 | ||
| 75 |
void setOpen(in boolean isOpen); |
|
| 76 | ||
| 77 |
boolean isOpen(); |
|
| 78 | ||
| 79 |
void setState(in String state); |
|
| 80 | ||
| 81 |
List<Message> getMessages(); |
|
| 82 | ||
| 83 |
List<Contact> getMembers(); |
|
| 84 | ||
| 85 |
} |
|
| src/com/beem/project/beem/service/aidl/IChatManager.aidl Fri Apr 06 17:43:01 2012 +0200 → src/com/beem/project/beem/service/aidl/IChatManager.aidl Tue Apr 10 14:23:32 2012 -0500 | ||
|---|---|---|
| 45 | 45 | |
| 46 | 46 |
import com.beem.project.beem.service.Contact; |
| 47 | 47 |
import com.beem.project.beem.service.aidl.IChat; |
| 48 |
import com.beem.project.beem.service.aidl.IChatMUC; |
|
| 48 | 49 |
import com.beem.project.beem.service.aidl.IMessageListener; |
| 49 | 50 |
import com.beem.project.beem.service.aidl.IChatManagerListener; |
| 50 | 51 | |
| ... | ... | |
| 61 | 62 |
* @return the chat session |
| 62 | 63 |
*/ |
| 63 | 64 |
IChat createChat(in Contact contact, in IMessageListener listener); |
| 65 |
IChatMUC createMUCChat(in Contact contact, in IMessageListener listener); |
|
| 64 | 66 | |
| 65 | 67 |
/** |
| 66 | 68 |
* Get an existing Chat session with a contact. |
| 67 | 69 |
* @return null if the chat session does not exist. |
| 68 | 70 |
*/ |
| 69 | 71 |
IChat getChat(in Contact contact); |
| 72 |
IChatMUC getMUCChat(in Contact contact); |
|
| 70 | 73 | |
| 71 | 74 |
/** |
| 72 | 75 |
* Destroy a chat session with a contact. |
| 73 | 76 |
* @param chat the chat session |
| 74 | 77 |
*/ |
| 75 | 78 |
void destroyChat(in IChat chat); |
| 79 |
void destroyMUCChat(in IChatMUC chat); |
|
| 76 | 80 | |
| 77 | 81 |
/** |
| 78 | 82 |
* @param chat the chat. |
| src/com/beem/project/beem/service/aidl/IMessageListener.aidl Fri Apr 06 17:43:01 2012 +0200 → src/com/beem/project/beem/service/aidl/IMessageListener.aidl Tue Apr 10 14:23:32 2012 -0500 | ||
|---|---|---|
| 45 | 45 | |
| 46 | 46 |
import com.beem.project.beem.service.Message; |
| 47 | 47 |
import com.beem.project.beem.service.aidl.IChat; |
| 48 |
import com.beem.project.beem.service.aidl.IChatMUC; |
|
| 48 | 49 | |
| 49 | 50 |
interface IMessageListener {
|
| 50 | 51 | |
| ... | ... | |
| 54 | 55 |
* @param msg the message received in the chat. |
| 55 | 56 |
*/ |
| 56 | 57 |
void processMessage(in IChat chat, in Message msg); |
| 58 |
void processMUCMessage(in IChatMUC chat, in Message msg); |
|
| 57 | 59 | |
| 58 | 60 |
/** |
| 59 | 61 |
* This method is executed when a new ChatState is received by the chat. |
| src/com/beem/project/beem/ui/Chat.java Fri Apr 06 17:43:01 2012 +0200 → src/com/beem/project/beem/ui/Chat.java Tue Apr 10 14:23:32 2012 -0500 | ||
|---|---|---|
| 98 | 98 |
import com.beem.project.beem.service.PresenceAdapter; |
| 99 | 99 |
import com.beem.project.beem.service.aidl.IBeemRosterListener; |
| 100 | 100 |
import com.beem.project.beem.service.aidl.IChat; |
| 101 |
import com.beem.project.beem.service.aidl.IChatMUC; |
|
| 101 | 102 |
import com.beem.project.beem.service.aidl.IChatManager; |
| 102 | 103 |
import com.beem.project.beem.service.aidl.IChatManagerListener; |
| 103 | 104 |
import com.beem.project.beem.service.aidl.IMessageListener; |
| ... | ... | |
| 141 | 142 |
|
| 142 | 143 |
private final List<MessageText> mListMessages = new ArrayList<MessageText>(); |
| 143 | 144 |
|
| 144 |
private IChat mChat; |
|
| 145 | 145 |
private IChatManager mChatManager; |
| 146 | 146 |
private final IMessageListener mMessageListener = new OnMessageListener(); |
| 147 | 147 |
private final IChatManagerListener mChatManagerListener = new ChatManagerListener(); |
| ... | ... | |
| 231 | 231 |
protected void onPause() {
|
| 232 | 232 |
super.onPause(); |
| 233 | 233 |
try {
|
| 234 |
IChat mChat = mChatManager.getChat(mContact); |
|
| 234 | 235 |
if (mChat != null) {
|
| 235 | 236 |
mChat.setOpen(false); |
| 236 | 237 |
mChat.removeMessageListener(mMessageListener); |
| 237 | 238 |
} |
| 239 |
IChatMUC mChatMUC = mChatManager.getMUCChat(mContact); |
|
| 240 |
if (mChatMUC != null) {
|
|
| 241 |
mChatMUC.setOpen(false); |
|
| 242 |
mChatMUC.removeMessageListener(mMessageListener); |
|
| 243 |
} |
|
| 238 | 244 |
if (mRoster != null) |
| 239 | 245 |
mRoster.removeRosterListener(mBeemRosterListener); |
| 240 | 246 |
if (mChatManager != null) |
| ... | ... | |
| 248 | 254 |
} |
| 249 | 255 |
mXmppFacade = null; |
| 250 | 256 |
mRoster = null; |
| 251 |
mChat = null; |
|
| 252 | 257 |
mChatManager = null; |
| 253 | 258 |
} |
| 254 | 259 |
|
| ... | ... | |
| 310 | 315 |
break; |
| 311 | 316 |
case R.id.chat_menu_close_chat: |
| 312 | 317 |
try {
|
| 318 |
IChat mChat = mChatManager.getChat(mContact); |
|
| 313 | 319 |
mChatManager.destroyChat(mChat); |
| 320 |
IChatMUC mMUCChat = mChatManager.getMUCChat(mContact); |
|
| 321 |
mChatManager.destroyMUCChat(mMUCChat); |
|
| 314 | 322 |
} catch (RemoteException e) {
|
| 315 | 323 |
Log.e(TAG, e.getMessage()); |
| 316 | 324 |
} |
| ... | ... | |
| 368 | 376 |
* @throws RemoteException If a Binder remote-invocation error occurred. |
| 369 | 377 |
*/ |
| 370 | 378 |
private void changeCurrentChat(Contact contact) throws RemoteException {
|
| 371 |
if (mChat != null) {
|
|
| 372 |
mChat.setOpen(false); |
|
| 373 |
mChat.removeMessageListener(mMessageListener); |
|
| 379 |
if (mContact.isMUC()) {
|
|
| 380 |
IChatMUC mChat = mChatManager.getMUCChat(mContact) ; |
|
| 381 |
if (mChat != null) {
|
|
| 382 |
mChat.setOpen(false); |
|
| 383 |
mChat.removeMessageListener(mMessageListener); |
|
| 384 |
} |
|
| 385 |
} else {
|
|
| 386 |
IChat mChat = mChatManager.getChat(mContact) ; |
|
| 387 |
if (mChat != null) {
|
|
| 388 |
mChat.setOpen(false); |
|
| 389 |
mChat.removeMessageListener(mMessageListener); |
|
| 390 |
} |
|
| 374 | 391 |
} |
| 375 |
mChat = mChatManager.getChat(contact); |
|
| 376 |
if (mChat != null) {
|
|
| 377 |
mChat.setOpen(true); |
|
| 378 |
mChat.addMessageListener(mMessageListener); |
|
| 379 |
mChatManager.deleteChatNotification(mChat); |
|
| 380 |
updateOtrInformations(mChat.getOtrStatus()); |
|
| 392 |
|
|
| 393 |
if (contact.isMUC()) {
|
|
| 394 |
IChatMUC newChat = mChatManager.getMUCChat(contact); |
|
| 395 |
if (newChat != null) {
|
|
| 396 |
newChat.setOpen(true); |
|
| 397 |
newChat.addMessageListener(mMessageListener); |
|
| 398 |
} |
|
| 399 |
mContact = contact; |
|
| 400 |
} else {
|
|
| 401 |
IChat newChat = mChatManager.getChat(contact); |
|
| 402 |
if (newChat != null) {
|
|
| 403 |
newChat.setOpen(true); |
|
| 404 |
newChat.addMessageListener(mMessageListener); |
|
| 405 |
mChatManager.deleteChatNotification(newChat); |
|
| 406 |
} |
|
| 407 |
mContact = mRoster.getContact(contact.getJID()); |
|
| 381 | 408 |
} |
| 382 |
mContact = mRoster.getContact(contact.getJID()); |
|
| 409 |
|
|
| 383 | 410 |
String res = contact.getSelectedRes(); |
| 384 | 411 |
if (mContact == null) |
| 385 |
mContact = contact;
|
|
| 412 |
mContact = contact;
|
|
| 386 | 413 |
if (!"".equals(res)) {
|
| 387 |
mContact.setSelectedRes(res);
|
|
| 414 |
mContact.setSelectedRes(res);
|
|
| 388 | 415 |
} |
| 389 | 416 |
updateContactInformations(); |
| 390 | 417 |
updateContactStatusIcon(); |
| ... | ... | |
| 398 | 425 |
*/ |
| 399 | 426 |
private void playRegisteredTranscript() throws RemoteException {
|
| 400 | 427 |
mListMessages.clear(); |
| 401 |
if (mChat != null) {
|
|
| 402 |
List<MessageText> msgList = convertMessagesList(mChat.getMessages()); |
|
| 403 |
mListMessages.addAll(msgList); |
|
| 404 |
mMessagesListAdapter.notifyDataSetChanged(); |
|
| 428 |
List<MessageText> msgList = null ; |
|
| 429 |
if (mContact.isMUC()) {
|
|
| 430 |
IChatMUC mChat = mChatManager.getMUCChat(mContact) ; |
|
| 431 |
if (mChat != null) {
|
|
| 432 |
msgList = convertMessagesList(mChat.getMessages()); |
|
| 433 |
} |
|
| 434 |
} else {
|
|
| 435 |
IChat mChat = mChatManager.getChat(mContact) ; |
|
| 436 |
if (mChat != null) {
|
|
| 437 |
msgList = convertMessagesList(mChat.getMessages()); |
|
| 438 |
} |
|
| 439 |
|
|
| 440 |
} |
|
| 441 |
|
|
| 442 |
if (msgList != null) {
|
|
| 443 |
mListMessages.addAll(msgList); |
|
| 444 |
mMessagesListAdapter.notifyDataSetChanged(); |
|
| 405 | 445 |
} |
| 406 | 446 |
} |
| 407 | 447 |
|
| ... | ... | |
| 421 | 461 |
String fromBareJid = StringUtils.parseBareAddress(m.getFrom()); |
| 422 | 462 |
if (m.getType() == Message.MSG_TYPE_ERROR) {
|
| 423 | 463 |
lastMessage = null; |
| 424 |
result.add(new MessageText(fromBareJid, name, m.getBody(), true, m.getTimestamp())); |
|
| 425 |
} else if (m.getType() == Message.MSG_TYPE_INFO) {
|
|
| 426 |
lastMessage = new MessageText("", "", m.getBody(), false);
|
|
| 427 |
result.add(lastMessage);
|
|
| 428 |
|
|
| 429 |
} else if (m.getType() == Message.MSG_TYPE_CHAT) {
|
|
| 430 |
if (fromBareJid == null) { //nofrom or from == yours
|
|
| 464 |
result.add(new MessageText(fromBareJid, name, m.getBody(), true, false, m.getTimestamp()));
|
|
| 465 |
} else if (m.getType() == Message.MSG_TYPE_CHAT || m.getType() == Message.MSG_TYPE_GROUP_CHAT) {
|
|
| 466 |
if (m.getType() == Message.MSG_TYPE_GROUP_CHAT) {
|
|
| 467 |
name = StringUtils.parseResource(m.getFrom());
|
|
| 468 |
} |
|
| 469 |
|
|
| 470 |
if (fromBareJid == null) { //nofrom or from == yours
|
|
| 431 | 471 |
name = localName; |
| 432 | 472 |
fromBareJid = ""; |
| 433 | 473 |
} |
| 434 | 474 |
|
| 435 | 475 |
if (m.getBody() != null) {
|
| 436 |
if (lastMessage == null || !fromBareJid.equals(lastMessage.getBareJid())) {
|
|
| 437 |
lastMessage = new MessageText(fromBareJid, name, m.getBody(), false, m.getTimestamp()); |
|
| 438 |
result.add(lastMessage); |
|
| 439 |
} else {
|
|
| 440 |
lastMessage.setMessage(lastMessage.getMessage().concat("\n" + m.getBody()));
|
|
| 441 |
} |
|
| 476 |
if (lastMessage != null && lastMessage.getBareJid().equals(fromBareJid) && lastMessage.getName().equals(name)) {
|
|
| 477 |
if (m.isHL()) {
|
|
| 478 |
lastMessage.setHL(true) ; |
|
| 479 |
} |
|
| 480 |
lastMessage.setMessage(lastMessage.getMessage().concat("\n" + m.getBody()));
|
|
| 481 |
} else {
|
|
| 482 |
lastMessage = new MessageText(fromBareJid, name, m.getBody(), false, m.isHL(), m.getTimestamp()); |
|
| 483 |
result.add(lastMessage); |
|
| 442 | 484 |
} |
| 443 | 485 |
} |
| 444 | 486 |
} |
| ... | ... | |
| 465 | 507 |
final String inputContent = mInputField.getText().toString(); |
| 466 | 508 |
|
| 467 | 509 |
if (!"".equals(inputContent)) {
|
| 468 |
Message msgToSend = new Message(mContact.getJIDWithRes(), Message.MSG_TYPE_CHAT); |
|
| 510 |
Message msgToSend; |
|
| 511 |
if (mContact.isMUC()) {
|
|
| 512 |
msgToSend = new Message(mContact.getJID(), Message.MSG_TYPE_GROUP_CHAT); |
|
| 513 |
} else {
|
|
| 514 |
msgToSend = new Message(mContact.getJIDWithRes(), Message.MSG_TYPE_CHAT); |
|
| 515 |
} |
|
| 469 | 516 |
msgToSend.setBody(inputContent); |
| 470 | 517 |
|
| 471 | 518 |
try {
|
| 472 |
if (mChat == null) {
|
|
| 473 |
mChat = mChatManager.createChat(mContact, mMessageListener); |
|
| 474 |
mChat.setOpen(true); |
|
| 519 |
if (mContact.isMUC()) {
|
|
| 520 |
IChatMUC mChatMUC = mChatManager.getMUCChat(mContact) ; |
|
| 521 |
mChatMUC.sendMessage(msgToSend); |
|
| 522 |
} else {
|
|
| 523 |
IChat mChat = mChatManager.getChat(mContact) ; |
|
| 524 |
if (mChat == null) {
|
|
| 525 |
mChat = mChatManager.createChat(mContact, mMessageListener); |
|
| 526 |
mChat.setOpen(true); |
|
| 527 |
} |
|
| 528 |
mChat.sendMessage(msgToSend); |
|
| 529 |
final String self = getString(R.string.chat_self); |
|
| 530 |
MessageText lastMessage = null; |
|
| 531 |
if (mListMessages.size() != 0) |
|
| 532 |
lastMessage = mListMessages.get(mListMessages.size() - 1); |
|
| 533 |
|
|
| 534 |
if (lastMessage != null && lastMessage.getName().equals(self)) {
|
|
| 535 |
lastMessage.setMessage(lastMessage.getMessage().concat("\n" + inputContent));
|
|
| 536 |
lastMessage.setTimestamp(new Date()); |
|
| 537 |
} else {
|
|
| 538 |
mListMessages.add(new MessageText(self, self, inputContent, false, false, new Date())); |
|
| 539 |
} |
|
| 475 | 540 |
} |
| 476 |
mChat.sendMessage(msgToSend); |
|
| 477 | 541 |
} catch (RemoteException e) {
|
| 478 | 542 |
Log.e(TAG, e.getMessage()); |
| 479 | 543 |
} |
| 480 | 544 |
|
| 481 |
final String self = getString(R.string.chat_self); |
|
| 482 |
MessageText lastMessage = null; |
|
| 483 |
if (mListMessages.size() != 0) |
|
| 484 |
lastMessage = mListMessages.get(mListMessages.size() - 1); |
|
| 485 |
|
|
| 486 |
if (lastMessage != null && lastMessage.getName().equals(self)) {
|
|
| 487 |
lastMessage.setMessage(lastMessage.getMessage().concat("\n" + inputContent));
|
|
| 488 |
lastMessage.setTimestamp(new Date()); |
|
| 489 |
} else |
|
| 490 |
mListMessages.add(new MessageText(self, self, inputContent, false, new Date())); |
|
| 491 | 545 |
mMessagesListAdapter.notifyDataSetChanged(); |
| 492 | 546 |
mInputField.setText(null); |
| 493 | 547 |
} |
| ... | ... | |
| 630 | 684 |
mChatManager.addChatCreationListener(mChatManagerListener); |
| 631 | 685 |
changeCurrentChat(mContact); |
| 632 | 686 |
} |
| 687 |
if (mContact!= null && mContact.isMUC()) {
|
|
| 688 |
IChatMUC muc = mChatManager.getMUCChat(mContact) ; |
|
| 689 |
if (muc == null) {
|
|
| 690 |
Log.d(TAG,"Service connected : "+mContact.getJIDWithRes()) ; |
|
| 691 |
IChatMUC mChatMUC = mChatManager.createMUCChat(mContact, mMessageListener) ; |
|
| 692 |
mChatMUC.addMessageListener(mMessageListener) ; |
|
| 693 |
mChatMUC.setOpen(true); |
|
| 694 |
} |
|
| 695 |
} |
|
| 633 | 696 |
} catch (RemoteException e) {
|
| 634 | 697 |
Log.e(TAG, e.getMessage()); |
| 635 | 698 |
} |
| ... | ... | |
| 725 | 788 |
@Override |
| 726 | 789 |
public void run() {
|
| 727 | 790 |
if (msg.getType() == Message.MSG_TYPE_ERROR) {
|
| 728 |
mListMessages.add(new MessageText(fromBareJid, mContact.getName(), msg.getBody(), true, msg |
|
| 729 |
.getTimestamp())); |
|
| 791 |
mListMessages.add(new MessageText(fromBareJid, mContact.getName(), msg.getBody(), true, false, msg.getTimestamp())); |
|
| 730 | 792 |
mMessagesListAdapter.notifyDataSetChanged(); |
| 731 | 793 |
} else if (msg.getBody() != null) {
|
| 732 | 794 |
MessageText lastMessage = null; |
| 733 | 795 |
if (mListMessages.size() != 0) |
| 734 | 796 |
lastMessage = mListMessages.get(mListMessages.size() - 1); |
| 735 | 797 |
|
| 736 |
if (lastMessage != null && lastMessage.getBareJid().equals(fromBareJid)) {
|
|
| 737 |
lastMessage.setMessage(lastMessage.getMessage().concat("\n" + msg.getBody()));
|
|
| 738 |
lastMessage.setTimestamp(msg.getTimestamp()); |
|
| 739 |
mListMessages.set(mListMessages.size() - 1, lastMessage); |
|
| 740 |
} else if (msg.getBody() != null) |
|
| 741 |
mListMessages.add(new MessageText(fromBareJid, mContact.getName(), msg.getBody(), |
|
| 742 |
false, msg.getTimestamp())); |
|
| 743 |
mMessagesListAdapter.notifyDataSetChanged(); |
|
| 798 |
String name; |
|
| 799 |
if (mContact.isMUC()) {
|
|
| 800 |
name = StringUtils.parseResource(msg.getFrom()); |
|
| 801 |
} else {
|
|
| 802 |
name = mContact.getName(); |
|
| 803 |
} |
|
| 804 |
|
|
| 805 |
if (lastMessage != null && lastMessage.getBareJid().equals(fromBareJid) && lastMessage.getName().equals(name)) {
|
|
| 806 |
if (msg.isHL()) {
|
|
| 807 |
lastMessage.setHL(true); |
|
| 808 |
} |
|
| 809 |
lastMessage.setMessage(lastMessage.getMessage().concat("\n" + msg.getBody()));
|
|
| 810 |
lastMessage.setTimestamp(msg.getTimestamp()); |
|
| 811 |
mListMessages.set(mListMessages.size() - 1, lastMessage); |
|
| 812 |
} else if (msg.getBody() != null) {
|
|
| 813 |
mListMessages.add(new MessageText(fromBareJid, name, msg.getBody(), false, msg.isHL(), msg.getTimestamp())); |
|
| 814 |
mMessagesListAdapter.notifyDataSetChanged(); |
|
| 815 |
} |
|
| 744 | 816 |
} |
| 745 | 817 |
} |
| 746 | 818 |
}); |
| 747 | 819 |
} |
| 748 | 820 |
} |
| 749 | 821 |
|
| 822 |
@Override |
|
| 823 |
public void processMUCMessage(IChatMUC chat, final Message msg) throws RemoteException {
|
|
| 824 |
processMessage(null, msg) ; |
|
| 825 |
} |
|
| 826 |
|
|
| 750 | 827 |
/** |
| 751 | 828 |
* {@inheritDoc}.
|
| 752 | 829 |
*/ |
| ... | ... | |
| 848 | 925 |
MessageText msg = mListMessages.get(position); |
| 849 | 926 |
TextView msgName = (TextView) sv.findViewById(R.id.chatmessagename); |
| 850 | 927 |
msgName.setText(msg.getName()); |
| 851 |
msgName.setTextColor(Color.WHITE); |
|
| 928 |
if (msg.isHL()) {
|
|
| 929 |
msgName.setTextColor(Color.RED); |
|
| 930 |
} else {
|
|
| 931 |
msgName.setTextColor(Color.WHITE); |
|
| 932 |
} |
|
| 852 | 933 |
msgName.setError(null); |
| 853 | 934 |
TextView msgText = (TextView) sv.findViewById(R.id.chatmessagetext); |
| 854 | 935 |
msgText.setText(msg.getMessage()); |
| ... | ... | |
| 877 | 958 |
private String mName; |
| 878 | 959 |
private String mMessage; |
| 879 | 960 |
private boolean mIsError; |
| 961 |
private boolean mHL; |
|
| 880 | 962 |
private Date mTimestamp; |
| 881 | 963 |
|
| 882 | 964 |
/** |
| ... | ... | |
| 912 | 994 |
* @param name A String containing the name of the message's author. |
| 913 | 995 |
* @param message A String containing the message. |
| 914 | 996 |
* @param isError if the message is an error message. |
| 915 |
* @param date the time of the message.
|
|
| 997 |
* @param isHL if the message is a highlight
|
|
| 916 | 998 |
*/ |
| 917 |
public MessageText(final String bareJid, final String name, final String message, final boolean isError, |
|
| 918 |
final Date date) {
|
|
| 999 |
|
|
| 1000 |
public MessageText(final String bareJid, final String name, final String message, final boolean isError, final boolean isHL) {
|
|
| 919 | 1001 |
mBareJid = bareJid; |
| 920 | 1002 |
mName = name; |
| 921 | 1003 |
mMessage = message; |
| 922 | 1004 |
mIsError = isError; |
| 1005 |
mHL = isHL; |
|
| 1006 |
} |
|
| 1007 |
|
|
| 1008 |
/** |
|
| 1009 |
* Constructor. |
|
| 1010 |
* @param bareJid A String containing the bare JID of the message's author. |
|
| 1011 |
* @param name A String containing the name of the message's author. |
|
| 1012 |
* @param message A String containing the message. |
|
| 1013 |
* @param isError if the message is an error message. |
|
| 1014 |
* @param isHL if the message is a highlight |
|
| 1015 |
* @param date the time of the message. |
|
| 1016 |
*/ |
|
| 1017 |
|
|
| 1018 |
public MessageText(final String bareJid, final String name, final String message, final boolean isError, final boolean isHL, Date date) {
|
|
| 1019 |
mBareJid = bareJid; |
|
| 1020 |
mName = name; |
|
| 1021 |
mMessage = message; |
|
| 1022 |
mIsError = isError; |
|
| 1023 |
mHL = isHL; |
|
| 923 | 1024 |
mTimestamp = date; |
| 924 | 1025 |
} |
| 925 | 1026 |
|
| ... | ... | |
| 982 | 1083 |
} |
| 983 | 1084 |
|
| 984 | 1085 |
/** |
| 1086 |
* Get if the message is a highlight. |
|
| 1087 |
* @return true if the message is a highlight. |
|
| 1088 |
*/ |
|
| 1089 |
public boolean isHL() {
|
|
| 1090 |
return mHL; |
|
| 1091 |
} |
|
| 1092 |
|
|
| 1093 |
/** |
|
| 1094 |
* Set whether the message is a highlight. |
|
| 1095 |
* @param hl true if the message is a highlight. |
|
| 1096 |
*/ |
|
| 1097 |
public void setHL(boolean hl) {
|
|
| 1098 |
mHL = hl ; |
|
| 1099 |
} |
|
| 1100 |
|
|
| 1101 |
/** |
|
| 985 | 1102 |
* Set the Date of the message. |
| 986 | 1103 |
* @param date date of the message. |
| 987 | 1104 |
*/ |
| ... | ... | |
| 1019 | 1136 |
String chatJid = chat.getParticipant().getJIDWithRes(); |
| 1020 | 1137 |
if (chatJid.equals(contactJid)) {
|
| 1021 | 1138 |
// This should not be happened but to be sure |
| 1139 |
IChat mChat = mChatManager.getChat(mContact); |
|
| 1022 | 1140 |
if (mChat != null) {
|
| 1023 | 1141 |
mChat.setOpen(false); |
| 1024 | 1142 |
mChat.removeMessageListener(mMessageListener); |
| src/com/beem/project/beem/ui/ContactList.java Fri Apr 06 17:43:01 2012 +0200 → src/com/beem/project/beem/ui/ContactList.java Tue Apr 10 14:23:32 2012 -0500 | ||
|---|---|---|
| 102 | 102 |
import com.beem.project.beem.ui.dialogs.builders.Alias; |
| 103 | 103 |
import com.beem.project.beem.ui.dialogs.builders.ChatList; |
| 104 | 104 |
import com.beem.project.beem.ui.dialogs.builders.DeleteContact; |
| 105 |
import com.beem.project.beem.ui.dialogs.builders.JoinMUC; |
|
| 105 | 106 |
import com.beem.project.beem.ui.dialogs.builders.ResendSubscription; |
| 106 | 107 |
import com.beem.project.beem.utils.BeemBroadcastReceiver; |
| 107 | 108 |
import com.beem.project.beem.utils.SortedList; |
| ... | ... | |
| 166 | 167 |
public final boolean onOptionsItemSelected(MenuItem item) {
|
| 167 | 168 |
switch (item.getItemId()) {
|
| 168 | 169 |
case R.id.contact_list_menu_settings: |
| 169 |
startActivity(new Intent(this, Settings.class)); |
|
| 170 |
return true; |
|
| 170 |
startActivity(new Intent(this, Settings.class));
|
|
| 171 |
return true;
|
|
| 171 | 172 |
case R.id.contact_list_menu_add_contact: |
| 172 |
startActivity(new Intent(ContactList.this, AddContact.class)); |
|
| 173 |
return true; |
|
| 173 |
startActivity(new Intent(ContactList.this, AddContact.class));
|
|
| 174 |
return true;
|
|
| 174 | 175 |
case R.id.menu_change_status: |
| 175 |
startActivity(new Intent(ContactList.this, ChangeStatus.class)); |
|
| 176 |
return true; |
|
| 176 |
startActivity(new Intent(ContactList.this, ChangeStatus.class));
|
|
| 177 |
return true;
|
|
| 177 | 178 |
case R.id.contact_list_menu_chatlist: |
| 178 |
List<Contact> openedChats; |
|
| 179 |
try {
|
|
| 180 |
openedChats = mChatManager.getOpenedChatList();
|
|
| 181 |
Log.d(TAG, "opened chats = " + openedChats);
|
|
| 182 |
Dialog chatList = new ChatList(ContactList.this, openedChats).create();
|
|
| 183 |
chatList.show();
|
|
| 184 |
} catch (RemoteException e) {
|
|
| 185 |
e.printStackTrace();
|
|
| 186 |
} |
|
| 187 |
return true; |
|
| 179 |
List<Contact> openedChats;
|
|
| 180 |
try {
|
|
| 181 |
openedChats = mChatManager.getOpenedChatList();
|
|
| 182 |
Log.d(TAG, "opened chats = " + openedChats);
|
|
| 183 |
Dialog chatList = new ChatList(ContactList.this, openedChats).create();
|
|
| 184 |
chatList.show();
|
|
| 185 |
} catch (RemoteException e) {
|
|
| 186 |
e.printStackTrace();
|
|
| 187 |
}
|
|
| 188 |
return true;
|
|
| 188 | 189 |
case R.id.menu_disconnect: |
| 189 |
stopService(SERVICE_INTENT); |
|
| 190 |
finish(); |
|
| 191 |
return true; |
|
| 190 |
stopService(SERVICE_INTENT); |
|
| 191 |
finish(); |
|
| 192 |
return true; |
|
| 193 |
case R.id.muc: |
|
| 194 |
Dialog joinmuc = new JoinMUC(ContactList.this).create() ; |
|
| 195 |
joinmuc.show() ; |
|
| 196 |
return true; |
|
| 192 | 197 |
default: |
| 193 |
return false; |
|
| 198 |
return false;
|
|
| 194 | 199 |
} |
| 195 | 200 |
} |
| 196 | 201 | |
| ... | ... | |
| 266 | 271 |
delete.show(); |
| 267 | 272 |
result = true; |
| 268 | 273 |
break; |
| 274 |
case R.id.contact_list_context_menu_joinasmuc_item: |
|
| 275 |
Contact c = new Contact(mSelectedContact.getJID(), true); |
|
| 276 |
Intent i = new Intent(ContactList.this, Chat.class); |
|
| 277 |
i.setData(c.toUri(mSettings.getString("settings_key_nickname", "BeemGuest")));
|
|
| 278 |
startActivity(i); |
|
| 279 |
result = true; |
|
| 280 |
break; |
|
| 269 | 281 |
default: |
| 270 | 282 |
result = super.onContextItemSelected(item); |
| 271 | 283 |
break; |
| src/com/beem/project/beem/ui/dialogs/builders/ChatList.java Fri Apr 06 17:43:01 2012 +0200 → src/com/beem/project/beem/ui/dialogs/builders/ChatList.java Tue Apr 10 14:23:32 2012 -0500 | ||
|---|---|---|
| 73 | 73 | |
| 74 | 74 |
int i = 0; |
| 75 | 75 |
for (Contact c : openedChats) {
|
| 76 |
items[i++] = c.getName(); |
|
| 76 |
if (c.isMUC()) {
|
|
| 77 |
items[i++] = "[C] "+c.getJID(); |
|
| 78 |
} else {
|
|
| 79 |
items[i++] = c.getJIDWithRes(); |
|
| 80 |
} |
|
| 77 | 81 |
} |
| 78 | 82 |
setTitle(R.string.chat_dialog_change_chat_title); |
| 79 | 83 |
setItems(items, new DialogInterface.OnClickListener() {
|
| /dev/null Thu Jan 01 00:00:00 1970 +0000 → src/com/beem/project/beem/ui/dialogs/builders/JoinMUC.java Tue Apr 10 14:23:32 2012 -0500 | ||
|---|---|---|
| 1 |
/* |
|
| 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, |
|
| 9 |
Vincent Veronis. |
|
| 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 | ||
| 29 |
Epitech, hereby disclaims all copyright interest in the program "Beem" |
|
| 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 | ||
| 43 |
*/ |
|
| 44 |
package com.beem.project.beem.ui.dialogs.builders; |
|
| 45 | ||
| 46 |
import android.app.AlertDialog; |
|
| 47 |
import android.content.Context; |
|
| 48 |
import android.content.DialogInterface; |
|
| 49 |
import android.content.Intent; |
|
| 50 |
import android.view.LayoutInflater; |
|
| 51 |
import android.view.View; |
|
| 52 |
import android.widget.EditText; |
|
| 53 | ||
| 54 |
import com.beem.project.beem.R; |
|
| 55 |
import com.beem.project.beem.service.Contact; |
|
| 56 |
import com.beem.project.beem.ui.Chat; |
|
| 57 | ||
| 58 |
/** |
|
| 59 |
* Create dialog alias. |
|
| 60 |
*/ |
|
| 61 |
public class JoinMUC extends AlertDialog.Builder {
|
|
| 62 | ||
| 63 |
private static final String TAG = "Dialogs.Builders > JoinMUC"; |
|
| 64 | ||
| 65 |
private Context context ; |
|
| 66 |
private EditText mEditTextRoom; |
|
| 67 |
private EditText mEditTextPseudo; |
|
| 68 | ||
| 69 |
/** |
|
| 70 |
* Constructor. |
|
| 71 |
* @param context context activity. |
|
| 72 |
* @param roster Beem roster. |
|
| 73 |
* @param contact the contact to modify. |
|
| 74 |
*/ |
|
| 75 |
public JoinMUC(final Context context) {
|
|
| 76 |
super(context); |
|
| 77 |
this.context = context ; |
|
| 78 |
LayoutInflater factory = LayoutInflater.from(context); |
|
| 79 |
final View textEntryView = factory.inflate( |
|
| 80 |
R.layout.joinmucdialog, null); |
|
| 81 |
setTitle("Join MUC");
|
|
| 82 |
setView(textEntryView); |
|
| 83 |
mEditTextRoom = (EditText) textEntryView.findViewById(R.id.CDRoomDialogName); |
|
| 84 |
mEditTextPseudo = (EditText) textEntryView.findViewById(R.id.CDNickDialogName); |
|
| 85 |
setPositiveButton(R.string.OkButton, new DialogClickListener()); |
|
| 86 |
setNegativeButton(R.string.CancelButton, new DialogClickListener()); |
|
| 87 |
} |
|
| 88 | ||
| 89 |
/** |
|