join muc
authorVincent V.<marseille@beem-project.com>
Mon, 20 Feb 2012 19:51:02 +0100
changeset 932 cdbfa28949bb
parent 931 067387e7ab43
child 933 20b3b1db3d29
join muc
AndroidManifest.xml
src/com/beem/project/beem/BeemIntent.java
src/com/beem/project/beem/BeemService.java
src/com/beem/project/beem/ui/ContactList.java
--- a/AndroidManifest.xml	Mon Feb 20 18:20:41 2012 +0100
+++ b/AndroidManifest.xml	Mon Feb 20 19:51:02 2012 +0100
@@ -196,6 +196,7 @@
                 <action android:name="com.beem.project.beem.intent.action.SEND_MESSAGE" />
                 <action android:name="com.beem.project.beem.intent.action.ADD_CONTACT" />
                 <action android:name="com.beem.project.beem.intent.action.CHANGE_STATUS" />
+                <action android:name="com.beem.project.beem.intent.action.MUC_JOIN" />
             </intent-filter>
         </service>
     </application>
--- a/src/com/beem/project/beem/BeemIntent.java	Mon Feb 20 18:20:41 2012 +0100
+++ b/src/com/beem/project/beem/BeemIntent.java	Mon Feb 20 19:51:02 2012 +0100
@@ -58,6 +58,8 @@
     public static final String ACTION_ADD_CONTACT = "com.beem.project.beem.intent.action.ADD_CONTACT";
 
     public static final String ACTION_CHANGE_STATUS = "com.beem.project.beem.intent.action.CHANGE_STATUS";
+    
+    public static final String ACTION_MUC_JOIN = "com.beem.project.beem.intent.action.MUC_JOIN";
 
     /* Broadcast Receiver's action */
     public static final String ACTION_CONNECTED = "com.beem.project.beem.intent.action.CONNECTED";
--- a/src/com/beem/project/beem/BeemService.java	Mon Feb 20 18:20:41 2012 +0100
+++ b/src/com/beem/project/beem/BeemService.java	Mon Feb 20 19:51:02 2012 +0100
@@ -114,7 +114,9 @@
     private static final int MESSAGE_SYNC = 0x4;
     private static final int MESSAGE_ADD_CONTACT = 0x5;
     private static final int MESSAGE_CHANGE_STATUS = 0x7;
-    //Next = 0x8;
+    private static final int MESSAGE_MUC_JOIN = 0x8;
+
+    //Next = 0x9;
 
     private Map<String, XmppConnectionAdapter> mConnection = new HashMap<String, XmppConnectionAdapter>();
     private Map<String, BeemConnection> mBeemConnection = new HashMap<String, BeemConnection>();
@@ -435,6 +437,8 @@
 	    msg = mHandler.obtainMessage(MESSAGE_ADD_CONTACT, intent.getExtras());
 	} else if (BeemIntent.ACTION_CHANGE_STATUS.equals(action)) {
 	    msg = mHandler.obtainMessage(MESSAGE_CHANGE_STATUS, intent.getExtras());
+	} else if (BeemIntent.ACTION_MUC_JOIN.equals(action)) {
+	    msg = mHandler.obtainMessage(MESSAGE_MUC_JOIN, intent.getExtras());
 	} else {
 	    Log.w(TAG, "Unknown intent " + intent);
 	}
@@ -523,6 +527,18 @@
 			mConnection.get(accountName).changeStatus(status, "");
 		    }
 		    break;
+		case MESSAGE_MUC_JOIN:
+		    String mucjid = b.getString(BeemIntent.EXTRA_JID);
+		    MultiUserChat muc2 = new MultiUserChat(connection.getAdaptee(), mucjid);
+
+		    DiscussionHistory history = new DiscussionHistory();
+		    history.setMaxStanzas(5);
+		    try {
+			muc2.join("beem", "", history, SmackConfiguration.getPacketReplyTimeout());
+		    } catch (XMPPException e) {
+			Log.e(TAG, "MUC Join Problem", e);
+		    }
+		    break;
 		default:
 		    Log.w(TAG, "Unknown message " + msg);
 	    }
--- a/src/com/beem/project/beem/ui/ContactList.java	Mon Feb 20 18:20:41 2012 +0100
+++ b/src/com/beem/project/beem/ui/ContactList.java	Mon Feb 20 19:51:02 2012 +0100
@@ -570,9 +570,14 @@
 	public void onItemClick(AdapterView<?> arg0, View v, int pos, long lpos) {
 	    String jid = (String) v.getTag();
 	    Log.i(TAG, "OnClick MUC Jid:" + jid);
-	    Intent i = new Intent(ContactList.this, Chat.class);
-	    i.setData(Uri.parse("imto://jabber/" + jid));
-	    startActivity(i);
+	    Intent intent = new Intent(BeemIntent.ACTION_MUC_JOIN);
+	    intent.putExtra(BeemIntent.EXTRA_ACCOUNT, mAccountName);
+	    intent.putExtra(BeemIntent.EXTRA_JID, jid);
+	    startService(intent);
+
+	    //	    Intent i = new Intent(ContactList.this, Chat.class);
+	    //	    i.setData(Uri.parse("imto://jabber/" + jid));
+	    //	    startActivity(i);
 	}
     }
 
@@ -625,7 +630,7 @@
 			ContactsContract.RawContacts.SOURCE_ID }, new int[] { R.id.avatar, R.id.contactlistpseudo,
 			R.id.contactlistmsgperso });
 	    }
-	    if (cursor != null) {	
+	    if (cursor != null) {
 		registerForContextMenu(listView);
 		listView.setAdapter(mAdapterContactList);
 		mAdapterContactList.changeCursor(cursor);