1 | /* ***** BEGIN LICENSE BLOCK ***** |
---|
2 | This program is free software; you can redistribute it and/or modify |
---|
3 | it under the terms of the GNU General Public License as published by |
---|
4 | the Free Software Foundation; either version 2 of the License, or |
---|
5 | (at your option) any later version. |
---|
6 | |
---|
7 | This program is distributed in the hope that it will be useful, |
---|
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
10 | GNU General Public License for more details. |
---|
11 | |
---|
12 | You should have received a copy of the GNU General Public License |
---|
13 | along with this program; if not, write to the Free Software |
---|
14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
15 | |
---|
16 | The Original Code is the Virtual Identity Extension. |
---|
17 | |
---|
18 | The Initial Developer of the Original Code is Rene Ejury. |
---|
19 | Portions created by the Initial Developer are Copyright (C) 2007 |
---|
20 | the Initial Developer. All Rights Reserved. |
---|
21 | |
---|
22 | Contributor(s): |
---|
23 | * ***** END LICENSE BLOCK ***** */ |
---|
24 | |
---|
25 | var EXPORTED_SYMBOLS = []; |
---|
26 | |
---|
27 | const Ci = Components.interfaces; |
---|
28 | const Cc = Components.classes; |
---|
29 | const Cu = Components.utils; |
---|
30 | |
---|
31 | |
---|
32 | Cu.import("resource://v_identity/vI_identityDataExtras.js"); |
---|
33 | Cu.import("resource://v_identity/vI_log.js"); |
---|
34 | let Log = setupLogging("virtualIdentity.identityDataExtras.PGPSignature"); |
---|
35 | let vc = Cc["@mozilla.org/xpcom/version-comparator;1"].getService(Ci.nsIVersionComparator); |
---|
36 | |
---|
37 | function identityDataExtrasObject_PGPSignature(currentWindow) { |
---|
38 | this._currentWindow = currentWindow; |
---|
39 | this.field = "PGPSig"; // description of the option |
---|
40 | this.option = "storageExtras_openPGP_messageSignature"; // option string to get preference settings |
---|
41 | this.enigmail_active = (typeof this._currentWindow.Enigmail != 'undefined'); |
---|
42 | } |
---|
43 | identityDataExtrasObject_PGPSignature.prototype = { |
---|
44 | __proto__: identityDataExtrasCheckboxObject.prototype, |
---|
45 | |
---|
46 | readIdentityValue: function (identity) { |
---|
47 | if (this.enigmail_active && this.active) { |
---|
48 | if (identity.getIntAttribute('defaultEncryptionPolicy') > 0) |
---|
49 | this.value = (identity.getBoolAttribute('pgpSignEncrypted')) ? "true" : "false"; |
---|
50 | else |
---|
51 | this.value = (identity.getBoolAttribute('pgpSignPlain')) ? "true" : "false"; |
---|
52 | } |
---|
53 | }, |
---|
54 | |
---|
55 | setValueToEnvironment_msgCompose: function () { |
---|
56 | if (!this.enigmail_active || !this.active || (this.value == null)) |
---|
57 | return; |
---|
58 | |
---|
59 | if (this.value == "true") { |
---|
60 | this._currentWindow.Enigmail.msg.setFinalSendMode("final-signYes"); |
---|
61 | } else { |
---|
62 | this._currentWindow.Enigmail.msg.setFinalSendMode("final-signNo"); |
---|
63 | } |
---|
64 | }, |
---|
65 | |
---|
66 | getValueFromEnvironment_msgCompose: function () { |
---|
67 | if (this.enigmail_active && this.active) { |
---|
68 | this.value = ( |
---|
69 | this._currentWindow.Enigmail.msg.statusSigned == this._currentWindow.EnigmailConstants.ENIG_FINAL_YES || |
---|
70 | this._currentWindow.Enigmail.msg.statusSigned == this._currentWindow.EnigmailConstants.ENIG_FINAL_FORCEYES) ? "true" : "false"; |
---|
71 | } |
---|
72 | } |
---|
73 | } |
---|
74 | registerIdExtrasObject(identityDataExtrasObject_PGPSignature); |
---|