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) 2011 |
---|
20 | the Initial Developer. All Rights Reserved. |
---|
21 | |
---|
22 | Contributor(s): |
---|
23 | * ***** END LICENSE BLOCK ***** */ |
---|
24 | |
---|
25 | var EXPORTED_SYMBOLS = ["initReplyTo", "addReplyToSelf"] |
---|
26 | |
---|
27 | const {classes: Cc, interfaces: Ci, utils: Cu, results : Cr} = Components; |
---|
28 | Cu.import("resource://v_identity/vI_prefs.js"); |
---|
29 | Cu.import("resource://v_identity/vI_log.js"); |
---|
30 | let Log = setupLogging("virtualIdentity.replyToSelf"); |
---|
31 | |
---|
32 | function initReplyTo() { |
---|
33 | if (vIprefs.get("autoReplyToSelf")) { |
---|
34 | replyToSelfObj.removeAttribute("hidden"); |
---|
35 | removeAllReplyTos(); |
---|
36 | } |
---|
37 | else |
---|
38 | replyToSelfObj.setAttribute("hidden", "true"); |
---|
39 | }; |
---|
40 | |
---|
41 | function removeAllReplyTos() { |
---|
42 | if (!replyToSelfObj.hasAttribute("hidden")) { |
---|
43 | for (var row = 1; row <= top.MAX_RECIPIENTS; row ++) { |
---|
44 | var awType = currentWindow.awGetPopupElement(row).selectedItem.getAttribute("value"); |
---|
45 | if (awType == "addr_reply") { |
---|
46 | Log.debug("removed ReplyTo found in row " + row + "\n"); |
---|
47 | currentWindow.awDeleteRow(row--); // removed one line therefore decrease row-value |
---|
48 | } |
---|
49 | } |
---|
50 | } |
---|
51 | }; |
---|
52 | |
---|
53 | function addReplyToSelf() { |
---|
54 | if (!replyToSelfObj.hasAttribute("hidden")) { |
---|
55 | currentWindow.awAddRecipient("addr_reply",currentWindow.document.getElementById("virtualIdentityExtension_msgIdentityClone").label); |
---|
56 | Log.debug("added ReplyToSelf"); |
---|
57 | replyToSelfObj.setAttribute("hidden","true"); |
---|
58 | } |
---|
59 | } |
---|
60 | |
---|
61 | let replyToSelfObj = null; |
---|
62 | currentWindow = Cc["@mozilla.org/appshell/window-mediator;1"] |
---|
63 | .getService(Ci.nsIWindowMediator) |
---|
64 | .getMostRecentWindow(null); |
---|
65 | currentWindow.addEventListener("load", function () { |
---|
66 | replyToSelfObj = currentWindow.document.getElementById("virtualIdentityExtension_autoReplyToSelfLabel"); |
---|
67 | }, false); |
---|