From ee1c9e611b011495f1587f5d07c464650b5749d5 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 21 Mar 2014 23:09:14 +0100 Subject: more otr fixes --- .../siacs/conversations/entities/Conversation.java | 30 ++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'src/eu/siacs/conversations/entities') diff --git a/src/eu/siacs/conversations/entities/Conversation.java b/src/eu/siacs/conversations/entities/Conversation.java index a13d4ea67..79757f1ec 100644 --- a/src/eu/siacs/conversations/entities/Conversation.java +++ b/src/eu/siacs/conversations/entities/Conversation.java @@ -218,22 +218,32 @@ public class Conversation extends AbstractEntity { this.mode = mode; } - public void startOtrSession(Context context, String presence) { - SessionID sessionId = new SessionID(this.getContactJid(), presence, - "xmpp"); - this.otrSession = new SessionImpl(sessionId, getAccount().getOtrEngine( - context)); - try { - this.otrSession.startSession(); - } catch (OtrException e) { - Log.d("xmppServic", "couldnt start otr"); + public SessionImpl startOtrSession(Context context, String presence, boolean sendStart) { + if (this.otrSession != null) { + return this.otrSession; + } else { + SessionID sessionId = new SessionID(this.getContactJid(), presence, + "xmpp"); + this.otrSession = new SessionImpl(sessionId, getAccount().getOtrEngine( + context)); + try { + if (sendStart) { + this.otrSession.startSession(); + return this.otrSession; + } + return this.otrSession; + } catch (OtrException e) { + Log.d("xmppServic", "couldnt start otr"); + return null; + } } + } public SessionImpl getOtrSession() { return this.otrSession; } - + public void resetOtrSession() { this.otrSession = null; } -- cgit v1.2.3