From 0ff9d6b35c20541073ea94adc0e4be0c1e25129a Mon Sep 17 00:00:00 2001 From: n8fr8 Date: Tue, 22 May 2018 23:48:11 -0400 Subject: [PATCH] switched to cobratbq's OTR implementation from here: https://github.com/cobratbq/otr4j/blob/master/MODIFICATIONS updated to new API structure --- app/build.gradle | 3 +- .../java/org/awesomeapp/messenger/ImApp.java | 8 +- .../crypto/otr/OtrAndroidKeyManagerImpl.java | 64 ++----- .../messenger/crypto/otr/OtrChatListener.java | 13 +- .../messenger/crypto/otr/OtrChatManager.java | 172 ++++++++---------- .../crypto/otr/OtrChatSessionAdapter.java | 5 +- .../messenger/crypto/otr/OtrDataHandler.java | 2 +- .../messenger/crypto/otr/OtrDebugLogger.java | 2 +- .../crypto/otr/OtrEngineHostImpl.java | 161 +++++----------- .../messenger/model/ChatSession.java | 52 +++--- .../messenger/model/DataHandler.java | 2 +- .../messenger/model/MessageListener.java | 2 +- .../messenger/plugin/xmpp/XmppConnection.java | 2 +- .../messenger/service/RemoteImService.java | 19 +- .../service/adapters/ChatSessionAdapter.java | 26 +-- .../messenger/tasks/ChatSessionInitTask.java | 25 --- .../messenger/ui/AccountFragment.java | 2 - .../ui/ConversationDetailActivity.java | 38 +--- .../messenger/ui/ConversationView.java | 12 +- 19 files changed, 200 insertions(+), 410 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 3caaa90ba..2c74f7bf8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -133,7 +133,8 @@ dependencies { implementation fileTree(include: '*.jar', dir: 'libs') //implementation project(':otr4jandroid') - implementation 'com.github.otr4j:otr4j:0.22' + // implementation 'com.github.otr4j:otr4j:0.22' + implementation 'com.github.cobratbq:otr4j:1ed70336c6' // implementation 'com.github.otr4j:otr4j:aac20b11de' implementation project(':tibetanTextLibrary') diff --git a/app/src/main/java/org/awesomeapp/messenger/ImApp.java b/app/src/main/java/org/awesomeapp/messenger/ImApp.java index 7e4f167a0..bdea3aecd 100644 --- a/app/src/main/java/org/awesomeapp/messenger/ImApp.java +++ b/app/src/main/java/org/awesomeapp/messenger/ImApp.java @@ -260,11 +260,11 @@ public void onCreate() { mCacheWord.connectToService(); if (sThreadPoolExecutor == null) { - int corePoolSize = 20; - int maximumPoolSize = 120; - int keepAliveTime = 30; + int corePoolSize = 10; + int maximumPoolSize = 20; + int keepAliveTime = 5; BlockingQueue workQueue = new LinkedBlockingQueue(maximumPoolSize); - sThreadPoolExecutor = new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, TimeUnit.SECONDS, workQueue); + sThreadPoolExecutor = new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, TimeUnit.MINUTES, workQueue); } IntentFilter intentFilter = new IntentFilter(); diff --git a/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrAndroidKeyManagerImpl.java b/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrAndroidKeyManagerImpl.java index 9e6155196..f8b4553c3 100644 --- a/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrAndroidKeyManagerImpl.java +++ b/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrAndroidKeyManagerImpl.java @@ -35,12 +35,9 @@ import java.util.Set; import java.util.Vector; -import net.java.otr4j.OtrKeyManager; -import net.java.otr4j.OtrKeyManagerListener; -import net.java.otr4j.OtrKeyManagerStore; -import net.java.otr4j.crypto.OtrCryptoEngineImpl; +import net.java.otr4j.crypto.OtrCryptoEngine; import net.java.otr4j.crypto.OtrCryptoException; -import net.java.otr4j.session.SessionID; +import net.java.otr4j.api.SessionID; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; @@ -57,11 +54,10 @@ import info.guardianproject.iocipher.*; -public class OtrAndroidKeyManagerImpl extends IOtrKeyManager.Stub implements OtrKeyManager { +public class OtrAndroidKeyManagerImpl extends IOtrKeyManager.Stub { private SimplePropertiesStore store; - private OtrCryptoEngineImpl cryptoEngine; private final static String KEY_ALG = "DSA"; private final static int KEY_SIZE = 1024; @@ -100,7 +96,7 @@ private OtrAndroidKeyManagerImpl(File filepath) throws IOException { store = new SimplePropertiesStore(filepath); - cryptoEngine = new OtrCryptoEngineImpl(); + } @@ -167,7 +163,7 @@ private void upgradeStore() { } */ - static class SimplePropertiesStore implements OtrKeyManagerStore { + static class SimplePropertiesStore { private Properties mProperties = new Properties(); private File mStoreFile; @@ -374,20 +370,6 @@ public Set getKeySet () } } - private List listeners = new Vector(); - - public void addListener(OtrKeyManagerListener l) { - synchronized (listeners) { - if (!listeners.contains(l)) - listeners.add(l); - } - } - - public void removeListener(OtrKeyManagerListener l) { - synchronized (listeners) { - listeners.remove(l); - } - } public void generateLocalKeyPair(SessionID sessionID) { if (sessionID == null) @@ -407,7 +389,7 @@ public void regenerateLocalPublicKey(KeyFactory factory, String fullUserId, DSAP PublicKey pubKey; try { pubKey = factory.generatePublic(keySpec); - storeLocalPublicKey(userId, pubKey); + storePublicKey(userId, pubKey); } catch (Exception e) { throw new RuntimeException(e); @@ -447,8 +429,7 @@ public void storeKeyPair (String userId, KeyPair keyPair) { // Store Public Key. PublicKey pubKey = keyPair.getPublic(); - storeLocalPublicKey(userId, pubKey); //this will do saving - + storePublicKey(userId, pubKey); //this will do saving } catch (Exception e) { @@ -497,11 +478,11 @@ public void generateLocalKeyPair(String fullUserId) { }*/ } - public void storeLocalPublicKey(String fullUserId, PublicKey pubKey) throws OtrCryptoException { + public void storePublicKey(String fullUserId, PublicKey pubKey) throws OtrCryptoException { String userId = Address.stripResource(fullUserId); - String fingerprintString = cryptoEngine.getFingerprint(pubKey); + String fingerprintString = OtrCryptoEngine.getFingerprint(pubKey); String fingerprintKey = userId + ".fingerprint"; //check if we already have this @@ -561,7 +542,6 @@ public String getLocalFingerprint(SessionID sessionID) { return getLocalFingerprint(sessionID.getAccountID()); } - @Override public byte[] getLocalFingerprintRaw(SessionID sessionID) { String userId = Address.stripResource(sessionID.getAccountID()); @@ -571,7 +551,7 @@ public byte[] getLocalFingerprintRaw(SessionID sessionID) { return null; try { - return cryptoEngine.getFingerprintRaw(keyPair.getPublic()); + return OtrCryptoEngine.getFingerprintRaw(keyPair.getPublic()); } catch (Exception e) { @@ -594,15 +574,12 @@ public String getLocalFingerprint(String fullUserId) { public String getFingerprint (PublicKey pubKey) { - try { - String fingerprint = cryptoEngine.getFingerprint(pubKey); + + String fingerprint = OtrCryptoEngine.getFingerprint(pubKey); // OtrDebugLogger.log("got fingerprint for: " + userId + "=" + fingerprint); return fingerprint; - } catch (OtrCryptoException e) { - e.printStackTrace(); - return null; - } + } public String getRemoteFingerprint(SessionID sessionID) { @@ -651,11 +628,11 @@ public String getRemoteFingerprint(String fullUserId) { try { // Store the fingerprint, for posterity. - String fingerprintString = new OtrCryptoEngineImpl().getFingerprint(remotePublicKey); + String fingerprintString = OtrCryptoEngine.getFingerprint(remotePublicKey); this.store.setProperty(fullUserId + ".fingerprint", fingerprintString); return fingerprintString; - } catch (OtrCryptoException e) { + } catch (Exception e) { throw new RuntimeException("OtrCryptoException getting remote fingerprint",e); } @@ -763,7 +740,7 @@ public KeyPair loadLocalKeyPair(SessionID sessionID) { if (sessionID == null) return null; - return loadLocalKeyPair(sessionID.getUserID()); + return loadLocalKeyPair(sessionID.getAccountID()); } private KeyPair loadLocalKeyPair(String fullUserId) { @@ -835,8 +812,6 @@ private PublicKey loadRemotePublicKeyFromStore(String fullUserId) { } public void savePublicKey(SessionID sessionID, PublicKey pubKey) { - if (sessionID == null) - return; X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(pubKey.getEncoded()); @@ -849,7 +824,7 @@ public void savePublicKey(SessionID sessionID, PublicKey pubKey) { // Stash the associated fingerprint. This saves calculating it in the future // and is useful for transferring rosters to other apps. try { - String fingerprintString = new OtrCryptoEngineImpl().getFingerprint(pubKey); + String fingerprintString = OtrCryptoEngine.getFingerprint(pubKey); String verifiedToken = buildPublicKeyVerifiedId(sessionID.getUserID(), fingerprintString); String fingerprintKey = fullUserId + ".fingerprint"; @@ -866,7 +841,7 @@ public void savePublicKey(SessionID sessionID, PublicKey pubKey) { } - } catch (OtrCryptoException e) { + } catch (Exception e) { Log.e(ImApp.LOG_TAG,"otr error: " + e.getMessage(),e); } } @@ -880,9 +855,6 @@ public void unverify(SessionID sessionID) { unverifyUser(sessionID.getUserID()); - for (OtrKeyManagerListener l : listeners) - l.verificationStatusChanged(sessionID); - } public void unverifyUser(String fullUserId) { diff --git a/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrChatListener.java b/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrChatListener.java index 7fb225190..9de269790 100644 --- a/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrChatListener.java +++ b/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrChatListener.java @@ -1,6 +1,11 @@ package org.awesomeapp.messenger.crypto.otr; import android.text.TextUtils; +import android.util.Log; + +import net.java.otr4j.api.SessionID; +import net.java.otr4j.api.SessionStatus; +import net.java.otr4j.api.TLV; import org.awesomeapp.messenger.model.ChatSession; import org.awesomeapp.messenger.model.ImErrorInfo; @@ -11,10 +16,6 @@ import java.util.ArrayList; import java.util.List; -import net.java.otr4j.OtrException; -import net.java.otr4j.session.SessionID; -import net.java.otr4j.session.SessionStatus; -import net.java.otr4j.session.TLV; public class OtrChatListener implements MessageListener { @@ -98,9 +99,9 @@ public boolean onIncomingMessage(ChatSession session, Message msg, boolean notif } } - } catch (OtrException oe) { + } catch (Exception oe) { - OtrDebugLogger.log("error decrypting message: " + msg.getID()); + OtrDebugLogger.log("error decrypting message: " + msg.getID(),oe); // mOtrChatManager.refreshSession(sessionID.getLocalUserId(),sessionID.getRemoteUserId()); // msg.setBody("[" + "You received an unreadable encrypted message" + "]"); // mMessageListener.onIncomingMessage(session, msg); diff --git a/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrChatManager.java b/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrChatManager.java index 506c7f957..6cfce32e0 100644 --- a/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrChatManager.java +++ b/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrChatManager.java @@ -6,19 +6,20 @@ import android.support.annotation.NonNull; import android.text.TextUtils; -import net.java.otr4j.OtrEngineListener; -import net.java.otr4j.OtrException; -import net.java.otr4j.OtrKeyManager; -import net.java.otr4j.OtrPolicy; -import net.java.otr4j.OtrPolicyImpl; -import net.java.otr4j.session.Session; -import net.java.otr4j.session.SessionID; -import net.java.otr4j.session.SessionImpl; -import net.java.otr4j.session.SessionStatus; -import net.java.otr4j.session.TLV; +import net.java.otr4j.api.InstanceTag; +import net.java.otr4j.api.OtrEngineHost; +import net.java.otr4j.api.OtrEngineListener; +import net.java.otr4j.api.OtrException; +import net.java.otr4j.api.OtrPolicy; +import net.java.otr4j.api.Session; +import net.java.otr4j.api.SessionID; +import net.java.otr4j.api.SessionStatus; +import net.java.otr4j.api.TLV; +import net.java.otr4j.session.OtrSessionManager; import org.awesomeapp.messenger.ImApp; import org.awesomeapp.messenger.model.Message; +import org.awesomeapp.messenger.plugin.xmpp.XmppAddress; import org.awesomeapp.messenger.service.RemoteImService; import java.security.KeyPair; @@ -27,6 +28,8 @@ import java.util.Hashtable; import java.util.List; +import javax.annotation.Nonnull; + /* * OtrChatManager keeps track of the status of chats and their OTR stuff */ @@ -35,8 +38,9 @@ public class OtrChatManager implements OtrEngineListener { //the singleton instance private static OtrChatManager mInstance; - private OtrEngineHostImpl mOtrEngineHost; + private OtrEngineHost mOtrEngineHost; private Hashtable mSessions; + private OtrAndroidKeyManagerImpl mKeyManager; private Context mContext; private ImApp mApp; @@ -46,8 +50,12 @@ public class OtrChatManager implements OtrEngineListener { private OtrChatManager(int otrPolicy, RemoteImService imService, OtrAndroidKeyManagerImpl otrKeyManager) throws Exception { mContext = imService; + mKeyManager = otrKeyManager; + + OtrPolicy policy = new OtrPolicy(OtrPolicy.ALLOW_V2 | OtrPolicy.ALLOW_V3 + | OtrPolicy.ERROR_START_AKE | OtrPolicy.OTRL_POLICY_MANUAL); - mOtrEngineHost = new OtrEngineHostImpl(new OtrPolicyImpl(otrPolicy), + mOtrEngineHost = new OtrEngineHostImpl(policy, mContext, otrKeyManager, imService); mSessions = new Hashtable<>(); @@ -75,11 +83,15 @@ public static OtrChatManager getInstance() public void setPolicy(int otrPolicy) { - mOtrEngineHost.setSessionPolicy(new OtrPolicyImpl(otrPolicy)); + //mOtrEngineHost.setSessionPolicy(new OtrPolicy(otrPolicy|OtrPolicy.ALLOW_V2 | OtrPolicy.ALLOW_V3 + // | OtrPolicy.ERROR_START_AKE)); + + + } - public OtrKeyManager getKeyManager() { - return mOtrEngineHost.getKeyManager(); + public OtrAndroidKeyManagerImpl getKeyManager() { + return mKeyManager; } public static String processResource(String userId) { @@ -92,14 +104,9 @@ public static String processResource(String userId) { private final static String SESSION_TYPE_XMPP = "XMPP"; - public SessionID getSessionId(String localUserId, String remoteUserId) { - - //if (!remoteUserId.contains("/")) - // Log.w(ImApp.LOG_TAG,"resource is not set: " + remoteUserId); + public synchronized SessionID getSessionId(String localUserId, String remoteUserId) { - // boolean stripResource = !remoteUserId.startsWith("group"); - //SessionID sIdTemp = new SessionID(localUserId, XmppAddress.stripResource(remoteUserId), SESSION_TYPE_XMPP); - SessionID sessionId = new SessionID(localUserId, remoteUserId, SESSION_TYPE_XMPP); + SessionID sessionId = new SessionID( XmppAddress.stripResource(localUserId), XmppAddress.stripResource(remoteUserId), SESSION_TYPE_XMPP); Session session = mSessions.get(sessionId.toString()); @@ -184,19 +191,23 @@ private SessionID startSession(String localUserId, String remoteUserId) throws E * * @param sessionId the {@link SessionID} of the OTR session */ - public SessionID startSession(SessionID sessionId) { + public synchronized SessionID startSession(SessionID sessionId) { try { Session session = getSession(sessionId); + if (session == null) { - session = new SessionImpl(sessionId,mOtrEngineHost); + session = OtrSessionManager.createSession(sessionId,mOtrEngineHost); + // session.setOutgoingSession(InstanceTag.ZERO_TAG); session.addOtrEngineListener(this); mSessions.put(sessionId.toString(),session); } - session.startSession(); + if (session.getSessionStatus() != SessionStatus.ENCRYPTED) { + session.startSession(); + } return sessionId; @@ -227,12 +238,6 @@ public void endSession(SessionID sessionId) { } } - public void endSession(String localUserId, String remoteUserId) { - - SessionID sessionId = getSessionId(localUserId, remoteUserId); - endSession(sessionId); - - } public void status(String localUserId, String remoteUserId) { getSessionStatus(getSessionId(localUserId,remoteUserId)); @@ -243,29 +248,19 @@ public String decryptMessage(String localUserId, String remoteUserId, String msg String plain = null; Session session = getSession(getSessionId(localUserId, remoteUserId)); + if (session == null) { + SessionID sid = getSessionId(localUserId, remoteUserId); + startSession(sid); + session = getSession(sid); + } - if (session != null) { - - mOtrEngineHost.putSessionResource(session.getSessionID(), processResource(remoteUserId)); - - //plain = mOtrEngine.transformReceiving(sessionId, msg, tlvs); - - plain = session.transformReceiving(msg); - /** - OtrSm otrSm = mOtrSms.get(sessionId.toString()); +// mOtrEngineHost.putSessionResource(session.getSessionID(), processResource(remoteUserId)); - if (otrSm != null) { - List smTlvs = otrSm.getPendingTlvs(); - if (smTlvs != null) { - String encrypted = mOtrEngine.transformSending(sessionId, "", smTlvs); - mOtrEngineHost.injectMessage(sessionId, encrypted); - } - }**/ + plain = session.transformReceiving(msg); - //not null, but empty so make it null! - if (TextUtils.isEmpty(plain)) - return null; - } + //not null, but empty so make it null! + if (TextUtils.isEmpty(plain)) + return null; return plain; } @@ -274,10 +269,17 @@ public String decryptMessage(String localUserId, String remoteUserId, String msg public boolean transformSending(Message message) { String localUserId = message.getFrom().getAddress(); String remoteUserId = message.getTo().getAddress(); - String plainText = message.getBody(); Session session = getSession(getSessionId(localUserId, remoteUserId)); - + try { + String[] cipherText = session.transformSending(message.getBody()); + message.setBody(cipherText[0]); + return true; + } catch (OtrException e) { + OtrDebugLogger.log("error transforming otr message",e); + return false; + } + /** String body = null; if (session != null) { @@ -320,33 +322,36 @@ public boolean transformSending(Message message) { OtrDebugLogger.log("error encrypting", e); return false; } - } + }**/ - message.setBody(body); - - return true; } @Override - public void sessionStatusChanged(final SessionID sessionID) { - SessionStatus sStatus = getSessionStatus(sessionID); + public void sessionStatusChanged(@Nonnull SessionID sessionID, @Nonnull InstanceTag instanceTag) { - OtrDebugLogger.log("session status changed: " + sStatus); final Session session = mSessions.get(sessionID.toString()); + SessionStatus sStatus = session.getSessionStatus(); + OtrDebugLogger.log("session status changed: " + sStatus); if (session != null) { + //session.setOutgoingSession(instanceTag); if (sStatus == SessionStatus.ENCRYPTED) { - PublicKey remoteKey = session.getRemotePublicKey(); - mOtrEngineHost.storeRemoteKey(sessionID, remoteKey); + + try { + mKeyManager.storePublicKey(sessionID.getUserID(),session.getRemotePublicKey()); + + } catch (OtrException e) { + e.printStackTrace(); + } } else if (sStatus == SessionStatus.PLAINTEXT) { - mOtrEngineHost.removeSessionResource(sessionID); + // mOtrEngineHost.removeSessionResource(sessionID); } else if (sStatus == SessionStatus.FINISHED) { @@ -370,53 +375,26 @@ public void outgoingSessionChanged(SessionID sessionID) { public boolean isRemoteKeyVerified (String userId, String fingerprint) { - return mOtrEngineHost.isRemoteKeyVerified(userId, fingerprint); + //return mOtrEngineHost.isRemoteKeyVerified(userId, fingerprint); + return mKeyManager.isVerified(userId, fingerprint); } public String getRemoteKeyFingerprint (String userId) { - return mOtrEngineHost.getRemoteKeyFingerprint(userId); - } - - public ArrayList getRemoteKeyFingerprints (String userId) - { - return mOtrEngineHost.getRemoteKeyFingerprints(userId); + //return mOtrEngineHost.getRemoteKeyFingerprint(userId); + return mKeyManager.getRemoteFingerprint(userId); } public boolean hasRemoteKeyFingerprint (String userId) { - return mOtrEngineHost.hasRemoteKeyFingerprint(userId); - } - - public String getLocalKeyFingerprint(String localUserId) { - return mOtrEngineHost.getLocalKeyFingerprint(localUserId); - } - - public void injectMessage(SessionID sessionID, String msg) { - - mOtrEngineHost.injectMessage(sessionID, msg); - } - - public void showWarning(SessionID sessionID, String warning) { - - mOtrEngineHost.showWarning(sessionID, warning); - + //return mOtrEngineHost.hasRemoteKeyFingerprint(userId); + return mKeyManager.hasRemoteFingerprint(userId); } public void showError(SessionID sessionID, String error) { mOtrEngineHost.showError(sessionID, error); - - - } - - public OtrPolicy getSessionPolicy(SessionID sessionID) { - - return mOtrEngineHost.getSessionPolicy(sessionID); } - public KeyPair getKeyPair(SessionID sessionID) { - return mOtrEngineHost.getKeyPair(sessionID); - } /** public void askForSecret(SessionID sessionID, String question) { @@ -531,7 +509,7 @@ public boolean transformPushWhitelistTokenSending(@NonNull Message message, OtrDebugLogger.log("session status: " + session.getSessionStatus()); String msgs[] = session.transformSending(body, tlvs); - message.setTo(mOtrEngineHost.appendSessionResource(sessionId, message.getTo())); + // message.setTo(mOtrEngineHost.appendSessionResource(sessionId, message.getTo())); message.setBody(msgs[0]); } diff --git a/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrChatSessionAdapter.java b/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrChatSessionAdapter.java index db5bbdb79..1780f2d0b 100644 --- a/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrChatSessionAdapter.java +++ b/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrChatSessionAdapter.java @@ -3,9 +3,8 @@ import org.awesomeapp.messenger.crypto.IOtrChatSession.Stub; import org.awesomeapp.messenger.model.ImEntity; import org.awesomeapp.messenger.util.Debug; -import net.java.otr4j.OtrException; -import net.java.otr4j.session.SessionID; -import net.java.otr4j.session.SessionStatus; +import net.java.otr4j.api.SessionID; +import net.java.otr4j.api.SessionStatus; import android.os.RemoteException; public class OtrChatSessionAdapter extends Stub { diff --git a/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrDataHandler.java b/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrDataHandler.java index 6d80d00de..766756c5b 100644 --- a/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrDataHandler.java +++ b/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrDataHandler.java @@ -61,7 +61,7 @@ import java.util.Set; import java.util.UUID; -import net.java.otr4j.session.SessionStatus; +import net.java.otr4j.api.SessionStatus; import org.apache.commons.io.IOUtils; import org.apache.commons.io.output.NullOutputStream; diff --git a/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrDebugLogger.java b/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrDebugLogger.java index 9beebd589..d975c0ab7 100644 --- a/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrDebugLogger.java +++ b/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrDebugLogger.java @@ -8,7 +8,7 @@ public class OtrDebugLogger { public static void log(String msg) { - if (Debug.DEBUG_ENABLED)// && Log.isLoggable(ImApp.LOG_TAG, Log.DEBUG)) + //if (Debug.DEBUG_ENABLED)// && Log.isLoggable(ImApp.LOG_TAG, Log.DEBUG)) Log.d(ImApp.LOG_TAG, LogCleaner.clean(msg)); } diff --git a/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrEngineHostImpl.java b/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrEngineHostImpl.java index 73161740f..42f47408d 100644 --- a/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrEngineHostImpl.java +++ b/app/src/main/java/org/awesomeapp/messenger/crypto/otr/OtrEngineHostImpl.java @@ -15,16 +15,16 @@ import java.util.ArrayList; import java.util.Hashtable; -import net.java.otr4j.OtrEngineHost; -import net.java.otr4j.OtrException; -import net.java.otr4j.OtrKeyManager; -import net.java.otr4j.OtrPolicy; -import net.java.otr4j.session.FragmenterInstructions; -import net.java.otr4j.session.InstanceTag; -import net.java.otr4j.session.SessionID; +import net.java.otr4j.api.InstanceTag; +import net.java.otr4j.api.OtrEngineHost; +import net.java.otr4j.api.OtrException; +import net.java.otr4j.api.OtrPolicy; +import net.java.otr4j.api.SessionID; import android.content.Context; +import javax.annotation.Nonnull; + /* * OtrEngineHostImpl is the connects this app and the OtrEngine * http://code.google.com/p/otr4j/wiki/QuickStart @@ -37,39 +37,14 @@ public class OtrEngineHostImpl implements OtrEngineHost { private Context mContext; - private Hashtable mSessionResources; - private RemoteImService mImService; public OtrEngineHostImpl(OtrPolicy policy, Context context, OtrAndroidKeyManagerImpl otrKeyManager, RemoteImService imService) throws IOException { mPolicy = policy; mContext = context; - - mSessionResources = new Hashtable(); - mOtrKeyManager = otrKeyManager; - mImService = imService; - - } - - public void putSessionResource(SessionID session, String resource) { - mSessionResources.put(session, resource); - } - - public void removeSessionResource(SessionID session) { - mSessionResources.remove(session); - } - - public Address appendSessionResource(SessionID session, Address to) { - - String resource = mSessionResources.get(session); - if (resource != null) - return new XmppAddress(to.getBareAddress() + '/' + resource); - else - return to; - } public ImConnectionAdapter findConnection(SessionID session) { @@ -77,47 +52,6 @@ public ImConnectionAdapter findConnection(SessionID session) { return mImService.getConnection(Address.stripResource(session.getAccountID())); } - public OtrKeyManager getKeyManager() { - return mOtrKeyManager; - } - - public void storeRemoteKey(SessionID sessionID, PublicKey remoteKey) { - mOtrKeyManager.savePublicKey(sessionID, remoteKey); - } - - public boolean isRemoteKeyVerified(String userId, String fingerprint) { - return mOtrKeyManager.isVerified(userId, fingerprint); - } - - public boolean isRemoteKeyVerified(SessionID sessionID) { - return mOtrKeyManager.isVerified(sessionID); - } - - public String getLocalKeyFingerprint(SessionID sessionID) { - return mOtrKeyManager.getLocalFingerprint(sessionID); - } - - public String getLocalKeyFingerprint(String userId) { - return mOtrKeyManager.getLocalFingerprint(userId); - } - - public String getRemoteKeyFingerprint(SessionID sessionID) { - return mOtrKeyManager.getRemoteFingerprint(sessionID); - } - - public String getRemoteKeyFingerprint(String userId) { - return mOtrKeyManager.getRemoteFingerprint(userId); - } - - public ArrayList getRemoteKeyFingerprints(String userId) { - return mOtrKeyManager.getRemoteKeyFingerprints(userId); - } - - public boolean hasRemoteKeyFingerprint (String userid) - { - return mOtrKeyManager.hasRemoteFingerprint(userid); - } - public KeyPair getKeyPair(SessionID sessionID) { KeyPair kp = null; kp = mOtrKeyManager.loadLocalKeyPair(sessionID); @@ -134,12 +68,12 @@ public OtrPolicy getSessionPolicy(SessionID sessionID) { } @Override - public FragmenterInstructions getFragmenterInstructions(SessionID sessionID) { - return null; + public int getMaxFragmentSize(@Nonnull SessionID sessionID) { + return Integer.MAX_VALUE; } @Override - public KeyPair getLocalKeyPair(SessionID sessionID) throws OtrException { + public KeyPair getLocalKeyPair(SessionID sessionID) { return getKeyPair(sessionID); } @@ -153,10 +87,6 @@ public void askForSecret(SessionID sessionID, InstanceTag instanceTag, String s) } - @Override - public void verify(SessionID sessionID, String s, boolean b) { - - } @Override public void unverify(SessionID sessionID, String s) { @@ -175,11 +105,18 @@ public String getFallbackMessage(SessionID sessionID) { @Override public void messageFromAnotherInstanceReceived(SessionID sessionID) { + OtrDebugLogger.log(sessionID.toString() + ": messageFromAnotherInstanceReceived"); } @Override public void multipleInstancesDetected(SessionID sessionID) { + OtrDebugLogger.log(sessionID.toString() + ": multipleInstancesDetected"); + } + + @Override + public void extraSymmetricKeyDiscovered(@Nonnull SessionID sessionID, @Nonnull String s, @Nonnull byte[] bytes, @Nonnull byte[] bytes1) { + OtrDebugLogger.log(sessionID.toString() + ": extraSymmetricKeyDiscovered"); } @@ -188,7 +125,6 @@ public void setSessionPolicy(OtrPolicy policy) { } public void injectMessage(SessionID sessionID, String text) { - OtrDebugLogger.log(sessionID.toString() + ": injecting message: " + text); ImConnectionAdapter connection = findConnection(sessionID); if (connection != null) @@ -196,40 +132,32 @@ public void injectMessage(SessionID sessionID, String text) { ChatSessionManagerAdapter chatSessionManagerAdapter = (ChatSessionManagerAdapter) connection .getChatSessionManager(); ChatSessionAdapter chatSessionAdapter = (ChatSessionAdapter) chatSessionManagerAdapter - .getChatSession(sessionID.getAccountID()); + .getChatSession(sessionID.getUserID()); - if (chatSessionAdapter != null) - { - String body = text; + if (chatSessionAdapter == null) + chatSessionAdapter = (ChatSessionAdapter)chatSessionManagerAdapter.createChatSession(sessionID.getUserID(),true); - if (body == null) - body = ""; //don't allow null messages, only empty ones! + String body = text; - Message msg = new Message(body); - Address to = new XmppAddress(sessionID.getAccountID()); - msg.setTo(to); + if (body == null) + body = ""; //don't allow null messages, only empty ones! - if (!to.getAddress().contains("/")) { - //always send OTR messages to a resource - msg.setTo(appendSessionResource(sessionID, to)); - } + Message msg = new Message(body); + Address to = new XmppAddress(sessionID.getUserID()); + msg.setTo(to); - boolean verified = mOtrKeyManager.isVerified(sessionID); + /** + if (!to.getAddress().contains("/")) { + //always send OTR messages to a resource + msg.setTo(appendSessionResource(sessionID, to)); + }**/ - if (verified) { - msg.setType(Imps.MessageType.OUTGOING_ENCRYPTED_VERIFIED); - } else { - msg.setType(Imps.MessageType.OUTGOING_ENCRYPTED); - } + msg.setType(Imps.MessageType.OUTGOING_ENCRYPTED_VERIFIED); - // msg ID is set by plugin - chatSessionManagerAdapter.getChatSessionManager().sendMessageAsync(chatSessionAdapter.getAdaptee(), msg); + // msg ID is set by plugin + chatSessionManagerAdapter.getChatSessionManager().sendMessageAsync(chatSessionAdapter.getAdaptee(), msg); - } - else { - OtrDebugLogger.log(sessionID.toString() + ": could not find chatSession"); - } } else { @@ -241,13 +169,13 @@ public void injectMessage(SessionID sessionID, String text) { } @Override - public void unreadableMessageReceived(SessionID sessionID) throws OtrException { + public void unreadableMessageReceived(SessionID sessionID) { OtrDebugLogger.log(sessionID.toString() + ": unreadableMessageReceived"); } @Override - public void unencryptedMessageReceived(SessionID sessionID, String s) throws OtrException { + public void unencryptedMessageReceived(SessionID sessionID, String s) { OtrDebugLogger.log(sessionID.toString() + ": unencryptedMessageReceived=" + s); } @@ -259,30 +187,29 @@ public void showError(SessionID sessionID, String error) { } @Override - public void smpError(SessionID sessionID, int i, boolean b) throws OtrException { + public void smpError(SessionID sessionID, int i, boolean b) { } @Override - public void smpAborted(SessionID sessionID) throws OtrException { + public void smpAborted(SessionID sessionID) { } @Override - public void finishedSessionMessage(SessionID sessionID, String s) throws OtrException { - OtrDebugLogger.log(sessionID.toString() + ": finishedSessionMessage=" + s); + public void verify(@Nonnull SessionID sessionID, @Nonnull String s) { } @Override - public void requireEncryptedMessage(SessionID sessionID, String s) throws OtrException { - OtrDebugLogger.log(sessionID.toString() + ": requireEncryptedMessage=" + s); + public void finishedSessionMessage(SessionID sessionID, String s) { + OtrDebugLogger.log(sessionID.toString() + ": finishedSessionMessage=" + s); } - public void showWarning(SessionID sessionID, String warning) { - OtrDebugLogger.log(sessionID.toString() + ": WARNING=" + warning); - + @Override + public void requireEncryptedMessage(SessionID sessionID, String s) { + OtrDebugLogger.log(sessionID.toString() + ": requireEncryptedMessage=" + s); } diff --git a/app/src/main/java/org/awesomeapp/messenger/model/ChatSession.java b/app/src/main/java/org/awesomeapp/messenger/model/ChatSession.java index 502f179bb..8cfbc4c38 100644 --- a/app/src/main/java/org/awesomeapp/messenger/model/ChatSession.java +++ b/app/src/main/java/org/awesomeapp/messenger/model/ChatSession.java @@ -24,8 +24,8 @@ import org.jxmpp.jid.impl.JidCreate; import org.jxmpp.stringprep.XmppStringprepException; -import net.java.otr4j.session.SessionID; -import net.java.otr4j.session.SessionStatus; +import net.java.otr4j.api.SessionID; +import net.java.otr4j.api.SessionStatus; import android.support.annotation.NonNull; import android.text.TextUtils; @@ -168,8 +168,6 @@ public int sendMessageAsync(Message message) { SessionStatus otrStatus = cm.getSessionStatus(sId); boolean verified = cm.getKeyManager().isVerified(sId); - boolean isOffline = !((Contact) mParticipant).getPresence().isOnline(); - message.setTo(mXa); message.setType(Imps.MessageType.QUEUED); @@ -182,41 +180,35 @@ public int sendMessageAsync(Message message) { mManager.sendMessageAsync(this, message); } else { - //try to send ChatSecure Push message as a client - if (isOffline) { - - - } - else { - //do OTR! - - if (otrStatus == SessionStatus.ENCRYPTED) { + //do OTR! - if (verified) { - message.setType(Imps.MessageType.OUTGOING_ENCRYPTED_VERIFIED); - } else { - message.setType(Imps.MessageType.OUTGOING_ENCRYPTED); - } + if (otrStatus == SessionStatus.ENCRYPTED) { + if (verified) { + message.setType(Imps.MessageType.OUTGOING_ENCRYPTED_VERIFIED); } else { - - OtrChatManager.getInstance().startSession(sId); - message.setType(Imps.MessageType.QUEUED); - return message.getType(); + message.setType(Imps.MessageType.OUTGOING_ENCRYPTED); } - boolean canSend = cm.transformSending(message); + } else { - if (canSend) { - mManager.sendMessageAsync(this, message); - } else { - //can't be sent due to OTR state - message.setType(Imps.MessageType.QUEUED); - return message.getType(); + OtrChatManager.getInstance().startSession(sId); + message.setType(Imps.MessageType.QUEUED); + return message.getType(); + } + + boolean canSend = cm.transformSending(message); + + if (canSend) { + mManager.sendMessageAsync(this, message); + } else { + //can't be sent due to OTR state + message.setType(Imps.MessageType.QUEUED); + return message.getType(); - } } + } } diff --git a/app/src/main/java/org/awesomeapp/messenger/model/DataHandler.java b/app/src/main/java/org/awesomeapp/messenger/model/DataHandler.java index 7f2dbe8bc..27ad60d8a 100644 --- a/app/src/main/java/org/awesomeapp/messenger/model/DataHandler.java +++ b/app/src/main/java/org/awesomeapp/messenger/model/DataHandler.java @@ -1,6 +1,6 @@ package org.awesomeapp.messenger.model; -import net.java.otr4j.session.SessionStatus; +import net.java.otr4j.api.SessionStatus; import org.awesomeapp.messenger.service.IDataListener; diff --git a/app/src/main/java/org/awesomeapp/messenger/model/MessageListener.java b/app/src/main/java/org/awesomeapp/messenger/model/MessageListener.java index 1a39b2009..ecba4d836 100644 --- a/app/src/main/java/org/awesomeapp/messenger/model/MessageListener.java +++ b/app/src/main/java/org/awesomeapp/messenger/model/MessageListener.java @@ -17,7 +17,7 @@ package org.awesomeapp.messenger.model; -import net.java.otr4j.session.SessionStatus; +import net.java.otr4j.api.SessionStatus; import org.awesomeapp.messenger.crypto.otr.OtrDataHandler.Transfer; diff --git a/app/src/main/java/org/awesomeapp/messenger/plugin/xmpp/XmppConnection.java b/app/src/main/java/org/awesomeapp/messenger/plugin/xmpp/XmppConnection.java index 9b0237761..ac9da382f 100644 --- a/app/src/main/java/org/awesomeapp/messenger/plugin/xmpp/XmppConnection.java +++ b/app/src/main/java/org/awesomeapp/messenger/plugin/xmpp/XmppConnection.java @@ -1620,7 +1620,7 @@ public void onOmemoKeyTransportReceived(CipherAndAuthTag cipherAndAuthTag, org.j public void onOmemoMessageReceived(String body, org.jivesoftware.smack.packet.Message message, org.jivesoftware.smack.packet.Message message1, OmemoMessageInformation omemoMessageInformation) { if (body != null) { - debug(TAG, "got inbound message omemo: from:" + message.getFrom() + "=" + message.getBody()); + debug(TAG, "got inbound message omemo: from:" + message.getFrom() + "=" + message.getBody()); message.setBody(body); handleMessage(message, true, true); } else { diff --git a/app/src/main/java/org/awesomeapp/messenger/service/RemoteImService.java b/app/src/main/java/org/awesomeapp/messenger/service/RemoteImService.java index e08e87d5d..94a6273dc 100644 --- a/app/src/main/java/org/awesomeapp/messenger/service/RemoteImService.java +++ b/app/src/main/java/org/awesomeapp/messenger/service/RemoteImService.java @@ -19,7 +19,6 @@ import android.annotation.TargetApi; import android.app.Notification; -import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; @@ -48,13 +47,7 @@ import android.util.Log; import android.widget.Toast; -import com.jrummyapps.android.shell.CommandResult; -import com.jrummyapps.android.shell.Shell; - -import net.java.otr4j.OtrEngineListener; -import net.java.otr4j.OtrKeyManagerListener; -import net.java.otr4j.OtrPolicy; -import net.java.otr4j.session.SessionID; +import net.java.otr4j.api.OtrPolicy; import org.awesomeapp.messenger.ImApp; import org.awesomeapp.messenger.MainActivity; @@ -70,18 +63,14 @@ import org.awesomeapp.messenger.model.ImException; import org.awesomeapp.messenger.plugin.ImPluginInfo; import org.awesomeapp.messenger.provider.Imps; +import org.awesomeapp.messenger.service.NetworkConnectivityReceiver.State; import org.awesomeapp.messenger.service.adapters.ImConnectionAdapter; -import org.awesomeapp.messenger.tasks.ChatSessionInitTask; import org.awesomeapp.messenger.ui.legacy.DummyActivity; import org.awesomeapp.messenger.ui.legacy.ImPluginHelper; -import org.awesomeapp.messenger.service.NetworkConnectivityReceiver.State; -import org.awesomeapp.messenger.util.BinaryInstaller; import org.awesomeapp.messenger.util.Debug; import org.awesomeapp.messenger.util.LogCleaner; import org.awesomeapp.messenger.util.SecureMediaStore; -import java.io.File; -import java.io.IOException; import java.security.GeneralSecurityException; import java.util.ArrayList; import java.util.Date; @@ -89,9 +78,9 @@ import java.util.List; import java.util.Map; +import im.zom.messenger.R; import info.guardianproject.cacheword.CacheWordHandler; import info.guardianproject.cacheword.ICacheWordSubscriber; -import im.zom.messenger.R; public class RemoteImService extends Service implements ImService, ICacheWordSubscriber { @@ -212,6 +201,8 @@ private int convertPolicy() { otrPolicy = OtrPolicy.OTRL_POLICY_MANUAL; } + + return otrPolicy; } diff --git a/app/src/main/java/org/awesomeapp/messenger/service/adapters/ChatSessionAdapter.java b/app/src/main/java/org/awesomeapp/messenger/service/adapters/ChatSessionAdapter.java index 7adafc87e..55055ddef 100644 --- a/app/src/main/java/org/awesomeapp/messenger/service/adapters/ChatSessionAdapter.java +++ b/app/src/main/java/org/awesomeapp/messenger/service/adapters/ChatSessionAdapter.java @@ -62,9 +62,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import net.java.otr4j.OtrEngineListener; -import net.java.otr4j.session.SessionID; -import net.java.otr4j.session.SessionStatus; import org.awesomeapp.messenger.service.RemoteImService; import org.awesomeapp.messenger.service.StatusBarNotifier; @@ -90,6 +87,8 @@ import android.webkit.MimeTypeMap; import android.webkit.URLUtil; +import net.java.otr4j.api.SessionStatus; + import static cz.msebera.android.httpclient.conn.ssl.SSLConnectionSocketFactory.TAG; public class ChatSessionAdapter extends org.awesomeapp.messenger.service.IChatSession.Stub { @@ -170,7 +169,7 @@ public ChatSessionAdapter(ChatSession chatSession, ImConnectionAdapter connectio initMuted(); initUseEncryption(); - sendPostponedMessages(); + // sendPostponedMessages(); } private void initOtrChatSession (ImEntity participant) @@ -455,24 +454,6 @@ private void sendMediaMessage(String localUrl, String publishUrl, org.awesomeapp } - private void sendUnstoredMessage(String text) { - - if (mConnection.getState() != ImConnection.LOGGED_IN) { - return; - } - - org.awesomeapp.messenger.model.Message msg = new org.awesomeapp.messenger.model.Message(text); - msg.setID(nextID()); - - msg.setFrom(mConnection.getLoginUser().getAddress()); - msg.setType(Imps.MessageType.QUEUED); - - long sendTime = System.currentTimeMillis(); - - int newType = mChatSession.sendMessageAsync(msg); - - - } @Override public boolean offerData(String offerId, final String mediaPath, final String mimeType) { @@ -1418,6 +1399,7 @@ public void onReceiptsExpected(ChatSession ses, boolean isExpected) { } + @Override public void onStatusChanged(ChatSession session, SessionStatus status) { try { diff --git a/app/src/main/java/org/awesomeapp/messenger/tasks/ChatSessionInitTask.java b/app/src/main/java/org/awesomeapp/messenger/tasks/ChatSessionInitTask.java index e0947c799..f39cde6d0 100644 --- a/app/src/main/java/org/awesomeapp/messenger/tasks/ChatSessionInitTask.java +++ b/app/src/main/java/org/awesomeapp/messenger/tasks/ChatSessionInitTask.java @@ -2,14 +2,8 @@ import android.os.AsyncTask; -import net.java.otr4j.OtrPolicy; - import org.awesomeapp.messenger.ImApp; -import org.awesomeapp.messenger.Preferences; -import org.awesomeapp.messenger.crypto.IOtrChatSession; -import org.awesomeapp.messenger.model.ChatSession; import org.awesomeapp.messenger.model.Contact; -import org.awesomeapp.messenger.model.ImConnection; import org.awesomeapp.messenger.provider.Imps; import org.awesomeapp.messenger.service.IChatSession; import org.awesomeapp.messenger.service.IImConnection; @@ -80,25 +74,6 @@ protected void onPostExecute(Long chatId) { } - private int getOtrPolicy() { - - int otrPolicy = OtrPolicy.OPPORTUNISTIC; - - String otrModeSelect = Preferences.getOtrMode(); - - if (otrModeSelect.equals("auto")) { - otrPolicy = OtrPolicy.OPPORTUNISTIC; - } else if (otrModeSelect.equals("disabled")) { - otrPolicy = OtrPolicy.NEVER; - } else if (otrModeSelect.equals("force")) { - otrPolicy = OtrPolicy.OTRL_POLICY_ALWAYS; - - } else if (otrModeSelect.equals("requested")) { - otrPolicy = OtrPolicy.OTRL_POLICY_MANUAL; - } - - return otrPolicy; - } } diff --git a/app/src/main/java/org/awesomeapp/messenger/ui/AccountFragment.java b/app/src/main/java/org/awesomeapp/messenger/ui/AccountFragment.java index f205e7841..8025cfe1d 100644 --- a/app/src/main/java/org/awesomeapp/messenger/ui/AccountFragment.java +++ b/app/src/main/java/org/awesomeapp/messenger/ui/AccountFragment.java @@ -40,8 +40,6 @@ import com.theartofdev.edmodo.cropper.CropImageView; -import net.java.otr4j.OtrKeyManager; - import org.awesomeapp.messenger.ImApp; import org.awesomeapp.messenger.crypto.omemo.Omemo; import org.awesomeapp.messenger.crypto.otr.OtrAndroidKeyManagerImpl; diff --git a/app/src/main/java/org/awesomeapp/messenger/ui/ConversationDetailActivity.java b/app/src/main/java/org/awesomeapp/messenger/ui/ConversationDetailActivity.java index a7986f30d..299de6e0e 100644 --- a/app/src/main/java/org/awesomeapp/messenger/ui/ConversationDetailActivity.java +++ b/app/src/main/java/org/awesomeapp/messenger/ui/ConversationDetailActivity.java @@ -29,7 +29,6 @@ import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; -import android.content.res.Configuration; import android.graphics.Color; import android.graphics.Typeface; import android.media.MediaRecorder; @@ -41,65 +40,44 @@ import android.os.Message; import android.os.Parcelable; import android.os.RemoteException; -import android.os.StrictMode; import android.preference.PreferenceManager; import android.provider.MediaStore; -import android.support.design.widget.AppBarLayout; -import android.support.design.widget.CollapsingToolbarLayout; -import android.support.design.widget.CoordinatorLayout; import android.support.design.widget.Snackbar; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.support.v4.content.FileProvider; -import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.WindowManager; -import android.widget.ImageView; import android.widget.TextView; -import android.widget.Toast; -//import com.bumptech.glide.Glide; - -import net.java.otr4j.session.SessionStatus; - -import org.awesomeapp.messenger.model.Contact; +import org.awesomeapp.messenger.ImApp; import org.awesomeapp.messenger.model.Presence; -import org.awesomeapp.messenger.plugin.xmpp.XmppAddress; import org.awesomeapp.messenger.provider.Imps; +import org.awesomeapp.messenger.service.IChatSession; +import org.awesomeapp.messenger.ui.widgets.ShareRequest; +import org.awesomeapp.messenger.util.SecureMediaStore; +import org.awesomeapp.messenger.util.SystemServices; +import org.ironrabbit.type.CustomTypefaceManager; +import org.ocpsoft.prettytime.PrettyTime; import java.io.File; import java.io.IOException; import java.lang.reflect.Field; -import java.net.HttpURLConnection; import java.net.URL; -import java.net.URLConnection; -import java.net.URLDecoder; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Locale; import java.util.UUID; -import org.awesomeapp.messenger.service.IChatSession; - import im.zom.messenger.BuildConfig; import im.zom.messenger.R; -import org.awesomeapp.messenger.service.IChatSessionManager; -import org.awesomeapp.messenger.service.IContactListManager; -import org.awesomeapp.messenger.service.IImConnection; -import org.awesomeapp.messenger.ui.widgets.ShareRequest; -import org.awesomeapp.messenger.util.LogCleaner; -import org.awesomeapp.messenger.util.SecureMediaStore; - -import org.awesomeapp.messenger.ImApp; -import org.awesomeapp.messenger.util.SystemServices; -import org.ironrabbit.type.CustomTypefaceManager; -import org.ocpsoft.prettytime.PrettyTime; +//import com.bumptech.glide.Glide; public class ConversationDetailActivity extends BaseActivity { diff --git a/app/src/main/java/org/awesomeapp/messenger/ui/ConversationView.java b/app/src/main/java/org/awesomeapp/messenger/ui/ConversationView.java index 96c100884..514d1e61a 100644 --- a/app/src/main/java/org/awesomeapp/messenger/ui/ConversationView.java +++ b/app/src/main/java/org/awesomeapp/messenger/ui/ConversationView.java @@ -95,8 +95,8 @@ import android.widget.TextView; import android.widget.Toast; -import net.java.otr4j.OtrPolicy; -import net.java.otr4j.session.SessionStatus; +import net.java.otr4j.api.OtrPolicy; +import net.java.otr4j.api.SessionStatus; import org.awesomeapp.messenger.ImApp; import org.awesomeapp.messenger.MainActivity; @@ -327,7 +327,7 @@ public void setSelected (boolean isSelected) } if ((mLastSessionStatus == null || mLastSessionStatus == SessionStatus.PLAINTEXT)) { - + /** boolean otrPolicyAuto = getOtrPolicy() == OtrPolicy.OPPORTUNISTIC || getOtrPolicy() == OtrPolicy.OTRL_POLICY_ALWAYS; @@ -358,7 +358,7 @@ public void run() { } }, 100); } - } + }**/ } @@ -2433,10 +2433,6 @@ else if (mLastSessionStatus == SessionStatus.FINISHED) { } - public SessionStatus getOtrSessionStatus () - { - return mLastSessionStatus; - } public boolean isOtrSessionVerified () {