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

source: chrome/content/v_identity/v_identity.xml @ 2a4365

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

prevent id pollution

  • Property mode set to 100644
File size: 28.4 KB
Line 
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="vI_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 = "virtualIdentityExtension_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" type="chrome" 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            virtualIdentityExtension.notificationBar.dump("** v_identity.xml vI_tooltipPopupset popupshowing.\n")
75        if (!this._identityInfo) {
76            this._identityInfo =
77                "<table><tr>" +
78                    "<td class='image'><img src='chrome://v_identity/skin/vi-info.png' /></td>" +
79                    "<td class='identityTable'>" +
80                        "<div class='name'>" + this.elem.identityData.combinedNameHtml + "</div>" +
81                        "<table><tbody>" + this.elem.identityData.getMatrix() + "</tbody></table>" +
82                    "</td>" +
83                "</tr></table>"
84            virtualIdentityExtension.notificationBar.dump("** v_identity.xml added tooltip with id='" +  this.elem.identityData.id.key + "'\n")
85            this._tooltipBrowser.outputString = this._identityInfo;
86        }
87        virtualIdentityExtension.notificationBar.dump("** v_identity.xml vI_tooltipPopupset popupshowing done.\n")
88        ]]></body>
89    </method>
90    <method name ="popuphidden">
91            <body><![CDATA[
92        if (!this.permanent) this._identityInfo = null;
93        ]]></body>
94    </method>   
95    <method name="resize">
96        <body><![CDATA[
97        if (!this._identityInfo) return;
98        var width = document.getElementById("msgIdentity_clone").boxObject.width * 0.7;
99        var height = this._tooltipBrowser.contentDocument.lastChild.scrollHeight + 5;
100        this.sizeTo(width, height);
101        width = document.getElementById("msgIdentity_clone").boxObject.width * 0.75;
102        this.sizeTo(width, height);
103        ]]></body>
104    </method>
105    <field name="permanent" />
106    <field name="elem" />
107<!--    <field name="identityData">this.elem.identityData</field> -->
108    <field name="_identityInfo">false</field>
109<!--    <field name="_initialized">false</field> -->
110    <field name="_tooltipBrowser">document.getAnonymousElementByAttribute(this, "anonid", "tooltipBrowser")</field>
111    </implementation>
112    </binding> 
113   
114    <binding id="fromPopupItem_clone" extends="chrome://global/content/bindings/menu.xml#menuitem">
115    <content excludes="template,observes,menupopup">
116        <xul:image class="menupopup_clone-icon" xbl:inherits="src"/>
117        <xul:label class="menupopup_clone-text" xbl:inherits="value=label,accesskey,crop" crop="right" flex="1"/>
118        <xul:label value="&vident.accPane.prettyName.prefix;" class="menupopup_clone-vid virtIdLabel" vid="false" xbl:inherits="vid" crop="right"/>
119            <xul:label class="menupopup_clone-description" xbl:inherits="value=description" crop="right"/>
120        <xul:label class="menupopup_clone-smtp" xbl:inherits="value=smtp,style=smtpStyle" crop="right"/>
121    </content>
122    <implementation>
123    <constructor>
124        <![CDATA[
125        this._identityDataStorage = this.identityData;
126       
127        this.label = this._identityDataStorage.combinedName;
128        this.value = this._identityDataStorage.id.key;
129        virtualIdentityExtension.notificationBar.dump("** v_identity.xml fromPopupItem_clone constructor id='" + this.value + "'.\n")
130
131        this.description = this._identityDataStorage.sideDescription;
132        this.smtp = this._identityDataStorage.smtp.value;
133        virtualIdentityExtension.notificationBar.dump("** v_identity.xml fromPopupItem_clone constructor smtp='" + this.smtp + "'.\n")
134        this.smtpStyle = "width:" + document.getElementById("smtp_server_list").clientWidth + "px;";
135        this._identityDataStorage.smtp.value;
136       
137        document.getElementById("virtualIdentityExtension_tooltipPopupset").addTooltip(this, true);
138        ]]>
139    </constructor>
140    <method name="clean">
141            <body><![CDATA[
142        document.getElementById("virtualIdentityExtension_tooltipPopupset")
143            .removeTooltip(this.tooltipElem.getAttribute("tooltip"));
144        ]]></body>
145    </method>
146    <destructor>
147        <![CDATA[
148        this.clean();
149        ]]>
150    </destructor>
151    <property name="_identityData" onget="return this._identityDataStorage;" />
152    <field name="tooltipElem">this</field>
153    <property name="vid" onget="return this.getAttribute('vid');" onset="this.setAttribute('vid', val); return val;" />
154    <property name="label" onget="return this.getAttribute('label');" onset="this.setAttribute('label', val); return val;" />
155    <property name="value" onget="return this.getAttribute('value');" onset="this.setAttribute('value', val); return val;" />
156    <property name="description" onget="return this.getAttribute('description');" onset="this.setAttribute('description', val); return val;" />
157    <property name="smtp" onget="return this.getAttribute('smtp');" onset="this.setAttribute('smtp', val); return val;" />
158    <property name="smtpStyle" onget="return this.getAttribute('smtpStyle');" onset="this.setAttribute('smtpStyle', val); return val;" />
159    </implementation>
160    </binding>
161
162    <binding id="smtpServerList">
163    <resources>
164            <stylesheet src="chrome://global/skin/menu.css"/>
165    </resources>
166    <content sizetopopup="pref">
167        <xul:hbox id="smtpServerHbox" class="smtpServerHbox">
168            <xul:menulist class="smtpServerMenuList" anonid="smtpServerMenuList" allowevents="true" id="smtp_server_list">
169                <xul:menupopup anonid="smtp_server_list_popup" />
170            </xul:menulist>
171            <xul:checkbox  id="saveSMTPSwitch" class="vI_plain" allowevents="true" oncommand="event.stopPropagation();virtualIdentityExtension.statusmenu.changeSMTPStatus(this);" >
172                <xul:observes element="virtualIdentityExtension_statusMenu_storage_saveSMTP" attribute="checked" />
173                <xul:observes element="virtualIdentityExtension_statusMenu_storage_saveSMTP" attribute="disabled" />
174            </xul:checkbox>
175            <xul:observes element="virtualIdentityExtension_statusMenu_storage_saveSMTP" attribute="checked" />
176            <xul:observes element="virtualIdentityExtension_statusMenu_storage_saveSMTP" attribute="disabled" />
177        </xul:hbox>
178    </content>
179    <implementation>
180    <method name="addNoneServer">
181        <body><![CDATA[
182        var listitem = document.createElement("menuitem");
183        listitem.setAttribute("class", "menuitem-non-iconic");
184        listitem.setAttribute("type", "non-iconic-noaccel");
185        listitem.setAttribute("label", " ");
186        listitem.setAttribute("key", virtualIdentityExtension.NO_SMTP_TAG);
187        this._smtpPopup.insertBefore(listitem, this._smtpPopup.firstChild);
188        this._smtpMenu.selectedItem = listitem;
189        ]]></body>
190    </method>
191    <method name="_addDefaultServer">
192            <body><![CDATA[
193        var listitem = document.createElement("menuitem");
194        listitem.setAttribute("class", "menuitem-non-iconic");
195        listitem.setAttribute("type", "non-iconic-noaccel");
196        listitem.setAttribute("label", document.getElementById("bundle_messenger").getString("defaultServerTag"));
197        this._smtpPopup.appendChild(listitem);
198        this._smtpMenu.selectedItem = listitem;
199        ]]></body>
200    </method>
201    <method name="_addServer">
202        <parameter name="server" />
203            <body><![CDATA[
204        if (server instanceof Components.interfaces.nsISmtpServer && !server.redirectorType) {
205            var listitem = document.createElement("menuitem");
206            listitem.setAttribute("class", "menuitem-non-iconic");
207            listitem.setAttribute("type", "non-iconic-noaccel");
208            listitem.setAttribute("label", (server.description?server.description:server.hostname));
209            listitem.setAttribute("key", server.key);
210            this._smtpPopup.appendChild(listitem);
211        }
212        ]]></body>
213    </method>
214    <method name="refresh">
215        <body><![CDATA[
216            this.unload();
217            this.load();
218        ]]></body>
219    </method>
220    <method name="load">
221        <body><![CDATA[
222            this._addDefaultServer();
223            this._smtpPopup.appendChild(document.createElement("menuseparator"));
224
225            var servers = Components.classes["@mozilla.org/messengercompose/smtp;1"]
226                .getService(Components.interfaces.nsISmtpService).smtpServers;
227           
228            while (servers && servers.hasMoreElements())
229                this._addServer(servers.getNext());
230        ]]></body>
231    </method>
232    <method name="unload">
233        <body><![CDATA[
234            var MenuItems = this._smtpPopup.childNodes
235            while (MenuItems.length > 0) { this._smtpPopup.removeChild(MenuItems[0]) }
236            this._smtpMenu.selectedItem = null;
237        ]]></body>
238    </method>
239    <constructor>
240        <![CDATA[
241            this.load();
242        ]]>
243    </constructor>
244    <property name="smtp" onget="return this._smtpMenu.selectedItem.getAttribute('key');" >
245        <setter><![CDATA[
246        if (val == virtualIdentityExtension.NO_SMTP_TAG) return; // dont overwrite if not set
247        virtualIdentityExtension.notificationBar.dump("** v_identity.xml smtp set to '" + val + "'\n")
248        var MenuItems = this._smtpPopup.childNodes
249        for (var index = 0; index < MenuItems.length; index++) {
250            if (MenuItems[index].localName == "menuseparator") continue;
251            if (MenuItems[index].getAttribute("key") == val) {
252                this._smtpMenu.selectedItem = MenuItems[index];
253                break;
254            }
255        }
256        ]]></setter>
257    </property>
258    <field name="_smtpPopup">document.getAnonymousElementByAttribute(this, "anonid", "smtp_server_list_popup")</field>
259    <field name="_smtpMenu">document.getAnonymousElementByAttribute(this, "anonid", "smtpServerMenuList")</field>
260    <field name="_smtpService"></field>
261
262    </implementation>
263    </binding>
264   
265   
266   
267   
268    <binding id="fromMenuList_clone" display="xul:menu" extends="chrome://global/content/bindings/menulist.xml#menulist-description">
269    <resources>
270            <stylesheet src="chrome://global/skin/menu.css"/>
271        <stylesheet src="chrome://global/skin/autocomplete.css"/>
272    </resources>
273    <content sizetopopup="pref">
274        <xul:hbox class="contentHBox" anonid="contentHBox" flex="1"  >
275            <xul:hbox id="identityHbox" class="identityHbox" flex="1">
276                <xul:vbox><xul:spacer flex="1" />
277                    <xul:image class="menulist_clone-icon" id="msgIdentity_clone_image" xbl:inherits="src"/>
278                <xul:spacer flex="1" /></xul:vbox>
279                <xul:vbox flex="1" id="msgIdentity_clone_fromVbox"><xul:spacer flex="1" />
280<!--                    textbox is internally an html:input field which inherits the onblur event.
281                    Thats why we have to search the textbox before calling blurEvent() -->
282                    <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();"
283                    onblur="event.stopPropagation(); var elem = this; while (elem.localName != 'textbox') elem = elem.parentNode; document.getBindingParent(elem).blurEvent();"
284                    crop="right" highlightnonmatches="true"/>
285                <xul:spacer flex="1" /></xul:vbox>
286                <xul:vbox id="saveSwitch"><xul:spacer flex="1" />
287                    <xul:checkbox class="vI_plain" allowevents="true" oncommand="event.stopPropagation();virtualIdentityExtension.statusmenu.changeSaveStatus(this);" >
288                        <xul:observes element="virtualIdentityExtension_statusMenu_storage_save" attribute="checked" />
289                    </xul:checkbox>
290                <xul:spacer flex="1" /></xul:vbox>
291                <xul:vbox><xul:spacer flex="1" />
292                    <xul:label value="&vident.accPane.prettyName.prefix;" class="menu_clone-vid virtIdLabel" xbl:inherits="vid" crop="right"/>
293                <xul:spacer flex="1" /></xul:vbox>
294                <xul:observes element="virtualIdentityExtension_statusMenu_storage_save" attribute="checked" />
295            </xul:hbox>
296            <xul:hbox id="baseIDHbox" class="baseIDHbox" >
297                <xul:vbox><xul:spacer flex="1" />
298                    <xul:hbox>
299                        <xul:label id="msgIdentity_base_id_label" class="menu_clone-description" xbl:inherits="value,hidden=base_id_key_hidden" crop="right" hidden="true"/>
300                        <xul:label id="msgIdentity_clone_label" class="menu_clone-description" xbl:inherits="value=description" crop="right"/>
301                    </xul:hbox>
302                <xul:spacer flex="1" /></xul:vbox>
303                <xul:vbox id="saveBaseIDSwitch"><xul:spacer flex="1" />
304                    <xul:checkbox class="vI_plain" allowevents="true" oncommand="event.stopPropagation();virtualIdentityExtension.statusmenu.changeBaseIDStatus(this);" >
305                        <xul:observes element="virtualIdentityExtension_statusMenu_storage_saveBaseID" attribute="checked" />
306                        <xul:observes element="virtualIdentityExtension_statusMenu_storage_saveBaseID" attribute="disabled" />
307                    </xul:checkbox>
308                <xul:spacer flex="1" /></xul:vbox>
309                <xul:observes element="virtualIdentityExtension_statusMenu_storage_saveBaseID" attribute="checked" />
310                <xul:observes element="virtualIdentityExtension_statusMenu_storage_saveBaseID" attribute="disabled" />
311            </xul:hbox>
312            <xul:hbox oncommand="event.stopPropagation();document.getBindingParent(this).smtp = this.smtp" xbl:inherits="showSmtp" anonid="smtpServerListHbox" class="smtpServerListHbox" />
313        </xul:hbox>
314        <children />
315    </content>
316        <implementation>
317    <constructor>
318        <![CDATA[       
319        var inputTextbox = document.getAnonymousElementByAttribute(this, "class", "plain menulist_clone-textbox");
320       
321        // check if 'search' textboxes are not implemented change to 'timed'
322        if (!inputTextbox.timeout) inputTextbox.setAttribute("type", "timed");
323        inputTextbox.setAttribute("timeout", "300")
324       
325        // too early to access virtualIdentityExtension_tooltipPopupset, this might break the interface
326        // it will be done in v_identity.js init
327        // document.getElementById("virtualIdentityExtension_tooltipPopupset").addTooltip(this, false);
328       
329        this._prefroot.addObserver("extensions.virtualIdentity.show_smtp", this._observer, false);
330        this._observer.observe();
331        ]]>
332    </constructor>
333    <destructor>
334        <![CDATA[
335        var tooltipPopupset = document.getElementById("virtualIdentityExtension_tooltipPopupset")
336        if (tooltipPopupset) tooltipPopupset.removeTooltip(this.tooltipElem.getAttribute("tooltip"));
337        this._prefroot.removeObserver("extensions.virtualIdentity.show_smtp", this._observer);
338        ]]>
339    </destructor>
340
341    <!--
342    double the Identity-Select Dropdown-Menu to be more flexible with modifying it
343    the original Identity Dropdown Menu is hidden and stores the base Identity, on which one
344    the Virtual Identity is build upon
345    -->
346    <method name="command">
347        <body><![CDATA[
348        virtualIdentityExtension.notificationBar.dump("\n** v_identity.xml msgIdentityCloneElem.doCommand() \n")
349        virtualIdentityExtension.notificationBar.dump("\n** v_identity.xml msgIdentityCloneElem.doCommand() \n")
350        // copy selected Menu-Value from clone to orig.
351        virtualIdentityExtension.notificationBar.dump("** v_identity.xmlcopy selected Menu-Value from clone to orig. Searching for id=" + this.selectedMenuItem.identityData.id.key + " \n")
352        if ( this.selectedMenuItem.identityData.id.key != null ) {
353            var MenuItems = this._msgIdentityPopupElem.childNodes
354            for (var index = 0; index < MenuItems.length; index++) {
355                if ( MenuItems[index].getAttribute("value") == this.selectedMenuItem.identityData.id.key ) {
356                    this._msgIdentityElem.selectedItem = MenuItems[index];
357                    this._msgIdentityElem.value = MenuItems[index].getAttribute("value");
358                    break;
359                }
360            }
361            this._msgIdentityPopupElem.doCommand();
362        }
363        this.identityData = this.selectedMenuItem.identityData.getDuplicate();
364        virtualIdentityExtension.notificationBar.dump("\n** v_identity.xml msgIdentityCloneElem.doCommand() this.value=" + this.value + "\n");
365        // if current SMTP is empty, take the one from current Identity
366        if (this.identityData.smtp.hasNoDefinedSMTP()) {
367            this.identityData.smtp.key = gAccountManager.getIdentity(this.value).smtpServerKey;
368            document.getAnonymousElementByAttribute(this, "anonid", "smtpServerListHbox").smtp = this.identityData.smtp.keyNice;
369            this.checkForVirtualIdentity();
370        }
371    ]]></body>
372    </method>   
373    <method name="init">
374        <body><![CDATA[
375        var MenuItems = this._msgIdentityPopupElem.childNodes
376        for (var index = 0; index < MenuItems.length; index++) {
377            var identity = gAccountManager.getIdentity(MenuItems[index].getAttribute("value"));
378           
379            var description;
380            var server = gAccountManager.GetServersForIdentity(identity).QueryElementAt(0, Components.interfaces.nsIMsgIncomingServer);
381            // if (server.type == "nntp")
382                description = server.prettyName
383            // else description = identity.description?"- "+identity.description:identity.accountname
384           
385            var newIdentity = new virtualIdentityExtension.identityData(identity.email, identity.fullName, identity.key,
386                        identity.smtpServerKey, null, description, true)
387            newIdentity.extras.readIdentityValues(identity);
388               
389            var menuItem = this.addIdentityToCloneMenu(newIdentity)
390
391            if (this._msgIdentity_selectedItem == MenuItems[index]) {
392                this.selectedItem = menuItem;
393                this.identityData = newIdentity.getDuplicate();
394            }
395        }
396        this._popupMenu_separator = true;
397        ]]></body>
398    </method>
399    <method name="clean">
400        <body><![CDATA[
401        var MenuItems = this._popupElem.childNodes;
402        while (MenuItems.length > 0) {
403            try {MenuItems[0].clean();} catch (e) { };
404            this._popupElem.removeChild(MenuItems[0])
405        }
406        this.selectedItem = null;
407        this.identityData = null;
408       
409        this._menu_separator = null;
410        ]]></body>
411    </method>   
412    <method name="addIdentityToCloneMenu">
413        <parameter name="localIdentityData" />
414        <body><![CDATA[
415        var existingItem = this._isExistingCloneMenuItem(localIdentityData);
416        if (!existingItem) {
417            var MenuItem = document.createElement("menuitem");
418                MenuItem.identityData = localIdentityData;
419            MenuItem.setAttribute("class", "identity_clone-popup-item");
420            MenuItem.setAttribute("type", "vIdentity"); // to prevent overriding with menuitem:not([type])
421            MenuItem.value = localIdentityData.id.key; // might be accessed before item is constructed
422
423            // set vid explicitely
424            if (this._popupMenu_separator) MenuItem.setAttribute("vid", "true");
425            else    MenuItem.setAttribute("vid", "false");
426                       
427            this._popupElem.appendChild(MenuItem);
428            return MenuItem;
429        }
430        else return existingItem;
431        ]]></body>
432    </method>
433    <method name="addIdentitiesToCloneMenu">
434        <parameter name="identityCollection" />
435        <body><![CDATA[
436        for (var index = 0; index < identityCollection.number; index++)
437            identityCollection.menuItems[index] =
438                this.addIdentityToCloneMenu(identityCollection.identityDataCollection[index])
439        ]]></body>
440    </method>
441    <method name="_getMenuItemForIdentity">
442        <parameter name="identitykey" />
443        <body><![CDATA[
444        var MenuItems = this._popupElem.childNodes;
445        for (var index = 0; index < MenuItems.length; index++) {
446            if (MenuItems[index].value == identitykey)
447                return MenuItems[index]
448        }
449        return null;
450        ]]></body>
451    </method>
452    <property name="_popupMenu_separator" >
453        <getter><![CDATA[
454            if (this._menu_separator) this._menu_separator.removeAttribute("hidden");
455            return this._menu_separator;
456        ]]></getter>
457        <setter><![CDATA[
458            if (!val) return;
459            // add hidden separator as indicator that now only virtual identities are added
460            this._menu_separator = document.createElement("menuseparator");
461            this._menu_separator.setAttribute("id", "vid_separator");
462            this._menu_separator.setAttribute("hidden", "true");
463            this._popupElem.appendChild(this._menu_separator)
464        ]]></setter>   
465    </property>
466    <property name="selectedMenuItem" >
467        <getter><![CDATA[
468            return this.selectedItem;
469        ]]></getter>
470        <setter><![CDATA[
471            if (typeof(val) == "object") this.selectedItem = val
472            else if (val == "default")
473                this.selectedItem = this._getMenuItemForIdentity(gAccountManager.defaultAccount.defaultIdentity.key)
474            else this.selectedItem = this._getMenuItemForIdentity(val)
475            this.doCommand();
476        ]]></setter>   
477    </property>
478    <method name="_isExistingCloneMenuItem">
479        <parameter name="localIdentityData" />
480        <body><![CDATA[
481        var MenuItems = this._popupElem.childNodes
482        for (var j = 0; j < MenuItems.length; j++) {
483            if (MenuItems[j].localName == "menuseparator") continue;
484            if (MenuItems[j].identityData.equals(localIdentityData)) return MenuItems[j];
485        }
486        return null;
487        ]]></body>
488    </method>
489    <field name="_msgIdentityElem">document.getElementById("msgIdentity")</field>
490    <field name="_msgIdentityPopupElem">document.getElementById("msgIdentityPopup")</field>
491    <property name="_msgIdentity_selectedItem" >
492        <getter><![CDATA[
493            if (!this._msgIdentityElem.selectedItem) {
494                virtualIdentityExtension.notificationBar.dump("** v_identity.xml: msgIdentityElem.selectedItem not set, using first Menuitem\n");
495                this._msgIdentityElem.selectedItem = this._msgIdentityPopupElem.firstChild
496                virtualIdentityExtension.notificationBar.dump("** v_identity.xml: msgIdentityElem.doCommand()\n");
497                this._msgIdentityElem.doCommand();
498            }
499            return this._msgIdentityElem.selectedItem;
500        ]]></getter>
501    </property> 
502    <method name="blurEvent">
503            <body><![CDATA[
504        virtualIdentityExtension.notificationBar.dump("\n** v_identity.xml blurEvent")
505        this.inputEvent(); // timeout might prevent inputEvent to fire before blurEvent
506       
507        this.label = this.identityData.combinedName; // add "<" and ">" to email if required
508        this.setAttribute("label", this.label);
509        ]]></body>
510    </method>
511    <method name="inputEvent">
512            <body><![CDATA[     
513        virtualIdentityExtension.notificationBar.dump("\n** v_identity.xml inputEvent\n")
514       
515        this.identityData.combinedName = this.label;
516       
517        var existingIdentity = this.checkForVirtualIdentity();
518        if (existingIdentity && this.selectedMenuItem.value != existingIdentity) this.selectedMenuItem = existingIdentity;
519        ]]></body>
520    </method>
521    <method name="checkForVirtualIdentity">
522        <body><![CDATA[
523        virtualIdentityExtension.notificationBar.dump("** v_identity.xml checkForVirtualIdentity: " + this.identityData.id.key + " '" + this.identityData.id.value + "'\n")
524        var existingIdentity = this.identityData.isExistingIdentity(false);
525       
526        this.vid = (!existingIdentity);
527       
528        virtualIdentityExtension.msgIdentityCloneTools.signatureSwitch(existingIdentity);
529       
530        return existingIdentity;
531        ]]></body>
532    </method>
533    <property name="smtp" onget="return this.identityData.smtp.key;" > // used to detect changes from SMTP-Menu
534        <setter><![CDATA[
535        this.identityData.smtp.key = val;
536       
537        document.getElementById("virtualIdentityExtension_tooltipPopupset").addTooltip(this);
538
539        var existingIdentity = this.checkForVirtualIdentity();
540        if (existingIdentity) this.selectedMenuItem = existingIdentity;
541        ]]></setter>
542    </property>
543    <property name="identityData">
544        <getter><![CDATA[
545        this._identityDataStorage.extras.readValues(); // update with current data
546        return this._identityDataStorage;
547        ]]></getter>
548        <setter><![CDATA[
549        virtualIdentityExtension.notificationBar.dump("** v_identity.xml identityData setter\n")
550        if (!val) this._identityDataStorage = null
551        else {
552            var oldIdentityData = this._identityDataStorage;
553            this._identityDataStorage = val;
554            if (oldIdentityData) { // indicates that it's not first time after clean
555                virtualIdentityExtension.notificationBar.dump("** v_identity.xml previousID: fullName='" + oldIdentityData.fullName + "' email='" + oldIdentityData.email + "' smtp='" + oldIdentityData.smtp.key + "' id='" + oldIdentityData.id.key + "' existingID='" + oldIdentityData.existingID + "'\n");
556                virtualIdentityExtension.notificationBar.dump("** v_identity.xml newID: fullName='" + this._identityDataStorage.fullName + "' email='" + this._identityDataStorage.email + "' smtp='" + this._identityDataStorage.smtp.key + "' id='" + this._identityDataStorage.id.key + "' existingID='" + this._identityDataStorage.existingID + "'\n");
557                if (!this._identityDataStorage.existingID && !this._identityDataStorage.combinedName)
558                    this._identityDataStorage.fullName = oldIdentityData.fullName;
559                if (!this._identityDataStorage.existingID && !this._identityDataStorage.email)
560                    this._identityDataStorage.email = oldIdentityData.email;
561                if (!this._identityDataStorage.smtp.key) this._identityDataStorage.smtp.key = oldIdentityData.smtp.key;
562                if (!this._identityDataStorage.id.key) this._identityDataStorage.id.key = oldIdentityData.id.key;
563                this._identityDataStorage.extras.setValues();
564                if (this._identityDataStorage.existingID) this.vid = false;
565                else this.checkForVirtualIdentity();
566            }
567            else    this.vid = false;       // first time after clean it's always a real identity
568           
569            this.label = this._identityDataStorage.combinedName;
570            this.value = this._identityDataStorage.id.key;
571            this.description = this._identityDataStorage.sideDescription;
572            document.getAnonymousElementByAttribute(this, "anonid", "smtpServerListHbox").smtp = this._identityDataStorage.smtp.keyNice;
573            virtualIdentityExtension.notificationBar.dump("** v_identity.xml resultingID: fullName='" + this._identityDataStorage.fullName + "' email='" + this._identityDataStorage.email + "' smtp='" + this._identityDataStorage.smtp.key + "' id='" + this._identityDataStorage.id.key + "' existingID='" + this._identityDataStorage.existingID + "'\n");         
574        }
575        virtualIdentityExtension.notificationBar.dump("** v_identity.xml identityData setter done.'\n")
576        ]]></setter>
577    </property>
578    <field name="_popupElem">document.getElementById("msgIdentityPopup_clone")</field>
579    <field name="tooltipElem">document.getAnonymousElementByAttribute(this, "anonid", "contentHBox")</field>
580    <field name="textBoxElem">document.getAnonymousElementByAttribute(this, "anonid", "textBox");</field>
581    <field name="_prefroot">Components.classes["@mozilla.org/preferences-service;1"]
582        .getService(Components.interfaces.nsIPrefService)
583        .getBranch(null).QueryInterface(Components.interfaces.nsIPrefBranch2)</field>
584    <field name="_observer"><![CDATA[({
585        _self: this,
586            observe: function(aSubject, aTopic, aPrefName) {
587            if (this._self._prefroot)
588                this._self.showSmtp =
589                this._self._prefroot.getBoolPref("extensions.virtualIdentity.show_smtp");
590                var MenuItems = this._self._popupElem.childNodes;
591                for (var j = 0; j < MenuItems.length; j++) {
592                    if (MenuItems[j].localName == "menuseparator") continue;
593                    MenuItems[j].smtpStyle = "width:" + document.getElementById("smtp_server_list").clientWidth + "px;";
594                }
595        }
596        })]]></field>
597    <property name="email" onset="this.identityData.email = val; this.label = this.identityData.combinedName; this.inputEvent()" />
598    <property name="vid" onget="return (this.getAttribute('vid') == 'true');" onset="this.setAttribute('vid',val?'true':'false'); return val;" />
599    <property name="label" onget="return this.textBoxElem.value;" onset="this.textBoxElem.value = val; return val;" />
600    <property name="value" onget="return this.getAttribute('value');" onset="this.setAttribute('value', val); return val;" />
601    <property name="extras" onget="return this.identityData.extras;" />
602    <property name="description" onget="return this.getAttribute('description');" onset="this.setAttribute('description', val); return val;" />
603    <property name="showSmtp" onget="return (this.getAttribute('showSmtp') == 'true');" onset="this.setAttribute('showSmtp',val?'true':'false'); return val;" />
604    </implementation>
605    </binding>
606</bindings>
Note: See TracBrowser for help on using the repository browser.