Permalink
Browse files

Show warning and use PGP/MIME with attachments

If we send a message with attachments using inline-PGP and quick reply,
attachments are not be encrypted. In the case we show warning message
and we can switch to PGP/MIME.
  • Loading branch information...
1 parent 7b1c553 commit b7951f422dde48418f55f258183f03984d8741b9 @shirosaki shirosaki committed Sep 14, 2012
Showing with 25 additions and 6 deletions.
  1. +1 −1 content/stub.compose-ui.js
  2. +1 −0 locale/en-US/message.properties
  3. +4 −3 modules/hook.js
  4. +19 −2 modules/plugins/enigmail.js
@@ -848,7 +848,7 @@ ComposeSession.prototype = {
to: to,
cc: cc,
bcc: bcc,
- }, ed, sendStatus, popOut);
+ }, ed, sendStatus, popOut, self.attachmentList);
if (priority != "_canceled")
sendStatus = newSendStatus;
}
@@ -65,6 +65,7 @@ signed=signed
encrypted=encrypted
unknownGood=unknown good signature
messageSendingCanceled=Sending the message was canceled.
+attachmentsNotEncrypted=Attachments will not be encrypted using inline-PGP.\nInstead send message using PGP/MIME?
# This is for the bugzilla support. View a bugzilla thread an follow the
# instructions to test this.
View
@@ -28,12 +28,13 @@ var EXPORTED_SYMBOLS = ['registerHook', 'getHooks', 'removeHook'];
* // @param aStatus.canceled Sending the message is canceled.
* // @param aStatus.securityInfo An object for PGM/MIME message.
* // @param aPopout if set, message will not be opened in compose window
+ * // @param aAttachmentList The AttachmentList object.
* // @return aStatus Same remark.
- * onMessageBeforeSendOrPopout_early: function (aAddress, aEditor, aStatus, aPopout) {
+ * onMessageBeforeSendOrPopout_early: function (aAddress, aEditor, aStatus, aPopout, aAttachmentList) {
* },
- * onMessageBeforeSendOrPopout: function (aAddress, aEditor, aStatus, aPopout) {
+ * onMessageBeforeSendOrPopout: function (aAddress, aEditor, aStatus, aPopout, aAttachmentList) {
* },
- * onMessageBeforeSendOrPopout_canceled: function (aAddress, aEditor, aStatus, aPopout) {
+ * onMessageBeforeSendOrPopout_canceled: function (aAddress, aEditor, aStatus, aPopout, aAttachmentList) {
* },
*
* // Called when quick reply body is composed.
@@ -425,7 +425,7 @@ let enigmailHook = {
}
},
- onMessageBeforeSendOrPopout: function _enigmailHook_onMessageBeforeSendOrPopout(aAddress, aEditor, aStatus, aPopout) {
+ onMessageBeforeSendOrPopout: function _enigmailHook_onMessageBeforeSendOrPopout(aAddress, aEditor, aStatus, aPopout, aAttachmentList) {
if (hasEnigmail)
this._originalText = null;
@@ -504,6 +504,23 @@ let enigmailHook = {
let origText;
let usingPGPMime = (sendFlags & nsIEnigmail.SEND_PGP_MIME) &&
(sendFlags & (ENCRYPT | SIGN));
+
+ if (!usingPGPMime && (sendFlags & ENCRYPT) &&
+ aAttachmentList && aAttachmentList.attachments.length > 0) {
+ // Attachments will not be encrypted using inline-PGP.
+ // We switch to PGP/MIME if possible.
+ if (EnigmailCommon.confirmDlg(window,
+ strings.get("attachmentsNotEncrypted"),
+ EnigmailCommon.getString("pgpMime_sMime.dlg.pgpMime.button"),
+ EnigmailCommon.getString("dlg.button.cancel"))) {
+ usingPGPMime = true;
+ sendFlags |= nsIEnigmail.SEND_PGP_MIME;
+ } else {
+ aStatus.canceled = true;
+ return aStatus;
+ }
+ }
+
if (usingPGPMime) {
uiFlags |= nsIEnigmail.UI_PGP_MIME;
@@ -585,7 +602,7 @@ let enigmailHook = {
return aStatus;
},
- onMessageBeforeSendOrPopout_canceled: function _enigmailHook_onMessageBeforeSendOrPopout_canceled(aAddress, aEditor, aStatus, aPopout) {
+ onMessageBeforeSendOrPopout_canceled: function _enigmailHook_onMessageBeforeSendOrPopout_canceled(aAddress, aEditor, aStatus, aPopout, aAttachmentList) {
if (hasEnigmail && !aPopout && aStatus.canceled && this._originalText !== null) {
aEditor.value = this._originalText;
}

0 comments on commit b7951f4

Please sign in to comment.