summaryrefslogtreecommitdiff
path: root/chrome/content/messengercompose.js
diff options
context:
space:
mode:
authorSukhbir Singh <sukhbir@torproject.org>2018-01-13 00:44:14 -0500
committerSukhbir Singh <sukhbir@torproject.org>2018-01-29 16:50:52 -0500
commit89d99387f7b72b5f629266c61c733974014cfdea (patch)
tree29ac3729f04a2e888d33df535cb677d175240ab9 /chrome/content/messengercompose.js
parent3084a2f99dafa173f3d0ee4128e0a43d6ba62b3c (diff)
[feat] Display encryption status when viewing a message
Display a notification bar in the message pane if the message was encrypted for messages in the "Inbox" folder. For messages in the "Sent" folder, we have placeholder code for displaying the message state and for adding custom headers if required. However, we need to understand how to handle the case for multiple recipients with different encryption states since it's possible to send encrypted messages to recipients with known keys but the same message will be send unencrypted to recipients whose keys are not known. In such a case we can display the message status per-recipient.
Diffstat (limited to 'chrome/content/messengercompose.js')
-rw-r--r--chrome/content/messengercompose.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/chrome/content/messengercompose.js b/chrome/content/messengercompose.js
index 4b12f64..c0c5ec3 100644
--- a/chrome/content/messengercompose.js
+++ b/chrome/content/messengercompose.js
@@ -1,8 +1,33 @@
+// Assume that gBitmaskEncryptionState is true; if we detect a recipient
+// whose public key we don't know, we will set it to false, indicating
+// that the message will not be encrypted.
+var gBitmaskEncryptionState = true;
+
var composeStateListener = {
NotifyComposeBodyReady: function() {
}
};
+function insertEncryptionHeaders(event) {
+ // let msgComposeWindow = document.getElementById("msgcomposeWindow");
+ // let msgType = msgComposeWindow.getAttribute("msgType");
+
+ // // We only care about an actual send event.
+ // if (!(msgType == nsIMsgCompDeliverMode.Now || msgType == nsIMsgCompDeliverMode.Later))
+ // return;
+
+ // // If gBitmaskEncryptionState is true that means that we know the public key
+ // // of all the recipients (see updateEncryptionStatus) and therefore we
+ // // manually add the encryption headers so that when we later call msg_status
+ // // from Bitmask, Thunderbird will know that the message was sent as
+ // // encrypted. This however does not work for older messages; see
+ // // https://0xacab.org/leap/bitmask-dev/issues/9202
+ // if (gBitmaskEncryptionState === true) {
+ // gMsgCompose.compFields.setHeader("X-Leap-Encryption", "decrypted");
+ // gMsgCompose.compFields.setHeader("X-Leap-Signature", "valid");
+ // }
+}
+
// From addressingWidgetOverlay.js; we use this to call the function to update
// the status of the encryption keys for the various "To" fields. This is for
// the case where the user presses "Return" or "Tab" and Thunderbird inserts a
@@ -62,6 +87,8 @@ var checkToField = {
toField.getElementsByTagName("image")[0].setAttribute("src",
"chrome://bitmask/skin/lock.png");
}).catch(function(error) {
+ // We detected a missing public key; message will be unencrypted.
+ gBitmaskEncryptionState = false;
toField.getElementsByTagName("image")[0].setAttribute("src",
"chrome://bitmask/skin/unlock.png");
});
@@ -76,3 +103,5 @@ var checkToField = {
window.addEventListener("compose-window-init", function(event) {
gMsgCompose.RegisterStateListener(composeStateListener);
}, true);
+
+window.addEventListener("compose-send-message", insertEncryptionHeaders, true);