IssueID #82
authornikita@nikita-portable
Sun, 17 May 2009 16:42:29 +0200
changeset 188 00aee9a42555
parent 187 ce342bfa7bdb
child 189 dae38cc05ddf
IssueID #82 Le chate state est bien envoyer et recu coter ui, il faut encore l'afficher, et donc prevoir un endroit ou l'afficher. Je laisse ca a barbi car je sais qu'il adore ├ža :D
src/com/beem/project/beem/service/BeemChatManager.java
src/com/beem/project/beem/service/aidl/IMessageListener.aidl
src/com/beem/project/beem/ui/SendIM.java
--- a/src/com/beem/project/beem/service/BeemChatManager.java	Sun May 17 16:11:01 2009 +0200
+++ b/src/com/beem/project/beem/service/BeemChatManager.java	Sun May 17 16:42:29 2009 +0200
@@ -186,9 +186,8 @@
 	@Override
 	public void processMessage(Chat chat, Message message) {
 	    IChat newchat = getChat(chat);
+	    try {
 
-	    try {
-		
 		if (message.getBody() != null)
 		    newchat.addToLastMessages(message.getBody());
 		final int n = mRemoteMessageListeners.beginBroadcast();
@@ -209,12 +208,23 @@
 
 	@Override
 	public void stateChanged(Chat chat, ChatState state) {
+	    IChat newchat = getChat(chat);
 	    try {
-		Log.d(TAG, "state changed");
-		mChats.get(chat.getParticipant()).setState(state.name());
+		newchat.setState(state.name());
 	    } catch (RemoteException e) {
 		e.printStackTrace();
 	    }
+	    final int n = mRemoteMessageListeners.beginBroadcast();
+
+	    for (int i = 0; i < n; i++) {
+		IMessageListener listener = mRemoteMessageListeners.getBroadcastItem(i);
+		try {
+		    listener.stateChanged(newchat);
+		} catch (RemoteException e) {
+		    Log.w(TAG, "Error while changing chat state", e);
+		}
+	    }
+	    mRemoteMessageListeners.finishBroadcast();
 	}
     }
 
--- a/src/com/beem/project/beem/service/aidl/IMessageListener.aidl	Sun May 17 16:11:01 2009 +0200
+++ b/src/com/beem/project/beem/service/aidl/IMessageListener.aidl	Sun May 17 16:42:29 2009 +0200
@@ -6,4 +6,9 @@
 interface IMessageListener {
 
 	void processMessage(in IChat chat, in Message msg);
+	
+	/**
+	* le chatState se trouve dans le IChat
+	*/
+	void stateChanged(in IChat chat);
 }
--- a/src/com/beem/project/beem/ui/SendIM.java	Sun May 17 16:11:01 2009 +0200
+++ b/src/com/beem/project/beem/ui/SendIM.java	Sun May 17 16:42:29 2009 +0200
@@ -107,7 +107,7 @@
 
     }
 
-   
+
     @Override
     protected void onResume() {
 	super.onResume();
@@ -116,7 +116,7 @@
 	    mBeemApplication.startBeemService();
 	mBeemApplication.callWhenConnectedToServer(mHandler, new Runnable() {
 
-    @Override
+	    @Override
 	    public void run() {
 		mService = mBeemApplication.getXmppFacade();
 		try {
@@ -131,7 +131,7 @@
 		    }
 		    mChat.setOpen(true);
 		} catch (RemoteException e) {
-		   Log.e(TAG, "Error during chat manager creation", e);
+		    Log.e(TAG, "Error during chat manager creation", e);
 		}
 	    }
 	});
@@ -280,5 +280,11 @@
 		}
 	    });
 	}
+
+	@Override
+	public void stateChanged(IChat chat) throws RemoteException {
+	    //TODO: a integrer dans l'ui
+	    //Log.d(TAG, "state changed");
+	}
     }
 }