1 | <?xml version="1.0"?> |
---|
2 | <!-- ***** BEGIN LICENSE BLOCK ***** |
---|
3 | - This program is free software; you can redistribute it and/or modify |
---|
4 | - it under the terms of the GNU General Public License as published by |
---|
5 | - the Free Software Foundation; either version 2 of the License, or |
---|
6 | - (at your option) any later version. |
---|
7 | |
---|
8 | - This program is distributed in the hope that it will be useful, |
---|
9 | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
11 | - GNU General Public License for more details. |
---|
12 | |
---|
13 | - You should have received a copy of the GNU General Public License |
---|
14 | - along with this program; if not, write to the Free Software |
---|
15 | - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
16 | |
---|
17 | - The Original Code is the Virtual Identity Extension. |
---|
18 | |
---|
19 | - The Initial Developer of the Original Code is Rene Ejury. |
---|
20 | - Portions created by the Initial Developer are Copyright (C) 2007 |
---|
21 | - the Initial Developer. All Rights Reserved. |
---|
22 | |
---|
23 | - Contributor(s): |
---|
24 | - ***** END LICENSE BLOCK ***** --> |
---|
25 | |
---|
26 | <!DOCTYPE overlay [ |
---|
27 | <!ENTITY % vIdentDTD SYSTEM "chrome://v_identity/locale/v_identity.dtd"> |
---|
28 | %vIdentDTD; |
---|
29 | ]> |
---|
30 | |
---|
31 | |
---|
32 | <bindings id="mailComposeBindings" |
---|
33 | xmlns="http://www.mozilla.org/xbl" |
---|
34 | xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
---|
35 | xmlns:xbl="http://www.mozilla.org/xbl"> |
---|
36 | |
---|
37 | <binding id="tooltipPopupset"> |
---|
38 | <implementation> |
---|
39 | <method name="addTooltip"> |
---|
40 | <parameter name="elem" /> |
---|
41 | <parameter name="permanent" /> |
---|
42 | <body><![CDATA[ |
---|
43 | var randID = elem.tooltipElem.getAttribute("tooltip"); |
---|
44 | this.removeTooltip(randID); |
---|
45 | if (!randID) { |
---|
46 | randID = "tooltip_" + parseInt((new Date()).getTime()); |
---|
47 | elem.tooltipElem.setAttribute("tooltip", randID); |
---|
48 | } |
---|
49 | var toolTip = document.createElement("tooltip"); |
---|
50 | toolTip.setAttribute("class", "identityDataTooltip"); |
---|
51 | toolTip.setAttribute("id", randID); |
---|
52 | toolTip.elem = elem; |
---|
53 | toolTip.permanent = permanent; |
---|
54 | this.appendChild(toolTip); |
---|
55 | ]]></body> |
---|
56 | </method> |
---|
57 | <method name="removeTooltip"> |
---|
58 | <parameter name="randID" /> |
---|
59 | <body><![CDATA[ |
---|
60 | if (randID) this.removeChild(document.getElementById(randID)) |
---|
61 | ]]></body> |
---|
62 | </method> |
---|
63 | </implementation> |
---|
64 | </binding> |
---|
65 | |
---|
66 | <binding id="vI_identityDataTooltip" extends="chrome://global/content/bindings/popup.xml#tooltip"> |
---|
67 | <content onpopuphidden="popuphidden();" onpopupshowing="this.popupshowing();this.resize()" onpopupshown="this.resize()" > |
---|
68 | <xul:browser style="overflow:hidden" anonid="tooltipBrowser" class="vI_htmlTextBox" cssSource="vI_TooltipBrowser.css" flex="1" disablehistory="true" onoverflow="document.getBindingParent(this).resize()"/> |
---|
69 | <children /> |
---|
70 | </content> |
---|
71 | <implementation> |
---|
72 | <method name="popupshowing"> |
---|
73 | <body><![CDATA[ |
---|
74 | if (!this._identityInfo) { |
---|
75 | this._identityInfo = |
---|
76 | "<table><tr>" + |
---|
77 | "<td class='image'><img src='chrome://v_identity/skin/vi-info.png' /></td>" + |
---|
78 | "<td class='identityTable'>" + |
---|
79 | "<div class='name'>" + this.elem.identityData.combinedNameHtml + "</div>" + |
---|
80 | "<table><tbody>" + this.elem.identityData.getMatrix() + "</tbody></table>" + |
---|
81 | "</td>" + |
---|
82 | "</tr></table>" |
---|
83 | // vI_notificationBar.dump("** v_identity.xml added tooltip with id='" + this.elem.identityData.id.key + "'\n") |
---|
84 | this._tooltipBrowser.outputString = this._identityInfo; |
---|
85 | } |
---|
86 | ]]></body> |
---|
87 | </method> |
---|
88 | <method name ="popuphidden"> |
---|
89 | <body><![CDATA[ |
---|
90 | if (!this.permanent) this._identityInfo = null; |
---|
91 | ]]></body> |
---|
92 | </method> |
---|
93 | <method name="resize"> |
---|
94 | <body><![CDATA[ |
---|
95 | if (!this._identityInfo) return; |
---|
96 | var width = document.getElementById("msgIdentity_clone").boxObject.width * 0.7; |
---|
97 | var height = this._tooltipBrowser.contentDocument.lastChild.scrollHeight + 5; |
---|
98 | this.sizeTo(width, height); |
---|
99 | width = document.getElementById("msgIdentity_clone").boxObject.width * 0.75; |
---|
100 | this.sizeTo(width, height); |
---|
101 | ]]></body> |
---|
102 | </method> |
---|
103 | <field name="permanent" /> |
---|
104 | <field name="elem" /> |
---|
105 | <!-- <field name="identityData">this.elem.identityData</field> --> |
---|
106 | <field name="_identityInfo">false</field> |
---|
107 | <!-- <field name="_initialized">false</field> --> |
---|
108 | <field name="_tooltipBrowser">document.getAnonymousElementByAttribute(this, "anonid", "tooltipBrowser")</field> |
---|
109 | </implementation> |
---|
110 | </binding> |
---|
111 | |
---|
112 | <binding id="fromPopupItem_clone" extends="chrome://global/content/bindings/menu.xml#menuitem"> |
---|
113 | <content excludes="template,observes,menupopup"> |
---|
114 | <xul:image class="menupopup_clone-icon" xbl:inherits="src"/> |
---|
115 | <xul:label class="menupopup_clone-text" xbl:inherits="value=label,accesskey,crop" crop="right" flex="1"/> |
---|
116 | <xul:label value="&vident.accPane.prettyName.prefix;" class="menupopup_clone-vid virtIdLabel" vid="false" xbl:inherits="vid" crop="right"/> |
---|
117 | <xul:label class="menupopup_clone-description" xbl:inherits="value=description" crop="right"/> |
---|
118 | <xul:label class="menupopup_clone-smtp" xbl:inherits="value=smtp,style=smtpStyle" crop="right"/> |
---|
119 | </content> |
---|
120 | <implementation> |
---|
121 | <constructor> |
---|
122 | <![CDATA[ |
---|
123 | this._identityDataStorage = this.identityData; |
---|
124 | |
---|
125 | this.label = this._identityDataStorage.combinedName; |
---|
126 | this.value = this._identityDataStorage.id.key; |
---|
127 | // vI_notificationBar.dump("** v_identity.xml fromPopupItem_clone constructor id='" + this.value + "'.\n") |
---|
128 | |
---|
129 | this.description = this._identityDataStorage.sideDescription; |
---|
130 | this.smtp = this._identityDataStorage.smtp.value; |
---|
131 | // vI_notificationBar.dump("** v_identity.xml fromPopupItem_clone constructor smtp='" + this.smtp + "'.\n") |
---|
132 | this.smtpStyle = "width:" + document.getElementById("smtp_server_list").clientWidth + "px;"; |
---|
133 | this._identityDataStorage.smtp.value; |
---|
134 | |
---|
135 | document.getElementById("vI_tooltipPopupset").addTooltip(this, true); |
---|
136 | ]]> |
---|
137 | </constructor> |
---|
138 | <method name="clean"> |
---|
139 | <body><![CDATA[ |
---|
140 | document.getElementById("vI_tooltipPopupset") |
---|
141 | .removeTooltip(this.tooltipElem.getAttribute("tooltip")); |
---|
142 | ]]></body> |
---|
143 | </method> |
---|
144 | <destructor> |
---|
145 | <![CDATA[ |
---|
146 | this.clean(); |
---|
147 | ]]> |
---|
148 | </destructor> |
---|
149 | <property name="_identityData" onget="return this._identityDataStorage;" /> |
---|
150 | <field name="tooltipElem">this</field> |
---|
151 | <property name="vid" onget="return this.getAttribute('vid');" onset="this.setAttribute('vid', val); return val;" /> |
---|
152 | <property name="label" onget="return this.getAttribute('label');" onset="this.setAttribute('label', val); return val;" /> |
---|
153 | <property name="value" onget="return this.getAttribute('value');" onset="this.setAttribute('value', val); return val;" /> |
---|
154 | <property name="description" onget="return this.getAttribute('description');" onset="this.setAttribute('description', val); return val;" /> |
---|
155 | <property name="smtp" onget="return this.getAttribute('smtp');" onset="this.setAttribute('smtp', val); return val;" /> |
---|
156 | <property name="smtpStyle" onget="return this.getAttribute('smtpStyle');" onset="this.setAttribute('smtpStyle', val); return val;" /> |
---|
157 | </implementation> |
---|
158 | </binding> |
---|
159 | |
---|
160 | <binding id="smtpServerList"> |
---|
161 | <resources> |
---|
162 | <stylesheet src="chrome://global/skin/menu.css"/> |
---|
163 | </resources> |
---|
164 | <content sizetopopup="pref"> |
---|
165 | <xul:hbox id="smtpServerHbox" class="smtpServerHbox"> |
---|
166 | <xul:menulist class="smtpServerMenuList" anonid="smtpServerMenuList" allowevents="true" id="smtp_server_list"> |
---|
167 | <xul:menupopup anonid="smtp_server_list_popup" /> |
---|
168 | </xul:menulist> |
---|
169 | <xul:checkbox id="saveSMTPSwitch" class="vI_plain" allowevents="true" oncommand="event.stopPropagation();vI_statusmenu.changeSMTPStatus(this);" > |
---|
170 | <xul:observes element="vI_statusMenu_storage_saveSMTP" attribute="checked" /> |
---|
171 | <xul:observes element="vI_statusMenu_storage_saveSMTP" attribute="disabled" /> |
---|
172 | </xul:checkbox> |
---|
173 | <xul:observes element="vI_statusMenu_storage_saveSMTP" attribute="checked" /> |
---|
174 | <xul:observes element="vI_statusMenu_storage_saveSMTP" attribute="disabled" /> |
---|
175 | </xul:hbox> |
---|
176 | </content> |
---|
177 | <implementation> |
---|
178 | <method name="addNoneServer"> |
---|
179 | <body><![CDATA[ |
---|
180 | var listitem = document.createElement("menuitem"); |
---|
181 | listitem.setAttribute("class", "menuitem-non-iconic"); |
---|
182 | listitem.setAttribute("type", "non-iconic-noaccel"); |
---|
183 | listitem.setAttribute("label", " "); |
---|
184 | listitem.setAttribute("key", NO_SMTP_TAG); |
---|
185 | this._smtpPopup.insertBefore(listitem, this._smtpPopup.firstChild); |
---|
186 | this._smtpMenu.selectedItem = listitem; |
---|
187 | ]]></body> |
---|
188 | </method> |
---|
189 | <method name="_addDefaultServer"> |
---|
190 | <body><![CDATA[ |
---|
191 | var listitem = document.createElement("menuitem"); |
---|
192 | listitem.setAttribute("class", "menuitem-non-iconic"); |
---|
193 | listitem.setAttribute("type", "non-iconic-noaccel"); |
---|
194 | listitem.setAttribute("label", document.getElementById("bundle_messenger").getString("defaultServerTag")); |
---|
195 | this._smtpPopup.appendChild(listitem); |
---|
196 | this._smtpMenu.selectedItem = listitem; |
---|
197 | ]]></body> |
---|
198 | </method> |
---|
199 | <method name="_addServer"> |
---|
200 | <parameter name="server" /> |
---|
201 | <body><![CDATA[ |
---|
202 | if (server instanceof Components.interfaces.nsISmtpServer && !server.redirectorType) { |
---|
203 | var listitem = document.createElement("menuitem"); |
---|
204 | listitem.setAttribute("class", "menuitem-non-iconic"); |
---|
205 | listitem.setAttribute("type", "non-iconic-noaccel"); |
---|
206 | listitem.setAttribute("label", (server.description?server.description:server.hostname)); |
---|
207 | listitem.setAttribute("key", server.key); |
---|
208 | this._smtpPopup.appendChild(listitem); |
---|
209 | } |
---|
210 | ]]></body> |
---|
211 | </method> |
---|
212 | <constructor> |
---|
213 | <![CDATA[ |
---|
214 | this._addDefaultServer(); |
---|
215 | this._smtpPopup.appendChild(document.createElement("menuseparator")); |
---|
216 | |
---|
217 | var servers = Components.classes["@mozilla.org/messengercompose/smtp;1"] |
---|
218 | .getService(Components.interfaces.nsISmtpService).smtpServers; |
---|
219 | |
---|
220 | if (typeof(servers.Count) == "undefined") // TB 3.x |
---|
221 | while (servers && servers.hasMoreElements()) |
---|
222 | this._addServer(servers.getNext()); |
---|
223 | else // TB 2.x |
---|
224 | for (var i=0 ; i<servers.Count(); i++) |
---|
225 | this._addServer(servers.QueryElementAt(i, Components.interfaces.nsISmtpServer)); |
---|
226 | |
---|
227 | ]]> |
---|
228 | </constructor> |
---|
229 | <property name="smtp" onget="return this._smtpMenu.selectedItem.getAttribute('key');" > |
---|
230 | <setter><![CDATA[ |
---|
231 | if (val == NO_SMTP_TAG) return; // dont overwrite if not set |
---|
232 | vI_notificationBar.dump("** v_identity.xml smtp set to '" + val + "'\n") |
---|
233 | var MenuItems = this._smtpPopup.childNodes |
---|
234 | for (var index = 0; index < MenuItems.length; index++) { |
---|
235 | if (MenuItems[index].localName == "menuseparator") continue; |
---|
236 | if (MenuItems[index].getAttribute("key") == val) { |
---|
237 | this._smtpMenu.selectedItem = MenuItems[index]; |
---|
238 | break; |
---|
239 | } |
---|
240 | } |
---|
241 | ]]></setter> |
---|
242 | </property> |
---|
243 | <field name="_smtpPopup">document.getAnonymousElementByAttribute(this, "anonid", "smtp_server_list_popup")</field> |
---|
244 | <field name="_smtpMenu">document.getAnonymousElementByAttribute(this, "anonid", "smtpServerMenuList")</field> |
---|
245 | <field name="_smtpService"></field> |
---|
246 | |
---|
247 | </implementation> |
---|
248 | </binding> |
---|
249 | |
---|
250 | |
---|
251 | |
---|
252 | |
---|
253 | <binding id="fromMenuList_clone" display="xul:menu" extends="chrome://global/content/bindings/menulist.xml#menulist-description"> |
---|
254 | <resources> |
---|
255 | <stylesheet src="chrome://global/skin/menu.css"/> |
---|
256 | <stylesheet src="chrome://global/skin/autocomplete.css"/> |
---|
257 | </resources> |
---|
258 | <content sizetopopup="pref"> |
---|
259 | <xul:hbox class="contentHBox" anonid="contentHBox" flex="1" > |
---|
260 | <xul:hbox id="identityHbox" class="identityHbox" flex="1"> |
---|
261 | <xul:vbox><xul:spacer flex="1" /> |
---|
262 | <xul:image class="menulist_clone-icon" id="msgIdentity_clone_image" xbl:inherits="src"/> |
---|
263 | <xul:spacer flex="1" /></xul:vbox> |
---|
264 | <xul:vbox flex="1" id="msgIdentity_clone_fromVbox"><xul:spacer flex="1" /> |
---|
265 | <!-- textbox is internally an html:input field which inherits the onblur event. |
---|
266 | Thats why we have to search the textbox before calling blurEvent() --> |
---|
267 | <xul:textbox anonid="textBox" type="search" id="msgIdentity_clonetextBoxElem" class="plain menulist_clone-textbox" allowevents="true" xbl:inherits="value=label,crop,accesskey,nomatch=vid" oncommand="event.stopPropagation(); document.getBindingParent(this).inputEvent();" |
---|
268 | onblur="event.stopPropagation(); var elem = this; while (elem.localName != 'textbox') elem = elem.parentNode; document.getBindingParent(elem).blurEvent();" |
---|
269 | crop="right" highlightnonmatches="true"/> |
---|
270 | <xul:spacer flex="1" /></xul:vbox> |
---|
271 | <xul:vbox id="saveSwitch"><xul:spacer flex="1" /> |
---|
272 | <xul:checkbox class="vI_plain" allowevents="true" oncommand="event.stopPropagation();vI_statusmenu.changeSaveStatus(this);" > |
---|
273 | <xul:observes element="vI_statusMenu_storage_save" attribute="checked" /> |
---|
274 | </xul:checkbox> |
---|
275 | <xul:spacer flex="1" /></xul:vbox> |
---|
276 | <xul:vbox><xul:spacer flex="1" /> |
---|
277 | <xul:label value="&vident.accPane.prettyName.prefix;" class="menu_clone-vid virtIdLabel" xbl:inherits="vid" crop="right"/> |
---|
278 | <xul:spacer flex="1" /></xul:vbox> |
---|
279 | <xul:observes element="vI_statusMenu_storage_save" attribute="checked" /> |
---|
280 | </xul:hbox> |
---|
281 | <xul:hbox id="baseIDHbox" class="baseIDHbox" > |
---|
282 | <xul:vbox><xul:spacer flex="1" /> |
---|
283 | <xul:hbox> |
---|
284 | <xul:label id="msgIdentity_base_id_label" class="menu_clone-description" xbl:inherits="value,hidden=base_id_key_hidden" crop="right" hidden="true"/> |
---|
285 | <xul:label id="msgIdentity_clone_label" class="menu_clone-description" xbl:inherits="value=description" crop="right"/> |
---|
286 | </xul:hbox> |
---|
287 | <xul:spacer flex="1" /></xul:vbox> |
---|
288 | <xul:vbox id="saveBaseIDSwitch"><xul:spacer flex="1" /> |
---|
289 | <xul:checkbox class="vI_plain" allowevents="true" oncommand="event.stopPropagation();vI_statusmenu.changeBaseIDStatus(this);" > |
---|
290 | <xul:observes element="vI_statusMenu_storage_saveBaseID" attribute="checked" /> |
---|
291 | <xul:observes element="vI_statusMenu_storage_saveBaseID" attribute="disabled" /> |
---|
292 | </xul:checkbox> |
---|
293 | <xul:spacer flex="1" /></xul:vbox> |
---|
294 | <xul:observes element="vI_statusMenu_storage_saveBaseID" attribute="checked" /> |
---|
295 | <xul:observes element="vI_statusMenu_storage_saveBaseID" attribute="disabled" /> |
---|
296 | </xul:hbox> |
---|
297 | <xul:hbox oncommand="event.stopPropagation();document.getBindingParent(this).smtp = this.smtp" anonid="smtpServerListHbox" class="smtpServerListHbox" /> |
---|
298 | </xul:hbox> |
---|
299 | <children /> |
---|
300 | </content> |
---|
301 | <implementation> |
---|
302 | <constructor> |
---|
303 | <![CDATA[ |
---|
304 | var inputTextbox = document.getAnonymousElementByAttribute(this, "class", "plain menulist_clone-textbox"); |
---|
305 | |
---|
306 | // check if 'search' textboxes are not implemented change to 'timed' |
---|
307 | if (!inputTextbox.timeout) inputTextbox.setAttribute("type", "timed"); |
---|
308 | inputTextbox.setAttribute("timeout", "300") |
---|
309 | |
---|
310 | // to ealy to access vI_tooltipPopupset, this might break the interface |
---|
311 | // it will be done in v_identity.js init |
---|
312 | // document.getElementById("vI_tooltipPopupset").addTooltip(this, false); |
---|
313 | |
---|
314 | this._prefroot.addObserver("extensions.virtualIdentity.show_smtp", this._observer, false); |
---|
315 | this._observer.observe(); |
---|
316 | ]]> |
---|
317 | </constructor> |
---|
318 | <destructor> |
---|
319 | <![CDATA[ |
---|
320 | document.getElementById("vI_tooltipPopupset") |
---|
321 | .removeTooltip(this.tooltipElem.getAttribute("tooltip")); |
---|
322 | this._prefroot.removeObserver("extensions.virtualIdentity.show_smtp", this._observer); |
---|
323 | ]]> |
---|
324 | </destructor> |
---|
325 | |
---|
326 | <!-- |
---|
327 | double the Identity-Select Dropdown-Menu to be more flexible with modifying it |
---|
328 | the original Identity Dropdown Menu is hidden and stores the base Identity, on which one |
---|
329 | the Virtual Identity is build upon |
---|
330 | --> |
---|
331 | <method name="command"> |
---|
332 | <body><![CDATA[ |
---|
333 | vI_notificationBar.dump("\n** v_identity.xml msgIdentityCloneElem.doCommand() \n") |
---|
334 | // copy selected Menu-Value from clone to orig. |
---|
335 | var MenuItems = this._msgIdentityPopupElem.childNodes |
---|
336 | for (var index = 0; index < MenuItems.length; index++) { |
---|
337 | if ( MenuItems[index].getAttribute("value") == this.selectedMenuItem.identityData.id.key ) { |
---|
338 | this._msgIdentityElem.selectedItem = MenuItems[index]; |
---|
339 | this._msgIdentityElem.value = MenuItems[index].getAttribute("value"); |
---|
340 | break; |
---|
341 | } |
---|
342 | } |
---|
343 | this._msgIdentityPopupElem.doCommand(); |
---|
344 | |
---|
345 | this.identityData = this.selectedMenuItem.identityData.getDuplicate(); |
---|
346 | |
---|
347 | // if current SMTP is empty, take the one from current Identity |
---|
348 | if (this.identityData.smtp.hasNoDefinedSMTP()) { |
---|
349 | this.identityData.smtp.key = gAccountManager.getIdentity(this.value).smtpServerKey; |
---|
350 | document.getAnonymousElementByAttribute(this, "anonid", "smtpServerListHbox").smtp = this.identityData.smtp.keyNice; |
---|
351 | this.checkForVirtualIdentity(); |
---|
352 | } |
---|
353 | ]]></body> |
---|
354 | </method> |
---|
355 | <method name="init"> |
---|
356 | <body><![CDATA[ |
---|
357 | var MenuItems = this._msgIdentityPopupElem.childNodes |
---|
358 | for (var index = 0; index < MenuItems.length; index++) { |
---|
359 | var identity = gAccountManager.getIdentity(MenuItems[index].getAttribute("value")); |
---|
360 | vI_notificationBar.dump("\n** newIdentity: " + " \n"); |
---|
361 | |
---|
362 | var description; |
---|
363 | var server = gAccountManager.GetServersForIdentity(identity).QueryElementAt(0, Components.interfaces.nsIMsgIncomingServer); |
---|
364 | // if (server.type == "nntp") |
---|
365 | description = server.prettyName |
---|
366 | // else description = identity.description?"- "+identity.description:identity.accountname |
---|
367 | |
---|
368 | var newIdentity = new identityData(identity.email, identity.fullName, identity.key, |
---|
369 | identity.smtpServerKey, null, description) |
---|
370 | newIdentity.extras.readIdentityValues(identity); |
---|
371 | |
---|
372 | var menuItem = this.addIdentityToCloneMenu(newIdentity) |
---|
373 | |
---|
374 | if (this._msgIdentity_selectedItem == MenuItems[index]) { |
---|
375 | this.selectedItem = menuItem; |
---|
376 | this.identityData = newIdentity.getDuplicate(); |
---|
377 | } |
---|
378 | } |
---|
379 | this._popupMenu_separator = true; |
---|
380 | ]]></body> |
---|
381 | </method> |
---|
382 | <method name="clean"> |
---|
383 | <body><![CDATA[ |
---|
384 | var MenuItems = this._popupElem.childNodes; |
---|
385 | while (MenuItems.length > 0) { |
---|
386 | try {MenuItems[0].clean();} catch (e) { }; |
---|
387 | this._popupElem.removeChild(MenuItems[0]) |
---|
388 | } |
---|
389 | this.selectedItem = null; |
---|
390 | this.identityData = null; |
---|
391 | |
---|
392 | this._menu_separator = null; |
---|
393 | ]]></body> |
---|
394 | </method> |
---|
395 | <method name="addIdentityToCloneMenu"> |
---|
396 | <parameter name="localIdentityData" /> |
---|
397 | <body><![CDATA[ |
---|
398 | var existingItem = this._isExistingCloneMenuItem(localIdentityData); |
---|
399 | if (!existingItem) { |
---|
400 | var MenuItem = document.createElement("menuitem"); |
---|
401 | MenuItem.identityData = localIdentityData; |
---|
402 | MenuItem.setAttribute("class", "identity_clone-popup-item"); |
---|
403 | MenuItem.setAttribute("type", "vIdentity"); // to prevent overriding with menuitem:not([type]) |
---|
404 | MenuItem.value = localIdentityData.id.key; // might be accessed before item is constructed |
---|
405 | |
---|
406 | // set vid explicitely |
---|
407 | if (this._popupMenu_separator) MenuItem.setAttribute("vid", "true"); |
---|
408 | else MenuItem.setAttribute("vid", "false"); |
---|
409 | |
---|
410 | this._popupElem.appendChild(MenuItem); |
---|
411 | return MenuItem; |
---|
412 | } |
---|
413 | else return existingItem; |
---|
414 | ]]></body> |
---|
415 | </method> |
---|
416 | <method name="addIdentitiesToCloneMenu"> |
---|
417 | <parameter name="identityCollection" /> |
---|
418 | <body><![CDATA[ |
---|
419 | for (var index = 0; index < identityCollection.number; index++) |
---|
420 | identityCollection.menuItems[index] = |
---|
421 | this.addIdentityToCloneMenu(identityCollection.identityDataCollection[index]) |
---|
422 | ]]></body> |
---|
423 | </method> |
---|
424 | <method name="_getMenuItemForIdentity"> |
---|
425 | <parameter name="identitykey" /> |
---|
426 | <body><![CDATA[ |
---|
427 | var MenuItems = this._popupElem.childNodes; |
---|
428 | for (var index = 0; index < MenuItems.length; index++) { |
---|
429 | if (MenuItems[index].value == identitykey) |
---|
430 | return MenuItems[index] |
---|
431 | } |
---|
432 | return null; |
---|
433 | ]]></body> |
---|
434 | </method> |
---|
435 | <property name="_popupMenu_separator" > |
---|
436 | <getter><![CDATA[ |
---|
437 | if (this._menu_separator) this._menu_separator.removeAttribute("hidden"); |
---|
438 | return this._menu_separator; |
---|
439 | ]]></getter> |
---|
440 | <setter><![CDATA[ |
---|
441 | if (!val) return; |
---|
442 | // add hidden separator as indicator that now only virtual identities are added |
---|
443 | this._menu_separator = document.createElement("menuseparator"); |
---|
444 | this._menu_separator.setAttribute("id", "vid_separator"); |
---|
445 | this._menu_separator.setAttribute("hidden", "true"); |
---|
446 | this._popupElem.appendChild(this._menu_separator) |
---|
447 | ]]></setter> |
---|
448 | </property> |
---|
449 | <property name="selectedMenuItem" > |
---|
450 | <getter><![CDATA[ |
---|
451 | return this.selectedItem; |
---|
452 | ]]></getter> |
---|
453 | <setter><![CDATA[ |
---|
454 | if (typeof(val) == "object") this.selectedItem = val |
---|
455 | else if (val == "default") |
---|
456 | this.selectedItem = this._getMenuItemForIdentity(gAccountManager.defaultAccount.defaultIdentity.key) |
---|
457 | else this.selectedItem = this._getMenuItemForIdentity(val) |
---|
458 | this.doCommand(); |
---|
459 | ]]></setter> |
---|
460 | </property> |
---|
461 | <method name="_isExistingCloneMenuItem"> |
---|
462 | <parameter name="localIdentityData" /> |
---|
463 | <body><![CDATA[ |
---|
464 | var MenuItems = this._popupElem.childNodes |
---|
465 | for (var j = 0; j < MenuItems.length; j++) { |
---|
466 | if (MenuItems[j].localName == "menuseparator") continue; |
---|
467 | if (MenuItems[j].identityData.equals(localIdentityData)) return MenuItems[j]; |
---|
468 | } |
---|
469 | return null; |
---|
470 | ]]></body> |
---|
471 | </method> |
---|
472 | <field name="_msgIdentityElem">document.getElementById("msgIdentity")</field> |
---|
473 | <field name="_msgIdentityPopupElem">document.getElementById("msgIdentityPopup")</field> |
---|
474 | <property name="_msgIdentity_selectedItem" > |
---|
475 | <getter><![CDATA[ |
---|
476 | if (!this._msgIdentityElem.selectedItem) { |
---|
477 | vI_notificationBar.dump("** v_identity.xml: msgIdentityElem.selectedItem not set, using first Menuitem\n"); |
---|
478 | this._msgIdentityElem.selectedItem = this._msgIdentityPopupElem.firstChild |
---|
479 | vI_notificationBar.dump("** v_identity.xml: msgIdentityElem.doCommand()\n"); |
---|
480 | this._msgIdentityElem.doCommand(); |
---|
481 | } |
---|
482 | return this._msgIdentityElem.selectedItem; |
---|
483 | ]]></getter> |
---|
484 | </property> |
---|
485 | <method name="blurEvent"> |
---|
486 | <body><![CDATA[ |
---|
487 | vI_notificationBar.dump("\n** v_identity.xml blurEvent") |
---|
488 | this.inputEvent(); // timeout might prevent inputEvent to fire before blurEvent |
---|
489 | |
---|
490 | this.label = this.identityData.combinedName; // add "<" and ">" to email if required |
---|
491 | this.setAttribute("label", this.label); |
---|
492 | ]]></body> |
---|
493 | </method> |
---|
494 | <method name="inputEvent"> |
---|
495 | <body><![CDATA[ |
---|
496 | vI_notificationBar.dump("\n** v_identity.xml inputEvent\n") |
---|
497 | |
---|
498 | this.identityData.combinedName = this.label; |
---|
499 | |
---|
500 | var existingIdentity = this.checkForVirtualIdentity(); |
---|
501 | if (existingIdentity) this.selectedMenuItem = existingIdentity; |
---|
502 | ]]></body> |
---|
503 | </method> |
---|
504 | <method name="checkForVirtualIdentity"> |
---|
505 | <body><![CDATA[ |
---|
506 | vI_notificationBar.dump("** v_identity.xml checkForVirtualIdentity: " + this.identityData.id.key + " '" + this.identityData.id.value + "'\n") |
---|
507 | var existingIdentity = this.identityData.isExistingIdentity(false); |
---|
508 | |
---|
509 | this.vid = (!existingIdentity); |
---|
510 | |
---|
511 | vI_msgIdentityCloneTools.signatureSwitch(existingIdentity); |
---|
512 | |
---|
513 | return existingIdentity; |
---|
514 | ]]></body> |
---|
515 | </method> |
---|
516 | <property name="smtp" onget="return this.identityData.smtp.key;" > // used to detect changes from SMTP-Menu |
---|
517 | <setter><![CDATA[ |
---|
518 | this.identityData.smtp.key = val; |
---|
519 | |
---|
520 | document.getElementById("vI_tooltipPopupset").addTooltip(this); |
---|
521 | |
---|
522 | var existingIdentity = this.checkForVirtualIdentity(); |
---|
523 | if (existingIdentity) this.selectedMenuItem = existingIdentity; |
---|
524 | ]]></setter> |
---|
525 | </property> |
---|
526 | <property name="identityData"> |
---|
527 | <getter><![CDATA[ |
---|
528 | this._identityDataStorage.extras.readValues(); // update with current data |
---|
529 | return this._identityDataStorage; |
---|
530 | ]]></getter> |
---|
531 | <setter><![CDATA[ |
---|
532 | vI_notificationBar.dump("** v_identity.xml identityData setter\n") |
---|
533 | if (!val) this._identityDataStorage = null |
---|
534 | else { |
---|
535 | var oldIdentityData = this._identityDataStorage; |
---|
536 | this._identityDataStorage = val; |
---|
537 | |
---|
538 | if (oldIdentityData) { // indicates that it's not first time after clean |
---|
539 | if (!this._identityDataStorage.id.key) { |
---|
540 | this._identityDataStorage.id.key = oldIdentityData.id.key; |
---|
541 | var idName = this._identityDataStorage.id.value; |
---|
542 | this._identityDataStorage.sideDescription = (idName)?" - "+idName:""; |
---|
543 | vI_notificationBar.dump("** v_identity.xml set new Id: " + this._identityDataStorage.id.key + " '" + this._identityDataStorage.id.value + "'\n") |
---|
544 | } |
---|
545 | this._identityDataStorage.extras.setValues(); |
---|
546 | |
---|
547 | this.checkForVirtualIdentity(); |
---|
548 | } |
---|
549 | else this.vid = false; // first time after clean it's always a real identity |
---|
550 | |
---|
551 | this.label = this._identityDataStorage.combinedName; |
---|
552 | this.value = this._identityDataStorage.id.key; |
---|
553 | vI_notificationBar.dump("** v_identity.xml identityData setter value='" + this.value + "'\n") |
---|
554 | this.description = this._identityDataStorage.sideDescription; |
---|
555 | vI_notificationBar.dump("** v_identity.xml identityData setter smtp='" + this._identityDataStorage.smtp.keyNice + "'\n") |
---|
556 | document.getAnonymousElementByAttribute(this, "anonid", "smtpServerListHbox").smtp = this._identityDataStorage.smtp.keyNice; |
---|
557 | |
---|
558 | } |
---|
559 | // vI_notificationBar.dump("** v_identity.xml identityData setter done.'\n") |
---|
560 | ]]></setter> |
---|
561 | </property> |
---|
562 | <field name="_popupElem">document.getElementById("msgIdentityPopup_clone")</field> |
---|
563 | <field name="tooltipElem">document.getAnonymousElementByAttribute(this, "anonid", "contentHBox")</field> |
---|
564 | <field name="textBoxElem">document.getAnonymousElementByAttribute(this, "anonid", "textBox");</field> |
---|
565 | <field name="_prefroot">Components.classes["@mozilla.org/preferences-service;1"] |
---|
566 | .getService(Components.interfaces.nsIPrefService) |
---|
567 | .getBranch(null).QueryInterface(Components.interfaces.nsIPrefBranch2)</field> |
---|
568 | <field name="_observer"><![CDATA[({ |
---|
569 | _self: this, |
---|
570 | observe: function(aSubject, aTopic, aPrefName) { |
---|
571 | if (this._self._prefroot) |
---|
572 | this._self.showSmtp = |
---|
573 | this._self._prefroot.getBoolPref("extensions.virtualIdentity.show_smtp"); |
---|
574 | var MenuItems = this._self._popupElem.childNodes; |
---|
575 | for (var j = 0; j < MenuItems.length; j++) { |
---|
576 | if (MenuItems[j].localName == "menuseparator") continue; |
---|
577 | MenuItems[j].smtpStyle = "width:" + document.getElementById("smtp_server_list").clientWidth + "px;"; |
---|
578 | } |
---|
579 | } |
---|
580 | })]]></field> |
---|
581 | <property name="email" onset="this.identityData.email = val; this.label = this.identityData.combinedName; this.inputEvent()" /> |
---|
582 | <property name="vid" onget="return (this.getAttribute('vid') == 'true');" onset="this.setAttribute('vid',val?'true':'false'); return val;" /> |
---|
583 | <property name="label" onget="return this.textBoxElem.value;" onset="this.textBoxElem.value = val; return val;" /> |
---|
584 | <property name="value" onget="return this.getAttribute('value');" onset="this.setAttribute('value', val); return val;" /> |
---|
585 | <property name="extras" onget="return this.identityData.extras;" /> |
---|
586 | <property name="description" onget="return this.getAttribute('description');" onset="this.setAttribute('description', val); return val;" /> |
---|
587 | <property name="showSmtp" onget="return (this.getAttribute('showSmtp') == 'true');" onset="this.setAttribute('showSmtp',val?'true':'false'); return val;" /> |
---|
588 | </implementation> |
---|
589 | </binding> |
---|
590 | </bindings> |
---|