From ccfccfb2cffece9273c0fef35d11d4a7462febd2 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Fri, 30 Aug 2013 21:18:46 +0200 Subject: [PATCH] Handle case where buddy starts OTR better. --- converse.js | 55 ++++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/converse.js b/converse.js index e6ba9b9a9..85bad5844 100644 --- a/converse.js +++ b/converse.js @@ -305,14 +305,13 @@ return myKey; }, - initiateOTR: function (myKey) { - var options = { + initiateOTR: function () { + this.otr = new otr.OTR({ fragment_size: 140, send_interval: 200, - priv: myKey, - debug: true - }; - this.otr = new otr.OTR(options); + priv: this.getPrivateKey(), + debug: this.debug + }); this.otr.on('ui', $.proxy(function (msg) { this.trigger('showReceivedOTRMessage', msg); }, this)); @@ -378,10 +377,8 @@ if (match) { // They want to initiate OTR if (!this.otr) { - // FIXME: this isn't yet correct... - this.initiateOTR(); + this.trigger('buddyStartsOTR'); } - this.otr.receiveMsg(match[0]); } else { // Normal unencrypted message. this.createMessage(message); @@ -403,7 +400,7 @@ 'click .close-chatbox-button': 'closeChat', 'keypress textarea.chat-textarea': 'keyPressed', 'click .toggle-otr': 'toggleOTRMenu', - 'click .start-otr': 'startOTR', + 'click .start-otr': 'startOTRFromToolbar', 'click .end-otr': 'endOTR', 'click .auth-otr': 'authOTR' }, @@ -420,7 +417,7 @@ '
' + '