Add an interface for sending im message.
authorDa Risk <darisk972@gmail.com>
Thu, 02 Apr 2009 19:00:57 +0200
changeset 55 66732dd2cb77
parent 54 dfbb0fbece57
child 56 d1a5bb00aaeb
Add an interface for sending im message. Do some javadoc comments
project.aidl
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/ChatAdapter.java
src/com/beem/project/beem/service/Contact.java
src/com/beem/project/beem/service/Message.java
src/com/beem/project/beem/service/RosterAdapter.java
src/com/beem/project/beem/service/XMPPConnectionAdapter.java
src/com/beem/project/beem/service/XMPPFacade.java
src/com/beem/project/beem/service/aidl/IBeemConnectionListener.aidl
src/com/beem/project/beem/service/aidl/IChat.aidl
src/com/beem/project/beem/service/aidl/IChatManager.aidl
src/com/beem/project/beem/service/aidl/IChatManagerListener.aidl
src/com/beem/project/beem/service/aidl/IMessageListener.aidl
src/com/beem/project/beem/service/aidl/IXMPPConnection.aidl
src/com/beem/project/beem/service/aidl/IXMPPFacade.aidl
src/com/beem/project/beem/service/aidl/IXmppConnection.aidl
--- a/project.aidl	Thu Apr 02 19:00:23 2009 +0200
+++ b/project.aidl	Thu Apr 02 19:00:57 2009 +0200
@@ -4,3 +4,4 @@
 
 parcelable com.beem.project.beem.BeemException
 parcelable com.beem.project.beem.service.Contact
+parcelable com.beem.project.beem.service.Message
--- a/src/com/beem/project/beem/BeemApplication.java	Thu Apr 02 19:00:23 2009 +0200
+++ b/src/com/beem/project/beem/BeemApplication.java	Thu Apr 02 19:00:57 2009 +0200
@@ -21,63 +21,18 @@
 import com.beem.project.beem.service.aidl.IXMPPFacade;
 
 /**
+ * The Beem application.
+ * This class has some methods utiliy needs by the activities.
  * @author darisk
  */
 public class BeemApplication extends Application {
 
+    private static BeemApplication mBeemApp;
     private IXMPPFacade mFacade;
-  
     private Context mApplicationContext;
     private Resources mPrivateResources;
-    private static BeemApplication mBeemApp;
     private List<Message> mQueue = new LinkedList<Message>();
     private boolean mIsConnected;
-    
-    public static BeemApplication getApplication(Activity activity) {
-	if (mBeemApp == null) {
-	    mBeemApp = new BeemApplication();
-	    mBeemApp.mApplicationContext = activity.getApplication();
-	    mBeemApp.mPrivateResources = activity.getResources();
-	    mBeemApp.onCreate();
-	}
-	return mBeemApp;
-    }
-    
-    @Override
-    public void onConfigurationChanged(Configuration newConfig) {
-	// TODO Auto-generated method stub
-	super.onConfigurationChanged(newConfig);
-    }
-
-    @Override
-    public void onCreate() {
-	// TODO Auto-generated method stub
-	super.onCreate();
-	mFacade = null;
-    }
-
-    @Override
-    public void onLowMemory() {
-	// TODO Auto-generated method stub
-	super.onLowMemory();
-    }
-
-    @Override
-    public void onTerminate() {
-	// TODO Auto-generated method stub
-	super.onTerminate();
-    }
-
-    public synchronized void startBeemService() {
-	if (!mIsConnected) {
-	    // Intent intent = new Intent(this, BeemService.class);
-	    Intent intent = new Intent();
-	    intent.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
-	    mApplicationContext.startService(intent);
-	    mApplicationContext.bindService(intent, mServConn, BIND_AUTO_CREATE);
-	    mIsConnected = true;
-	}
-    }
 
     private ServiceConnection mServConn = new ServiceConnection() {
 
@@ -100,16 +55,101 @@
 	}
     };
 
+    /**
+     * Constructor.
+     */
+    public BeemApplication() {
+	// TODO Auto-generated constructor stub
+    }
+
+    /**
+     * Get the Beem application for an activity.
+     * @param activity	the activity which want the Beem application
+     * @return		the Beem application
+     */
+    public static BeemApplication getApplication(Activity activity) {
+	if (mBeemApp == null) {
+	    mBeemApp = new BeemApplication();
+	    mBeemApp.mApplicationContext = activity.getApplication();
+	    mBeemApp.mPrivateResources = activity.getResources();
+	    mBeemApp.onCreate();
+	}
+	return mBeemApp;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void onConfigurationChanged(Configuration newConfig) {
+	// TODO Auto-generated method stub
+	super.onConfigurationChanged(newConfig);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void onCreate() {
+	// TODO Auto-generated method stub
+	super.onCreate();
+	mFacade = null;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void onLowMemory() {
+	// TODO Auto-generated method stub
+	super.onLowMemory();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void onTerminate() {
+	// TODO Auto-generated method stub
+	super.onTerminate();
+    }
+
+    /**
+     * Start the beem service.
+     */
+    public synchronized void startBeemService() {
+	if (!mIsConnected) {
+	    // Intent intent = new Intent(this, BeemService.class);
+	    Intent intent = new Intent();
+	    intent.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
+	    mApplicationContext.startService(intent);
+	    mApplicationContext.bindService(intent, mServConn, BIND_AUTO_CREATE);
+	    mIsConnected = true;
+	}
+    }
+
+    /**
+     * Stop the Beem service.
+     */
     public synchronized void stopBeemService() {
 	Intent intent = new Intent(this, BeemService.class);
 	mApplicationContext.unbindService(mServConn);
 	mApplicationContext.stopService(intent);
     }
 
+    /**
+     * Get the facade to use to access the Beem service.
+     * @return	the facade or null if the application is not connected to the beem service.
+     */
     public IXMPPFacade getXmppFacade() {
 	return mFacade;
     }
-    
+
+    /**
+     * Add a methode to execute when the application is connected to the Beem service.
+     * @param target	the handler which will execute the callback
+     * @param callback	the callback to execute
+     */
     public void callWhenServiceConnected(Handler target, Runnable callback) {
 	Message msg = Message.obtain(target, callback);
 	if (!mIsConnected) {
--- a/src/com/beem/project/beem/BeemService.java	Thu Apr 02 19:00:23 2009 +0200
+++ b/src/com/beem/project/beem/BeemService.java	Thu Apr 02 19:00:57 2009 +0200
@@ -1,19 +1,5 @@
-
-/**
- * 
- */
 package com.beem.project.beem;
 
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.jivesoftware.smack.Roster;
-import org.jivesoftware.smack.RosterListener;
-import org.jivesoftware.smack.packet.Presence;
-import org.jivesoftware.smack.XMPPConnection;
-import org.jivesoftware.smack.XMPPException;
-
 import android.app.Notification;
 import android.app.NotificationManager;
 import android.app.PendingIntent;
@@ -21,15 +7,13 @@
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.os.IBinder;
-import android.os.Looper;
 import android.os.RemoteException;
 import android.widget.Toast;
 
 import com.beem.project.beem.service.XMPPConnectionAdapter;
 import com.beem.project.beem.service.XMPPFacade;
-import com.beem.project.beem.service.aidl.IRoster;
-import com.beem.project.beem.service.aidl.IXMPPConnection;
 import com.beem.project.beem.service.aidl.IXMPPFacade;
+import com.beem.project.beem.service.aidl.IXmppConnection;
 /**
  * This class is for the Beem service.
  * @author darisk
@@ -37,20 +21,18 @@
  */
 public class BeemService extends Service {
 
-    private NotificationManager notificationManager;
+    private NotificationManager mNotificationManager;
 
-    private IXMPPConnection connection;
-    private SharedPreferences settings;
+    private IXmppConnection mConnection;
+    private SharedPreferences mSettings;
     private String mLogin;
     private String mPassword;
     private String mHost;
 
     private IXMPPFacade.Stub mBind;
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see android.app.Service#onBind(android.content.Intent)
+    /**
+     * {@inheritDoc}
      */
     @Override
     public IBinder onBind(Intent intent) {
@@ -60,20 +42,62 @@
 	// return null;
     }
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public void onCreate() {
 	super.onCreate();
-	settings = getSharedPreferences(getString(R.string.PreferenceFileName),
+	mSettings = getSharedPreferences(getString(R.string.PreferenceFileName),
 		MODE_PRIVATE);
-	mLogin = settings.getString(getString(R.string.PreferenceLoginKey), "");
-	mPassword = settings.getString(
+	mLogin = mSettings.getString(getString(R.string.PreferenceLoginKey), "");
+	mPassword = mSettings.getString(
 		getString(R.string.PreferencePasswordKey), "");
-	mHost = settings.getString(getString(R.string.PreferenceHostKey), "");
-	notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
-	connection = new XMPPConnectionAdapter("10.0.2.2", mLogin, mPassword); // address
-	mBind = new XMPPFacade((XMPPConnectionAdapter) connection);
+	mHost = mSettings.getString(getString(R.string.PreferenceHostKey), "");
+	mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+	mConnection = new XMPPConnectionAdapter("10.0.2.2", mLogin, mPassword); // address
+	mBind = new XMPPFacade((XMPPConnectionAdapter) mConnection);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void onStart(Intent intent, int startId) {
+	try {
+	    mConnection.connectSync();
+	} catch (RemoteException e) {
+	    // TODO Auto-generated catch block
+	    e.printStackTrace();
+	}
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void onDestroy() {
+	closeConnection();
+	showBasicNotification(R.string.BeemServiceDestroyed);
+    }
+
+    /**
+     * Close the connection to the xmpp server.
+     */
+    private void closeConnection() {
+	if (mConnection != null)
+	    try {
+		mConnection.disconnect();
+	    } catch (RemoteException e) {
+		// TODO Auto-generated catch block
+		e.printStackTrace();
+	    }
+    }
+
+    /**
+     * Add a notification in the notification status bar.
+     * @param stringResource	the ressource of the text to show
+     */
     private void showBasicNotification(int stringResource) {
         String text = (String) getText(stringResource);
         Notification notif = new Notification(R.drawable.logo, text, System
@@ -81,36 +105,11 @@
         notif.defaults = Notification.DEFAULT_ALL;
         notif.setLatestEventInfo(this, text, text, PendingIntent.getActivity(
                 this, 0, new Intent(), 0));
-        notificationManager.notify(stringResource, notif);
+        mNotificationManager.notify(stringResource, notif);
         Toast toast = Toast.makeText(this, R.string.BeemServiceCreated,
                 Toast.LENGTH_LONG);
         toast.show();
     }
 
-    @Override
-    public void onStart(Intent intent, int startId) {
-	try {
-	    connection.connectSync();
-	} catch (RemoteException e) {
-	    // TODO Auto-generated catch block
-	    e.printStackTrace();
-	}
-    }
-
-    @Override
-    public void onDestroy() {
-	closeConnection();
-	showBasicNotification(R.string.BeemServiceDestroyed);
-    }
-
-    private void closeConnection() {
-	if (connection != null)
-	    try {
-		connection.disconnect();
-	    } catch (RemoteException e) {
-		// TODO Auto-generated catch block
-		e.printStackTrace();
-	    }
-    }
 
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/service/BeemChatManager.java	Thu Apr 02 19:00:57 2009 +0200
@@ -0,0 +1,135 @@
+/**
+ * 
+ */
+package com.beem.project.beem.service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jivesoftware.smack.Chat;
+import org.jivesoftware.smack.ChatManager;
+import org.jivesoftware.smack.ChatManagerListener;
+import org.jivesoftware.smack.MessageListener;
+
+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.IChatManager;
+import com.beem.project.beem.service.aidl.IChatManagerListener;
+import com.beem.project.beem.service.aidl.IMessageListener;
+
+/**
+ * An adapter for smack's ChatManager. This class provides functionnality to handle chats.
+ * @author darisk
+ */
+public class BeemChatManager extends IChatManager.Stub {
+
+    /**
+     * Tag to use with log methods.
+     */
+    public static final String TAG = "BeemChatManager";
+    private ChatManager mAdaptee;
+    private Map<String, Chat> mChats = new HashMap<String, Chat>();
+    private ChatListener mChatListener = new ChatListener();
+    private RemoteCallbackList<IChatManagerListener> mRemoteChatCreationListeners =
+	new RemoteCallbackList<IChatManagerListener>();
+
+    /**
+     * Constructor.
+     * @param chatManager the smack ChatManager to adapt
+     */
+    public BeemChatManager(final ChatManager chatManager) {
+	// TODO Auto-generated constructor stub
+	mAdaptee = chatManager;
+	mAdaptee.addChatListener(mChatListener);
+    }
+
+    /**
+     * Create a chat session.
+     * @param jid the jid of the contact you want to chat with
+     * @param listener listener to use for chat events on this chat session
+     * @return the chat session
+     */
+    public Chat createChat(String jid, MessageListener listener) {
+	return mAdaptee.createChat(jid, listener);
+    }
+
+    /**
+     * Create a chat session.
+     * @param contact the contact you want to chat with
+     * @param listener listener to use for chat events on this chat session
+     * @return the chat session
+     */
+    public Chat createChat(Contact contact, MessageListener listener) {
+	String jid = contact.getJID();
+	return createChat(jid, listener);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void addChatCreationListener(IChatManagerListener listener) throws RemoteException {
+	// TODO Auto-generated method stub
+	mRemoteChatCreationListeners.register(listener);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public IChat createChat(Contact contact, IMessageListener listener) throws RemoteException {
+	// TODO Auto-generated method stub
+	return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void removeChatCreationListener(IChatManagerListener listener) throws RemoteException {
+	// TODO Auto-generated method stub
+	mRemoteChatCreationListeners.unregister(listener);
+    }
+
+    /**
+     * A listener for all the chat creation event that happens on the connection.
+     * @author darisk
+     */
+    private class ChatListener implements ChatManagerListener {
+
+	/**
+	 * Constructor.
+	 */
+	public ChatListener() {
+	    // TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void chatCreated(Chat chat, boolean locally) {
+	    if (!locally) {
+		mChats.put(chat.getParticipant(), chat);
+	    }
+	    final int n = mRemoteChatCreationListeners.beginBroadcast();
+
+	    for (int i = 0; i < n; i++) {
+		IChatManagerListener listener = mRemoteChatCreationListeners.getBroadcastItem(i);
+		try {
+		    IChat newchat = new ChatAdapter(chat);
+		    listener.chatCreated(newchat, locally);
+		} catch (RemoteException e) {
+		    // The RemoteCallbackList will take care of removing the
+		    // dead listeners.
+		    Log.w(TAG, "Error while triggering remote connection listeners", e);
+		}
+	    }
+	    mRemoteChatCreationListeners.finishBroadcast();
+	}
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/service/ChatAdapter.java	Thu Apr 02 19:00:57 2009 +0200
@@ -0,0 +1,57 @@
+/**
+ * 
+ */
+package com.beem.project.beem.service;
+
+import org.jivesoftware.smack.Chat;
+import org.jivesoftware.smack.XMPPException;
+
+import android.os.RemoteException;
+
+import com.beem.project.beem.service.aidl.IChat;
+
+/**
+ * An adapter for smack's Chat class.
+ * @author darisk
+ */
+public class ChatAdapter extends IChat.Stub {
+    private Chat mAdaptee;
+    private Contact mParticipant;
+
+    /**
+     * Constructor.
+     * @param chat The chat to adapt
+     */
+    public ChatAdapter(final Chat chat) {
+	mAdaptee = chat;
+	mParticipant = new Contact(chat.getParticipant());
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Contact getParticipant() throws RemoteException {
+	return mParticipant;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void sendMessage(Message message) throws RemoteException {
+	org.jivesoftware.smack.packet.Message send = new org.jivesoftware.smack.packet.Message();
+	send.setTo(message.getTo());
+	send.setBody(message.getBody());
+	send.setThread(message.getThread());
+	send.setSubject(message.getSubject());
+	send.setType(org.jivesoftware.smack.packet.Message.Type.chat);
+	try {
+	    mAdaptee.sendMessage(send);
+	} catch (XMPPException e) {
+	    // TODO Auto-generated catch block
+	    e.printStackTrace();
+	}
+    }
+
+}
--- a/src/com/beem/project/beem/service/Contact.java	Thu Apr 02 19:00:23 2009 +0200
+++ b/src/com/beem/project/beem/service/Contact.java	Thu Apr 02 19:00:57 2009 +0200
@@ -71,7 +71,6 @@
 	dest.writeString(mMsgState);
     }
 
-    
     /**
      * Get the Jabber ID of the contact.
      * @return the Jabber ID
--- a/src/com/beem/project/beem/service/Message.java	Thu Apr 02 19:00:23 2009 +0200
+++ b/src/com/beem/project/beem/service/Message.java	Thu Apr 02 19:00:57 2009 +0200
@@ -7,15 +7,27 @@
 import android.os.Parcelable;
 
 /**
+ * This class represents a instant message.
  * @author darisk
- *
  */
 public class Message implements Parcelable {
-    
-    public final static int MSG_TYPE_NORMAL = 100;
-    public final static int MSG_TYPE_CHAT = 200;
-    public final static int MSG_TYPE_GROUP_CHAT = 300;
-    
+
+    /**
+     * Normal message type.
+     * Theese messages are like an email, with subject.
+     */
+    public static  final int MSG_TYPE_NORMAL = 100;
+
+    /**
+     * Chat message type.
+     */
+    public static  final int MSG_TYPE_CHAT = 200;
+
+    /**
+     * Group chat message type.
+     */
+    public static  final int MSG_TYPE_GROUP_CHAT = 300;
+
     private int mType;
     private String mBody;
     private String mSubject;
@@ -37,19 +49,28 @@
 	    return new Message[size];
 	}
     };
-    
-    public Message(String to, int type) {
+
+    /**
+     * Constructor.
+     * @param to	the destinataire of the message
+     * @param type	the message type
+     */
+    public Message(final String to, final int type) {
 	mTo = to;
 	mType = type;
 	mBody = "";
 	mSubject = "";
 	mThread = "";
     }
-    
-    public Message(String to) {
+
+    /**
+     * Constructor a message of type chat.
+     * @param to	the destinataire of the message
+     */
+    public Message(final String to) {
 	this(to, MSG_TYPE_CHAT);
     }
-    
+
     /**
      * Construct a message from a parcel.
      * @param in parcel to use for construction
@@ -61,7 +82,10 @@
 	mSubject = in.readString();
 	mThread = in.readString();
     }
-    
+
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public void writeToParcel(Parcel dest, int flags) {
 	// TODO Auto-generated method stub
@@ -71,16 +95,18 @@
 	dest.writeString(mSubject);
 	dest.writeString(mThread);
     }
-    
+
     /**
-     * @return the Type
+     * Get the type of the message.
+     * @return the type of the message.
      */
     public int getType() {
         return mType;
     }
 
     /**
-     * @param type the Type to set
+     * Set the type of the message.
+     * @param type the type to set
      */
     public void setType(int type) {
         mType = type;
@@ -88,7 +114,8 @@
 
 
     /**
-     * @return the mBody
+     * Get the body of the message.
+     * @return the Body of the message
      */
     public String getBody() {
         return mBody;
@@ -96,7 +123,8 @@
 
 
     /**
-     * @param body the mBody to set
+     * Set the body of the message.
+     * @param body the body to set
      */
     public void setBody(String body) {
         mBody = body;
@@ -104,7 +132,8 @@
 
 
     /**
-     * @return the mSubject
+     * Get the subject of the message.
+     * @return the subject
      */
     public String getSubject() {
         return mSubject;
@@ -112,7 +141,8 @@
 
 
     /**
-     * @param subject the mSubject to set
+     * Set the subject of the message.
+     * @param subject the subject to set
      */
     public void setSubject(String subject) {
         mSubject = subject;
@@ -120,7 +150,8 @@
 
 
     /**
-     * @return the mTo
+     * Get the destinataire of the message.
+     * @return the destinataire of the message
      */
     public String getTo() {
         return mTo;
@@ -128,7 +159,8 @@
 
 
     /**
-     * @param to the mTo to set
+     * Set the destinataire of the message.
+     * @param to the destinataire to set
      */
     public void setTo(String to) {
         mTo = to;
@@ -136,7 +168,8 @@
 
 
     /**
-     * @return the mThread
+     * Get the thread of the message.
+     * @return the thread
      */
     public String getThread() {
         return mThread;
@@ -144,22 +177,20 @@
 
 
     /**
-     * @param thread the mThread to set
+     * Set the thread of the message.
+     * @param thread the thread to set
      */
     public void setThread(String thread) {
         mThread = thread;
     }
 
-
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public int describeContents() {
 	// TODO Auto-generated method stub
 	return 0;
     }
 
-
- 
-
-    
-    
 }
--- a/src/com/beem/project/beem/service/RosterAdapter.java	Thu Apr 02 19:00:23 2009 +0200
+++ b/src/com/beem/project/beem/service/RosterAdapter.java	Thu Apr 02 19:00:57 2009 +0200
@@ -1,11 +1,10 @@
 /**
- * 
+ *
  */
 package com.beem.project.beem.service;
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -89,6 +88,9 @@
 	return res;
     }
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public List<String> getGroupsNames() throws RemoteException {
 	Collection<RosterGroup> groups = mAdaptee.getGroups();
--- a/src/com/beem/project/beem/service/XMPPConnectionAdapter.java	Thu Apr 02 19:00:23 2009 +0200
+++ b/src/com/beem/project/beem/service/XMPPConnectionAdapter.java	Thu Apr 02 19:00:57 2009 +0200
@@ -10,21 +10,19 @@
 import org.jivesoftware.smack.XMPPException;
 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.service.aidl.IBeemConnectionListener;
 import com.beem.project.beem.service.aidl.IRoster;
-import com.beem.project.beem.service.aidl.IXMPPConnection;
+import com.beem.project.beem.service.aidl.IXmppConnection;
 
 /**
  * This class implements an adapter for XMPPConnection.
  * @author darisk
  */
-public class XMPPConnectionAdapter extends IXMPPConnection.Stub {
+public class XMPPConnectionAdapter extends IXmppConnection.Stub {
 
     private static final String TAG = "XMPPConnectionAdapter";
     private XMPPConnection mAdaptee;
--- a/src/com/beem/project/beem/service/XMPPFacade.java	Thu Apr 02 19:00:23 2009 +0200
+++ b/src/com/beem/project/beem/service/XMPPFacade.java	Thu Apr 02 19:00:57 2009 +0200
@@ -1,15 +1,13 @@
-/**
- * 
- */
 package com.beem.project.beem.service;
 import android.os.RemoteException;
 
 import com.beem.project.beem.service.aidl.IRoster;
-import com.beem.project.beem.service.aidl.IXMPPConnection;
+import com.beem.project.beem.service.aidl.IXmppConnection;
 import com.beem.project.beem.service.aidl.IXMPPFacade;
+
 /**
+ * This class is a facade for the Beem Service.
  * @author darisk
- *
  */
 public class XMPPFacade extends IXMPPFacade.Stub {
 
@@ -19,34 +17,49 @@
      * Constructor for XMPPFacade.
      * @param connection the connection use by the facade
      */
-    public XMPPFacade(XMPPConnectionAdapter connection) {
+    public XMPPFacade(final XMPPConnectionAdapter connection) {
 	this.mConnexion = connection;
     }
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public void connectAsync() throws RemoteException {
 	// TODO Auto-generated method stub
 	mConnexion.connectAsync();
     }
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public void connectSync() throws RemoteException {
 	// TODO Auto-generated method stub
 	mConnexion.connectSync();
     }
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
-    public IXMPPConnection createConnection() throws RemoteException {
+    public IXmppConnection createConnection() throws RemoteException {
 	// TODO Auto-generated method stub
 	return mConnexion;
     }
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public void disconnect() throws RemoteException {
 	// TODO Auto-generated method stub
 	mConnexion.disconnect();
     }
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public IRoster getRoster() throws RemoteException {
 	return mConnexion.getRoster();
--- a/src/com/beem/project/beem/service/aidl/IBeemConnectionListener.aidl	Thu Apr 02 19:00:23 2009 +0200
+++ b/src/com/beem/project/beem/service/aidl/IBeemConnectionListener.aidl	Thu Apr 02 19:00:57 2009 +0200
@@ -1,17 +1,39 @@
 package com.beem.project.beem.service.aidl;
 
+/**
+ * Interface to listen for connection events
+ * @author Da Risk <barthe_f@epitech.eu>
+ */
 interface IBeemConnectionListener {
 	
+    /**
+     *  Callback to call when the connection is closed
+     */
     void connectionClosed();
     
+    /**
+     *  Callback to call when the connection occurs
+     */
     void onConnect();
     
     //void connectionClosedOnError(in Exception e);
+    /**
+     *  Callback to call when the connection is closed on error
+     */
     void connectionClosedOnError();
      
+    /**
+     * Callback to call when trying to reconnecting
+     */
     void reconnectingIn(in int seconds);
     
+    /**
+     *  Callback to call when the reconnection has failed
+     */
     void reconnectionFailed();
      
+    /**
+     *  Callback to call when the reconnection is successfull
+     */ 
     void reconnectionSuccessful();
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/service/aidl/IChat.aidl	Thu Apr 02 19:00:57 2009 +0200
@@ -0,0 +1,22 @@
+package com.beem.project.beem.service.aidl;
+
+import  com.beem.project.beem.service.Contact;
+import  com.beem.project.beem.service.Message;
+
+/**
+ * An aidl interface for Chat session.
+ */
+interface IChat {
+    
+    	/**
+    	 * Send a message.
+    	 * @param message	the message to send
+    	 */
+	void sendMessage(in Message message);
+	
+	/**
+	 * Get the participant of the chat
+	 * @return the participant
+	 */
+	Contact getParticipant();	
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/service/aidl/IChatManager.aidl	Thu Apr 02 19:00:57 2009 +0200
@@ -0,0 +1,35 @@
+package com.beem.project.beem.service.aidl;
+
+import  com.beem.project.beem.service.Contact;
+import  com.beem.project.beem.service.aidl.IChat;
+import  com.beem.project.beem.service.aidl.IMessageListener;
+import  com.beem.project.beem.service.aidl.IChatManagerListener;
+
+/**
+ * Aidl interface for a chat manager.
+ * The chat manager will manage all the chat sessions.
+ */
+interface IChatManager {
+    
+    	//IChat createChat(in String jid, in IMessageListener listener);
+    
+    	/**
+    	 * Create a chat session with a contact.
+    	 * @param contact	the contact to chat with
+    	 * @param listener	the callback to call when a new message comes from this chat session
+    	 * @return 		the chat session
+    	 */
+	IChat createChat(in Contact contact, in IMessageListener listener);
+	
+	/**
+	 * Register a callback to call when a new chat session is created.
+	 * @param listener	the callback to add
+	 */
+	void addChatCreationListener(in IChatManagerListener listener);
+	
+	/**
+	 * Remove a callback for the creation of new chat session.
+	 * @param listener	the callback to remove.
+	 */
+	void removeChatCreationListener(in IChatManagerListener listener);
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/service/aidl/IChatManagerListener.aidl	Thu Apr 02 19:00:57 2009 +0200
@@ -0,0 +1,18 @@
+package com.beem.project.beem.service.aidl;
+
+import  com.beem.project.beem.service.aidl.IChat;
+
+/**
+ * Aidl interface for ChatManager listener.
+ * This listener will execute on events like creation of chat session.
+ */
+interface IChatManagerListener {
+    
+    	/**
+    	 * Call when a new chat session is created.
+    	 * @param chat		the created chat session
+    	 * @param locally	true if the session is create by a chat manager.
+    	 */
+    	void chatCreated(IChat chat, boolean locally);
+	
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/service/aidl/IMessageListener.aidl	Thu Apr 02 19:00:57 2009 +0200
@@ -0,0 +1,9 @@
+package com.beem.project.beem.service.aidl;
+
+import com.beem.project.beem.service.Message;
+import com.beem.project.beem.service.aidl.IChat;
+
+interface IMessageListener {
+
+	void processMessage(in IChat chat, in Message msg); 
+}
--- a/src/com/beem/project/beem/service/aidl/IXMPPConnection.aidl	Thu Apr 02 19:00:23 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-package com.beem.project.beem.service.aidl;
-
-import  com.beem.project.beem.service.aidl.IRoster;
-import  com.beem.project.beem.service.aidl.IBeemConnectionListener;
-
-interface IXMPPConnection {
-    
-    boolean connectSync();
-    
-    void connectAsync();
-    
-    boolean disconnect();
-    
-    IRoster getRoster();
-
-    void addConnectionListener(in IBeemConnectionListener listen);
-    void removeConnectionListener(in IBeemConnectionListener listen);
-}
\ No newline at end of file
--- a/src/com/beem/project/beem/service/aidl/IXMPPFacade.aidl	Thu Apr 02 19:00:23 2009 +0200
+++ b/src/com/beem/project/beem/service/aidl/IXMPPFacade.aidl	Thu Apr 02 19:00:57 2009 +0200
@@ -1,11 +1,11 @@
 package com.beem.project.beem.service.aidl;
 
-import  com.beem.project.beem.service.aidl.IXMPPConnection;
+import  com.beem.project.beem.service.aidl.IXmppConnection;
 import  com.beem.project.beem.service.aidl.IRoster;
 
 interface IXMPPFacade {
 
-    IXMPPConnection createConnection();
+    IXmppConnection createConnection();
     
     IRoster getRoster();
     
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/service/aidl/IXmppConnection.aidl	Thu Apr 02 19:00:57 2009 +0200
@@ -0,0 +1,20 @@
+package com.beem.project.beem.service.aidl;
+
+import  com.beem.project.beem.service.aidl.IRoster;
+import  com.beem.project.beem.service.aidl.IBeemConnectionListener;
+
+interface IXmppConnection {
+    
+    boolean connectSync();
+    
+    void connectAsync();
+    
+    boolean disconnect();
+    
+    IRoster getRoster();
+
+    void addConnectionListener(in IBeemConnectionListener listen);
+    void removeConnectionListener(in IBeemConnectionListener listen);
+    
+ //   IChatManager getChatManager();
+}
\ No newline at end of file