merge beem-ui
authorPhilippe Lago <lago_p@epitech.net>
Fri, 24 Apr 2009 11:51:54 +0200
changeset 169 b832216810ae
parent 168 fd5c328fa330 (current diff)
parent 166 d076437706a4 (diff)
child 170 e892a47de086
child 171 b214244738f7
child 176 b8d88affb228
merge beem-ui
src/com/beem/project/beem/ui/SendIM.java
--- a/AndroidManifest.xml	Fri Apr 24 00:20:57 2009 +0200
+++ b/AndroidManifest.xml	Fri Apr 24 11:51:54 2009 +0200
@@ -2,7 +2,8 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
 	package="com.beem.project.beem" android:versionCode="1"
 	android:versionName="1.0">
-	<application android:label="@string/app_name" android:name="BeemApplication" android:icon="@drawable/signal">
+	<application android:label="@string/app_name" android:name="BeemApplication"
+		android:icon="@drawable/signal">
 		<activity android:name=".ui.ContactList" android:label="@string/app_name">
 			<intent-filter>
 				<action android:name="android.intent.action.MAIN" />
@@ -30,4 +31,5 @@
 	<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
 	<uses-permission android:name="com.beem.project.beem.BEEM_SERVICE"></uses-permission>
 	<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"></uses-permission>
+	<uses-sdk android:minSdkVersion="2"></uses-sdk>
 </manifest> 
Binary file beem_key has changed
--- a/build.xml	Fri Apr 24 00:20:57 2009 +0200
+++ b/build.xml	Fri Apr 24 11:51:54 2009 +0200
@@ -46,7 +46,7 @@
 
     <taskdef name="setup"
         classname="com.android.ant.SetupTask"
-        classpathref="android.antlibs"/>
+	classpathref="android.antlibs"/>
 
     <!-- Execute the Android Setup task that will setup some properties specific to the target,
          and import the rules files.
--- a/res/layout/contactlistsettings.xml	Fri Apr 24 00:20:57 2009 +0200
+++ b/res/layout/contactlistsettings.xml	Fri Apr 24 11:51:54 2009 +0200
@@ -2,90 +2,22 @@
 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
 	android:orientation="vertical" android:layout_width="fill_parent"
 	android:layout_height="fill_parent">
-<LinearLayout
-	android:orientation="vertical" android:layout_width="fill_parent"
-	android:layout_height="fill_parent">
-
-	<TextView android:layout_width="fill_parent"
-		android:layout_height="wrap_content" android:text="Server connection"
-		android:textSize="18sp" />
-
-	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-		android:orientation="horizontal" android:layout_width="fill_parent"
-		android:layout_height="wrap_content">
-		<TextView android:layout_width="wrap_content"
-			android:layout_height="wrap_content" android:text="Host/Port:"
-			android:minWidth="90dp" android:textSize="14sp" />
-		<EditText android:id="@+id/host" android:layout_width="fill_parent"
-			android:layout_height="wrap_content" android:singleLine="true"
-			android:textSize="14sp" android:autoText="false" android:capitalize="none"
-			android:layout_weight="2" android:scrollHorizontally="true" />
-		<EditText android:id="@+id/port" android:layout_width="fill_parent"
-			android:layout_height="wrap_content" android:singleLine="true"
-			android:textSize="14sp" android:autoText="false" android:capitalize="none"
-			android:layout_weight="3" android:scrollHorizontally="true" />
-	</LinearLayout>
-
-	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-		android:orientation="horizontal" android:layout_width="fill_parent"
-		android:layout_height="wrap_content">
-		<TextView android:layout_width="wrap_content"
-			android:layout_height="wrap_content" android:text="Userid:"
-			android:minWidth="90dp" android:textSize="14sp" />
-		<EditText android:id="@+id/userid" android:layout_width="fill_parent"
-			android:layout_height="wrap_content" android:singleLine="true"
-			android:textSize="14sp" android:autoText="false" android:capitalize="none"
-			android:scrollHorizontally="true" />
-	</LinearLayout>
-
-	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-		android:orientation="horizontal" android:layout_width="fill_parent"
-		android:layout_height="wrap_content">
-		<TextView android:layout_width="wrap_content"
-			android:layout_height="wrap_content" android:text="Password:"
-			android:minWidth="90dp" android:textSize="14sp" />
-		<EditText android:id="@+id/password" android:layout_width="fill_parent"
-			android:layout_height="wrap_content" android:singleLine="true"
-			android:password="true" android:textSize="14sp" android:autoText="false"
-			android:capitalize="none" android:scrollHorizontally="true" />
-	</LinearLayout>
-
-	<Spinner android:id="@+id/proxy_type" android:layout_width="fill_parent"
-		android:layout_height="wrap_content" />
-
-	<LinearLayout android:id="@+id/proxy_layout"
-		android:orientation="vertical" android:layout_width="fill_parent"
-		android:layout_height="wrap_content">
+	<LinearLayout android:orientation="vertical"
+		android:layout_width="fill_parent" android:layout_height="fill_parent">
 
 		<TextView android:layout_width="fill_parent"
-			android:layout_height="wrap_content" android:text="Proxy informations"
+			android:layout_height="wrap_content" android:text="Server connection"
 			android:textSize="18sp" />
-
-		<LinearLayout android:orientation="horizontal"
-			android:layout_width="fill_parent" android:layout_height="wrap_content">
-			<TextView android:layout_width="wrap_content"
-				android:layout_height="wrap_content" android:text="Host/Port:"
-				android:minWidth="90dp" android:textSize="14sp" />
-			<EditText android:id="@+id/proxy_host" android:layout_width="fill_parent"
-				android:layout_height="wrap_content" android:singleLine="true"
-				android:textSize="14sp" android:autoText="false" android:capitalize="none"
-				android:layout_weight="2" android:scrollHorizontally="true" />
-			<EditText android:id="@+id/proxy_port" android:layout_width="fill_parent"
-				android:layout_height="wrap_content" android:singleLine="true"
-				android:textSize="14sp" android:autoText="false" android:capitalize="none"
-				android:layout_weight="3" android:scrollHorizontally="true" />
-		</LinearLayout>
-
 		<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 			android:orientation="horizontal" android:layout_width="fill_parent"
 			android:layout_height="wrap_content">
 			<TextView android:layout_width="wrap_content"
-				android:layout_height="wrap_content" android:text="Login :"
+				android:layout_height="wrap_content" android:text="Userid:"
 				android:minWidth="90dp" android:textSize="14sp" />
-			<EditText android:id="@+id/proxy_login"
-				android:layout_width="fill_parent" android:layout_height="wrap_content"
-				android:singleLine="true" android:textSize="14sp" android:autoText="false"
-				android:capitalize="none" android:scrollHorizontally="true" />
+			<EditText android:id="@+id/userid" android:layout_width="fill_parent"
+				android:layout_height="wrap_content" android:singleLine="true"
+				android:textSize="14sp" android:autoText="false" android:capitalize="none"
+				android:scrollHorizontally="true" />
 		</LinearLayout>
 
 		<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
@@ -94,23 +26,100 @@
 			<TextView android:layout_width="wrap_content"
 				android:layout_height="wrap_content" android:text="Password:"
 				android:minWidth="90dp" android:textSize="14sp" />
-			<EditText android:id="@+id/proxy_pwd" android:layout_width="fill_parent"
+			<EditText android:id="@+id/password" android:layout_width="fill_parent"
 				android:layout_height="wrap_content" android:singleLine="true"
 				android:password="true" android:textSize="14sp" android:autoText="false"
 				android:capitalize="none" android:scrollHorizontally="true" />
 		</LinearLayout>
-	</LinearLayout>
+
+		<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+			android:orientation="horizontal" android:layout_width="fill_parent"
+			android:layout_height="wrap_content">
+			<TextView android:layout_width="wrap_content"
+				android:layout_height="wrap_content" android:text="Service:"
+				android:minWidth="90dp" android:textSize="14sp" />
+			<EditText android:id="@+id/service" android:layout_width="fill_parent"
+				android:layout_height="wrap_content" android:singleLine="true"
+				android:textSize="14sp" android:autoText="false" android:capitalize="none"
+				android:scrollHorizontally="true" />
+		</LinearLayout>
+
+		<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+			android:orientation="horizontal" android:layout_width="fill_parent"
+			android:layout_height="wrap_content">
+			<TextView android:layout_width="wrap_content"
+				android:layout_height="wrap_content" android:text="Host/Port:"
+				android:minWidth="90dp" android:textSize="14sp" />
+			<EditText android:id="@+id/host" android:layout_width="fill_parent"
+				android:layout_height="wrap_content" android:singleLine="true"
+				android:textSize="14sp" android:autoText="false" android:capitalize="none"
+				android:layout_weight="2" android:scrollHorizontally="true" />
+			<EditText android:id="@+id/port" android:layout_width="fill_parent"
+				android:layout_height="wrap_content" android:singleLine="true"
+				android:textSize="14sp" android:autoText="false" android:capitalize="none"
+				android:layout_weight="3" android:scrollHorizontally="true" />
+		</LinearLayout>
+
+		<TextView android:layout_width="fill_parent"
+			android:layout_height="wrap_content" android:text="Proxy informations"
+			android:textSize="18sp" />
+
+		<Spinner android:id="@+id/proxy_type" android:layout_width="fill_parent"
+			android:layout_height="wrap_content" />
+
+		<LinearLayout android:id="@+id/proxy_layout"
+			android:orientation="vertical" android:layout_width="fill_parent"
+			android:layout_height="0sp">
+
+			<TextView android:layout_width="fill_parent"
+				android:layout_height="wrap_content" android:text="Proxy informations"
+				android:textSize="18sp" />
 
-	<Button android:id="@+id/ok" android:layout_width="wrap_content"
-		android:layout_height="wrap_content" android:layout_gravity="center_horizontal"
-		android:text="OK">
-		<requestFocus />
-	</Button>
-		<Button android:id="@+id/reconnect" android:layout_width="wrap_content"
-		android:layout_height="wrap_content" android:layout_gravity="center_horizontal"
-		android:text="Reconnect">
-		<requestFocus />
-	</Button>
+			<LinearLayout android:orientation="horizontal"
+				android:layout_width="fill_parent" android:layout_height="wrap_content">
+				<TextView android:layout_width="wrap_content"
+					android:layout_height="wrap_content" android:text="Host/Port:"
+					android:minWidth="90dp" android:textSize="14sp" />
+				<EditText android:id="@+id/proxy_host"
+					android:layout_width="fill_parent" android:layout_height="wrap_content"
+					android:singleLine="true" android:textSize="14sp" android:autoText="false"
+					android:capitalize="none" android:layout_weight="2"
+					android:scrollHorizontally="true" />
+				<EditText android:id="@+id/proxy_port"
+					android:layout_width="fill_parent" android:layout_height="wrap_content"
+					android:singleLine="true" android:textSize="14sp" android:autoText="false"
+					android:capitalize="none" android:layout_weight="3"
+					android:scrollHorizontally="true" />
+			</LinearLayout>
 
-</LinearLayout>
+			<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+				android:orientation="horizontal" android:layout_width="fill_parent"
+				android:layout_height="wrap_content">
+				<TextView android:layout_width="wrap_content"
+					android:layout_height="wrap_content" android:text="Login :"
+					android:minWidth="90dp" android:textSize="14sp" />
+				<EditText android:id="@+id/proxy_login"
+					android:layout_width="fill_parent" android:layout_height="wrap_content"
+					android:singleLine="true" android:textSize="14sp" android:autoText="false"
+					android:capitalize="none" android:scrollHorizontally="true" />
+			</LinearLayout>
+
+			<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+				android:orientation="horizontal" android:layout_width="fill_parent"
+				android:layout_height="wrap_content">
+				<TextView android:layout_width="wrap_content"
+					android:layout_height="wrap_content" android:text="Password:"
+					android:minWidth="90dp" android:textSize="14sp" />
+				<EditText android:id="@+id/proxy_pwd" android:layout_width="fill_parent"
+					android:layout_height="wrap_content" android:singleLine="true"
+					android:password="true" android:textSize="14sp" android:autoText="false"
+					android:capitalize="none" android:scrollHorizontally="true" />
+			</LinearLayout>
+		</LinearLayout>
+		<Button android:id="@+id/ok" android:layout_width="fill_parent"
+			android:layout_height="wrap_content" android:layout_gravity="center_horizontal"
+			android:text="OK">
+			<requestFocus />
+		</Button>
+	</LinearLayout>
 </ScrollView>
\ No newline at end of file
--- a/res/values/strings.xml	Fri Apr 24 00:20:57 2009 +0200
+++ b/res/values/strings.xml	Fri Apr 24 11:51:54 2009 +0200
@@ -27,6 +27,7 @@
 	<string name="PreferenceJID">Jabber ID</string>
 	<string name="PreferenceLoginKey">login</string>
 	<string name="PreferencePasswordKey">password</string>
+	<string name="PreferenceService">service</string>
 	<string name="PreferencePortKey">port</string>
 	<string name="PreferenceProxyHost">proxy_host</string>
 	<string name="PreferenceProxyPort">proxy_port</string>
--- a/src/com/beem/project/beem/BeemApplication.java	Fri Apr 24 00:20:57 2009 +0200
+++ b/src/com/beem/project/beem/BeemApplication.java	Fri Apr 24 11:51:54 2009 +0200
@@ -5,6 +5,7 @@
 
 import java.util.LinkedList;
 import java.util.List;
+
 import android.app.Activity;
 import android.app.Application;
 import android.app.ProgressDialog;
@@ -18,9 +19,13 @@
 import android.os.Message;
 import android.os.RemoteException;
 import android.util.Log;
+import android.widget.Toast;
+
 import com.beem.project.beem.service.aidl.IBeemConnectionListener;
 import com.beem.project.beem.service.aidl.IXmppConnection;
 import com.beem.project.beem.service.aidl.IXmppFacade;
+import com.beem.project.beem.ui.AddContact;
+import com.beem.project.beem.ui.ContactList;
 import com.beem.project.beem.utils.Status;
 
 /**
@@ -61,10 +66,10 @@
 	    try {
 		mConnection = mFacade.createConnection();
 		if (!mConnection.isAuthentificated()) {
-		    mProgressDialog.show();
 		    mConnection.addConnectionListener(mConnectionListener);
 		    mApplicationContext.startService(BeemApplication.SERVICE_INTENT);
 		}else {
+		    mProgressDialog.dismiss();
 		    synchronized (mQueue) {
 			for (Message msg : mQueue) {
 			    msg.sendToTarget();
@@ -98,7 +103,7 @@
 	mBeemApp.mActivity = activity;
 	mBeemApp.mProgressDialog = new ProgressDialog(activity);
 	mBeemApp.mProgressDialog.setTitle("Beem");
-	mBeemApp.mProgressDialog.setIcon(R.drawable.barthe_f);
+	mBeemApp.mProgressDialog.setIcon(R.drawable.signal);
 	mBeemApp.mProgressDialog.setMessage("Connecting...");
 	mBeemApp.mApplicationContext = activity.getApplication();
 	mBeemApp.mPrivateResources = activity.getResources();
@@ -111,6 +116,8 @@
      */
     public synchronized void startBeemService() {
 	if (!mIsConnected) {
+	    mProgressDialog.setMessage("Connecting...");
+	    mProgressDialog.show();
 	    // the connection will be made on service connect
 	    mApplicationContext.bindService(BeemApplication.SERVICE_INTENT, mServConn, BIND_AUTO_CREATE);
 	}
@@ -207,7 +214,6 @@
 	 * Constructor.
 	 */
 	public ConnectionListener() {
-
 	}
 
 	/**
@@ -215,9 +221,7 @@
 	 */
 	@Override
 	public void connectionClosed() throws RemoteException {
-	    // TODO Auto-generated method stub
-	    Log.e("BeemApp", "test1");
-
+	    Log.e(TAG, "Connection Close");
 	}
 
 	/**
@@ -252,8 +256,6 @@
 	 */
 	@Override
 	public void reconnectingIn(int seconds) throws RemoteException {
-	    // TODO Auto-generated method stub
-	    mProgressDialog.show();
 	}
 
 	/**
@@ -261,9 +263,6 @@
 	 */
 	@Override
 	public void reconnectionFailed() throws RemoteException {
-	    // TODO Auto-generated method stub
-	    Log.e("BeemApp", "test3");
-
 	}
 
 	/**
@@ -271,8 +270,6 @@
 	 */
 	@Override
 	public void reconnectionSuccessful() throws RemoteException {
-	    // TODO Auto-generated method stub
-
 	}
 
 	@Override
--- a/src/com/beem/project/beem/BeemService.java	Fri Apr 24 00:20:57 2009 +0200
+++ b/src/com/beem/project/beem/BeemService.java	Fri Apr 24 11:51:54 2009 +0200
@@ -49,6 +49,8 @@
     private String mLogin;
     private String mPassword;
     private String mHost;
+    private String mService;
+    private int mPort;
     private ConnectionConfiguration mConnectionConfiguration;
     private ProxyInfo mProxyInfo;
     private boolean mUseProxy;
@@ -81,8 +83,11 @@
 	mLogin = mSettings.getString(getString(R.string.PreferenceLoginKey), "");
 	mPassword = mSettings.getString(getString(R.string.PreferencePasswordKey), "");
 	mHost = mSettings.getString(getString(R.string.PreferenceHostKey), "");
+	mPort = mSettings.getInt(getString(R.string.PreferencePortKey), 5222);
+	mService = mSettings.getString(getString(R.string.PreferenceService), "");
+	
 	// TODO penser a commenter
-	//mHost = "10.0.2.2";
+	// mHost = "10.0.2.2";
 	initConnectionConfig();
 	mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
 	mConnection = new XmppConnectionAdapter(mConnectionConfiguration, mLogin, mPassword, this);
@@ -136,9 +141,9 @@
 	    int pport =  mSettings.getInt(getString(R.string.PreferenceProxyPort), 1080);
 	    ProxyInfo.ProxyType type = ProxyType.valueOf(stype);
 	    mProxyInfo = new ProxyInfo(type, phost, pport, puser, ppass);
-	    mConnectionConfiguration = new ConnectionConfiguration(mHost, mProxyInfo);
+	    mConnectionConfiguration = new ConnectionConfiguration(mHost, mPort, mService, mProxyInfo);
 	} else {
-	    mConnectionConfiguration = new ConnectionConfiguration(mHost);
+	    mConnectionConfiguration = new ConnectionConfiguration(mHost, mPort);
 	}
 	mConnectionConfiguration.setDebuggerEnabled(false);
 	mConnectionConfiguration.setSendPresence(true);
--- a/src/com/beem/project/beem/service/ChatAdapter.java	Fri Apr 24 00:20:57 2009 +0200
+++ b/src/com/beem/project/beem/service/ChatAdapter.java	Fri Apr 24 11:51:54 2009 +0200
@@ -4,16 +4,11 @@
 package com.beem.project.beem.service;
 
 import org.jivesoftware.smack.Chat;
-import org.jivesoftware.smack.MessageListener;
 import org.jivesoftware.smack.XMPPException;
-import org.jivesoftware.smack.packet.Message;
 
-import android.os.RemoteCallbackList;
 import android.os.RemoteException;
-import android.util.Log;
 
 import com.beem.project.beem.service.aidl.IChat;
-import com.beem.project.beem.service.aidl.IMessageListener;
 
 /**
  * An adapter for smack's Chat class.
--- a/src/com/beem/project/beem/service/Contact.java	Fri Apr 24 00:20:57 2009 +0200
+++ b/src/com/beem/project/beem/service/Contact.java	Fri Apr 24 11:51:54 2009 +0200
@@ -7,7 +7,6 @@
 import java.util.List;
 
 import org.jivesoftware.smack.packet.Presence;
-import org.jivesoftware.smack.packet.Presence.Mode;
 
 import com.beem.project.beem.utils.Status;
 
--- a/src/com/beem/project/beem/service/PresenceAdapter.java	Fri Apr 24 00:20:57 2009 +0200
+++ b/src/com/beem/project/beem/service/PresenceAdapter.java	Fri Apr 24 11:51:54 2009 +0200
@@ -2,13 +2,17 @@
 
 import org.jivesoftware.smack.packet.Presence;
 
-import android.os.IBinder;
+import com.beem.project.beem.utils.PresenceType;
+import com.beem.project.beem.utils.Status;
+
 import android.os.Parcel;
 import android.os.Parcelable;
 
 public class PresenceAdapter implements  Parcelable {
 	
-	private Presence mPresence;
+	private int mType;
+	private int mStatus;
+	private String mTo;
 	
 	/**
 	 * Parcelable.Creator needs by Android.
@@ -27,12 +31,16 @@
 	};
 	
 	public PresenceAdapter(Presence presence) {
-		mPresence = presence;
+		mType = PresenceType.getPresenceType(presence);
+		mStatus = Status.getStatusFromPresence(presence);
+		mTo = presence.getTo();
 	}
 	
 	
 	public PresenceAdapter(Parcel source) {
-		// TODO Auto-generated constructor stub
+		mType = source.readInt();
+		mStatus = source.readInt();
+		mTo = source.readString();
 	}
 
 	@Override
@@ -43,7 +51,55 @@
 
 	@Override
 	public void writeToParcel(Parcel dest, int flags) {
-		// TODO Auto-generated method stub
-		
+		dest.writeInt(mType);
+		dest.writeInt(mStatus);
+		dest.writeString(mTo);
+	}
+
+
+	/**
+	 * @param mStatus the mStatus to set
+	 */
+	public void setStatus(int mStatus) {
+	    this.mStatus = mStatus;
+	}
+
+
+	/**
+	 * @return the mStatus
+	 */
+	public int getStatus() {
+	    return mStatus;
+	}
+
+
+	/**
+	 * @param mType the mType to set
+	 */
+	public void setType(int mType) {
+	    this.mType = mType;
+	}
+
+
+	/**
+	 * @return the mType
+	 */
+	public int getType() {
+	    return mType;
+	}
+
+
+	/**
+	 * @param mTo the mTo to set
+	 */
+	public void setTo(String mTo) {
+	    this.mTo = mTo;
+	}
+
+	/**
+	 * @return the mTo
+	 */
+	public String getTo() {
+	    return mTo;
 	}
 }
--- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java	Fri Apr 24 00:20:57 2009 +0200
+++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java	Fri Apr 24 11:51:54 2009 +0200
@@ -4,19 +4,16 @@
 package com.beem.project.beem.service;
 
 import org.jivesoftware.smack.ConnectionConfiguration;
-import org.jivesoftware.smack.ConnectionCreationListener;
 import org.jivesoftware.smack.ConnectionListener;
 import org.jivesoftware.smack.Roster;
 import org.jivesoftware.smack.XMPPConnection;
 import org.jivesoftware.smack.XMPPException;
-import org.jivesoftware.smack.packet.XMPPError;
 import org.jivesoftware.smackx.ChatStateManager;
 import org.jivesoftware.smackx.ServiceDiscoveryManager;
 import org.jivesoftware.smackx.jingle.JingleManager;
 import android.os.RemoteCallbackList;
 import android.os.RemoteException;
 import android.util.Log;
-import com.beem.project.beem.BeemException;
 import com.beem.project.beem.BeemService;
 import com.beem.project.beem.service.aidl.IBeemConnectionListener;
 import com.beem.project.beem.service.aidl.IChatManager;
@@ -35,7 +32,6 @@
     private String mLogin;
     private String mPassword;
     private RosterAdapter mRoster;
-    private Object mLastException;
     private BeemService mService;
 
     private RemoteCallbackList<IBeemConnectionListener> mRemoteConnListeners = new RemoteCallbackList<IBeemConnectionListener>();
@@ -88,12 +84,14 @@
 	    // TODO find why this cause a null pointer exception
 	    this.initFeatures(); // pour declarer les features xmpp qu'on supporte
 	    ChatStateManager.getInstance(mAdaptee);
-	    mLastException = null;
 	    triggerAsynchronousConnectEvent();
 	    return true;
 	} catch (XMPPException e) {
 	    Log.e(TAG, "Error while connecting", e);
-	    mConListener.connectionFailed(e.getXMPPError().getMessage()); //
+	    if (e.getXMPPError() != null)
+		mConListener.connectionFailed(e.getXMPPError().getMessage()); //
+	    else
+		mConListener.connectionFailed("Error On Connection");
 	}
 	return false;
     }
@@ -104,7 +102,6 @@
     @Override
     public boolean disconnect() {
 	mAdaptee.disconnect();
-	mLastException = null;
 	return true;
     }
 
--- a/src/com/beem/project/beem/service/XmppFacade.java	Fri Apr 24 00:20:57 2009 +0200
+++ b/src/com/beem/project/beem/service/XmppFacade.java	Fri Apr 24 11:51:54 2009 +0200
@@ -5,7 +5,6 @@
 import android.app.Notification;
 import android.app.PendingIntent;
 import android.content.Intent;
-import android.graphics.Bitmap.CompressFormat;
 import android.os.RemoteException;
 
 import com.beem.project.beem.BeemService;
@@ -14,6 +13,7 @@
 import com.beem.project.beem.service.aidl.IXmppConnection;
 import com.beem.project.beem.service.aidl.IXmppFacade;
 import com.beem.project.beem.ui.ChangeStatus;
+import com.beem.project.beem.utils.PresenceType;
 
 /**
  * This class is a facade for the Beem Service.
@@ -101,10 +101,16 @@
 	mStatusNotification.defaults = Notification.DEFAULT_ALL;
 	mStatusNotification.flags = Notification.FLAG_NO_CLEAR;
 
-	// TODO
 	// mStatusNotification.contentView = ;
 	mStatusNotification.setLatestEventInfo(mBeemService, "Beem Status", text, PendingIntent.getActivity(
 	    mBeemService, 0, new Intent(mBeemService,ChangeStatus.class), 0));
 	mBeemService.sendNotification(BeemService.NOTIFICATION_STATUS_ID, mStatusNotification);
     }
+
+    @Override
+    public void sendPresencePacket(PresenceAdapter presence) throws RemoteException {
+	Presence presence2 = new Presence(PresenceType.getPresenceTypeFrom(presence.getType()));
+	presence2.setTo(presence.getTo());
+	mConnexion.getAdaptee().sendPacket(presence2);
+    }
 }
--- a/src/com/beem/project/beem/service/aidl/IXmppFacade.aidl	Fri Apr 24 00:20:57 2009 +0200
+++ b/src/com/beem/project/beem/service/aidl/IXmppFacade.aidl	Fri Apr 24 11:51:54 2009 +0200
@@ -3,6 +3,7 @@
 import  com.beem.project.beem.service.aidl.IXmppConnection;
 import  com.beem.project.beem.service.aidl.IRoster;
 import  com.beem.project.beem.service.aidl.IChatManager;
+import com.beem.project.beem.service.PresenceAdapter;
 
 interface IXmppFacade {
 
@@ -43,4 +44,6 @@
      */
     void changeStatus(in int status, in String msg);
     
+    void sendPresencePacket(in PresenceAdapter presence);
+    
 }
--- a/src/com/beem/project/beem/ui/AddContact.java	Fri Apr 24 00:20:57 2009 +0200
+++ b/src/com/beem/project/beem/ui/AddContact.java	Fri Apr 24 11:51:54 2009 +0200
@@ -43,7 +43,7 @@
     }
     
     private OnClickListener mOkListener = new OnClickListener() {
-
+	
 	@Override
 	public void onClick(View v) {
 	    boolean valid = true;
--- a/src/com/beem/project/beem/ui/ChangeStatus.java	Fri Apr 24 00:20:57 2009 +0200
+++ b/src/com/beem/project/beem/ui/ChangeStatus.java	Fri Apr 24 11:51:54 2009 +0200
@@ -41,7 +41,6 @@
     private static final int UNAVAILABLE_IDX = 4;
     private SharedPreferences mSettings;
     private ArrayAdapter<String> mAdapter;
-    private Context mContext = this;
     private Toast mToast;
     private static Integer nb = 0;
 
@@ -67,7 +66,7 @@
 	mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, STATUS);
 	mAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
 	mSpinner.setAdapter(mAdapter);
-	mToast = Toast.makeText(mContext, R.string.ChangeStatusOk, Toast.LENGTH_LONG);
+	mToast = Toast.makeText(this, R.string.ChangeStatusOk, Toast.LENGTH_LONG);
 	showSettings();
     }
 
--- a/src/com/beem/project/beem/ui/ContactList.java	Fri Apr 24 00:20:57 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Fri Apr 24 11:51:54 2009 +0200
@@ -8,6 +8,7 @@
 import android.app.ExpandableListActivity;
 import android.content.Context;
 import android.content.Intent;
+import android.content.SharedPreferences;
 import android.graphics.drawable.Drawable;
 import android.net.Uri;
 import android.os.Bundle;
@@ -43,6 +44,7 @@
     private IXmppFacade mService = null;
     private BeemApplication mBeemApplication;
     private BeemRosterListener mRosterListener;
+    private SharedPreferences mSettings;
     private IRoster mRoster;
 
     @SuppressWarnings("unchecked")
@@ -61,7 +63,20 @@
 	super.onCreate(saveBundle);
 	mBeemApplication = BeemApplication.getApplication(this);
 	mRosterListener = new BeemRosterListener();
-	mBeemApplication.startBeemService();
+	mSettings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE);
+	// bug fixe temporaire des betises de marseille
+	/*
+	 * SharedPreferences mSettings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE);
+	 * SharedPreferences.Editor editor = mSettings.edit(); editor.putInt(getString(R.string.PreferencePortKey),
+	 * 5222); editor.commit();
+	 */
+    }
+    
+    @Override
+    protected void onResume() {
+	super.onResume();
+	if (!mBeemApplication.isConnected())
+	    mBeemApplication.startBeemService();
 	mBeemApplication.callWhenConnectedToServer(new Handler(), new Runnable() {
 	    @Override
 	    public void run() {
@@ -144,19 +159,13 @@
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
 	if (requestCode == PREFERENCECHANGED) {
 	    if (resultCode == RESULT_OK) {
+		setListAdapter(null);
 		mBeemApplication.stopBeemService();
 		mBeemApplication.startBeemService();
 	    }
 	}
     }
 
-    private boolean isStatusOK(int status) {
-	if (status == Status.CONTACT_STATUS_AVAILABLE || status == Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT
-	    || status == Status.CONTACT_STATUS_AWAY || status == Status.CONTACT_STATUS_BUSY)
-	    return true;
-	return false;
-    }
-
     private void showContactList(List<String> listGroup, List<Contact> listContact) {
 	ExpandableListAdapter Adapter;
 	List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
@@ -181,10 +190,9 @@
 	    childData.add(children);
 	}
 
-	Adapter = new ContactExpandableListAdapter(this, groupData, R.layout.contactlistgroup,
-	    new String[] { GROUP }, new int[] { R.id.textgroup }, childData, R.layout.contactlistcontact,
-	    new String[] { CHILD }, new int[] { R.id.contactliststatus, R.id.contactlistpseudo,
-		R.id.contactlistmsgperso, R.id.contactlistavatar });
+	Adapter = new ContactExpandableListAdapter(this, groupData, R.layout.contactlistgroup, new String[] { GROUP },
+	    new int[] { R.id.textgroup }, childData, R.layout.contactlistcontact, new String[] { CHILD }, new int[] {
+		R.id.contactliststatus, R.id.contactlistpseudo, R.id.contactlistmsgperso, R.id.contactlistavatar });
 	setListAdapter(Adapter);
     }
 
--- a/src/com/beem/project/beem/ui/ContactListSettings.java	Fri Apr 24 00:20:57 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactListSettings.java	Fri Apr 24 11:51:54 2009 +0200
@@ -2,8 +2,10 @@
 
 import android.app.Activity;
 import android.content.Context;
+import android.content.Intent;
 import android.content.SharedPreferences;
 import android.os.Bundle;
+import android.text.Layout;
 import android.util.Log;
 import android.view.View;
 import android.view.View.OnClickListener;
@@ -15,6 +17,7 @@
 import android.widget.Spinner;
 import android.widget.TextView;
 import android.widget.AdapterView.OnItemSelectedListener;
+import android.widget.LinearLayout.LayoutParams;
 
 import com.beem.project.beem.R;
 
@@ -51,17 +54,6 @@
 	showSettings();
 	Button ok = (Button) findViewById(R.id.ok);
 	ok.setOnClickListener(mOkListener);
-	
-	Button reco = (Button) findViewById(R.id.reconnect);
-	reco.setOnClickListener(new OnClickListener () {
-
-	    @Override
-	    public void onClick(View v) {
-		setResult(RESULT_OK);
-		finish();
-	    }
-	    
-	});
     }
 
     private OnItemSelectedListener mProxyType = new OnItemSelectedListener() {
@@ -71,12 +63,16 @@
 	    String value = parent.getSelectedItem().toString();
 	    LinearLayout ll = (LinearLayout) findViewById(R.id.proxy_layout);
 	    SharedPreferences.Editor editor = mSettings.edit();
-
+	    LayoutParams lp = (LayoutParams) ll.getLayoutParams();
 	    if (value.equals(getString(R.string.PreferenceProxyTypeNone))) {
-		ll.setVisibility(LinearLayout.INVISIBLE);
+		ll.setVisibility(LinearLayout.INVISIBLE);		
+		lp.height = 0;
+		ll.setLayoutParams(lp);
 		editor.putBoolean(getString(R.string.PreferenceUseProxy), false);
 	    } else {
 		ll.setVisibility(LinearLayout.VISIBLE);
+		lp.height = LayoutParams.WRAP_CONTENT;
+		ll.setLayoutParams(lp);
 		editor.putBoolean(getString(R.string.PreferenceUseProxy), true);
 	    }
 	    if (!value.equals(getPreferenceString(R.string.PreferenceProxyType))) {
@@ -95,13 +91,13 @@
     private OnClickListener mOkListener = new OnClickListener() {
 	public void onClick(View v) {
 	    SharedPreferences.Editor editor = mSettings.edit();
-	    
+
 	    if (isChanged(R.id.host, R.string.PreferenceHostKey)) {
 		editor.putString(getString(R.string.PreferenceHostKey), getWidgetText(R.id.host));
 		mIsChanged = true;
 	    }
-	    if (isChanged(R.id.port, R.string.PreferencePortKey)) {
-		editor.putString(getString(R.string.PreferencePortKey), getWidgetText(R.id.port));
+	    if (Integer.parseInt(getWidgetText(R.id.port)) != mSettings.getInt(getString(R.string.PreferencePortKey), 5222) ) {
+		editor.putInt(getString(R.string.PreferencePortKey), Integer.parseInt(getWidgetText(R.id.port)));
 		mIsChanged = true;
 	    }
 	    if (isChanged(R.id.userid, R.string.PreferenceLoginKey)) {
@@ -112,13 +108,19 @@
 		editor.putString(getString(R.string.PreferencePasswordKey), getWidgetText(R.id.password));
 		mIsChanged = true;
 	    }
+	    if (isChanged(R.id.host, R.string.PreferenceService)) {
+		editor.putString(getString(R.string.PreferenceService), getWidgetText(R.id.service));
+		mIsChanged = true;
+	    }
 
 	    if (isChanged(R.id.proxy_host, R.string.PreferenceProxyHost)) {
 		editor.putString(getString(R.string.PreferenceProxyHost), getWidgetText(R.id.proxy_host));
 		mIsChanged = true;
 	    }
-	    if (Integer.parseInt(getWidgetText(R.id.proxy_port)) != mSettings.getInt(getString(R.string.PreferenceProxyPort), 1080) ) {
-		editor.putInt(getString(R.string.PreferenceProxyPort), Integer.parseInt(getWidgetText(R.id.proxy_port)));
+	    if (Integer.parseInt(getWidgetText(R.id.proxy_port)) != mSettings.getInt(
+		getString(R.string.PreferenceProxyPort), 1080)) {
+		editor
+		    .putInt(getString(R.string.PreferenceProxyPort), Integer.parseInt(getWidgetText(R.id.proxy_port)));
 		mIsChanged = true;
 	    }
 	    if (isChanged(R.id.proxy_login, R.string.PreferenceProxyUser)) {
@@ -147,11 +149,13 @@
 	EditText e = (EditText) findViewById(R.id.host);
 	e.setText(getPreferenceString(R.string.PreferenceHostKey));
 	e = (EditText) findViewById(R.id.port);
-	e.setText(getPreferenceString(R.string.PreferencePortKey));
+	e.setText(String.valueOf(mSettings.getInt(getString(R.string.PreferencePortKey), 1080)));
 	e = (EditText) findViewById(R.id.userid);
 	e.setText(getPreferenceString(R.string.PreferenceLoginKey));
 	e = (EditText) findViewById(R.id.password);
 	e.setText(getPreferenceString(R.string.PreferencePasswordKey));
+	e = (EditText) findViewById(R.id.service);
+	e.setText(getPreferenceString(R.string.PreferenceService));
 
 	e = (EditText) findViewById(R.id.proxy_host);
 	e.setText(getPreferenceString(R.string.PreferenceProxyHost));
--- a/src/com/beem/project/beem/ui/SendIM.java	Fri Apr 24 00:20:57 2009 +0200
+++ b/src/com/beem/project/beem/ui/SendIM.java	Fri Apr 24 11:51:54 2009 +0200
@@ -109,7 +109,8 @@
     @Override
     protected void onResume() {
 	super.onResume();
-	mBeemApplication.startBeemService();
+	if (!mBeemApplication.isConnected())
+	    mBeemApplication.startBeemService();
 	mBeemApplication.callWhenConnectedToServer(mHandler, new Runnable() {
 
 	    @Override
--- a/src/com/beem/project/beem/ui/SendIMDialogSmiley.java	Fri Apr 24 00:20:57 2009 +0200
+++ b/src/com/beem/project/beem/ui/SendIMDialogSmiley.java	Fri Apr 24 11:51:54 2009 +0200
@@ -4,7 +4,6 @@
 
 import android.app.Dialog;
 import android.content.SharedPreferences;
-import android.widget.Button;
 
 public class SendIMDialogSmiley extends Dialog {
     private SendIM	mSendIM;
--- a/src/com/beem/project/beem/ui/Subscription.java	Fri Apr 24 00:20:57 2009 +0200
+++ b/src/com/beem/project/beem/ui/Subscription.java	Fri Apr 24 11:51:54 2009 +0200
@@ -3,21 +3,71 @@
  */
 package com.beem.project.beem.ui;
 
+import org.jivesoftware.smack.packet.Presence;
+import org.jivesoftware.smack.packet.Presence.Type;
+
+import com.beem.project.beem.BeemApplication;
 import com.beem.project.beem.R;
+import com.beem.project.beem.service.PresenceAdapter;
+import com.beem.project.beem.service.aidl.IXmppFacade;
 
 import android.app.Activity;
 import android.os.Bundle;
-import android.widget.Button;
+import android.os.RemoteException;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Toast;
 
 /**
  * @author nikita
  *
  */
 public class Subscription extends Activity {
+    
+    private IXmppFacade mService;
+    private String mContact;
+    
     @Override
     protected void onCreate(Bundle savedInstanceState) {
 	super.onCreate(savedInstanceState);
 	setContentView(R.layout.subscription);
-	//mOk = (Button) findViewById(R.id.SubscriptionAccept);
+	findViewById(R.id.SubscriptionAccept).setOnClickListener(mClickListener);
+	findViewById(R.id.SubscriptionRefuse).setOnClickListener(mClickListener);
+	mContact = getIntent().getStringExtra("from");
+	mService = BeemApplication.getApplication(this).getXmppFacade();
     }
+    
+    private OnClickListener mClickListener = new OnClickListener() {
+
+	@Override
+	public void onClick(View v) {
+	    switch (v.getId()) {
+		case R.id.SubscriptionAccept:
+		    Presence presence = new Presence(Type.subscribed);
+		    presence.setTo(mContact);
+		    PresenceAdapter preAdapt = new PresenceAdapter(presence);
+		    try {
+			mService.sendPresencePacket(preAdapt);
+			Toast.makeText(Subscription.this, "Subscription accept",
+	                    Toast.LENGTH_SHORT).show();
+			finish();
+		    } catch (RemoteException e) {
+			Toast.makeText(Subscription.this, "Subscription error",
+	                    Toast.LENGTH_SHORT).show();
+			e.printStackTrace();
+		    }
+		    break ;
+		case R.id.SubscriptionRefuse:
+		    Toast.makeText(Subscription.this, "Subscription refused",
+	                    Toast.LENGTH_SHORT).show();
+		    
+		    break ;
+		default:
+		    Toast.makeText(Subscription.this, "Subscription error",
+	                    Toast.LENGTH_SHORT).show();
+	    };
+	    
+	}
+	
+    };
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/utils/PresenceType.java	Fri Apr 24 11:51:54 2009 +0200
@@ -0,0 +1,117 @@
+/**
+ * 
+ */
+package com.beem.project.beem.utils;
+
+import org.jivesoftware.smack.packet.Presence;
+
+/**
+ * @author nikita
+ *
+ */
+public class PresenceType {
+
+    /**
+     * The user is available to receive messages (default).
+     */
+    public static final int AVAILABLE = 100;
+
+    /**
+     * The user is unavailable to receive messages.
+     */
+    public static final int UNAVAILABLE = 200;
+
+    /**
+     * Request subscription to recipient's presence.
+     */
+
+    public static final int SUBSCRIBE = 300;
+
+    /**
+     * Grant subscription to sender's presence.
+     */
+    public static final int SUBSCRIBED = 400;
+
+    /**
+     * Request removal of subscription to sender's presence.
+     */
+    public static final int UNSUBSCRIBE = 500;
+
+    /**
+     * Grant removal of subscription to sender's presence.
+     */
+    public static final int UNSUBSCRIBED = 600;
+
+    /**
+     * The presence packet contains an error message.
+     */
+    public static final int ERROR = 701;
+
+    /**
+     * Get the presence type from a presence packet.
+     * @param presence the presence type
+     */
+    public static int getPresenceType(Presence presence) {
+	int res = PresenceType.ERROR;
+	switch (presence.getType()) {
+	    case available:
+		res = PresenceType.AVAILABLE;
+		break;
+	    case unavailable:
+		res = PresenceType.UNAVAILABLE;
+		break;
+	    case subscribe:
+		res = PresenceType.SUBSCRIBE;
+		break;
+	    case subscribed:
+		res = PresenceType.SUBSCRIBED;
+		break;
+	    case unsubscribe:
+		res = PresenceType.UNSUBSCRIBE;
+		break;
+	    case unsubscribed:
+		res = PresenceType.UNSUBSCRIBED;
+		break;
+	    case error:
+	    default:
+		res = PresenceType.ERROR;
+	};
+	return res;
+    }
+    
+    /**
+     * Get the smack presence mode for a status
+     * @param status the status in beem
+     * @return the presence mode to use in presence packet
+     * 		or null if there is no mode to use
+     */
+    public static Presence.Type getPresenceTypeFrom(int type){
+	Presence.Type res;
+	switch (type) {
+	    case AVAILABLE:
+		res = Presence.Type.available;
+		break;
+	    case UNAVAILABLE:
+		res = Presence.Type.unavailable;		
+		break;
+	    case SUBSCRIBE:
+		res = Presence.Type.subscribe;
+		break;
+	    case SUBSCRIBED:
+		res = Presence.Type.subscribed;
+		break;
+	    case UNSUBSCRIBE:
+		res = Presence.Type.unsubscribe;
+		break;
+	    case UNSUBSCRIBED:
+		res = Presence.Type.unsubscribed;
+		break;
+	    case ERROR:
+		res = Presence.Type.error;
+		break;
+	    default:
+		return null;
+	}
+	return res;
+    }
+}
--- a/src/com/beem/project/beem/utils/Status.java	Fri Apr 24 00:20:57 2009 +0200
+++ b/src/com/beem/project/beem/utils/Status.java	Fri Apr 24 11:51:54 2009 +0200
@@ -7,7 +7,7 @@
 import org.jivesoftware.smack.packet.Presence.Mode;
 
 /**
- * @author darisk
+ * @author caribou
  */
 public class Status {