merge with ui
authorDa Risk <darisk972@gmail.com>
Wed, 15 Apr 2009 19:41:35 +0200
changeset 108 c60aa2237865
parent 107 71ad42062140 (diff)
parent 104 b31649abe731 (current diff)
child 109 ec30f9790f83
merge with ui
res/layout/messagelist.xml
src/com/beem/project/beem/BeemApplication.java
src/com/beem/project/beem/BeemService.java
src/com/beem/project/beem/service/BeemChatManager.java
src/com/beem/project/beem/service/Contact.java
src/com/beem/project/beem/ui/ContactList.java
--- a/.hgignore	Wed Apr 15 16:50:15 2009 +0200
+++ b/.hgignore	Wed Apr 15 19:41:35 2009 +0200
@@ -3,3 +3,5 @@
 R.java
 doc/javadoc
 src/com/beem/project/beem/service/aidl/*.java
+gen/*
+local.properties
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build.properties	Wed Apr 15 19:41:35 2009 +0200
@@ -0,0 +1,3 @@
+external-libs=libs
+javadoc-output=doc/javadoc
+
--- a/build.xml	Wed Apr 15 16:50:15 2009 +0200
+++ b/build.xml	Wed Apr 15 19:41:35 2009 +0200
@@ -1,316 +1,75 @@
-<?xml version="1.0" ?>
-<project name="Beem" default="debug">
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="Beem" default="help">
+
+    <!-- The local.properties file is created and updated by the 'android' tool.
+         It contain the path to the SDK. It should *NOT* be checked in in Version
+         Control Systems. -->
+    <property file="local.properties"/>
 
     <!-- The build.properties file can be created by you and is never touched
-         by activitycreator. If you want to manually set properties, this is
-         the best place to set them. -->
+         by the 'android' tool. This is the place to change some of the default property values
+         used by the Ant rules.
+         Here are some properties you may want to change/update:
+
+         application-package
+             the name of your application package as defined in the manifest. Used by the
+             'uninstall' rule.
+         source-folder
+             the name of the source folder. Default is 'src'.
+         out-folder
+             the name of the output folder. Default is 'bin'.
+
+         Properties related to the SDK location or the project target should be updated
+          using the 'android' tool with the 'update' action.
+
+         This file is an integral part of the build system for your application and
+         should be checked in in Version Control Systems.
+
+         -->
     <property file="build.properties"/>
 
-    <!-- The default.properties file is created and updated by activitycreator.
-         It will set any properties not already defined by build.properties. -->
+    <!-- The default.properties file is created and updated by the 'android' tool, as well
+         as ADT. 
+         This file is an integral part of the build system for your application and
+         should be checked in in Version Control Systems. -->
     <property file="default.properties"/>
 
-    <!-- ************************************************************************************* -->
-    <!-- These settings were written by activitycreator.
-         Do not change them unless you really know what you are doing. -->
-
-    <!-- Application Package Name -->
-    <property name="application-package" value="com.beem.project.beem" />
-
-    <!-- The intermediates directory, Eclipse uses "bin"
-         for its own output, so we do the same. -->
-    <property name="outdir" value="bin" />
-    
-    <!-- ************************************************************************************* -->
-    <!-- No user servicable parts below. -->
-
-    <property name="android-tools" value="${sdk-folder}/tools" />
-    <property name="android-framework" value="${android-tools}/lib/framework.aidl" />
-
-    <!-- Input directories -->
-    <property name="resource-dir" value="res" />
-    <property name="asset-dir" value="assets" />
-    <property name="srcdir" value="src" />
-    <condition property="srcdir-ospath"
-            value="${basedir}\${srcdir}"
-            else="${basedir}/${srcdir}" >
-        <os family="windows"/>
-    </condition>
-
-    <!-- folder for the 3rd party java libraries -->
-    <property name="external-libs" value="libs" />
-    <condition property="external-libs-ospath"
-            value="${basedir}\${external-libs}"
-            else="${basedir}/${external-libs}" >
-        <os family="windows"/>
-    </condition>
-
-    <!-- folder for the native libraries -->
-    <property name="native-libs" value="libs" />
-    <condition property="native-libs-ospath"
-            value="${basedir}\${native-libs}"
-            else="${basedir}/${native-libs}" >
-        <os family="windows"/>
-    </condition>
-
-    <!-- Output directories -->
-    <property name="outdir-classes" value="${outdir}/classes" />
-    <condition property="outdir-classes-ospath"
-            value="${basedir}\${outdir-classes}"
-            else="${basedir}/${outdir-classes}" >
-        <os family="windows"/>
-    </condition>
-
-    <!-- Create R.java in the source directory -->
-    <property name="outdir-r" value="src" />
-
-    <!-- Intermediate files -->
-    <property name="dex-file" value="classes.dex" />
-    <property name="intermediate-dex" value="${outdir}/${dex-file}" />
-    <condition property="intermediate-dex-ospath"
-            value="${basedir}\${intermediate-dex}"
-            else="${basedir}/${intermediate-dex}" >
-        <os family="windows"/>
-    </condition>
-
-    <!-- The final package file to generate -->
-    <property name="resources-package" value="${outdir}/${ant.project.name}.ap_" />
-    <condition property="resources-package-ospath"
-            value="${basedir}\${resources-package}"
-            else="${basedir}/${resources-package}" >
-        <os family="windows"/>
-    </condition>
+    <!-- Custom Android task to deal with the project target, and import the proper rules.
+         This requires ant 1.6.0 or above. -->
+    <path id="android.antlibs">
+        <pathelement path="${sdk-location}/tools/lib/anttasks.jar" />
+        <pathelement path="${sdk-location}/tools/lib/sdklib.jar" />
+        <pathelement path="${sdk-location}/tools/lib/androidprefs.jar" />
+        <pathelement path="${sdk-location}/tools/lib/apkbuilder.jar" />
+        <pathelement path="${sdk-location}/tools/lib/jarutils.jar" />
+    </path>
 
-    <property name="out-debug-package" value="${outdir}/${ant.project.name}-debug.apk" />
-    <condition property="out-debug-package-ospath"
-            value="${basedir}\${out-debug-package}"
-            else="${basedir}/${out-debug-package}" >
-        <os family="windows"/>
-    </condition>
-
-    <property name="out-unsigned-package" value="${outdir}/${ant.project.name}-unsigned.apk" />
-    <condition property="out-unsigned-package-ospath"
-            value="${basedir}\${out-unsigned-package}"
-            else="${basedir}/${out-unsigned-package}" >
-        <os family="windows"/>
-    </condition>
-
-    <!-- Tools -->
-    <condition property="aapt" value="${android-tools}/aapt.exe" else="${android-tools}/aapt" >
-        <os family="windows"/>
-    </condition>
-    <condition property="aidl" value="${android-tools}/aidl.exe" else="${android-tools}/aidl" >
-        <os family="windows"/>
-    </condition>
-    <condition property="adb" value="${android-tools}/adb.exe" else="${android-tools}/adb" >
-        <os family="windows"/>
-    </condition>
-    <condition property="dx" value="${android-tools}/dx.bat" else="${android-tools}/dx" >
-        <os family="windows"/>
-    </condition>
-    <condition property="apk-builder" value="${android-tools}/apkbuilder.bat" else="${android-tools}/apkbuilder" >
-        <os family="windows"/>
-    </condition>
-
-    <property name="android-jar" value="${sdk-folder}/android.jar" />
-
-    <property name="javadoc-output" value="doc/javadoc" />
-	
-    <!-- Rules -->
-
-    <!-- Create the output directories if they don't exist yet. -->
-    <target name="dirs">
-        <echo>Creating output directories if needed...</echo>
-        <mkdir dir="${outdir}" />
-        <mkdir dir="${outdir-classes}" />
-    	<mkdir dir="${javadoc-output}" />
-    </target>
-
-    <!-- Generate the R.java file for this project's resources. -->
-    <target name="resource-src" depends="dirs">
-        <echo>Generating R.java / Manifest.java from the resources...</echo>
-        <exec executable="${aapt}" failonerror="true">
-            <arg value="package" />
-            <arg value="-m" />
-            <arg value="-J" />
-            <arg value="${outdir-r}" />
-            <arg value="-M" />
-            <arg value="AndroidManifest.xml" />
-            <arg value="-S" />
-            <arg value="${resource-dir}" />
-            <arg value="-I" />
-            <arg value="${android-jar}" />
-        </exec>
-    </target>
-
-    <!-- Generate java classes from .aidl files. -->
-    <target name="aidl" depends="dirs">
-        <echo>Compiling aidl files into Java classes...</echo>
-        <apply executable="${aidl}" failonerror="true">
-            <arg value="-p${android-framework}" />
-            <arg value="-p${basedir}/project.aidl"/>
-            <arg value="-I${srcdir}" />
-            <fileset dir="${srcdir}">
-                <include name="**/*.aidl"/>
-            </fileset>
-        </apply>
-    	
-    </target>
+    <taskdef name="setup"
+        classname="com.android.ant.SetupTask"
+        classpathref="android.antlibs"/>
 
-    <!-- Compile this project's .java files into .class files. -->
-    <target name="compile" depends="dirs, resource-src, aidl">
-        <javac encoding="ascii" target="1.5" debug="true" extdirs=""
-                srcdir="."
-                destdir="${outdir-classes}"
-                bootclasspath="${android-jar}">
-            <classpath>
-                <fileset dir="${external-libs}" includes="*.jar"/>
-            </classpath>
-         </javac>
-    </target>
-
-    <!-- Convert this project's .class files into .dex files. -->
-    <target name="dex" depends="compile">
-        <echo>Converting compiled files and external libraries into ${outdir}/${dex-file}...</echo>
-        <apply executable="${dx}" failonerror="true" parallel="true">
-            <arg value="--dex" />
-            <arg value="--output=${intermediate-dex-ospath}" />
-            <arg path="${outdir-classes-ospath}" />
-            <fileset dir="${external-libs}" includes="*.jar"/>
-        </apply>
-    </target>
-
-    <!-- Put the project's resources into the output package file. -->
-    <target name="package-res-and-assets">
-        <echo>Packaging resources and assets...</echo>
-        <exec executable="${aapt}" failonerror="true">
-            <arg value="package" />
-            <arg value="-f" />
-            <arg value="-M" />
-            <arg value="AndroidManifest.xml" />
-            <arg value="-S" />
-            <arg value="${resource-dir}" />
-            <arg value="-A" />
-            <arg value="${asset-dir}" />
-            <arg value="-I" />
-            <arg value="${android-jar}" />
-            <arg value="-F" />
-            <arg value="${resources-package}" />
-        </exec>
-    </target>
-
-    <!-- Same as package-res-and-assets, but without "-A ${asset-dir}" -->
-    <target name="package-res-no-assets">
-        <echo>Packaging resources...</echo>
-        <exec executable="${aapt}" failonerror="true">
-            <arg value="package" />
-            <arg value="-f" />
-            <arg value="-M" />
-            <arg value="AndroidManifest.xml" />
-            <arg value="-S" />
-            <arg value="${resource-dir}" />
-            <!-- No assets directory -->
-            <arg value="-I" />
-            <arg value="${android-jar}" />
-            <arg value="-F" />
-            <arg value="${resources-package}" />
-        </exec>
-    </target>
-
-    <!-- Invoke the proper target depending on whether or not
-         an assets directory is present. -->
-    <!-- TODO: find a nicer way to include the "-A ${asset-dir}" argument
-         only when the assets dir exists. -->
-    <target name="package-res">
-        <available file="${asset-dir}" type="dir"
-                property="res-target" value="and-assets" />
-        <property name="res-target" value="no-assets" />
-        <antcall target="package-res-${res-target}" />
-    </target>
+    <!-- Execute the Android Setup task that will setup some properties specific to the target,
+         and import the rules files.
+         To customize the rules, copy/paste them below the task, and disable import by setting
+         the import attribute to false:
+            <setup import="false" />
+         
+         This will ensure that the properties are setup correctly but that your customized
+         targets are used.
+    -->
+    <setup />
+	
+	  <target name="clean"
+		    description="Delete old build and dist directories">
+		<delete verbose="false" dir="${out-folder}"/>
+	    </target>
 
-    <!-- Package the application and sign it with a debug key.
-         This is the default target when building. It is used for debug. -->
-    <target name="debug" depends="dex, package-res">
-        <echo>Packaging ${out-debug-package}, and signing it with a debug key...</echo>
-        <exec executable="${apk-builder}" failonerror="true">
-            <arg value="${out-debug-package-ospath}" />
-            <arg value="-z" />
-            <arg value="${resources-package-ospath}" />
-            <arg value="-f" />
-            <arg value="${intermediate-dex-ospath}" />
-            <arg value="-rf" />
-            <arg value="${srcdir-ospath}" />
-            <arg value="-rj" />
-            <arg value="${external-libs-ospath}" />
-            <arg value="-nf" />
-            <arg value="${native-libs-ospath}" />
-        </exec>
-    </target>
-
-    <!-- Package the application without signing it.
-         This allows for the application to be signed later with an official publishing key. -->
-    <target name="release" depends="dex, package-res"
-    	description="Package the application without signing it.
-        This allows for the application to be signed later with an official publishing key.">
-        <echo>Packaging ${out-unsigned-package} for release...</echo>
-        <exec executable="${apk-builder}" failonerror="true">
-            <arg value="${out-unsigned-package-ospath}" />
-            <arg value="-u" />
-            <arg value="-z" />
-            <arg value="${resources-package-ospath}" />
-            <arg value="-f" />
-            <arg value="${intermediate-dex-ospath}" />
-            <arg value="-rf" />
-            <arg value="${srcdir-ospath}" />
-            <arg value="-rj" />
-            <arg value="${external-libs-ospath}" />
-            <arg value="-nf" />
-            <arg value="${native-libs-ospath}" />
-        </exec>
-        <echo>It will need to be signed with jarsigner before being published.</echo>
-    </target>
-
-    <!-- Install the package on the default emulator -->
-    <target name="install" depends="debug"
-    	description="Install the package on the default emulator">
-        <echo>Installing ${out-debug-package} onto default emulator...</echo>
-        <exec executable="${adb}" failonerror="true">
-            <arg value="install" />
-            <arg value="${out-debug-package}" />
-        </exec>
-    </target>
-
-    <target name="reinstall" depends="debug">
-        <echo>Installing ${out-debug-package} onto default emulator...</echo>
-        <exec executable="${adb}" failonerror="true">
-            <arg value="install" />
-            <arg value="-r" />
-            <arg value="${out-debug-package}" />
-        </exec>
-    </target>
-
-    <!-- Uninstall the package from the default emulator -->
-    <target name="uninstall"
-    	description="Uninstall the package from the default emulator">
-        <echo>Uninstalling ${application-package} from the default emulator...</echo>
-        <exec executable="${adb}" failonerror="true">
-            <arg value="uninstall" />
-            <arg value="${application-package}" />
-	</exec>
-    </target>
-
-    <target name="clean"
-	    description="Delete old build and dist directories">
-	<delete verbose="false" dir="${outdir}"/>
-    </target>
-
-    <target name="javadoc" depends="aidl"
-    	description="Build the javadoc">
-	<javadoc sourcepath="${srcdir}" destdir="${javadoc-output}">
-	    <classpath>
-		<fileset dir="${external-libs}" includes="*.jar" />
-	    </classpath>
-	</javadoc>	
-    </target>
-
+	    <target name="javadoc" depends="aidl"
+	    	description="Build the javadoc">
+		<javadoc sourcepath="${source-folder}" destdir="${javadoc-output}">
+		    <classpath>
+			<fileset dir="${external-libs}" includes="*.jar" />
+		    </classpath>
+		</javadoc>	
+	    </target>
 </project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/default.properties	Wed Apr 15 19:41:35 2009 +0200
@@ -0,0 +1,22 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+# 
+# This file must be checked in Version Control Systems.
+# 
+# To customize properties used by the Ant build system use,
+# "build.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-3
+# apk configurations. This property allows creation of APK files with limited
+# resources. For example, if your application contains many locales and
+# you wish to release multiple smaller apks instead of a large one, you can
+# define configuration to create apks with limited language sets.
+# Format is a comma separated list of configuration names. For each
+# configuration, a property will declare the resource configurations to
+# include. Example:
+#     apk-configurations=european,northamerica
+#     apk-config-european=en,fr,it,de,es
+#     apk-config-northamerica=en,es
+apk-configurations=
--- a/src/com/beem/project/beem/BeemApplication.java	Wed Apr 15 16:50:15 2009 +0200
+++ b/src/com/beem/project/beem/BeemApplication.java	Wed Apr 15 19:41:35 2009 +0200
@@ -25,6 +25,7 @@
 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.utils.Status;
 
 /**
  * The Beem application. This class has some methods utiliy needs by the activities.
@@ -216,7 +217,7 @@
 	public void connectionClosedOnError() throws RemoteException {
 	    mBeemApp.mProgressDialog.setMessage("Connexion closed on error");
 	    Log.e(TAG,"onnectionClosedOnError");
-	    // afficher une notification et reafficher le progress dialog
+	    // TODO afficher une notification et reafficher le progress dialog
 	}
 
 	/**
@@ -226,7 +227,8 @@
 	public void onConnect() throws RemoteException {
 	    // TODO Auto-generated method stub
 	    mProgressDialog.dismiss();
-	    mFacade.changeStatus();
+	    // TODO recuperer les informations de status dans les preferences
+	    mFacade.changeStatus(Status.CONTACT_STATUS_AVAILABLE, null);
 	    synchronized (mQueue) {
 		for (Message msg : mQueue) {
 		    msg.sendToTarget();
--- a/src/com/beem/project/beem/service/BeemChatManager.java	Wed Apr 15 16:50:15 2009 +0200
+++ b/src/com/beem/project/beem/service/BeemChatManager.java	Wed Apr 15 19:41:35 2009 +0200
@@ -120,6 +120,7 @@
 	    IChat newchat = getChat(chat);
 	    if (!locally) {
 		mChats.put(chat.getParticipant(), newchat);
+		// TODO startActivity 
 	    }
 	    final int n = mRemoteChatCreationListeners.beginBroadcast();
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/service/Contact.aidl	Wed Apr 15 19:41:35 2009 +0200
@@ -0,0 +1,3 @@
+package com.beem.project.beem.service;
+
+parcelable Contact;
--- a/src/com/beem/project/beem/service/Contact.java	Wed Apr 15 16:50:15 2009 +0200
+++ b/src/com/beem/project/beem/service/Contact.java	Wed Apr 15 19:41:35 2009 +0200
@@ -9,6 +9,8 @@
 import org.jivesoftware.smack.packet.Presence;
 import org.jivesoftware.smack.packet.Presence.Mode;
 
+import com.beem.project.beem.utils.Status;
+
 import android.os.Parcel;
 import android.os.Parcelable;
 import android.util.Log;
@@ -19,36 +21,6 @@
  */
 public class Contact implements Parcelable {
 
-    /**
-     * Status of a disconnected contact.
-     */
-    public static final int CONTACT_STATUS_DISCONNECT = 100;
-
-    /**
-     * Status of a unavailable (long away) contact.
-     */
-    public static final int CONTACT_STATUS_UNAVAILABLE = 200;
-
-    /**
-     * Status of a away contact.
-     */
-    public static final int CONTACT_STATUS_AWAY = 300;
-
-    /**
-     * Status of a busy contact.
-     */
-    public static final int CONTACT_STATUS_BUSY = 400;
-
-    /**
-     * Status of a available contact.
-     */
-    public static final int CONTACT_STATUS_AVAILABLE = 500;
-
-    /**
-     * Status of a available for chat contact.
-     */
-    public static final int CONTACT_STATUS_AVAILABLE_FOR_CHAT = 600;
-
     private static final String TAG = "Contact";
 
     private int mID;
@@ -86,7 +58,7 @@
      */
     public Contact(final String jid) {
 	mJID = jid;
-	mStatus = Contact.CONTACT_STATUS_DISCONNECT;
+	mStatus = Status.CONTACT_STATUS_DISCONNECT;
 	mRes = new ArrayList<String>();
 	mRes.add("none");
     }
@@ -163,44 +135,7 @@
      */
     public void setStatus(Presence presence) {
 	Log.i(TAG,"PRESENCE");
-	if (presence.getType().equals(Presence.Type.unavailable)) {
-	    Log.d(TAG, "Presence pas dispo");
-	    mStatus = Contact.CONTACT_STATUS_DISCONNECT;
-	} else {
-	    Log.d(TAG, "Presence OK");
-	    Mode mode = presence.getMode();
-	    if (mode == null) {
-		mStatus = Contact.CONTACT_STATUS_AVAILABLE;
-	    }
-	    else {
-		switch (mode) {
-		    case available:
-			Log.d(TAG, "Available");
-			mStatus = Contact.CONTACT_STATUS_AVAILABLE;
-			break;
-		    case away:
-			Log.d(TAG, "Away");
-			mStatus = Contact.CONTACT_STATUS_AWAY;
-			break;
-		    case chat:
-			Log.d(TAG, "Chat");
-			mStatus = Contact.CONTACT_STATUS_AVAILABLE_FOR_CHAT;
-			break;
-		    case dnd:
-			Log.d(TAG, "Dnd");
-			mStatus = Contact.CONTACT_STATUS_BUSY;
-			break;
-		    case xa:
-			Log.d(TAG, "Xa");
-			mStatus = Contact.CONTACT_STATUS_UNAVAILABLE;
-			break;
-		    default:
-			Log.d(TAG, "Status mode non gere");
-		    mStatus = Contact.CONTACT_STATUS_DISCONNECT;
-		    break;
-		}
-	    }
-	}
+	mStatus = Status.getStatusFromPresence(presence);
     }
 
     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/service/Message.aidl	Wed Apr 15 19:41:35 2009 +0200
@@ -0,0 +1,3 @@
+package com.beem.project.beem.service;
+
+parcelable Message;
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/service/PresenceAdapter.aidl	Wed Apr 15 19:41:35 2009 +0200
@@ -0,0 +1,3 @@
+package com.beem.project.beem.service;
+
+parcelable PresenceAdapter;
\ No newline at end of file
--- a/src/com/beem/project/beem/service/XmppFacade.java	Wed Apr 15 16:50:15 2009 +0200
+++ b/src/com/beem/project/beem/service/XmppFacade.java	Wed Apr 15 19:41:35 2009 +0200
@@ -1,9 +1,13 @@
 package com.beem.project.beem.service;
 
+import org.jivesoftware.smack.packet.Presence;
+
 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;
 import com.beem.project.beem.service.aidl.IChatManager;
 import com.beem.project.beem.service.aidl.IRoster;
@@ -16,7 +20,7 @@
  */
 public class XmppFacade extends IXmppFacade.Stub {
 
-    private IXmppConnection mConnexion;
+    private XmppConnectionAdapter mConnexion;
     private BeemService mBeemService;
 
     /**
@@ -24,7 +28,7 @@
      * @param connection the connection use by the facade
      * @param service the service which holds the facade
      */
-    public XmppFacade(final IXmppConnection connection, final BeemService service) {
+    public XmppFacade(final XmppConnectionAdapter connection, final BeemService service) {
 	this.mConnexion = connection;
 	this.mBeemService = service;
     }
@@ -80,9 +84,18 @@
     /**
      * {@inheritDoc}
      */
-    public void changeStatus() {
+    @Override
+    public void changeStatus(int status, String msg) {
+	Presence pres = new Presence(Presence.Type.available);
+	if (msg != null)
+	    pres.setStatus(msg);
+	Presence.Mode mode = com.beem.project.beem.utils.Status.getPresenceModeFromStatus(status);
+	if (mode != null)
+	    pres.setMode(mode);
+	mConnexion.getAdaptee().sendPacket(pres);
+	
 	Notification mStatusNotification;
-	String text = "Salut les amirs !!!!";
+	String text = (msg == null ? "" : msg);
 	mStatusNotification = new Notification(com.beem.project.beem.R.drawable.logo, text, System.currentTimeMillis());
 	mStatusNotification.defaults = Notification.DEFAULT_ALL;
 	mStatusNotification.flags = Notification.FLAG_NO_CLEAR;
--- a/src/com/beem/project/beem/service/aidl/IXmppFacade.aidl	Wed Apr 15 16:50:15 2009 +0200
+++ b/src/com/beem/project/beem/service/aidl/IXmppFacade.aidl	Wed Apr 15 19:41:35 2009 +0200
@@ -6,19 +6,41 @@
 
 interface IXmppFacade {
 
+    /**
+     * Get the XmppConnection of the facade.
+     */
     IXmppConnection createConnection();
     
+    /**
+     * Get the roster of the user
+     */ 
     IRoster getRoster();
     
+    /**
+     * Connect and login synchronously on the server.
+     */
     void connectSync();
     
+    /**
+     * Connect and login asynchronously on the server.
+     */
     void connectAsync();
     
+    /**
+     * Disconnect from the server
+     */
     void disconnect();
 
+    /**
+     * Get the chat manager.
+     */
     IChatManager getChatManager();
     
-    // to ameliore
-    void changeStatus();
+    /**
+     * Change the status of the user.
+     * @param status the status to set
+     * @param msg the message state to set
+     */
+    void changeStatus(in int status, in String msg);
     
 }
--- a/src/com/beem/project/beem/ui/ContactList.java	Wed Apr 15 16:50:15 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Wed Apr 15 19:41:35 2009 +0200
@@ -9,7 +9,6 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
-import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.os.Handler;
@@ -33,6 +32,7 @@
 import com.beem.project.beem.service.aidl.IBeemRosterListener;
 import com.beem.project.beem.service.aidl.IRoster;
 import com.beem.project.beem.service.aidl.IXmppFacade;
+import com.beem.project.beem.utils.Status;
 
 public class ContactList extends ExpandableListActivity {
 
@@ -246,27 +246,27 @@
 		ImageView imgV = (ImageView) view.findViewById(to[0]);
 		Drawable imageDrawable = null;
 		switch (c.getStatus()) {
-		    case Contact.CONTACT_STATUS_AVAILABLE:
+		    case Status.CONTACT_STATUS_AVAILABLE:
 			imageDrawable = (Drawable) getResources().getDrawable(
 				R.drawable.online);
 			break;
-		    case Contact.CONTACT_STATUS_AVAILABLE_FOR_CHAT:
+		    case Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT:
 			imageDrawable = (Drawable) getResources().getDrawable(
 				R.drawable.chat);
 			break;
-		    case Contact.CONTACT_STATUS_AWAY:
+		    case Status.CONTACT_STATUS_AWAY:
 			imageDrawable = (Drawable) getResources().getDrawable(
 				R.drawable.away);
 			break;
-		    case Contact.CONTACT_STATUS_BUSY:
+		    case Status.CONTACT_STATUS_BUSY:
 			imageDrawable = (Drawable) getResources().getDrawable(
 				R.drawable.dnd);
 			break;
-		    case Contact.CONTACT_STATUS_DISCONNECT:
+		    case Status.CONTACT_STATUS_DISCONNECT:
 			imageDrawable = (Drawable) getResources().getDrawable(
 				R.drawable.offline);
 			break;
-		    case Contact.CONTACT_STATUS_UNAVAILABLE:
+		    case Status.CONTACT_STATUS_UNAVAILABLE:
 			imageDrawable = (Drawable) getResources().getDrawable(
 				R.drawable.requested);
 			break;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/utils/Status.java	Wed Apr 15 19:41:35 2009 +0200
@@ -0,0 +1,112 @@
+/**
+ * 
+ */
+package com.beem.project.beem.utils;
+
+import org.jivesoftware.smack.packet.Presence;
+import org.jivesoftware.smack.packet.Presence.Mode;
+
+/**
+ * @author darisk
+ */
+public class Status {
+
+    /**
+     * Status of a disconnected contact.
+     */
+    public static final int CONTACT_STATUS_DISCONNECT = 100;
+
+    /**
+     * Status of a unavailable (long away) contact.
+     */
+    public static final int CONTACT_STATUS_UNAVAILABLE = 200;
+
+    /**
+     * Status of a away contact.
+     */
+    public static final int CONTACT_STATUS_AWAY = 300;
+
+    /**
+     * Status of a busy contact.
+     */
+    public static final int CONTACT_STATUS_BUSY = 400;
+
+    /**
+     * Status of a available contact.
+     */
+    public static final int CONTACT_STATUS_AVAILABLE = 500;
+
+    /**
+     * Status of a available for chat contact.
+     */
+    public static final int CONTACT_STATUS_AVAILABLE_FOR_CHAT = 600;
+
+    /**
+     * Get the status of from a presence packet.
+     * @param presence the presence containing status
+     */
+    public static int getStatusFromPresence(Presence presence) {
+	int res = Status.CONTACT_STATUS_DISCONNECT;
+	if (presence.getType().equals(Presence.Type.unavailable)) {
+	    res = Status.CONTACT_STATUS_DISCONNECT;
+	} else {
+	    Mode mode = presence.getMode();
+	    if (mode == null) {
+		res = Status.CONTACT_STATUS_AVAILABLE;
+	    } else {
+		switch (mode) {
+		    case available:
+			res = Status.CONTACT_STATUS_AVAILABLE;
+			break;
+		    case away:
+			res = Status.CONTACT_STATUS_AWAY;
+			break;
+		    case chat:
+			res = Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT;
+			break;
+		    case dnd:
+			res = Status.CONTACT_STATUS_BUSY;
+			break;
+		    case xa:
+			res = Status.CONTACT_STATUS_UNAVAILABLE;
+			break;
+		    default:
+			res = Status.CONTACT_STATUS_DISCONNECT;
+			break;
+		}
+	    }
+	}
+	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.Mode getPresenceModeFromStatus(int status){
+	Presence.Mode res;
+	switch (status) {
+	    case CONTACT_STATUS_AVAILABLE:
+		res = Presence.Mode.available;
+		break;
+	    case CONTACT_STATUS_AVAILABLE_FOR_CHAT:
+		res = Presence.Mode.chat;		
+		break;
+	    case CONTACT_STATUS_AWAY:
+		res = Presence.Mode.away;
+		break;
+	    case CONTACT_STATUS_BUSY:
+		res = Presence.Mode.dnd;
+		break;
+	    case CONTACT_STATUS_UNAVAILABLE:
+		res = Presence.Mode.xa;
+		break;
+	    default:
+		return null;
+	}
+	return res;
+    }
+    
+}