--- a/src/com/beem/project/beem/otr/BeemOtrManager.java Wed Dec 08 21:43:17 2010 +0100
+++ b/src/com/beem/project/beem/otr/BeemOtrManager.java Sun Dec 12 22:24:43 2010 +0100
@@ -20,17 +20,16 @@
public class BeemOtrManager implements OtrEngineHost {
private static final String TAG = "BeemOtrEngineHostImpl";
- private static final BeemOtrManager INSTANCE = new BeemOtrManager();
+ private static BeemOtrManager INSTANCE;
- private OtrEngine mOtrEngine = new OtrEngineImpl(INSTANCE);;
+ private OtrEngine mOtrEngine;
//Map of chat, needed because of the message injection
private final Map<SessionID, ChatAdapter> mChats = new HashMap<SessionID, ChatAdapter>();
//We will have a global policy for Beem as long as we won't need to modify the policy per chat.
- private final OtrPolicy mGlobalPolicy = new OtrPolicyImpl(OtrPolicy.ALLOW_V2 | OtrPolicy.ERROR_START_AKE);
+ private static final OtrPolicy mGlobalPolicy = new OtrPolicyImpl(OtrPolicy.ALLOW_V2 | OtrPolicy.ERROR_START_AKE);
- private final OtrEngineListener mOtrListener = new BeemOtrListener();
private Map<SessionID, KeyPair> mKeys = new HashMap<SessionID, KeyPair>();
@@ -39,11 +38,14 @@
}
// Private constructor prevents instantiation from other classes
- private BeemOtrManager() {
- mOtrEngine.addOtrEngineListener(mOtrListener);
+ private BeemOtrManager() {
+ mOtrEngine = new OtrEngineImpl(this);;
+ mOtrEngine.addOtrEngineListener( new BeemOtrListener());
}
public static BeemOtrManager getInstance() {
+ if (INSTANCE == null)
+ INSTANCE = new BeemOtrManager();
return INSTANCE;
}
@@ -106,7 +108,7 @@
@Override
public void sessionStatusChanged(final SessionID sessionID) {
Log.d(TAG, "OTR Status changed for " + sessionID + " : " + mOtrEngine.getSessionStatus(sessionID));
-
+ mChats.get(sessionID).otrStateChanged(mOtrEngine.getSessionStatus(sessionID).toString());
}
}
}
--- a/src/com/beem/project/beem/service/ChatAdapter.java Wed Dec 08 21:43:17 2010 +0100
+++ b/src/com/beem/project/beem/service/ChatAdapter.java Sun Dec 12 22:24:43 2010 +0100
@@ -280,11 +280,13 @@
mRemoteListeners.finishBroadcast();
}
- /**
+
+ }
+ /**
* This method is executed when the otr session status change.
* @param otrState the new state of otr session.
*/
- void otrStateChanged(final String otrState) {
+public void otrStateChanged(final String otrState) {
final int n = mRemoteListeners.beginBroadcast();
for (int i = 0; i < n; i++) {
@@ -297,8 +299,6 @@
}
mRemoteListeners.finishBroadcast();
}
- }
-
@Override
public void startOtrSession() throws RemoteException {
if (mOtrSessionId != null)