source: content/bindings/vI_rdfAccountMismatchDialog.xml @ d8da4b

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

changed imports to prevent namespace pollution

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