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 @ 9cedc0

ng_0.9
Last change on this file since 9cedc0 was 9cedc0, checked in by rene <rene@…>, 11 years ago

compatibility for conversation plugin

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