source: chrome/content/v_identity/vI_rdfAccountMismatchDialog.xml @ 2e8903

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

dialog to re-assign mismatched identities / smtps

  • Property mode set to 100644
File size: 10.2 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<bindings id="rdfMismatchBindings"
27          xmlns="http://www.mozilla.org/xbl"
28          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
29          xmlns:xbl="http://www.mozilla.org/xbl">
30   
31    <binding id="mismatch-line">
32    <content>     
33        <xul:label class="identityDesc-name" xbl:inherits="value=label,accesskey,crop" crop="end" flex="1"/>
34        <xul:label class="identityDesc-ext1" xbl:inherits="value=ext1" crop="end" />
35        <xul:label class="identityDesc-ext2" xbl:inherits="value=ext2" crop="end" />
36        <xul:label class="identityDesc-count" xbl:inherits="value=count" crop="end" />
37        <xul:menulist class="mismatchMenulist" >
38            <xul:menupopup class="mismatchMenupopup" xbl:inherits="type" />
39        </xul:menulist>
40    </content>
41    <implementation>
42    <property name="key" >
43        <getter><![CDATA[
44            return document.getAnonymousElementByAttribute(this, "class", "mismatchMenulist").selectedItem.getAttribute("key");
45        ]]></getter>
46    </property>
47    </implementation>
48    </binding>
49         
50    <binding id="mismatch-menuitem" extends="chrome://global/content/bindings/menu.xml#menuitem">
51    <content>
52        <xul:label class="identityDesc-name" xbl:inherits="value=label,accesskey,crop" crop="end" flex="1"/>
53        <xul:label class="identityDesc-ext1" xbl:inherits="value=ext1" crop="end" />
54        <xul:label class="identityDesc-ext2" xbl:inherits="value=ext2" crop="end" />
55    </content>
56    </binding>
57   
58    <binding id="mismatch-menulist" extends="chrome://global/content/bindings/menulist.xml#menulist">
59    <content>
60        <xul:hbox class="menulist-label-box" flex="1">
61            <xul:label class="identityDesc-name" xbl:inherits="value=label,accesskey,crop" crop="end" flex="1"/>
62            <xul:label class="identityDesc-ext1" xbl:inherits="value=ext1" crop="end" />
63            <xul:label class="identityDesc-ext2" xbl:inherits="value=ext2" crop="end" />
64        </xul:hbox>     
65        <xul:dropmarker class="menulist-dropmarker" type="menu" xbl:inherits="disabled,open"/>
66        <children includes="menupopup"/>
67    </content>
68    <implementation>
69    <constructor>
70        <![CDATA[       
71        var menuitem = document.createElement("menuitem");
72        menuitem.setAttribute("class", "mismatchMenuitem");
73        menuitem.setAttribute("label",  document.getElementById("removeRelationLabel").getAttribute("value"));
74        menuitem.setAttribute("key",  "");
75        document.getAnonymousElementByAttribute(this, "class", "mismatchMenupopup").appendChild(menuitem);
76        this.selectedItem = menuitem;
77        ]]>
78    </constructor>
79    <property name="selectedItem" onget="return this.mSelectedInternal;" >
80        <setter><![CDATA[
81        var oldval = this.mSelectedInternal;
82        if (oldval == val)
83        return val;
84
85        if (val && !this.contains(val))
86        return val;
87
88        if (oldval) {
89        oldval.removeAttribute('selected');
90        if (document instanceof Components.interfaces.nsIDOMXULDocument) {
91            document.removeBroadcastListenerFor(oldval, this, "value");
92            document.removeBroadcastListenerFor(oldval, this, "label");
93            document.removeBroadcastListenerFor(oldval, this, "image");
94            document.removeBroadcastListenerFor(oldval, this, "ext1");
95            document.removeBroadcastListenerFor(oldval, this, "ext2");
96        }
97        else
98            oldval.removeEventListener("DOMAttrModified", this, false);
99        }
100
101        this.mSelectedInternal = val;
102        if (val) {
103        val.setAttribute('selected', 'true');
104        this.setAttribute('value', val.getAttribute('value'));
105        this.setAttribute('image', val.getAttribute('image'));
106        this.setAttribute('label', val.getAttribute('label'));
107        this.setAttribute('ext1', val.getAttribute('ext1'));
108        this.setAttribute('ext2', val.getAttribute('ext2'));
109        // DOMAttrModified listeners slow down setAttribute calls within
110        // the document, see bug 395496
111        if (document instanceof Components.interfaces.nsIDOMXULDocument) {
112            document.addBroadcastListenerFor(val, this, "value");
113            document.addBroadcastListenerFor(val, this, "label");
114            document.addBroadcastListenerFor(val, this, "image");
115            document.addBroadcastListenerFor(val, this, "ext1");
116            document.addBroadcastListenerFor(val, this, "ext2");
117        }
118        else
119            val.addEventListener("DOMAttrModified", this, false);
120        }
121        else {
122        this.removeAttribute('value');
123        this.removeAttribute('image');
124        this.removeAttribute('label');
125        this.removeAttribute('ext1');
126        this.removeAttribute('ext2');
127        }
128
129        var event = document.createEvent("Events");
130        event.initEvent("select", true, true);
131        this.dispatchEvent(event);
132
133        var event = document.createEvent("Events");
134        event.initEvent("ValueChange", true, true);
135        this.dispatchEvent(event);
136
137        return val;
138        ]]></setter>
139    </property>
140    </implementation>
141    </binding>
142
143    <binding id="mismatch-menupopup" extends="chrome://global/content/bindings/popup.xml#popup">
144    <content>
145        <children />
146    </content>
147    <implementation>
148    <method name="_addIdentities">
149        <body><![CDATA[
150        vI_notificationBar.dump("## mismatchID-menupopup: _addIdentities.\n");
151        var AccountManager = Components.classes["@mozilla.org/messenger/account-manager;1"]
152            .getService(Components.interfaces.nsIMsgAccountManager);
153        for (let i = 0; i < AccountManager.accounts.Count(); i++) {
154            var account = AccountManager.accounts.QueryElementAt(i, Components.interfaces.nsIMsgAccount);
155            for (let j = 0; j < account.identities.Count(); j++) {
156                var identity = account.identities.QueryElementAt(j, Components.interfaces.nsIMsgIdentity);
157                const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
158                var menuitem = document.createElementNS(XUL_NS, "menuitem"); // create a new XUL menuitem
159                menuitem.setAttribute("class", "mismatchMenuitem");
160                menuitem.setAttribute("label",  identity.identityName);
161                menuitem.setAttribute("ext1",  identity.fullName);
162                menuitem.setAttribute("ext2",  identity.email);
163                menuitem.setAttribute("key",  identity.key);
164                this.appendChild(menuitem);
165            }
166        }       
167        ]]></body>
168    </method>
169    <method name="_addSmtp">
170        <parameter name="server" />
171        <body><![CDATA[
172            vI_notificationBar.dump("## mismatchID-menupopup: _addSmtp.\n");
173            const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
174            var menuitem = document.createElementNS(XUL_NS, "menuitem"); // create a new XUL menuitem
175            menuitem.setAttribute("class", "mismatchMenuitem");
176            menuitem.setAttribute("label",  (server.description?server.description:server.hostname));
177            menuitem.setAttribute("ext1",  server.hostname);
178            menuitem.setAttribute("ext2",  server.username);
179            menuitem.setAttribute("key",  server.key);
180            this.appendChild(menuitem);       
181        ]]></body>
182    </method>
183    <method name="_addSmtpServers">
184        <body><![CDATA[
185            vI_notificationBar.dump("## mismatchID-menupopup: _addSmtpServers.\n");
186           
187            const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
188            var menuitem = document.createElementNS(XUL_NS, "menuitem"); // create a new XUL menuitem
189            menuitem.setAttribute("class", "mismatchMenuitem");
190            const DEFAULT_SMTP_TAG = "vI_useDefaultSMTP"
191            menuitem.setAttribute("key", DEFAULT_SMTP_TAG);
192            menuitem.setAttribute("label", document.getElementById("bundle_messenger").getString("defaultServerTag"));
193            this.appendChild(menuitem);
194           
195            var servers = Components.classes["@mozilla.org/messengercompose/smtp;1"]
196                .getService(Components.interfaces.nsISmtpService).smtpServers;
197            if (typeof(servers.Count) == "undefined")                   // TB 3.x
198                while (servers && servers.hasMoreElements()) {
199                    var server = servers.getNext();
200                    if (server instanceof Components.interfaces.nsISmtpServer && !server.redirectorType) this._addSmtp(server);
201                }
202            else                                                        // TB 2.x
203                for (var i=0 ; i<servers.Count(); i++) this._addSmtp(servers.QueryElementAt(i, Components.interfaces.nsISmtpServer));
204        ]]></body>
205    </method>
206    <constructor>
207        <![CDATA[       
208        vI_notificationBar.dump("## mismatchID-menupopup: constructor.\n");
209        const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
210        this.appendChild(document.createElementNS(XUL_NS, "menuseparator")); // create a new XUL menuseparator
211        if (this.getAttribute("type") == "identity") this._addIdentities();
212        else    this._addSmtpServers();
213        ]]>
214    </constructor>
215    </implementation>
216    </binding>
217</bindings>
Note: See TracBrowser for help on using the repository browser.