Add/join muc - temporary stopped
authorVincent V. <marseille@beem-project.com>
Tue, 10 Apr 2012 11:32:31 +0200
changeset 940 b8e23e8da2f7
parent 939 85a46554a5d5
child 941 2777c49a84b0
Add/join muc - temporary stopped
AndroidManifest.xml
res/layout/addmuc.xml
res/menu/muc_list.xml
res/values/strings.xml
src/com/beem/project/beem/BeemIntent.java
src/com/beem/project/beem/BeemService.java
src/com/beem/project/beem/ui/AddMuc.java
src/com/beem/project/beem/ui/ContactList.java
--- a/AndroidManifest.xml	Thu Feb 23 13:15:47 2012 +0100
+++ b/AndroidManifest.xml	Tue Apr 10 11:32:31 2012 +0200
@@ -5,34 +5,34 @@
     android:versionName="0.1.5" >
 
     <application
+        android:name=".BeemApplication"
         android:icon="@drawable/beem_launcher_icon_silver"
         android:label="@string/app_name"
-        android:name=".BeemApplication"
         android:theme="@style/Theme.BEEM.Default" >
         <activity
+            android:name=".ui.Login"
             android:label="@string/app_name"
-            android:launchMode="standard"
-            android:name=".ui.Login" >
-            <intent-filter >
+            android:launchMode="standard" >
+            <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
 
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
         <activity
-            android:label="Account wizard"
-            android:name=".ui.wizard.Account" />
+            android:name=".ui.wizard.Account"
+            android:label="Account wizard" />
         <activity
-            android:label="Account wizard"
-            android:name=".ui.wizard.AccountConfigure" />
+            android:name=".ui.wizard.AccountConfigure"
+            android:label="Account wizard" />
         <activity
+            android:name=".ui.LoginAnim"
             android:label="@string/login_login_progress"
             android:launchMode="singleTop"
-            android:name=".ui.LoginAnim"
             android:screenOrientation="portrait" />
         <activity
-            android:label="@string/edit_settings_name"
-            android:name=".ui.Settings" >
+            android:name=".ui.Settings"
+            android:label="@string/edit_settings_name" >
             <intent-filter android:label="Beem Android Account" >
                 <action android:name="com.beem.project.beem.SETTINGS" />
 
@@ -43,13 +43,13 @@
             </intent-filter>
         </activity>
         <activity
+            android:name=".ui.Chat"
             android:label="@string/chat_name"
-            android:launchMode="singleTop"
-            android:name=".ui.Chat" >
+            android:launchMode="singleTop" >
             <intent-filter android:label="Beem Connection" >
                 <action android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
             </intent-filter>
-            <intent-filter >
+            <intent-filter>
                 <action android:name="android.intent.action.SENDTO" />
 
                 <category android:name="android.intent.category.DEFAULT" />
@@ -57,7 +57,7 @@
 
                 <data android:scheme="im" />
             </intent-filter>
-            <intent-filter >
+            <intent-filter>
                 <action android:name="android.intent.action.SENDTO" />
 
                 <category android:name="android.intent.category.DEFAULT" />
@@ -68,17 +68,17 @@
             </intent-filter>
         </activity>
         <activity
+            android:name=".ui.MucChat"
             android:label="@string/chat_name"
-            android:launchMode="singleTop"
-            android:name=".ui.MucChat" >
+            android:launchMode="singleTop" >
             <intent-filter android:label="Beem Connection" >
                 <action android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
             </intent-filter>
         </activity>
         <activity
+            android:name=".ui.ChangeStatus"
             android:label="@string/ChangeStatusActTitle"
             android:launchMode="singleTask"
-            android:name=".ui.ChangeStatus"
             android:windowSoftInputMode="stateHidden" >
             <intent-filter android:label="Beem Android Account" >
                 <action android:name="com.beem.project.beem.CHANGESTATUS" />
@@ -90,8 +90,8 @@
             </intent-filter>
         </activity>
         <activity
-            android:label="@string/AddCActTitle"
-            android:name=".ui.AddContact" >
+            android:name=".ui.AddContact"
+            android:label="@string/AddCActTitle" >
             <intent-filter android:label="Create Contact" >
                 <action android:name="android.intent.action.INSERT" />
 
@@ -103,40 +103,44 @@
             </intent-filter>
         </activity>
         <activity
-            android:label="@string/app_name"
-            android:name=".ui.Subscription" >
+            android:name=".ui.AddMuc"
+            android:label="@string/AddMucTitle" >
+        </activity>
+        <activity
+            android:name=".ui.Subscription"
+            android:label="@string/app_name" >
             <intent-filter android:label="Beem Connection" >
                 <action android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
             </intent-filter>
         </activity>
         <activity
-            android:label="@string/create_account_name"
-            android:name=".ui.CreateAccount" />
+            android:name=".ui.CreateAccount"
+            android:label="@string/create_account_name" />
         <activity
+            android:name=".ui.ContactList"
             android:label="@string/contact_list_name"
-            android:launchMode="singleTask"
-            android:name=".ui.ContactList" >
+            android:launchMode="singleTask" >
             <intent-filter android:label="Beem Connection" >
                 <action android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
             </intent-filter>
         </activity>
         <activity
-            android:label="GroupList"
-            android:name=".ui.GroupList" >
+            android:name=".ui.GroupList"
+            android:label="GroupList" >
             <intent-filter android:label="Beem Connection" >
                 <action android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
             </intent-filter>
         </activity>
         <activity
-            android:label="@string/privacy_list_name"
-            android:name=".ui.PrivacyList" >
+            android:name=".ui.PrivacyList"
+            android:label="@string/privacy_list_name" >
             <intent-filter android:label="Beem Connection" >
                 <action android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
             </intent-filter>
         </activity>
         <activity
-            android:label="Sync Settings"
-            android:name="com.beem.project.beem.account.ManageAccountsSettings" >
+            android:name="com.beem.project.beem.account.ManageAccountsSettings"
+            android:label="Sync Settings" >
         </activity>
         <!--
 			Could be interesting if we would launch beem at startup <receiver
@@ -146,24 +150,24 @@
 			</intent-filter> </receiver>
         -->
         <provider
+            android:name=".providers.AvatarProvider"
             android:authorities="com.beem.project.beem.providers.avatarprovider"
             android:exported="false"
-            android:label="Avatar Provider"
-            android:name=".providers.AvatarProvider" />
+            android:label="Avatar Provider" />
         <provider
+            android:name=".providers.MessageProvider"
             android:authorities="com.beem.project.beem.providers.messageprovider"
-            android:label="Message Provider"
-            android:name=".providers.MessageProvider" />
+            android:label="Message Provider" />
         <provider
+            android:name=".providers.MUCsProvider"
             android:authorities="com.beem.project.beem.providers.mucsprovider"
-            android:label="MUCs Provider"
-            android:name=".providers.MUCsProvider" />
+            android:label="MUCs Provider" />
 
         <service
+            android:name=".account.AuthenticatorService"
             android:exported="true"
-            android:name=".account.AuthenticatorService"
             android:process=":auth" >
-            <intent-filter >
+            <intent-filter>
                 <action android:name="android.accounts.AccountAuthenticator" />
             </intent-filter>
 
@@ -172,10 +176,10 @@
                 android:resource="@xml/authenticator" />
         </service>
         <service
+            android:name=".account.SyncAdapterService"
             android:exported="true"
-            android:name=".account.SyncAdapterService"
             android:process=":contacts" >
-            <intent-filter >
+            <intent-filter>
                 <action android:name="android.content.SyncAdapter" />
             </intent-filter>
 
@@ -187,15 +191,11 @@
                 android:resource="@xml/contacts" />
         </service>
         <service
+            android:name="BeemService"
             android:enabled="true"
             android:label="Beem Service"
-            android:name="BeemService"
             android:permission="com.beem.project.beem.BEEM_SERVICE" >
-            <intent-filter >
-                <action android:name="com.beem.project.beem.BeemService" >
-                </action>
-            </intent-filter>
-            <intent-filter >
+            <intent-filter>
                 <action android:name="com.beem.project.beem.BeemService" />
                 <action android:name="com.beem.project.beem.intent.action.SYNC" />
                 <action android:name="com.beem.project.beem.intent.action.CONNECT" />
@@ -206,14 +206,15 @@
                 <action android:name="com.beem.project.beem.intent.action.CHANGE_STATUS" />
                 <action android:name="com.beem.project.beem.intent.action.MUC_JOIN" />
                 <action android:name="com.beem.project.beem.intent.action.MUC_SEND_MESSAGE" />
+                <action android:name="com.beem.project.beem.intent.action.ADD_MUC" />
             </intent-filter>
         </service>
     </application>
 
     <permission
+        android:name="com.beem.project.beem.BEEM_SERVICE"
         android:description="@string/BeemServiceDescription"
         android:label="BeemService"
-        android:name="com.beem.project.beem.BEEM_SERVICE"
         android:permissionGroup="android.permission-group.NETWORK" />
 
     <uses-permission android:name="android.permission.INTERNET" />
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/addmuc.xml	Tue Apr 10 11:32:31 2012 +0200
@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="vertical" >
+
+    <LinearLayout
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical"
+        android:padding="10dip" >
+
+        <TextView
+            style="@style/Label"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_vertical"
+            android:text="@string/AddMJid" />
+
+        <EditText
+            android:id="@+id/addm_jid"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_margin="3dip"
+            android:contentDescription="@string/AddMJid"
+            android:imeOptions="actionNext"
+            android:inputType="textEmailAddress"
+            android:scrollHorizontally="true" />
+
+        <View
+            android:layout_width="fill_parent"
+            android:layout_height="1dp"
+            android:background="?android:attr/listDivider" />
+
+        <TextView
+            style="@style/Label"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_vertical"
+            android:text="@string/AddMName" />
+
+        <EditText
+            android:id="@+id/addm_name"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_margin="3dip"
+            android:contentDescription="@string/AddMName"
+            android:imeOptions="actionNext"
+            android:inputType="text"
+            android:scrollHorizontally="true" />
+
+        <View
+            android:layout_width="fill_parent"
+            android:layout_height="1dp"
+            android:background="?android:attr/listDivider" />
+
+        <TextView
+            style="@style/Label"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_vertical"
+            android:text="@string/AddMNickname" />
+
+        <EditText
+            android:id="@+id/addm_nickname"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_margin="3dip"
+            android:contentDescription="@string/AddMNickname"
+            android:imeOptions="actionNext"
+            android:inputType="text"
+            android:scrollHorizontally="true" />
+
+        <View
+            android:layout_width="fill_parent"
+            android:layout_height="1dp"
+            android:background="?android:attr/listDivider" />
+
+        <TextView
+            style="@style/Label"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_vertical"
+            android:text="@string/AddMPassword" />
+
+        <EditText
+            android:id="@+id/addm_password"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_margin="3dip"
+            android:contentDescription="@string/AddMPassword"
+            android:imeOptions="actionNext"
+            android:inputType="text"
+            android:scrollHorizontally="true" />
+
+        <View
+            android:layout_width="fill_parent"
+            android:layout_height="1dp"
+            android:background="?android:attr/listDivider" />
+
+        <LinearLayout
+            xmlns:android="http://schemas.android.com/apk/res/android"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:orientation="horizontal" >
+
+            <TextView
+                style="@style/Label"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center_vertical"
+                android:text="@string/AddMAutojoin" />
+
+            <CheckBox
+                android:id="@+id/addm_autojoin"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="3dip"
+                android:contentDescription="@string/AddMAutojoin" />
+        </LinearLayout>
+
+        <View
+            android:layout_width="fill_parent"
+            android:layout_height="1dp"
+            android:background="?android:attr/listDivider" />
+
+        <Button
+            android:id="@+id/addm_ok"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_gravity="bottom"
+            android:layout_marginTop="10dip"
+            android:text="@string/AddCOkButton"
+            android:textColor="#333333"
+            android:textSize="18sp"
+            android:textStyle="bold" />
+    </LinearLayout>
+
+</ScrollView>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/menu/muc_list.xml	Tue Apr 10 11:32:31 2012 +0200
@@ -0,0 +1,19 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <item
+        android:id="@+id/contact_list_menu_muc_add_contact"
+        android:icon="@drawable/ic_menu_add"
+        android:title="@string/contact_list_menu_muc_add_contact"
+        android:visible="true"/>
+    <item
+        android:id="@+id/contact_list_menu_settings"
+        android:icon="@drawable/ic_menu_manage"
+        android:title="@string/contact_list_menu_settings"
+        android:visible="true"/>
+    <item
+        android:id="@+id/menu_disconnect"
+        android:icon="@drawable/ic_menu_close_clear_cancel"
+        android:title="@string/contact_list_menu_disconnect"
+        android:visible="true"/>
+
+</menu>
\ No newline at end of file
--- a/res/values/strings.xml	Thu Feb 23 13:15:47 2012 +0100
+++ b/res/values/strings.xml	Tue Apr 10 11:32:31 2012 +0200
@@ -44,6 +44,16 @@
 	<string name="AddCBadForm">Bad form</string>
 	<string name="AddCContactAlready">Contact already exist</string>
 
+	<!--  AddMuc class -->
+	<string name="AddMucTitle">Beem - Add MUC</string>
+	
+	<string name="AddMJid">Room Jid</string>
+	<string name="AddMName">Room Name</string>
+	<string name="AddMAutojoin">Auto join</string>
+	<string name="AddMShared">Shared</string>
+	<string name="AddMNickname">Nickname</string>
+	<string name="AddMPassword">Password</string>
+	
 	<!--  ChangeStatus class -->
 	<string name="ChangeStatusActTitle">Beem - Change my status</string>
 	<string name="ChangeStatusType">My status</string>
@@ -245,6 +255,7 @@
 	<string name="contact_list_menu_settings">Settings</string>
 	<string name="contact_list_menu_sync">Sync</string>
 	<string name="contact_list_menu_disconnect">Disconnect</string>
+	<string name="contact_list_menu_muc_add_contact">Add MUC</string>
 	<string name="contact_list_all_contact">All contacts</string>
 	<string name="contact_list_no_group">No group</string>
 
--- a/src/com/beem/project/beem/BeemIntent.java	Thu Feb 23 13:15:47 2012 +0100
+++ b/src/com/beem/project/beem/BeemIntent.java	Tue Apr 10 11:32:31 2012 +0200
@@ -63,6 +63,8 @@
 
     public static final String ACTION_MUC_SEND_MESSAGE = "com.beem.project.beem.intent.action.MUC_SEND_MESSAGE";
 
+    public static final String ACTION_ADD_MUC = "com.beem.project.beem.intent.action.ADD_MUC";
+
     /* Broadcast Receiver's action */
     public static final String ACTION_CONNECTED = "com.beem.project.beem.intent.action.CONNECTED";
 
@@ -70,6 +72,7 @@
 
     public static final String ACTION_MESSAGE_RECEIVED = "com.beem.project.beem.intent.action.MESSAGE_RECEIVED";
 
+    /* Content */
     public static final String EXTRA_ACCOUNT = "com.beem.project.beem.intent.extra.ACCOUNT";
 
     public static final String EXTRA_JID = "com.beem.project.beem.intent.extra.JID";
--- a/src/com/beem/project/beem/BeemService.java	Thu Feb 23 13:15:47 2012 +0100
+++ b/src/com/beem/project/beem/BeemService.java	Tue Apr 10 11:32:31 2012 +0200
@@ -120,6 +120,12 @@
     private static final int MESSAGE_CHANGE_STATUS = 0x7;
     private static final int MESSAGE_MUC_JOIN = 0x8;
     private static final int MESSAGE_MUC_SEND_MSG = 0x9;
+    private static final int MESSAGE_ADD_MUC = 0xA;
+
+    public static final String MUC_NAME = "muc_name";
+    public static final String MUC_NICKNAME = "muc_nickname";
+    public static final String MUC_PASSWORD = "muc_password";
+    public static final String MUC_AUTOJOIN = "muc_autojoin";
 
     private Map<String, XmppConnectionAdapter> mConnection = new HashMap<String, XmppConnectionAdapter>();
     private Map<String, BeemConnection> mBeemConnection = new HashMap<String, BeemConnection>();
@@ -444,6 +450,8 @@
 	    msg = mHandler.obtainMessage(MESSAGE_MUC_JOIN, intent.getExtras());
 	} else if (BeemIntent.ACTION_MUC_SEND_MESSAGE.equals(action)) {
 	    msg = mHandler.obtainMessage(MESSAGE_MUC_SEND_MSG, intent.getExtras());
+	} else if (BeemIntent.ACTION_ADD_MUC.equals(action)) {
+	    msg = mHandler.obtainMessage(MESSAGE_ADD_MUC, intent.getExtras());
 	} else {
 	    Log.w(TAG, "Unknown intent " + intent);
 	}
@@ -530,7 +538,7 @@
 		    } else {
 			handleConnect(accountName);
 			if (mConnection.containsKey(accountName)) {
-			   mConnection.get(accountName).changeStatus(status, "");
+			    mConnection.get(accountName).changeStatus(status, "");
 			}
 		    }
 		    break;
@@ -557,12 +565,28 @@
 		case MESSAGE_MUC_SEND_MSG:
 		    MultiUserChat mucmsg = new MultiUserChat(connection.getAdaptee(), b.getString(BeemIntent.EXTRA_JID));
 		    try {
-			Log.e(TAG, "-" + b.getString(BeemIntent.EXTRA_MESSAGE));
+			Log.i(TAG, "-" + b.getString(BeemIntent.EXTRA_MESSAGE));
 			mucmsg.sendMessage(b.getString(BeemIntent.EXTRA_MESSAGE));
 		    } catch (XMPPException e) {
 			Log.e(TAG, "Error send message to muc", e);
 		    }
 		    break;
+		case MESSAGE_ADD_MUC:
+		    Bundle extra = b.getBundle(BeemIntent.EXTRA_MESSAGE);
+
+		    String mucName = extra.getString(MUC_NAME);
+		    String mucNickname = extra.getString(MUC_NICKNAME);
+		    String mucPassword = extra.getString(MUC_PASSWORD);
+		    boolean mucAutojoin = extra.getBoolean(MUC_AUTOJOIN);
+		    BookmarkManager bm;
+		    try {
+			bm = BookmarkManager.getBookmarkManager(connection.getAdaptee());
+			bm.addBookmarkedConference(mucName, b.getString(BeemIntent.EXTRA_JID), mucAutojoin,
+			    mucNickname, mucPassword);
+		    } catch (XMPPException e) {
+			Log.e(TAG, "Error add muc", e);
+		    }
+		    break;
 		default:
 		    Log.w(TAG, "Unknown message " + msg);
 	    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/ui/AddMuc.java	Tue Apr 10 11:32:31 2012 +0200
@@ -0,0 +1,158 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+
+    Epitech, hereby disclaims all copyright interest in the program "Beem"
+    written by Frederic-Charles Barthelery,
+               Jean-Manuel Da Silva,
+               Nikita Kozlov,
+               Philippe Lago,
+               Jean Baptiste Vergely,
+               Vincent Veronis.
+
+    Nicolas Sadirac, November 26, 2009
+    President of Epitech.
+
+    Flavien Astraud, November 26, 2009
+    Head of the EIP Laboratory.
+
+ */
+package com.beem.project.beem.ui;
+
+import java.util.regex.Pattern;
+
+import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.EditText;
+import android.widget.Toast;
+
+import com.beem.project.beem.BeemApplication;
+import com.beem.project.beem.BeemIntent;
+import com.beem.project.beem.BeemService;
+import com.beem.project.beem.R;
+import com.beem.project.beem.ui.wizard.AccountConfigure;
+
+/**
+ * This activity is used to add a contact.
+ * @author nikita
+ */
+public class AddMuc extends Activity {
+
+    private static final String TAG = "AddContact";
+    private final OkListener mOkListener = new OkListener();
+    private String mAccount = null;
+
+    /**
+     * Constructor.
+     */
+    public AddMuc() {
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+	super.onCreate(savedInstanceState);
+	setContentView(R.layout.addmuc);
+
+	Button ok = (Button) findViewById(R.id.addm_ok);
+	ok.setOnClickListener(mOkListener);
+
+    }
+
+    @Override
+    protected void onResume() {
+	super.onResume();
+
+	Bundle b = getIntent().getExtras();
+	if (b != null && b.containsKey(BeemIntent.EXTRA_ACCOUNT))
+	    mAccount = b.getString(BeemIntent.EXTRA_ACCOUNT);
+	else {
+	    AccountManager am = AccountManager.get(AddMuc.this);
+	    Account allAccount[] = am.getAccountsByType(BeemApplication.BEEM_PACKAGE);
+	    Log.e(TAG, "NB ACCOUNT :" + allAccount.length);
+	    if (allAccount.length == 0) {
+		//TODO: Add toast to advice need to configure at least 1 beem account
+		startActivity(new Intent(AddMuc.this, AccountConfigure.class));
+	    } else if (allAccount.length == 1) {
+		//TODO: Add toast to advice we are adding contact to the account : mAccount
+		mAccount = allAccount[0].name;
+	    } else if (allAccount.length > 1)
+		;// TODO : if multi account propose select
+	}
+    }
+
+    /**
+     * Get the text of a widget.
+     * @param id the id of the widget.
+     * @return the text of the widget.
+     */
+    private String getWidgetText(int id) {
+	EditText widget = (EditText) this.findViewById(id);
+	return widget.getText().toString();
+    }
+
+    /**
+     * Listener.
+     */
+    private class OkListener implements OnClickListener {
+
+	/**
+	 * Constructor.
+	 */
+	public OkListener() {
+	}
+
+	@Override
+	public void onClick(View v) {
+	    Log.e(TAG, "Account : " + mAccount);
+	    String mucJid = getWidgetText(R.id.addm_jid);
+	    Bundle b = new Bundle();
+	    b.putString(BeemService.MUC_NAME, getWidgetText(R.id.addm_name));
+	    b.putString(BeemService.MUC_NICKNAME, getWidgetText(R.id.addm_nickname));
+	    b.putString(BeemService.MUC_PASSWORD, getWidgetText(R.id.addm_password));
+	    CheckBox checkboxWidget = (CheckBox) findViewById(R.id.addm_autojoin);
+	    b.putBoolean(BeemService.MUC_AUTOJOIN, checkboxWidget.isChecked());
+
+	    Intent intent = new Intent(BeemIntent.ACTION_ADD_MUC);
+	    intent.putExtra(BeemIntent.EXTRA_ACCOUNT, mAccount);
+	    intent.putExtra(BeemIntent.EXTRA_JID, mucJid);
+	    intent.putExtra(BeemIntent.EXTRA_MESSAGE, b);
+	    startService(intent);
+
+	}
+    };
+}
--- a/src/com/beem/project/beem/ui/ContactList.java	Thu Feb 23 13:15:47 2012 +0100
+++ b/src/com/beem/project/beem/ui/ContactList.java	Tue Apr 10 11:32:31 2012 +0200
@@ -162,11 +162,15 @@
      * {@inheritDoc}
      */
     @Override
-    public final boolean onCreateOptionsMenu(Menu menu) {
-	super.onCreateOptionsMenu(menu);
+    public boolean onPrepareOptionsMenu(Menu menu) {
+	menu.clear();
 	MenuInflater inflater = getMenuInflater();
-	inflater.inflate(R.menu.contact_list, menu);
-	return true;
+	if (mAdapterContactList.getClass() == BeemMucList.class)
+	    inflater.inflate(R.menu.muc_list, menu);
+	else
+	    inflater.inflate(R.menu.contact_list, menu);
+	return super.onPrepareOptionsMenu(menu);
+
     }
 
     /**
@@ -181,7 +185,14 @@
 		startActivity(i);
 		return true;
 	    case R.id.contact_list_menu_add_contact:
-		startActivity(new Intent(ContactList.this, AddContact.class));
+		Intent addContactIntent = new Intent(ContactList.this, AddContact.class);
+		addContactIntent.putExtra("account_name", mAccountName);
+		startActivity(addContactIntent);
+		return true;
+	    case R.id.contact_list_menu_muc_add_contact:
+		Intent addMUCIntent = new Intent(ContactList.this, AddMuc.class);
+		addMUCIntent.putExtra("account_name", mAccountName);
+		startActivity(addMUCIntent);
 		return true;
 	    case R.id.menu_change_status:
 		startActivity(new Intent(ContactList.this, ChangeStatus.class));
@@ -196,7 +207,7 @@
 		//		} catch (RemoteException e) {
 		//		    e.printStackTrace();
 		//		}
-		//		return true;
+		return true;
 	    case R.id.contact_list_menu_sync:
 		Intent intent = new Intent(BeemIntent.ACTION_SYNC);
 		intent.putExtra(BeemIntent.EXTRA_ACCOUNT, mAccountName);