diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-06-24 15:07:59 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-06-24 15:07:59 +0200 |
commit | 6ef9421d3525e35e18b052d3eab31560d49d31b8 (patch) | |
tree | 2d1198394756095bb8fb011a9785e5e7bcedc7d2 /src/eu/siacs/conversations/entities | |
parent | 2a8f9642d562179b20938908e28a93f2d0480a4b (diff) |
fixes for offline otr
Diffstat (limited to 'src/eu/siacs/conversations/entities')
-rw-r--r-- | src/eu/siacs/conversations/entities/Conversation.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/eu/siacs/conversations/entities/Conversation.java b/src/eu/siacs/conversations/entities/Conversation.java index 640d89e9..3379e11d 100644 --- a/src/eu/siacs/conversations/entities/Conversation.java +++ b/src/eu/siacs/conversations/entities/Conversation.java @@ -64,6 +64,8 @@ public class Conversation extends AbstractEntity { private byte[] symmetricKey; + private boolean otrSessionNeedsStarting = false; + public Conversation(String name, Account account, String contactJid, int mode) { this(java.util.UUID.randomUUID().toString(), name, null, account @@ -237,7 +239,10 @@ public class Conversation extends AbstractEntity { try { if (sendStart) { this.otrSession.startSession(); + this.otrSessionNeedsStarting = false; return this.otrSession; + } else { + this.otrSessionNeedsStarting = true; } return this.otrSession; } catch (OtrException e) { @@ -252,9 +257,20 @@ public class Conversation extends AbstractEntity { } public void resetOtrSession() { + this.otrSessionNeedsStarting = false; this.otrSession = null; } + public void startOtrIfNeeded() { + if (this.otrSession != null && this.otrSessionNeedsStarting) { + try { + this.otrSession.startSession(); + } catch (OtrException e) { + this.resetOtrSession(); + } + } + } + public void endOtrIfNeeded() { if (this.otrSession != null) { if (this.otrSession.getSessionStatus() == SessionStatus.ENCRYPTED) { |