added some OTR logging

This commit is contained in:
Daniel Gultsch 2016-02-16 09:15:41 +01:00
parent c0b3a3ff0c
commit 0ca4a33bfb
2 changed files with 14 additions and 5 deletions

View File

@ -517,15 +517,18 @@ public class Conversation extends AbstractEntity implements Blockable {
return mSmp; return mSmp;
} }
public void startOtrIfNeeded() { public boolean startOtrIfNeeded() {
if (this.otrSession != null if (this.otrSession != null && this.otrSession.getSessionStatus() != SessionStatus.ENCRYPTED) {
&& this.otrSession.getSessionStatus() != SessionStatus.ENCRYPTED) {
try { try {
this.otrSession.startSession(); this.otrSession.startSession();
return true;
} catch (OtrException e) { } catch (OtrException e) {
this.resetOtrSession(); this.resetOtrSession();
return false;
} }
} } else {
return true;
}
} }
public boolean endOtrIfNeeded() { public boolean endOtrIfNeeded() {

View File

@ -288,7 +288,9 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
List<Conversation> conversations = getConversations(); List<Conversation> conversations = getConversations();
for (Conversation conversation : conversations) { for (Conversation conversation : conversations) {
if (conversation.getAccount() == account && conversation.getMode() == Conversation.MODE_SINGLE) { 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); sendUnsentMessages(conversation);
} }
} }
@ -900,8 +902,11 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
if (message.fixCounterpart()) { if (message.fixCounterpart()) {
conversation.startOtrSession(message.getCounterpart().getResourcepart(), true); conversation.startOtrSession(message.getCounterpart().getResourcepart(), true);
} else { } else {
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": could not fix counterpart for OTR message to contact "+message.getContact().getJid());
break; break;
} }
} else {
Log.d(Config.LOGTAG,account.getJid().toBareJid()+" OTR session with "+message.getContact()+" is in wrong state: "+otrSession.getSessionStatus().toString());
} }
break; break;
case Message.ENCRYPTION_AXOLOTL: case Message.ENCRYPTION_AXOLOTL:
@ -946,6 +951,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
break; break;
case Message.ENCRYPTION_OTR: case Message.ENCRYPTION_OTR:
if (!conversation.hasValidOtrSession() && message.getCounterpart() != null) { 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); conversation.startOtrSession(message.getCounterpart().getResourcepart(), false);
} }
break; break;