From f20cf4817a4de515ad26bb3f264435e8cf982c89 Mon Sep 17 00:00:00 2001 From: "Arlo Breault ext:(%2C%20Kai%20Engert%20%3Ckaie%40kuix.de%3E%2C%20Alessandro%20Castellani%20%3Calessandro%40thunderbird.net%3E)" Date: Fri, 17 May 2019 16:21:48 +0200 Subject: [PATCH] Bug 1518172 - Import ctypes-otr, updated by kaie/aleca. r=florian,clokep,mkmelin Original MPL v2 code by Arlo Breault from https://github.com/arlolra/ctypes-otr/ Ported to Thunderbird by Kai Engert, includes UI changes by Alessandro Castellani. --- chat/content/jar.mn | 16 + chat/content/otr-add-finger.dtd | 9 + chat/content/otr-add-finger.properties | 6 + chat/content/otr-add-fingerprint.js | 50 + chat/content/otr-add-fingerprint.xul | 27 + chat/content/otr-auth.dtd | 20 + chat/content/otr-auth.js | 175 +++ chat/content/otr-auth.properties | 15 + chat/content/otr-auth.xul | 71 ++ chat/content/otr-chat.dtd | 8 + chat/content/otr-generate-key.dtd | 6 + chat/content/otr-generate-key.js | 29 + chat/content/otr-generate-key.properties | 8 + chat/content/otr-generate-key.xul | 26 + chat/content/otr.properties | 72 ++ chat/content/otrUI.properties | 59 + chat/content/otrWorker.js | 54 + chat/locales/jar.mn | 8 + chat/modules/CLib.jsm | 74 ++ chat/modules/OTR.jsm | 1110 +++++++++++++++++ chat/modules/OTRHelpers.jsm | 38 + chat/modules/OTRLib.jsm | 918 ++++++++++++++ chat/modules/OTRUI.jsm | 711 +++++++++++ chat/modules/moz.build | 5 + .../themes/icons/otr-connection-encrypted.svg | 7 + chat/themes/icons/otr-connection-finished.svg | 7 + chat/themes/jar.mn | 3 + chat/themes/otr.css | 142 +++ mail/app/profile/all-thunderbird.js | 2 + .../im/content/chat-conversation-info.js | 111 +- .../im/content/chat-messenger.inc.xul | 115 +- mail/components/im/content/chat-messenger.js | 42 + mail/components/im/themes/chat.css | 6 +- 33 files changed, 3878 insertions(+), 72 deletions(-) create mode 100644 chat/content/otr-add-finger.dtd create mode 100644 chat/content/otr-add-finger.properties create mode 100644 chat/content/otr-add-fingerprint.js create mode 100644 chat/content/otr-add-fingerprint.xul create mode 100644 chat/content/otr-auth.dtd create mode 100644 chat/content/otr-auth.js create mode 100644 chat/content/otr-auth.properties create mode 100644 chat/content/otr-auth.xul create mode 100644 chat/content/otr-chat.dtd create mode 100644 chat/content/otr-generate-key.dtd create mode 100644 chat/content/otr-generate-key.js create mode 100644 chat/content/otr-generate-key.properties create mode 100644 chat/content/otr-generate-key.xul create mode 100644 chat/content/otr.properties create mode 100644 chat/content/otrUI.properties create mode 100644 chat/content/otrWorker.js create mode 100644 chat/modules/CLib.jsm create mode 100644 chat/modules/OTR.jsm create mode 100644 chat/modules/OTRHelpers.jsm create mode 100644 chat/modules/OTRLib.jsm create mode 100644 chat/modules/OTRUI.jsm create mode 100644 chat/themes/icons/otr-connection-encrypted.svg create mode 100644 chat/themes/icons/otr-connection-finished.svg create mode 100644 chat/themes/otr.css diff --git a/chat/content/jar.mn b/chat/content/jar.mn index 3a26471559..cf14bbf5ba 100644 --- a/chat/content/jar.mn +++ b/chat/content/jar.mn @@ -12,3 +12,19 @@ chat.jar: * content/chat/imtooltip.xml content/chat/conversation-browser.js content/chat/conv.html + content/chat/otr-add-fingerprint.js + content/chat/otr-add-fingerprint.xul + content/chat/otr-auth.js + content/chat/otr-auth.xul + content/chat/otr-generate-key.js + content/chat/otr-generate-key.xul + content/chat/otrWorker.js + content/chat/otr-auth.dtd + content/chat/otr-auth.properties + content/chat/otr-add-finger.dtd + content/chat/otr-add-finger.properties + content/chat/otr.properties + content/chat/otr-generate-key.dtd + content/chat/otr-generate-key.properties + content/chat/otrUI.properties + content/chat/otr-chat.dtd diff --git a/chat/content/otr-add-finger.dtd b/chat/content/otr-add-finger.dtd new file mode 100644 index 0000000000..7af1713527 --- /dev/null +++ b/chat/content/otr-add-finger.dtd @@ -0,0 +1,9 @@ + + + + + + + diff --git a/chat/content/otr-add-finger.properties b/chat/content/otr-add-finger.properties new file mode 100644 index 0000000000..661e72c0b8 --- /dev/null +++ b/chat/content/otr-add-finger.properties @@ -0,0 +1,6 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# LOCALIZATION NOTE (addfinger.title): %S is the name of a chat contact person +addfinger.title=Enter the fingerprint of the OTR key used by %S diff --git a/chat/content/otr-add-fingerprint.js b/chat/content/otr-add-fingerprint.js new file mode 100644 index 0000000000..9232205372 --- /dev/null +++ b/chat/content/otr-add-fingerprint.js @@ -0,0 +1,50 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +const { + XPCOMUtils, + l10nHelper, +} = ChromeUtils.import("resource:///modules/imXPCOMUtils.jsm"); +const {OTR} = ChromeUtils.import("resource:///modules/OTR.jsm"); + +XPCOMUtils.defineLazyGetter(this, "_", () => + l10nHelper("chrome://chat/content/otr-add-finger.properties") +); + +var args = window.arguments[0].wrappedJSObject; + +var otrAddFinger = { + onload() { + document.title = _("addfinger.title", args.screenname); + + document.addEventListener("dialogaccept", () => { + return this.add(); + }); + }, + + oninput(e) { + e.value = e.value.replace(/[^0-9a-fA-F]/gi, ""); + document.documentElement.getButton("accept").disabled = (e.value.length != 40); + }, + + add(e) { + let hex = document.getElementById("finger").value; + let context = OTR.getContextFromRecipient( + args.account, + args.protocol, + args.screenname + ); + let finger = OTR.addFingerprint(context, hex); + if (finger.isNull()) + return; + try { + // Ignore the return, this is just a test. + OTR.getUIConvFromContext(context); + } catch (error) { + // We expect that a conversation may not have been started. + context = null; + } + OTR.setTrust(finger, true, context); + }, +}; diff --git a/chat/content/otr-add-fingerprint.xul b/chat/content/otr-add-fingerprint.xul new file mode 100644 index 0000000000..9c7c72b04b --- /dev/null +++ b/chat/content/otr-add-fingerprint.xul @@ -0,0 +1,27 @@ + + + + + + + + + +