aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-02-16 09:15:41 +0100
committerDaniel Gultsch <daniel@gultsch.de>2016-02-16 09:15:41 +0100
commit0ca4a33bfb76d63a3c2d4447643a5bd90ac5315f (patch)
treebcebfb79f37f966fb2bc867e6da3536e6b34f1b0 /src
parentc0b3a3ff0c32c8025174ebb92fbcf4a7fc67f497 (diff)
added some OTR logging
Diffstat (limited to 'src')
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Conversation.java11
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java8
2 files changed, 14 insertions, 5 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java
index a0600d130..c72ac09e3 100644
--- a/src/main/java/eu/siacs/conversations/entities/Conversation.java
+++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java
@@ -517,15 +517,18 @@ public class Conversation extends AbstractEntity implements Blockable {
return mSmp;
}
- public void startOtrIfNeeded() {
- if (this.otrSession != null
- && this.otrSession.getSessionStatus() != SessionStatus.ENCRYPTED) {
+ public boolean startOtrIfNeeded() {
+ if (this.otrSession != null && this.otrSession.getSessionStatus() != SessionStatus.ENCRYPTED) {
try {
this.otrSession.startSession();
+ return true;
} catch (OtrException e) {
this.resetOtrSession();
+ return false;
}
- }
+ } else {
+ return true;
+ }
}
public boolean endOtrIfNeeded() {
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index 10f6b5efd..a8fe7586f 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -288,7 +288,9 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
List<Conversation> conversations = getConversations();
for (Conversation conversation : conversations) {
if (conversation.getAccount() == account && conversation.getMode() == Conversation.MODE_SINGLE) {
- conversation.startOtrIfNeeded();
+ if (!conversation.startOtrIfNeeded()) {
+ Log.d(Config.LOGTAG,account.getJid().toBareJid()+": couldn't start OTR with "+conversation.getContact().getJid()+" when needed");
+ }
sendUnsentMessages(conversation);
}
}
@@ -900,8 +902,11 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
if (message.fixCounterpart()) {
conversation.startOtrSession(message.getCounterpart().getResourcepart(), true);
} else {
+ Log.d(Config.LOGTAG,account.getJid().toBareJid()+": could not fix counterpart for OTR message to contact "+message.getContact().getJid());
break;
}
+ } else {
+ Log.d(Config.LOGTAG,account.getJid().toBareJid()+" OTR session with "+message.getContact()+" is in wrong state: "+otrSession.getSessionStatus().toString());
}
break;
case Message.ENCRYPTION_AXOLOTL:
@@ -946,6 +951,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
break;
case Message.ENCRYPTION_OTR:
if (!conversation.hasValidOtrSession() && message.getCounterpart() != null) {
+ Log.d(Config.LOGTAG,account.getJid().toBareJid()+": create otr session without starting for "+message.getContact().getJid());
conversation.startOtrSession(message.getCounterpart().getResourcepart(), false);
}
break;