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-pre" value="(" crop="end" /> |
---|
36 | <xul:label class="identityDesc-ext1" xbl:inherits="value=ext1" crop="end" /> |
---|
37 | <xul:label class="identityDesc-mid" value="/" crop="end" /> |
---|
38 | <xul:label class="identityDesc-ext2" xbl:inherits="value=ext2" crop="end" /> |
---|
39 | <xul:label class="identityDesc-post" value=")" crop="end" /> |
---|
40 | </xul:listcell> |
---|
41 | <xul:listcell class="identityDesc-count-cell"> |
---|
42 | <xul:label class="identityDesc-count" xbl:inherits="value=count" crop="end" /> |
---|
43 | </xul:listcell> |
---|
44 | <xul:listcell> |
---|
45 | <xul:menulist class="mismatchMenulist" sizetopopup="always" hidden="true"> |
---|
46 | <xul:menupopup class="mismatchMenupopup" xbl:inherits="type" /> |
---|
47 | </xul:menulist> |
---|
48 | </xul:listcell> |
---|
49 | </content> |
---|
50 | <implementation> |
---|
51 | <property name="key" > |
---|
52 | <getter><![CDATA[ |
---|
53 | return document.getAnonymousElementByAttribute(this, "class", "mismatchMenulist").selectedItem.getAttribute("key"); |
---|
54 | ]]></getter> |
---|
55 | </property> |
---|
56 | </implementation> |
---|
57 | </binding> |
---|
58 | |
---|
59 | <binding id="mismatch-menuitem" extends="chrome://global/content/bindings/menu.xml#menuitem"> |
---|
60 | <content> |
---|
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 | </content> |
---|
65 | </binding> |
---|
66 | |
---|
67 | <binding id="mismatch-menulist" extends="chrome://global/content/bindings/menulist.xml#menulist"> |
---|
68 | <content> |
---|
69 | <xul:hbox class="menulist-label-box" flex="1"> |
---|
70 | <xul:label class="identityDesc-name" xbl:inherits="value=label,accesskey,crop" crop="end" flex="1"/> |
---|
71 | <xul:label class="identityDesc-ext1" xbl:inherits="value=ext1" crop="end" /> |
---|
72 | <xul:label class="identityDesc-ext2" xbl:inherits="value=ext2" crop="end" /> |
---|
73 | </xul:hbox> |
---|
74 | <xul:dropmarker class="menulist-dropmarker" type="menu" xbl:inherits="disabled,open"/> |
---|
75 | <children includes="menupopup"/> |
---|
76 | </content> |
---|
77 | <implementation> |
---|
78 | <constructor> |
---|
79 | <![CDATA[ |
---|
80 | var menuitem = document.createElement("menuitem"); |
---|
81 | menuitem.setAttribute("class", "mismatchMenuitem"); |
---|
82 | menuitem.setAttribute("label", document.getElementById("virtualIdentityExtension_removeRelationLabel").getAttribute("value")); |
---|
83 | menuitem.setAttribute("key", ""); |
---|
84 | document.getAnonymousElementByAttribute(this, "class", "mismatchMenupopup").appendChild(menuitem); |
---|
85 | this.selectedItem = menuitem; |
---|
86 | this.removeAttribute("hidden"); |
---|
87 | ]]> |
---|
88 | </constructor> |
---|
89 | <property name="selectedItem" onget="return this.mSelectedInternal;" > |
---|
90 | <setter><![CDATA[ |
---|
91 | var oldval = this.mSelectedInternal; |
---|
92 | if (oldval == val) |
---|
93 | return val; |
---|
94 | |
---|
95 | if (val && !this.contains(val)) |
---|
96 | return val; |
---|
97 | |
---|
98 | if (oldval) { |
---|
99 | oldval.removeAttribute('selected'); |
---|
100 | if (ChromeUtils.getClassName(document) == "XULDocument") { |
---|
101 | document.removeBroadcastListenerFor(oldval, this, "value"); |
---|
102 | document.removeBroadcastListenerFor(oldval, this, "label"); |
---|
103 | document.removeBroadcastListenerFor(oldval, this, "image"); |
---|
104 | document.removeBroadcastListenerFor(oldval, this, "ext1"); |
---|
105 | document.removeBroadcastListenerFor(oldval, this, "ext2"); |
---|
106 | } |
---|
107 | else |
---|
108 | oldval.removeEventListener("DOMAttrModified", this, false); |
---|
109 | } |
---|
110 | |
---|
111 | this.mSelectedInternal = val; |
---|
112 | if (val) { |
---|
113 | val.setAttribute('selected', 'true'); |
---|
114 | this.setAttribute('value', val.getAttribute('value')); |
---|
115 | this.setAttribute('image', val.getAttribute('image')); |
---|
116 | this.setAttribute('label', val.getAttribute('label')); |
---|
117 | this.setAttribute('ext1', val.getAttribute('ext1')); |
---|
118 | this.setAttribute('ext2', val.getAttribute('ext2')); |
---|
119 | // DOMAttrModified listeners slow down setAttribute calls within |
---|
120 | // the document, see bug 395496 |
---|
121 | if (ChromeUtils.getClassName(document) == "XULDocument") { |
---|
122 | document.addBroadcastListenerFor(val, this, "value"); |
---|
123 | document.addBroadcastListenerFor(val, this, "label"); |
---|
124 | document.addBroadcastListenerFor(val, this, "image"); |
---|
125 | document.addBroadcastListenerFor(val, this, "ext1"); |
---|
126 | document.addBroadcastListenerFor(val, this, "ext2"); |
---|
127 | } |
---|
128 | else |
---|
129 | val.addEventListener("DOMAttrModified", this, false); |
---|
130 | } |
---|
131 | else { |
---|
132 | this.removeAttribute('value'); |
---|
133 | this.removeAttribute('image'); |
---|
134 | this.removeAttribute('label'); |
---|
135 | this.removeAttribute('ext1'); |
---|
136 | this.removeAttribute('ext2'); |
---|
137 | } |
---|
138 | |
---|
139 | var event = document.createEvent("Events"); |
---|
140 | event.initEvent("select", true, true); |
---|
141 | this.dispatchEvent(event); |
---|
142 | |
---|
143 | var event = document.createEvent("Events"); |
---|
144 | event.initEvent("ValueChange", true, true); |
---|
145 | this.dispatchEvent(event); |
---|
146 | |
---|
147 | return val; |
---|
148 | ]]></setter> |
---|
149 | </property> |
---|
150 | </implementation> |
---|
151 | </binding> |
---|
152 | |
---|
153 | <binding id="mismatch-menupopup" extends="chrome://global/content/bindings/popup.xml#popup"> |
---|
154 | <content> |
---|
155 | <children /> |
---|
156 | </content> |
---|
157 | <implementation> |
---|
158 | <method name="_addIdentities"> |
---|
159 | <body><![CDATA[ |
---|
160 | //virtualIdentityExtension.Log.debug("rdfAccountMismatchDialog.xml mismatchID-menupopup: _addIdentities."); |
---|
161 | Components.utils.import("resource://v_identity/vI_accountUtils.js", virtualIdentityExtension); |
---|
162 | var accounts = virtualIdentityExtension.getAccountsArray(); |
---|
163 | for (let acc = 0; acc < accounts.length; acc++) { |
---|
164 | let account = accounts[acc]; |
---|
165 | let identities = virtualIdentityExtension.getIdentitiesArray(account); |
---|
166 | for (let i = 0; i < identities.length; i++) { |
---|
167 | let identity = identities[i]; |
---|
168 | const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; |
---|
169 | var menuitem = document.createElementNS(XUL_NS, "menuitem"); // create a new XUL menuitem |
---|
170 | menuitem.setAttribute("class", "mismatchMenuitem"); |
---|
171 | menuitem.setAttribute("label", identity.identityName); |
---|
172 | menuitem.setAttribute("ext1", identity.fullName); |
---|
173 | menuitem.setAttribute("ext2", identity.email); |
---|
174 | menuitem.setAttribute("key", identity.key); |
---|
175 | this.appendChild(menuitem); |
---|
176 | } |
---|
177 | } |
---|
178 | ]]></body> |
---|
179 | </method> |
---|
180 | <method name="_addSmtp"> |
---|
181 | <parameter name="server" /> |
---|
182 | <body><![CDATA[ |
---|
183 | //virtualIdentityExtension.Log.debug("rdfAccountMismatchDialog.xml mismatchID-menupopup: _addSmtp."); |
---|
184 | const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; |
---|
185 | var menuitem = document.createElementNS(XUL_NS, "menuitem"); // create a new XUL menuitem |
---|
186 | menuitem.setAttribute("class", "mismatchMenuitem"); |
---|
187 | menuitem.setAttribute("label", (server.description?server.description:server.hostname)); |
---|
188 | menuitem.setAttribute("ext1", server.hostname); |
---|
189 | menuitem.setAttribute("ext2", server.username); |
---|
190 | menuitem.setAttribute("key", server.key); |
---|
191 | this.appendChild(menuitem); |
---|
192 | ]]></body> |
---|
193 | </method> |
---|
194 | <method name="_addSmtpServers"> |
---|
195 | <body><![CDATA[ |
---|
196 | //virtualIdentityExtension.Log.debug("rdfAccountMismatchDialog.xml mismatchID-menupopup: _addSmtpServers."); |
---|
197 | |
---|
198 | const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; |
---|
199 | var menuitem = document.createElementNS(XUL_NS, "menuitem"); // create a new XUL menuitem |
---|
200 | menuitem.setAttribute("class", "mismatchMenuitem"); |
---|
201 | menuitem.setAttribute("key", virtualIdentityExtension.DEFAULT_SMTP_TAG); |
---|
202 | menuitem.setAttribute("label", Components.classes["@mozilla.org/intl/stringbundle;1"] |
---|
203 | .getService(Components.interfaces.nsIStringBundleService) |
---|
204 | .createBundle("chrome://messenger/locale/messenger.properties") |
---|
205 | .GetStringFromName("defaultServerTag")); |
---|
206 | this.appendChild(menuitem); |
---|
207 | |
---|
208 | var servers, smtpService = Components.classes["@mozilla.org/messengercompose/smtp;1"] |
---|
209 | .getService(Components.interfaces.nsISmtpService); |
---|
210 | // check for new https://hg.mozilla.org/comm-central/rev/fab9e5145cd4 smtpService |
---|
211 | if (typeof(smtpService.servers) == "object") servers = smtpService.servers; |
---|
212 | else servers = smtpService.smtpServers; |
---|
213 | |
---|
214 | while (servers && servers.hasMoreElements()) { |
---|
215 | var server = servers.getNext(); |
---|
216 | if (server instanceof Components.interfaces.nsISmtpServer && !server.redirectorType) this._addSmtp(server); |
---|
217 | } |
---|
218 | ]]></body> |
---|
219 | </method> |
---|
220 | |
---|
221 | <method name="_addIdentitiesWithSmtp"> |
---|
222 | <body><![CDATA[ |
---|
223 | virtualIdentityExtension.Log.debug("rdfAccountMismatchDialog.xml mismatchID-menupopup: _addIdentitiesWithSmtp."); |
---|
224 | Components.utils.import("resource://v_identity/vI_accountUtils.js", virtualIdentityExtension); |
---|
225 | var accounts = virtualIdentityExtension.getAccountsArray(); |
---|
226 | for (let acc = 0; acc < accounts.length; acc++) { |
---|
227 | let account = accounts[acc]; |
---|
228 | let identities = virtualIdentityExtension.getIdentitiesArray(account); |
---|
229 | for (let i = 0; i < identities.length; i++) { |
---|
230 | let identity = identities[i]; |
---|
231 | const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; |
---|
232 | var menuitem = document.createElementNS(XUL_NS, "menuitem"); // create a new XUL menuitem |
---|
233 | menuitem.setAttribute("class", "mismatchMenuitem"); |
---|
234 | menuitem.setAttribute("label", identity.identityName); |
---|
235 | |
---|
236 | ChromeUtils.import("resource:///modules/mailServices.js"); |
---|
237 | var servers = MailServices.smtp.servers; |
---|
238 | |
---|
239 | var smtpName; |
---|
240 | while (servers && servers.hasMoreElements()) { |
---|
241 | var server = servers.getNext(); |
---|
242 | if (server instanceof Components.interfaces.nsISmtpServer && |
---|
243 | !server.redirectorType && identity.smtpServerKey == server.key) { |
---|
244 | smtpName = server.description ? server.description : server.hostname; |
---|
245 | break; |
---|
246 | } |
---|
247 | } |
---|
248 | |
---|
249 | menuitem.setAttribute("ext1", smtpName); |
---|
250 | menuitem.setAttribute("key", identity.key); |
---|
251 | this.appendChild(menuitem); |
---|
252 | } |
---|
253 | } |
---|
254 | virtualIdentityExtension.Log.debug("rdfAccountMismatchDialog.xml mismatchID-menupopup: _addIdentitiesWithSmtp done."); |
---|
255 | ]]></body> |
---|
256 | </method> |
---|
257 | <constructor> |
---|
258 | <![CDATA[ |
---|
259 | //virtualIdentityExtension.Log.debug("rdfAccountMismatchDialog.xml mismatchID-menupopup: constructor."); |
---|
260 | const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; |
---|
261 | this.appendChild(document.createElementNS(XUL_NS, "menuseparator")); // create a new XUL menuseparator |
---|
262 | switch (this.getAttribute("type")) { |
---|
263 | case "identity": |
---|
264 | this._addIdentities(); |
---|
265 | break; |
---|
266 | case "smtp": |
---|
267 | this._addSmtpServers(); |
---|
268 | break; |
---|
269 | case "smtpid": |
---|
270 | this._addIdentitiesWithSmtp(); |
---|
271 | break; |
---|
272 | } |
---|
273 | ]]> |
---|
274 | </constructor> |
---|
275 | </implementation> |
---|
276 | </binding> |
---|
277 | </bindings> |
---|