IssueId #100
Probeleme resolu chez moi, par contre il va falloir faire une gestion
des anciennes conversations.
J'ouvre un ticket pour ca.
--- a/src/com/beem/project/beem/service/BeemChatManager.java Sat May 16 22:59:02 2009 +0200
+++ b/src/com/beem/project/beem/service/BeemChatManager.java Sun May 17 16:11:01 2009 +0200
@@ -108,7 +108,6 @@
public void destroyChat(IChat chat) throws RemoteException {
// TODO gerer les resources egalement
Log.d(TAG, "destroy chat jid "+ chat.getParticipant().getJID());
- ChatAdapter res = mChats.get(chat.getParticipant().getJID());
IChat c = mChats.remove(chat.getParticipant().getJID());
if (c == null)
Log.w(TAG, "CA devrait pas 1!!" + chat.getParticipant().getJID());
@@ -141,15 +140,11 @@
*/
@Override
public void chatCreated(Chat chat, boolean locally) {
- Log.d(TAG,"new chat");
IChat newchat = getChat(chat);
if (!locally) {
// chat.addMessageListener(mChatListener);
- Log.d(TAG, "new local chat");
notifyNewChat(newchat);
}
- else
- Log.d(TAG, "reuse local chat");
chat.addMessageListener(mChatListener);
final int n = mRemoteChatCreationListeners.beginBroadcast();
@@ -184,15 +179,16 @@
int id = chat.hashCode();
mService.sendNotification(id, notif);
} catch (RemoteException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ Log.e(TAG, "notification error", e);
}
}
@Override
public void processMessage(Chat chat, Message message) {
IChat newchat = getChat(chat);
+
try {
+
if (message.getBody() != null)
newchat.addToLastMessages(message.getBody());
final int n = mRemoteMessageListeners.beginBroadcast();
@@ -201,6 +197,9 @@
listener.processMessage(newchat, new com.beem.project.beem.service.Message(message));
}
mRemoteMessageListeners.finishBroadcast();
+ if (newchat.isOpen() == false) {
+ notifyNewChat(newchat);
+ }
} catch (RemoteException e) {
// The RemoteCallbackList will take care of removing the
// dead listeners.
--- a/src/com/beem/project/beem/service/aidl/IChat.aidl Sat May 16 22:59:02 2009 +0200
+++ b/src/com/beem/project/beem/service/aidl/IChat.aidl Sun May 17 16:11:01 2009 +0200
@@ -23,6 +23,10 @@
String getState();
+ void setOpen(in boolean isOpen);
+
+ boolean isOpen();
+
void setState(in String state);
String getLastMessages();
--- a/src/com/beem/project/beem/ui/SendIM.java Sat May 16 22:59:02 2009 +0200
+++ b/src/com/beem/project/beem/ui/SendIM.java Sun May 17 16:11:01 2009 +0200
@@ -93,7 +93,7 @@
mLogin.setTextColor(getResources().getColor(R.color.white));
String statmsg = mContact.getMsgState();
if (statmsg != null)
- status.setText(statmsg);
+ status.setText(statmsg);;
}
@Override
@@ -101,12 +101,13 @@
super.onStart();
// TODO cancel the notification if any
if (mContact == null)
- mContact = getIntent().getParcelableExtra("contact");
+ mContact = getIntent().getParcelableExtra("contact");
+ mService = mBeemApplication.getXmppFacade();
setViewHeader();
- mService = mBeemApplication.getXmppFacade();
}
+
@Override
protected void onResume() {
super.onResume();
@@ -115,7 +116,7 @@
mBeemApplication.startBeemService();
mBeemApplication.callWhenConnectedToServer(mHandler, new Runnable() {
- @Override
+ @Override
public void run() {
mService = mBeemApplication.getXmppFacade();
try {
@@ -126,11 +127,11 @@
if (!"".equals(text)) {
mText.append(mContact.getJID() + " " + getString(R.string.SendIMSays));
mText.append(text);
- mChat.clearLastMessages();
+ //mChat.clearLastMessages();
}
+ mChat.setOpen(true);
} catch (RemoteException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ Log.e(TAG, "Error during chat manager creation", e);
}
}
});
@@ -139,14 +140,10 @@
@Override
protected void onPause() {
Log.d(TAG, "onPause");
- if (mChatManager != null) {
- try {
- mChatManager.removeChatCreationListener(mChatManagerListener);
- mChatManager.destroyChat(mChat);
- } catch (RemoteException e) {
- Log.e(TAG, "error on pause");
- e.printStackTrace();
- }
+ try {
+ mChat.setOpen(false);
+ } catch (RemoteException e) {
+ Log.d(TAG, "mchat open false", e);
}
super.onPause();
}
@@ -155,14 +152,10 @@
protected void onStop() {
super.onStop();
Log.d(TAG, "onStop");
- if (mChatManager != null) {
- try {
- mChatManager.removeChatCreationListener(mChatManagerListener);
- mChatManager.destroyChat(mChat);
- } catch (RemoteException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ try {
+ mChat.setOpen(false);
+ } catch (RemoteException e) {
+ Log.d(TAG, "mchat open false", e);
}
mBeemApplication.unbindBeemService();
}
@@ -175,8 +168,7 @@
mChatManager.removeChatCreationListener(mChatManagerListener);
mChatManager.destroyChat(mChat);
} catch (RemoteException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ Log.e(TAG, "mchat manager and SendIM destroy", e);
}
}
}