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 | |
---|
25 | var vI_prefDialog = { |
---|
26 | preferences : Components.classes["@mozilla.org/preferences-service;1"] |
---|
27 | .getService(Components.interfaces.nsIPrefService) |
---|
28 | .getBranch("extensions.virtualIdentity."), |
---|
29 | |
---|
30 | unicodeConverter : Components.classes["@mozilla.org/intl/scriptableunicodeconverter"] |
---|
31 | .createInstance(Components.interfaces.nsIScriptableUnicodeConverter), |
---|
32 | |
---|
33 | base : { |
---|
34 | _elementIDs : [ "VIdent_identity.doFcc", |
---|
35 | "VIdent_identity.fccFolderPickerMode", |
---|
36 | "VIdent_identity.fccFolder", |
---|
37 | "VIdent_identity.fccReplyFollowsParent", |
---|
38 | "VIdent_identity.draftFolderPickerMode", |
---|
39 | "VIdent_identity.draftFolder", |
---|
40 | "VIdent_identity.stationeryFolderPickerMode", |
---|
41 | "VIdent_identity.stationeryFolder", |
---|
42 | "VIdent_identity.copySMIMESettings", |
---|
43 | "VIdent_identity.copyAttachVCardSettings", |
---|
44 | "VIdent_identity.smart_reply", |
---|
45 | "VIdent_identity.smart_detectByReceivedHeader", |
---|
46 | "VIdent_identity.smart_reply_for_newsgroups", |
---|
47 | "VIdent_identity.show_smtp", |
---|
48 | "VIdent_identity.fcc_show_switch", |
---|
49 | "VIdent_identity.menu_entry", |
---|
50 | "VIdent_identity.smart_reply_headers", |
---|
51 | "VIdent_identity.smart_reply_filter", |
---|
52 | "VIdent_identity.smart_draft", |
---|
53 | "VIdent_identity.smart_reply_notification", |
---|
54 | "VIdent_identity.get_header_notification", |
---|
55 | "VIdent_identity.smart_reply_defaultFullName", |
---|
56 | "VIdent_identity.smart_reply_ignoreFullName", |
---|
57 | "VIdent_identity.autoTimestamp", |
---|
58 | "VIdent_identity.notification_timeout", |
---|
59 | "VIdent_identity.debug_notification", |
---|
60 | "VIdent_identity.warn_nonvirtual", |
---|
61 | "VIdent_identity.warn_virtual", |
---|
62 | "VIdent_identity.hide_signature", |
---|
63 | "VIdent_identity.storage", |
---|
64 | "VIdent_identity.storage_storedefault", |
---|
65 | "VIdent_identity.storage_store_base_id", |
---|
66 | "VIdent_identity.storage_store_SMTP", |
---|
67 | "VIdent_identity.storage_dont_update_multiple", |
---|
68 | "VIdent_identity.storage_show_switch", |
---|
69 | "VIdent_identity.storage_show_baseID_switch", |
---|
70 | "VIdent_identity.storage_show_SMTP_switch", |
---|
71 | "VIdent_identity.storage_colorIndication", |
---|
72 | "VIdent_identity.storage_warn_update", |
---|
73 | "VIdent_identity.storage_warn_vI_replace", |
---|
74 | "VIdent_identity.storage_notification", |
---|
75 | "VIdent_identity.storage_getOneOnly", |
---|
76 | "VIdent_identity.storageExtras_returnReciept", |
---|
77 | "VIdent_identity.storageExtras_fcc", |
---|
78 | "VIdent_identity.storageExtras_characterEncoding", |
---|
79 | "VIdent_identity.storageExtras_messageFormat", |
---|
80 | "VIdent_identity.storageExtras_sMime_messageEncryption", |
---|
81 | "VIdent_identity.storageExtras_sMime_messageSignature", |
---|
82 | "VIdent_identity.storageExtras_openPGP_messageEncryption", |
---|
83 | "VIdent_identity.storageExtras_openPGP_messageSignature", |
---|
84 | "VIdent_identity.storageExtras_openPGP_PGPMIME", |
---|
85 | "VIdent_identity.idSelection_storage_prefer_smart_reply", |
---|
86 | "VIdent_identity.idSelection_storage_ignore_smart_reply", |
---|
87 | "VIdent_identity.idSelection_ask", |
---|
88 | "VIdent_identity.idSelection_ask_always", |
---|
89 | "VIdent_identity.idSelection_autocreate", |
---|
90 | "VIdent_identity.idSelection_preferExisting", |
---|
91 | "VIdent_identity.autoReplyToSelf"], |
---|
92 | |
---|
93 | init : function() { |
---|
94 | // initialize the default window values... |
---|
95 | for( var i = 0; i < vI_prefDialog.base._elementIDs.length; i++ ) { |
---|
96 | var elementID = vI_prefDialog.base._elementIDs[i]; |
---|
97 | var element = document.getElementById(elementID); |
---|
98 | if (!element) break; |
---|
99 | var eltType = element.localName; |
---|
100 | try { |
---|
101 | if (eltType == "radiogroup") |
---|
102 | element.selectedItem = element.childNodes[ |
---|
103 | vI_prefDialog.preferences.getIntPref(element.getAttribute("prefstring"))]; |
---|
104 | else if (eltType == "checkbox") |
---|
105 | element.checked = |
---|
106 | vI_prefDialog.preferences.getBoolPref(element.getAttribute("prefstring")); |
---|
107 | else if (eltType == "textbox") |
---|
108 | if (element.getAttribute("preftype") == "int") |
---|
109 | element.setAttribute("value", |
---|
110 | vI_prefDialog.preferences.getIntPref(element.getAttribute("prefstring")) ); |
---|
111 | else element.setAttribute("value", |
---|
112 | vI_prefDialog.unicodeConverter.ConvertToUnicode(vI_prefDialog.preferences.getCharPref(element.getAttribute("prefstring"))) ); |
---|
113 | } catch (ex) {} |
---|
114 | } |
---|
115 | }, |
---|
116 | |
---|
117 | savePrefs : function() { |
---|
118 | for( var i = 0; i < vI_prefDialog.base._elementIDs.length; i++ ) { |
---|
119 | var elementID = vI_prefDialog.base._elementIDs[i]; |
---|
120 | var element = document.getElementById(elementID); |
---|
121 | if (!element) break; |
---|
122 | var eltType = element.localName; |
---|
123 | if (eltType == "radiogroup") |
---|
124 | vI_prefDialog.preferences.setIntPref( |
---|
125 | element.getAttribute("prefstring"), parseInt(element.value)); |
---|
126 | else if (eltType == "checkbox") |
---|
127 | vI_prefDialog.preferences.setBoolPref( |
---|
128 | element.getAttribute("prefstring"), element.checked); |
---|
129 | else if (eltType == "textbox") { |
---|
130 | if (element.getAttribute("preftype") == "int") |
---|
131 | vI_prefDialog.preferences.setIntPref( |
---|
132 | element.getAttribute("prefstring"), element.value); |
---|
133 | else vI_prefDialog.preferences.setCharPref( |
---|
134 | element.getAttribute("prefstring"), vI_prefDialog.unicodeConverter.ConvertFromUnicode(element.value)); |
---|
135 | //~ alert(elementID + " " + element.getAttribute("prefstring") + " " + parseInt(element.value)) |
---|
136 | } |
---|
137 | } |
---|
138 | }, |
---|
139 | |
---|
140 | modifyAttribute : function(elemID, attribute, value) { |
---|
141 | if (value) document.getElementById(elemID).removeAttribute(attribute); |
---|
142 | else document.getElementById(elemID).setAttribute(attribute, "true"); |
---|
143 | }, |
---|
144 | |
---|
145 | constraints : function() { |
---|
146 | var storage = document.getElementById("VIdent_identity.storage").checked; |
---|
147 | var smartDraft = document.getElementById("VIdent_identity.smart_draft").checked; |
---|
148 | var smartReply = document.getElementById("VIdent_identity.smart_reply").checked; |
---|
149 | var mAttr = vI_prefDialog.base.modifyAttribute; |
---|
150 | |
---|
151 | // idSelectionConstraint |
---|
152 | var idSelectionConstraint = (storage || smartReply || smartDraft); |
---|
153 | mAttr("VIdent_identity.idSelection_ask","disabled",idSelectionConstraint); |
---|
154 | mAttr("VIdent_identity.idSelection_ask_always","disabled",idSelectionConstraint); |
---|
155 | mAttr("VIdent_identity.idSelection_autocreate","disabled",idSelectionConstraint); |
---|
156 | mAttr("VIdent_identity.idSelection_autocreate.desc","disabled",idSelectionConstraint); |
---|
157 | mAttr("VIdent_identity.idSelection_preferExisting","disabled",idSelectionConstraint); |
---|
158 | mAttr("selection","featureDisabled",idSelectionConstraint); |
---|
159 | mAttr("toCompose","featureDisabled",idSelectionConstraint); |
---|
160 | |
---|
161 | // idSelectionInputConstraint |
---|
162 | var idSelectionInputConstraint = (storage && smartReply); |
---|
163 | mAttr("VIdent_identity.idSelection_storage_prefer_smart_reply","disabled",idSelectionInputConstraint); |
---|
164 | mAttr("VIdent_identity.idSelection_storage_ignore_smart_reply","disabled",idSelectionInputConstraint); |
---|
165 | if (idSelectionInputConstraint) vI_prefDialog.base.idSelectionResultConstraint(); |
---|
166 | |
---|
167 | // sourceEmailConstraint |
---|
168 | var sourceEmailConstraint = (smartReply || smartDraft); |
---|
169 | mAttr("sourceEmail","featureDisabled",sourceEmailConstraint); |
---|
170 | mAttr("toSelection","featureDisabled",sourceEmailConstraint); |
---|
171 | |
---|
172 | }, |
---|
173 | |
---|
174 | idSelectionResultConstraint : function() { |
---|
175 | var ask = document.getElementById("VIdent_identity.idSelection_ask") |
---|
176 | var ask_always = document.getElementById("VIdent_identity.idSelection_ask_always") |
---|
177 | var autocreate = document.getElementById("VIdent_identity.idSelection_autocreate") |
---|
178 | var autocreate_desc = document.getElementById("VIdent_identity.idSelection_autocreate.desc") |
---|
179 | ask_always.setAttribute("disabled", (autocreate.checked || !ask.checked)) |
---|
180 | autocreate.setAttribute("disabled", (ask.checked && ask_always.checked)) |
---|
181 | autocreate_desc.setAttribute("disabled", (ask.checked && ask_always.checked)) |
---|
182 | autocreate_desc.setAttribute("hidden", !ask.checked) |
---|
183 | }, |
---|
184 | |
---|
185 | smartReplyConstraint : function(element) { |
---|
186 | var mAttr = vI_prefDialog.base.modifyAttribute; |
---|
187 | mAttr("VIdent_identity.smart_reply_for_newsgroups","disabled",element.checked); |
---|
188 | mAttr("VIdent_identity.smart_reply_headers","disabled",element.checked); |
---|
189 | mAttr("VIdent_identity.smart_reply_filter","disabled",element.checked); |
---|
190 | mAttr("VIdent_identity.smart_reply_defaultFullName","disabled",element.checked); |
---|
191 | mAttr("VIdent_identity.smart_reply_ignoreFullName","disabled",element.checked); |
---|
192 | mAttr("VIdent_identity.smart_reply_headers_reset","disabled",element.checked); |
---|
193 | mAttr("VIdent_identity.smart_detectByReceivedHeader","disabled",element.checked); |
---|
194 | vI_prefDialog.base.constraints(); |
---|
195 | }, |
---|
196 | |
---|
197 | smartReplyHeaderReset : function() { |
---|
198 | var textfield = document.getElementById("VIdent_identity.smart_reply_headers") |
---|
199 | textfield.value = "envelope-to\nx-original-to\nto\ncc" |
---|
200 | }, |
---|
201 | |
---|
202 | smartReplyHideSignature : function() { |
---|
203 | const switch_signature_ID="{2ab1b709-ba03-4361-abf9-c50b964ff75d}" |
---|
204 | if (vI_helper.extensionActive(switch_signature_ID)) { |
---|
205 | document.getElementById("VIdent_identity.HideSignature.warning").setAttribute("hidden", "true"); |
---|
206 | document.getElementById("VIdent_identity.hide_signature").setAttribute("disabled", "false"); |
---|
207 | } |
---|
208 | }, |
---|
209 | |
---|
210 | storageConstraint : function(element) { |
---|
211 | var mAttr = vI_prefDialog.base.modifyAttribute; |
---|
212 | mAttr("VIdent_identity.storage_storedefault","disabled",element.checked); |
---|
213 | mAttr("VIdent_identity.storage_store_base_id","disabled",element.checked); |
---|
214 | mAttr("VIdent_identity.storage_store_SMTP","disabled",element.checked); |
---|
215 | mAttr("VIdent_identity.storage_dont_update_multiple","disabled",element.checked); |
---|
216 | mAttr("VIdent_identity.storage_show_switch","disabled",element.checked); |
---|
217 | mAttr("VIdent_identity.storage_show_baseID_switch","disabled",element.checked); |
---|
218 | mAttr("VIdent_identity.storage_show_SMTP_switch","disabled",element.checked); |
---|
219 | mAttr("VIdent_identity.storage_colorIndication","disabled",element.checked); |
---|
220 | mAttr("VIdent_identity.storage_warn_update","disabled",element.checked); |
---|
221 | mAttr("VIdent_identity.storage_warn_vI_replace","disabled",element.checked); |
---|
222 | mAttr("VIdent_identity.storage_notification","disabled",element.checked); |
---|
223 | mAttr("VIdent_identity.storage_getOneOnly","disabled",element.checked); |
---|
224 | mAttr("VIdent_identity.storageExtras_returnReciept","disabled",element.checked); |
---|
225 | mAttr("VIdent_identity.storageExtras_fcc","disabled",element.checked); |
---|
226 | mAttr("VIdent_identity.storageExtras_characterEncoding","disabled",element.checked); |
---|
227 | mAttr("VIdent_identity.storageExtras_messageFormat","disabled",element.checked); |
---|
228 | mAttr("VIdent_identity.storageExtras_sMime_messageEncryption","disabled",element.checked); |
---|
229 | mAttr("VIdent_identity.storageExtras_sMime_messageSignature","disabled",element.checked); |
---|
230 | mAttr("VIdent_identity.storageExtras_openPGP_messageEncryption","disabled",element.checked); |
---|
231 | mAttr("VIdent_identity.storageExtras_openPGP_messageSignature","disabled",element.checked); |
---|
232 | mAttr("VIdent_identity.storageExtras_openPGP_PGPMIME","disabled",element.checked); |
---|
233 | mAttr("storageOut","featureDisabled",element.checked); |
---|
234 | mAttr("storageUp","featureDisabled",element.checked); |
---|
235 | mAttr("storageUpDown","featureDisabled",element.checked); |
---|
236 | vI_prefDialog.base.constraints(); |
---|
237 | } |
---|
238 | }, |
---|
239 | |
---|
240 | init : function() { |
---|
241 | vI_prefDialog.unicodeConverter.charset="UTF-8"; |
---|
242 | vI_prefDialog.base.init(); |
---|
243 | onInitCopiesAndFolders() |
---|
244 | |
---|
245 | if (vI_helper.olderVersion("TB", "2.0b") || vI_helper.olderVersion("SM", "1.5a")) { |
---|
246 | document.getElementById("version-warning").setAttribute("hidden", "false"); |
---|
247 | document.getElementById("VIdent_identity.smart_draft").setAttribute("disabled", "true"); |
---|
248 | document.getElementById("VIdent_messageDraftsTab").setAttribute("hidden", "true"); |
---|
249 | document.getElementById("VIdent_messageTemplatesTab").setAttribute("hidden", "true"); |
---|
250 | } |
---|
251 | if (vI_helper.olderVersion("TB", "1.5.0.7")) { |
---|
252 | document.getElementById("notificationGroupBox").setAttribute("hidden", "true"); |
---|
253 | } |
---|
254 | if (vI_helper.olderVersion("TB", "2.0")) { |
---|
255 | document.getElementById("fccReplyFollowsParentBox").setAttribute("hidden", "true"); |
---|
256 | } |
---|
257 | const enigmail_ID="{847b3a00-7ab1-11d4-8f02-006008948af5}" |
---|
258 | if (!vI_helper.extensionActive(enigmail_ID)) |
---|
259 | document.getElementById("openPGPencryption").setAttribute("hidden", "true"); |
---|
260 | |
---|
261 | vI_prefDialog.base.smartReplyConstraint(document.getElementById("VIdent_identity.smart_reply")); |
---|
262 | vI_prefDialog.base.smartReplyHideSignature(); |
---|
263 | vI_prefDialog.base.storageConstraint(document.getElementById("VIdent_identity.storage")); |
---|
264 | vI_prefDialog.base.constraints(); |
---|
265 | if (vI_storageExtrasHelper.seamonkey_to_old()) { |
---|
266 | document.getElementById("storageExtrasTreeitem1").setAttribute("hidden", "true") |
---|
267 | document.getElementById("storageExtrasTreeitem2").setAttribute("hidden", "true") |
---|
268 | } |
---|
269 | }, |
---|
270 | |
---|
271 | savePrefs : function() { |
---|
272 | // Copy all changes to Elements |
---|
273 | onSaveCopiesAndFolders(); |
---|
274 | vI_prefDialog.base.savePrefs(); |
---|
275 | }, |
---|
276 | |
---|
277 | openURL : function(aURL) { |
---|
278 | var uri = Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURI); |
---|
279 | var protocolSvc = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"].getService(Components.interfaces.nsIExternalProtocolService); |
---|
280 | |
---|
281 | uri.spec = aURL; |
---|
282 | protocolSvc.loadUrl(uri); |
---|
283 | } |
---|
284 | } |
---|