Merge avec barbu pour tester les messages d'erreur
authorDa Risk <darisk972@gmail.com>
Wed, 08 Apr 2009 18:39:12 +0200
changeset 93 a4501bbd1549
parent 92 e48817ca2398 (current diff)
parent 91 d8c5c3191491 (diff)
child 94 904759c1bd62
Merge avec barbu pour tester les messages d'erreur
res/layout/contactlistdialogsettings.xml
src/com/beem/project/beem/ui/ContactListDialogSettings.java
--- a/AndroidManifest.xml	Wed Apr 08 18:35:28 2009 +0200
+++ b/AndroidManifest.xml	Wed Apr 08 18:39:12 2009 +0200
@@ -9,6 +9,7 @@
 				<category android:name="android.intent.category.LAUNCHER" />
 			</intent-filter>
 		</activity>
+		<activity android:name=".ui.ContactListSettings" android:label="@string/app_name" />
 		<activity android:name=".ui.SendIM" android:label="@string/app_name" />
 		<service android:name="BeemService" android:enabled="true"
 			android:label="Beem Service" android:permission="com.beem.project.beem.BEEM_SERVICE">
--- a/res/layout/contactlistdialogsettings.xml	Wed Apr 08 18:35:28 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-              android:orientation="vertical"
-              android:layout_width="fill_parent"
-              android:layout_height="fill_parent"
-        >
-    <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="70dp"
-                />
-                
-        <EditText android:id="@+id/host"
-                  android:layout_width="wrap_content"
-                  android:layout_height="wrap_content"
-                  android:singleLine="true"
-                  android:textSize="16sp"
-                  android:autoText="false"
-                  android:capitalize="none"
-                  android:minWidth="150dp"
-                  android:scrollHorizontally="true"/>
-        <EditText android:id="@+id/port"
-                  android:layout_width="wrap_content"
-                  android:layout_height="wrap_content"
-                  android:singleLine="true"
-                  android:textSize="16sp"
-                  android:autoText="false"
-                  android:minWidth="80dp"
-                  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="Userid:"
-                android:minWidth="70dp"
-                />
-        <EditText android:id="@+id/userid"
-                  android:layout_width="wrap_content"
-                  android:layout_height="wrap_content"
-                  android:singleLine="true"
-                  android:textSize="16sp"
-                  android:autoText="false"
-                  android:minWidth="250dp"
-                  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="70dp"
-                />
-        <EditText android:id="@+id/password"
-                  android:layout_width="wrap_content"
-                  android:layout_height="wrap_content"
-                  android:singleLine="true"
-                  android:password="true"
-                  android:textSize="16sp"
-                  android:autoText="false"
-                  android:minWidth="250dp"
-                  android:capitalize="none"
-                  android:scrollHorizontally="true"/>
-    </LinearLayout>
-
-    <Button android:id="@+id/ok"
-            android:layout_width="fill_parent"
-            android:layout_height="fill_parent"
-            android:text="OK">
-        <requestFocus/>
-    </Button>
-</LinearLayout>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/contactlistsettings.xml	Wed Apr 08 18:39:12 2009 +0200
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:orientation="vertical"
+              android:layout_width="fill_parent"
+              android:layout_height="fill_parent"
+        >
+    <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="70dp"
+                />
+                
+        <EditText android:id="@+id/host"
+                  android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:singleLine="true"
+                  android:textSize="16sp"
+                  android:autoText="false"
+                  android:capitalize="none"
+                  android:minWidth="150dp"
+                  android:scrollHorizontally="true"/>
+        <EditText android:id="@+id/port"
+                  android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:singleLine="true"
+                  android:textSize="16sp"
+                  android:autoText="false"
+                  android:minWidth="80dp"
+                  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="Userid:"
+                android:minWidth="70dp"
+                />
+        <EditText android:id="@+id/userid"
+                  android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:singleLine="true"
+                  android:textSize="16sp"
+                  android:autoText="false"
+                  android:minWidth="250dp"
+                  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="70dp"
+                />
+        <EditText android:id="@+id/password"
+                  android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:singleLine="true"
+                  android:password="true"
+                  android:textSize="16sp"
+                  android:autoText="false"
+                  android:minWidth="250dp"
+                  android:capitalize="none"
+                  android:scrollHorizontally="true"/>
+    </LinearLayout>
+
+    <Button android:id="@+id/ok"
+            android:layout_width="fill_parent"
+            android:layout_height="fill_parent"
+            android:text="OK">
+        <requestFocus/>
+    </Button>
+</LinearLayout>
\ No newline at end of file
--- a/res/layout/messagelist.xml	Wed Apr 08 18:35:28 2009 +0200
+++ b/res/layout/messagelist.xml	Wed Apr 08 18:39:12 2009 +0200
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <TextView xmlns:android="http://schemas.android.com/apk/res/android" id="text1"
           android:textSize="2mm"
-          android:textColor="@color/black"
           android:singleLine="false"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"/>
\ No newline at end of file
--- a/res/layout/sendim.xml	Wed Apr 08 18:35:28 2009 +0200
+++ b/res/layout/sendim.xml	Wed Apr 08 18:39:12 2009 +0200
@@ -2,8 +2,7 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical"
     android:layout_width="fill_parent" 
-    android:layout_height="fill_parent"
-    android:background="@color/blue_sky">
+    android:layout_height="fill_parent">
 
     <ListView android:id="@android:id/list"
         android:layout_width="fill_parent" 
--- a/res/values/strings.xml	Wed Apr 08 18:35:28 2009 +0200
+++ b/res/values/strings.xml	Wed Apr 08 18:39:12 2009 +0200
@@ -28,7 +28,7 @@
 	<string name="PreferenceProxyTypeSocks5">SOCKS5</string>
 
 	<!--  SendIM class -->
-	<string name="SendIMSays">says :\n</string>
+	<string name="SendIMSays"> says :\n</string>
 	<string name="SendIMHint">Tip text here</string>
 	<string name="SendIMState">Is : </string>
 	<string name="SendIMFrom">and is speaking from : </string>
--- a/src/com/beem/project/beem/ui/ContactList.java	Wed Apr 08 18:35:28 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Wed Apr 08 18:39:12 2009 +0200
@@ -13,7 +13,6 @@
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.os.Handler;
-import android.os.IBinder;
 import android.os.RemoteException;
 import android.util.Log;
 import android.view.Menu;
@@ -32,17 +31,17 @@
 import com.beem.project.beem.service.Contact;
 import com.beem.project.beem.service.PresenceAdapter;
 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.service.aidl.IRoster;
 
 public class ContactList extends ExpandableListActivity {
 
     private static final String TAG = "CONTACTLIST_ACT";
+    private static final int PREFERENCECHANGED = 0; 
     private IXmppFacade mService = null;
     private SharedPreferences mSettings;
     private Handler mHandler;
     private BeemApplication mBeemApplication;
-    private ContactListDialogSettings mDialog;
     private BeemRosterListener mRosterListener;
     private IRoster mRoster;
 
@@ -66,33 +65,12 @@
 	mBeemApplication = BeemApplication.getApplication(this);
 	mSettings = getSharedPreferences(
 		getString(R.string.PreferenceFileName), MODE_PRIVATE);
-	mDialog = new ContactListDialogSettings(this, mSettings);
 	mRosterListener = new BeemRosterListener();
-
-	mSettings
-		.registerOnSharedPreferenceChangeListener(new OnSharedPreferenceChangeListener() {
-		    @Override
-		    public void onSharedPreferenceChanged(
-			    SharedPreferences sharedPreferences, String key) {
-			/*
-			 * TODO : A faire apres listener nikita
-			 * 
-			 * mBeemApplication.stopBeemService();
-			 * mBeemApplication.startBeemService();
-			 * mBeemApplication.callWhenServiceConnected(mHandler,
-			 * new Runnable() {
-			 * 
-			 * @Override public void run() {
-			 * callbackShowContactList(); } });
-			 */
-		    }
-		});
     }
 
     @Override
     protected void onStart() {
 	super.onStart();
-	Log.i(TAG, "onStart");
 	mBeemApplication.startBeemService();
     }
 
@@ -103,18 +81,22 @@
 	 * @TODO: A ameliorer apres listener de nikita
 	 */
 	Log.i(TAG, "onResume");
-	mBeemApplication.startBeemService();
 	mBeemApplication.callWhenConnectedToServer(mHandler, new Runnable() {
 	    @Override
 	    public void run() {
 		mService = mBeemApplication.getXmppFacade();
 		try {
 		    mRoster = mService.getRoster();
-		    mRoster.addConnectionListener(mRosterListener);
-		    Log.i(TAG, "ROSTERLISTENER OK");
-		} catch (RemoteException e) {
-		    e.printStackTrace();
-		}		
+		} catch (RemoteException e1) {
+		    e1.printStackTrace();
+		}
+		if (mRoster != null) {
+		    try {
+			mRoster.addConnectionListener(mRosterListener);
+		    } catch (RemoteException e) {
+			e.printStackTrace();
+		    }
+		}
 		callbackShowContactList();
 	    }
 	});
@@ -126,10 +108,11 @@
 	 */
 	if (mRoster != null)
 	    try {
-		showContactList(mRoster.getGroupsNames(), mRoster.getContactList());
+		showContactList(mRoster.getGroupsNames(), mRoster
+			.getContactList());
 	    } catch (RemoteException e) {
 		e.printStackTrace();
-	    }	
+	    }
     }
 
     /**
@@ -158,7 +141,7 @@
     public final boolean onOptionsItemSelected(MenuItem item) {
 	switch (item.getItemId()) {
 	    case R.id.account_edit:
-		mDialog.show();
+		startActivityForResult(new Intent(this, ContactListSettings.class), PREFERENCECHANGED);
 		return true;
 	    case R.id.account_about:
 		return true;
@@ -166,6 +149,17 @@
 		return false;
 	}
     }
+    
+    protected void onActivityResult(int requestCode, int resultCode,
+            Intent data) {
+        if (requestCode == PREFERENCECHANGED) {
+            if (resultCode == RESULT_OK) {
+                mBeemApplication.stopBeemService();
+                mBeemApplication.startBeemService();
+            }            
+        }
+    }
+
 
     private void showContactList(List<String> listGroup,
 	    List<Contact> listContact) {
@@ -186,7 +180,7 @@
 		Map<String, Contact> curChildMap = new HashMap<String, Contact>();
 		children.add(curChildMap);
 		Contact c = listContact.get(j);
-		Log.i(TAG, c.getID() + " " +c.getJID());
+		Log.i(TAG, c.getID() + " " + c.getJID());
 		curChildMap.put("CHILD", c);
 	    }
 	    childData.add(children);
@@ -278,7 +272,7 @@
 		    default:
 			imageDrawable = (Drawable) getResources().getDrawable(
 				R.drawable.error);
-		    	break;
+			break;
 		}
 		imgV.setImageDrawable(imageDrawable);
 
@@ -286,9 +280,7 @@
 		if (v != null) {
 		    v.setText(c.getJID());
 		}
-		/*
-		 * @TODO: Rajouter le message perso du contact v = (TextView)
-		 */
+
 		v = (TextView) view.findViewById(to[2]);
 		if (v != null) {
 		    v.setText(c.getMsgState());
@@ -314,26 +306,29 @@
 	public void onEntriesAdded(List<String> addresses)
 		throws RemoteException {
 	    Log.i(TAG, "ENTRIES ADDED");
-	    
+
 	}
+
 	@Override
 	public void onEntriesDeleted(List<String> addresses)
 		throws RemoteException {
 	    Log.i(TAG, "ENTRIES DEL");
-	    
+
 	}
+
 	@Override
 	public void onEntriesUpdated(List<String> addresses)
 		throws RemoteException {
 	    Log.i(TAG, "ENTRIES UPD");
-	    
+
 	}
+
 	@Override
 	public void onPresenceChanged(PresenceAdapter presence)
 		throws RemoteException {
 	    Log.i(TAG, "PRESENCE CHANGED");
-	    
+
 	}
-	
+
     }
 }
\ No newline at end of file
--- a/src/com/beem/project/beem/ui/ContactListDialogSettings.java	Wed Apr 08 18:35:28 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-package com.beem.project.beem.ui;
-
-import android.app.Activity;
-import android.app.Dialog;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.os.RemoteException;
-import android.util.Log;
-import android.view.View;
-import android.widget.Button;
-import android.widget.EditText;
-
-import com.beem.project.beem.BeemApplication;
-import com.beem.project.beem.R;
-
-/**
- *
- */
-public class ContactListDialogSettings extends Dialog implements
-	android.view.View.OnClickListener {
-
-    private SharedPreferences mSettings;
-
-    public ContactListDialogSettings(Activity activity,
-	    SharedPreferences settings) {
-	super(activity);
-	this.mSettings = settings;
-    }
-
-    @Override
-    protected void onStart() {
-	super.onStart();
-	setContentView(R.layout.contactlistdialogsettings);
-	getWindow().setFlags(4, 4);
-	setTitle("Jabber Account Settings");
-	showSettings();
-	Button ok = (Button) findViewById(R.id.ok);
-	ok.setOnClickListener(this);
-    }
-
-    @Override
-    public void onClick(View v) {
-	SharedPreferences.Editor editor = mSettings.edit();
-	Context ctx = getContext();
-	editor.putString(ctx.getString(R.string.PreferenceHostKey),
-		getWidgetText(R.id.host));
-	editor.putString(ctx.getString(R.string.PreferencePortKey),
-		getWidgetText(R.id.port));
-	editor.putString(ctx.getString(R.string.PreferenceLoginKey),
-		getWidgetText(R.id.userid));
-	editor.putString(ctx.getString(R.string.PreferencePasswordKey),
-		getWidgetText(R.id.password));
-	String JID = ctx.getString(R.string.PreferenceLoginKey) + "@"
-		+ ctx.getString(R.string.PreferenceHostKey);
-	editor.putString(ctx.getString(R.string.PreferenceJID), JID);
-	editor.putBoolean("ACCOUNT_CONFIGURED", true);
-	editor.commit();
-	dismiss();
-    }
-
-    private void showSettings() {
-	Context ctx = getContext();
-	EditText e = (EditText) findViewById(R.id.host);
-	e.setText(mSettings.getString(
-		ctx.getString(R.string.PreferenceHostKey), ""));
-	e = (EditText) findViewById(R.id.port);
-	e.setText(mSettings.getString(
-		ctx.getString(R.string.PreferencePortKey), ""));
-	e = (EditText) findViewById(R.id.userid);
-	e.setText(mSettings.getString(ctx
-		.getString(R.string.PreferenceLoginKey), ""));
-	e = (EditText) findViewById(R.id.password);
-	e.setText(mSettings.getString(ctx
-		.getString(R.string.PreferencePasswordKey), ""));
-    }
-
-    private String getWidgetText(int id) {
-	EditText widget = (EditText) this.findViewById(id);
-	return widget.getText().toString();
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/ui/ContactListSettings.java	Wed Apr 08 18:39:12 2009 +0200
@@ -0,0 +1,93 @@
+package com.beem.project.beem.ui;
+
+import android.app.Activity;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.view.View;
+import android.util.Log;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.EditText;
+
+import com.beem.project.beem.R;
+
+public class ContactListSettings extends Activity {
+
+    public static final int CHANGE = 1;
+    private SharedPreferences mSettings;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+	super.onCreate(savedInstanceState);
+	setContentView(R.layout.contactlistsettings);
+	mSettings = getSharedPreferences(
+		getString(R.string.PreferenceFileName), MODE_PRIVATE);
+	showSettings();
+	Button ok = (Button) findViewById(R.id.ok);
+	ok.setOnClickListener(mOkListener);
+    }
+
+    private OnClickListener mOkListener = new OnClickListener() {
+	public void onClick(View v) {
+	    boolean b = false;
+	    SharedPreferences.Editor editor = mSettings.edit();
+
+	    if (isChanged(R.id.host, R.string.PreferenceHostKey)) {
+		editor.putString(
+			getString(R.string.PreferenceHostKey),
+			getWidgetText(R.id.host));
+		b = true;
+	    }
+	    if (isChanged(R.id.port, R.string.PreferencePortKey)) {
+		editor.putString(
+			getString(R.string.PreferencePortKey),
+			getWidgetText(R.id.port));
+		b = true;
+	    }
+	    if (isChanged(R.id.userid, R.string.PreferenceLoginKey)) {
+		editor.putString(
+			getString(R.string.PreferenceLoginKey),
+			getWidgetText(R.id.userid));
+		b = true;
+	    }
+	    if (isChanged(R.id.password, R.string.PreferencePasswordKey)) {
+		editor.putString(
+			getString(R.string.PreferencePasswordKey),
+			getWidgetText(R.id.password));
+		b = true;
+	    }
+
+	    if (b == true) {
+		editor.commit();
+		setResult(RESULT_OK);
+	    } else
+		setResult(RESULT_CANCELED);
+	    finish();
+	}
+    };
+
+    private boolean isChanged(int idEdit, int idPreference) {
+	return (!getWidgetText(idEdit).equals(getPreferenceString(idPreference)));
+    }
+
+    private void showSettings() {
+	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 = (EditText) findViewById(R.id.userid);
+	e.setText(getPreferenceString(R.string.PreferenceLoginKey));
+	e = (EditText) findViewById(R.id.password);
+	e.setText(getPreferenceString(R.string.PreferencePasswordKey));
+    }
+
+    private String getWidgetText(int id) {
+	EditText widget = (EditText) this.findViewById(id);
+	return widget.getText().toString();
+    }
+
+    private String getPreferenceString(int id) {
+	return mSettings.getString(getString(id), "");
+    }
+
+}
--- a/src/com/beem/project/beem/ui/SendIM.java	Wed Apr 08 18:35:28 2009 +0200
+++ b/src/com/beem/project/beem/ui/SendIM.java	Wed Apr 08 18:39:12 2009 +0200
@@ -4,7 +4,10 @@
 
 import android.app.ListActivity;
 import android.content.SharedPreferences;
+import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
 import android.os.Bundle;
+import android.os.Handler;
+import android.os.RemoteException;
 import android.util.Log;
 import android.view.KeyEvent;
 import android.view.Menu;
@@ -16,8 +19,15 @@
 import android.widget.ArrayAdapter;
 import android.widget.EditText;
 
+import com.beem.project.beem.BeemApplication;
 import com.beem.project.beem.R;
 import com.beem.project.beem.service.Contact;
+import com.beem.project.beem.service.Message;
+import com.beem.project.beem.service.aidl.IChat;
+import com.beem.project.beem.service.aidl.IChatManager;
+import com.beem.project.beem.service.aidl.IChatManagerListener;
+import com.beem.project.beem.service.aidl.IMessageListener;
+import com.beem.project.beem.service.aidl.IXmppFacade;
 
 /**
  * @author barbu This activity class provide the view for instant messaging
@@ -31,7 +41,15 @@
     private ArrayAdapter<String> mAdapter;
     private SendIMDialogSmiley mSmyDialog;
     private SharedPreferences mSet;
+    private SharedPreferences mGlobalSettings;
+    private BeemApplication mBeemApplication;
+    private Handler mHandler;
+    private IXmppFacade mService = null;
     private Contact mContact;
+    private IChatManager mChatManager;
+    private IChatManagerListener mChatManagerListener;
+    private IMessageListener mMessageListener;
+    private IChat mChat;
 
     /**
      * Constructor.
@@ -46,11 +64,15 @@
     @Override
     public void onCreate(Bundle saveBundle) {
 	super.onCreate(saveBundle);
-
+	mHandler = new Handler();
+	mChatManagerListener = new OnChatListener();
+	mMessageListener = new OnMessageListener();
+	mBeemApplication = BeemApplication.getApplication(this);
 	setContentView(R.layout.sendim);
 	mToSend = (EditText) findViewById(R.id.userText);
 	mSet = getSharedPreferences("lol", MODE_PRIVATE);
 	mSmyDialog = new SendIMDialogSmiley(this, mSet);
+	mGlobalSettings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE);
 
 	mAdapter = new ArrayAdapter<String>(this, R.layout.messagelist,
 		mMessages);
@@ -65,7 +87,16 @@
     @Override
     public void onStart() {
 	super.onStart();
-
+	mBeemApplication.startBeemService();
+	mService = mBeemApplication.getXmppFacade();
+	try {
+	    mChatManager = mService.getChatManager();
+	    mChatManager.addChatCreationListener(mChatManagerListener);
+	    mChat = mChatManager.createChat(mContact, mMessageListener);
+	} catch (RemoteException e) {
+	    // TODO Auto-generated catch block
+	    e.printStackTrace();
+	}
     }
 
     /**
@@ -82,19 +113,17 @@
      */
     private void sendText() {
 	String text = mToSend.getText().toString();
+	String from = mGlobalSettings.getString(getString(R.string.PreferenceJID), "You");
 	if (!text.equals("")) {
-	    /*
-	     * Prepare the message to be send
-	     */
-	    /* Message msg = new Message("barbu", Message.Type.chat); */
-	    /* msg.setBody(text); */
-	    /*
-	     * Rien a voir il faut changer le mContact.getJID() et remplacer
-	     * avec son pseudo cetait juste un test pour savoir qu'on recupere
-	     * bien le contact a qui envoyer les infos
-	     */
-	    mAdapter.add(mContact.getJID() + " "
-		    + getString(R.string.SendIMSays) + text);
+	    Message msg = new Message(mContact.getJID(), Message.MSG_TYPE_CHAT);
+	    msg.setBody(text);
+	    try {
+		mChat.sendMessage(msg);
+	    } catch (RemoteException e) {
+		// TODO Auto-generated catch block
+		e.printStackTrace();
+	    }
+	    mAdapter.add(from + getString(R.string.SendIMSays) + text);
 	    mToSend.setText(null);
 	}
     }
@@ -139,4 +168,27 @@
 		return false;
 	}
     }
+    
+    private class OnChatListener extends IChatManagerListener.Stub {
+
+	@Override
+	public void chatCreated(IChat chat, boolean locally)
+		throws RemoteException {
+	    Log.i("LOG", "chatCreated");
+	    
+	}
+	
+    }
+    
+    private class OnMessageListener extends IMessageListener.Stub {
+
+	@Override
+	public void processMessage(IChat chat, Message msg)
+		throws RemoteException {
+	    Log.i("LOG", "processMessage");
+	    mAdapter.add(mContact.getJID() + " "
+		    + getString(R.string.SendIMSays) + msg.getBody());
+	}
+	
+    }
 }