parent a2edd876
[submodule "app/otr4j"]
path = app/otr4j
url = https://github.com/otr4j/otr4j.git
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
repositories {
mavenCentral()
mavenLocal()
}
android { android {
compileSdkVersion 21 compileSdkVersion 21
buildToolsVersion "21.1.2" buildToolsVersion "21.1.2"
...@@ -12,6 +17,12 @@ android { ...@@ -12,6 +17,12 @@ android {
versionName '0.10.18' versionName '0.10.18'
} }
sourceSets {
main {
java.srcDirs = ['src/main/java', 'otr4j/src/main/java']
}
}
buildTypes { buildTypes {
release { release {
minifyEnabled false minifyEnabled false
...@@ -25,7 +36,7 @@ android { ...@@ -25,7 +36,7 @@ android {
} }
dependencies { dependencies {
compile files('libs/otr4j.jar')
compile 'com.android.support:appcompat-v7:21.0.3' compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v13:21.0.3' compile 'com.android.support:support-v13:21.0.3'
compile 'org.bouncycastle:bcprov-jdk15on:1.49'
} }
Subproject commit 1811af26058c45aa0b67accd29ee278c80b02f0a
...@@ -39,6 +39,7 @@ import com.xabber.android.data.message.MessageManager; ...@@ -39,6 +39,7 @@ import com.xabber.android.data.message.MessageManager;
import com.xabber.android.data.notification.EntityNotificationProvider; import com.xabber.android.data.notification.EntityNotificationProvider;
import com.xabber.android.data.notification.NotificationManager; import com.xabber.android.data.notification.NotificationManager;
import com.xabber.android.data.roster.RosterManager; import com.xabber.android.data.roster.RosterManager;
import com.xabber.androiddev.BuildConfig;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import com.xabber.xmpp.archive.OtrMode; import com.xabber.xmpp.archive.OtrMode;
import com.xabber.xmpp.archive.SaveMode; import com.xabber.xmpp.archive.SaveMode;
...@@ -51,9 +52,9 @@ import net.java.otr4j.OtrPolicyImpl; ...@@ -51,9 +52,9 @@ import net.java.otr4j.OtrPolicyImpl;
import net.java.otr4j.crypto.OtrCryptoEngineImpl; import net.java.otr4j.crypto.OtrCryptoEngineImpl;
import net.java.otr4j.crypto.OtrCryptoException; import net.java.otr4j.crypto.OtrCryptoException;
import net.java.otr4j.io.SerializationUtils; import net.java.otr4j.io.SerializationUtils;
import net.java.otr4j.session.InstanceTag;
import net.java.otr4j.session.Session; import net.java.otr4j.session.Session;
import net.java.otr4j.session.SessionID; import net.java.otr4j.session.SessionID;
import net.java.otr4j.session.SessionImpl;
import net.java.otr4j.session.SessionStatus; import net.java.otr4j.session.SessionStatus;
import java.security.KeyPair; import java.security.KeyPair;
...@@ -194,7 +195,7 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener, ...@@ -194,7 +195,7 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener,
return session; return session;
AccountItem accountItem = AccountManager.getInstance().getAccount( AccountItem accountItem = AccountManager.getInstance().getAccount(
account); account);
session = new SessionImpl(new SessionID(account, user, session = new Session(new SessionID(account, user,
accountItem == null ? "" : accountItem.getConnectionSettings() accountItem == null ? "" : accountItem.getConnectionSettings()
.getProtocol().toString()), this); .getProtocol().toString()), this);
session.addOtrEngineListener(this); session.addOtrEngineListener(this);
...@@ -283,7 +284,7 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener, ...@@ -283,7 +284,7 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener,
} }
@Override @Override
public String getReplyForUnreadableMessage() { public String getReplyForUnreadableMessage(SessionID sessionID) {
return Application.getInstance().getString( return Application.getInstance().getString(
R.string.otr_unreadable_message); R.string.otr_unreadable_message);
} }
...@@ -318,7 +319,7 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener, ...@@ -318,7 +319,7 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener,
} }
@Override @Override
public void finishedSessionMessage(SessionID sessionID) throws OtrException { public void finishedSessionMessage(SessionID sessionID, String msgText) throws OtrException {
newAction(sessionID.getAccountID(), sessionID.getUserID(), null, newAction(sessionID.getAccountID(), sessionID.getUserID(), null,
ChatAction.otr_finished_session); ChatAction.otr_finished_session);
throw new OtrException( throw new OtrException(
...@@ -413,7 +414,7 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener, ...@@ -413,7 +414,7 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener,
} }
@Override @Override
public void askForSecret(SessionID sessionID, String question) { public void askForSecret(SessionID sessionID, InstanceTag receiverTag, String question) {
smRequestProvider.add( smRequestProvider.add(
new SMRequest(sessionID.getAccountID(), sessionID.getUserID(), new SMRequest(sessionID.getAccountID(), sessionID.getUserID(),
question), true); question), true);
...@@ -430,8 +431,13 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener, ...@@ -430,8 +431,13 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener,
*/ */
public String transformSending(String account, String user, String content) public String transformSending(String account, String user, String content)
throws OtrException { throws OtrException {
return getOrCreateSession(account, user) String parts[] = getOrCreateSession(account, user)
.transformSending(content, null); .transformSending(content, null);
if (BuildConfig.DEBUG && parts.length != 1) {
throw new RuntimeException(
"We do not use fragmentation, so there must be only one otr fragment.");
}
return parts[0];
} }
/** /**
...@@ -516,7 +522,7 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener, ...@@ -516,7 +522,7 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener,
} }
@Override @Override
public void verify(SessionID sessionID, boolean approved) { public void verify(SessionID sessionID, String fingerprint, boolean approved) {
if (approved) if (approved)
setVerify(sessionID, true); setVerify(sessionID, true);
else if (isVerified(sessionID.getAccountID(), sessionID.getUserID())) else if (isVerified(sessionID.getAccountID(), sessionID.getUserID()))
...@@ -526,7 +532,7 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener, ...@@ -526,7 +532,7 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener,
} }
@Override @Override
public void unverify(SessionID sessionID) { public void unverify(SessionID sessionID, String fingerprint) {
setVerify(sessionID, false); setVerify(sessionID, false);
removeSMProgress(sessionID.getAccountID(), sessionID.getUserID()); removeSMProgress(sessionID.getAccountID(), sessionID.getUserID());
} }
...@@ -555,7 +561,7 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener, ...@@ -555,7 +561,7 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener,
} }
@Override @Override
public String getFallbackMessage() { public String getFallbackMessage(SessionID sessionID) {
return Application.getInstance().getString(R.string.otr_request); return Application.getInstance().getString(R.string.otr_request);
} }
...@@ -712,4 +718,30 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener, ...@@ -712,4 +718,30 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener,
endAllSessions(); endAllSessions();
} }
@Override
public int getMaxFragmentSize(SessionID sessionID) {
// we do not want fragmentation
return Integer.MAX_VALUE;
}
@Override
public void outgoingSessionChanged(SessionID sessionID) {
LogManager.i(this, "Outgoing session change with SessionID " + sessionID);
// TODO what to in this situation?
}
@Override
public void messageFromAnotherInstanceReceived(SessionID sessionID) {
LogManager.i(this, "Message from another instance received on SessionID "
+ sessionID + ". Restarting OTR session for this user.");
newAction(sessionID.getAccountID(), sessionID.getUserID(), null,
ChatAction.otr_unreadable);
}
@Override
public void multipleInstancesDetected(SessionID sessionID) {
LogManager.i(this, "Multiple instances detected on SessionID " + sessionID);
// since this is not supported, we don't need to do anything
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment