This is just some static backup of the original site, don't expect every link to work!

source: chrome/content/v_identity/vI_msgIdentityCloneTools.js @ 542354

multiEditng_0.6ng_0.8ng_0.9
Last change on this file since 542354 was 542354, checked in by rene <rene@…>, 13 years ago

modified hiding of SMIME/GPG signatures to be more robust

  • Property mode set to 100644
File size: 5.6 KB
Line 
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): Thunderbird Developers
23 * ***** END LICENSE BLOCK ***** */
24
25var vI_msgIdentityCloneTools = {   
26    copySelectedIdentity : function(id_key) {
27        vI_notificationBar.dump("## vI_msgIdentityCloneTools: copySelectedIdentity\n");
28        var msgIdentityElem = document.getElementById("msgIdentity");
29        var msgIdentityPopupElem = document.getElementById("msgIdentityPopup");
30        // copy selected Menu-Value from clone to orig.
31        var MenuItems = msgIdentityPopupElem.childNodes
32        for (var index = 0; index < MenuItems.length; index++) {
33            if ( MenuItems[index].getAttribute("value") == id_key ) {
34                msgIdentityElem.selectedItem = MenuItems[index];
35                msgIdentityElem.value = MenuItems[index].getAttribute("value");
36                break;
37            }
38        }
39        msgIdentityPopupElem.doCommand();
40    },
41       
42    signatureSwitch: function(existingIdentity) {
43        // always initialize Security/Enigmail-Options
44        try { setSecuritySettings(1); enigSetMenuSettings(''); } catch(vErr) { };
45        if (!existingIdentity) {
46            vI_notificationBar.dump("## vI_msgIdentityCloneTools: signatureSwitch hide/remove signatures\n");
47            // code to hide the text signature
48            try { if (vI.preferences.getBoolPref("hide_signature") && ss_signature.length == 0) {
49                vI_notificationBar.dump("## vI_msgIdentityCloneTools: hide text/html signature");
50                ss_main.signatureSwitch()
51                vI_notificationBar.dump("\n");
52            } } catch(vErr) { vI_notificationBar.dump(" -- missing signatureSwitch extension?\n"); };
53            // code to hide the sMime signature
54            try { if (vI.preferences.getBoolPref("hide_sMime_messageSignature")) {
55                var element = document.getElementById("menu_securitySign1");
56                if (element.getAttribute("checked") == "true") {
57                    vI_notificationBar.dump("## signatureSwitch hide_sMime_messageSignature with doCommand\n");
58                    element.doCommand();
59                }
60            }
61            //  document.getElementById("menu_securitySign1").removeAttribute("checked");
62            } catch(vErr) { };
63            // code to hide the openGPG signature
64            try { if (vI.preferences.getBoolPref("hide_openPGP_messageSignature")) {
65                var element = document.getElementById("enigmail_signed_send");
66                if (element.getAttribute("checked") == "true") {
67                    var skipChangeGPGsign = false;
68                    // sometimes GPG delays changing with dialog, so don't act if EnigmailAlertWindow is open to prevent double changes
69                    var windows = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
70                        .getService(Components.interfaces.nsIWindowWatcher).getWindowEnumerator();
71                    while (windows.hasMoreElements()) {
72                        var window = windows.getNext();
73                        skipChangeGPGsign = skipChangeGPGsign || (window.document.title == EnigGetString("enigAlert"));
74                    }
75                    if (skipChangeGPGsign)
76                        vI_notificationBar.dump("## signatureSwitch skip hide_openPGP_messageSignature - EnigMail AlertWindow open\n");
77                    else {
78                        vI_notificationBar.dump("## signatureSwitch hide_openPGP_messageSignature with doCommand\n");
79                        element.doCommand();
80                    }
81                }
82            }
83            //  document.getElementById("enigmail_signed_send").removeAttribute("checked");
84            } catch(vErr) { };
85        }
86        else {
87            vI_notificationBar.dump("## vI_msgIdentityCloneTools: signatureSwitch restore signature\n");
88            // code to show the text signature
89            try { if (ss_signature.length > 0) {
90                vI_notificationBar.dump("## vI_msgIdentityCloneTools: show text/html signature");
91                ss_main.signatureSwitch()
92                vI_notificationBar.dump("\n");
93            } } catch(vErr) { vI_notificationBar.dump(" -- missing signatureSwitch extension?\n"); };
94            // sMime and openGPG signature will not be re-added automatically
95        }
96    },
97   
98    initReplyTo : function() {
99        if (vI_statusmenu.prefroot.getBoolPref("extensions.virtualIdentity.autoReplyToSelf")) {
100            document.getElementById("autoReplyToSelfLabel").removeAttribute("hidden");
101            vI_msgIdentityCloneTools.removeAllReplyTos();
102        }
103        else document.getElementById("autoReplyToSelfLabel").setAttribute("hidden", "true");
104    },
105   
106    removeAllReplyTos : function() {
107        if (!document.getElementById("autoReplyToSelfLabel").hasAttribute("hidden")) {
108            for (var row = 1; row <= top.MAX_RECIPIENTS; row ++) {
109                var awType = awGetPopupElement(row).selectedItem.getAttribute("value");
110                if (awType == "addr_reply") {
111                    vI_notificationBar.dump("## vI_msgIdentityCloneTools: removed ReplyTo found in row " + row + "\n");
112                    awDeleteRow(row--); // removed one line therefore decrease row-value
113                }
114            }
115        }
116    },
117
118    addReplyToSelf : function() {
119        if (!document.getElementById("autoReplyToSelfLabel").hasAttribute("hidden")) {
120            awAddRecipient("addr_reply",document.getElementById("msgIdentity_clone").label);
121            vI_notificationBar.dump("## vI_msgIdentityCloneTools: added ReplyToSelf");
122            document.getElementById("autoReplyToSelfLabel").setAttribute("hidden","true");
123        }
124    }
125}
Note: See TracBrowser for help on using the repository browser.