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("virtualIdentityExtension_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 (ChromeUtils.getClassName(document) == "XULDocument") { |
---|
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 (ChromeUtils.getClassName(document) == "XULDocument") { |
---|
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.Log.debug("rdfAccountMismatchDialog.xml mismatchID-menupopup: _addIdentities."); |
---|
158 | Components.utils.import("resource://v_identity/vI_accountUtils.js", virtualIdentityExtension); |
---|
159 | var accounts = virtualIdentityExtension.getAccountsArray(); |
---|
160 | for (let acc = 0; acc < accounts.length; acc++) { |
---|
161 | let account = accounts[acc]; |
---|
162 | let identities = virtualIdentityExtension.getIdentitiesArray(account); |
---|
163 | for (let i = 0; i < identities.length; i++) { |
---|
164 | let identity = identities[i]; |
---|
165 | const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; |
---|
166 | var menuitem = document.createElementNS(XUL_NS, "menuitem"); // create a new XUL menuitem |
---|
167 | menuitem.setAttribute("class", "mismatchMenuitem"); |
---|
168 | menuitem.setAttribute("label", identity.identityName); |
---|
169 | menuitem.setAttribute("ext1", identity.fullName); |
---|
170 | menuitem.setAttribute("ext2", identity.email); |
---|
171 | menuitem.setAttribute("key", identity.key); |
---|
172 | this.appendChild(menuitem); |
---|
173 | } |
---|
174 | } |
---|
175 | ]]></body> |
---|
176 | </method> |
---|
177 | <method name="_addIdentitiesWithSmtp"> |
---|
178 | <body><![CDATA[ |
---|
179 | virtualIdentityExtension.Log.debug("rdfAccountMismatchDialog.xml mismatchID-menupopup: _addIdentitiesWithSmtp."); |
---|
180 | Components.utils.import("resource://v_identity/vI_accountUtils.js", virtualIdentityExtension); |
---|
181 | var accounts = virtualIdentityExtension.getAccountsArray(); |
---|
182 | for (let acc = 0; acc < accounts.length; acc++) { |
---|
183 | let account = accounts[acc]; |
---|
184 | let identities = virtualIdentityExtension.getIdentitiesArray(account); |
---|
185 | for (let i = 0; i < identities.length; i++) { |
---|
186 | let identity = identities[i]; |
---|
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 | menuitem.setAttribute("label", identity.identityName); |
---|
191 | |
---|
192 | ChromeUtils.import("resource:///modules/mailServices.js"); |
---|
193 | var servers = MailServices.smtp.servers; |
---|
194 | |
---|
195 | var smtpName; |
---|
196 | while (servers && servers.hasMoreElements()) { |
---|
197 | var server = servers.getNext(); |
---|
198 | if (server instanceof Components.interfaces.nsISmtpServer && |
---|
199 | !server.redirectorType && identity.smtpServerKey == server.key) { |
---|
200 | smtpName = server.description ? server.description : server.hostname; |
---|
201 | break; |
---|
202 | } |
---|
203 | } |
---|
204 | |
---|
205 | menuitem.setAttribute("ext1", smtpName); |
---|
206 | menuitem.setAttribute("key", identity.key); |
---|
207 | this.appendChild(menuitem); |
---|
208 | } |
---|
209 | } |
---|
210 | virtualIdentityExtension.Log.debug("rdfAccountMismatchDialog.xml mismatchID-menupopup: _addIdentitiesWithSmtp done."); |
---|
211 | ]]></body> |
---|
212 | </method> |
---|
213 | <constructor> |
---|
214 | <![CDATA[ |
---|
215 | virtualIdentityExtension.Log.debug("rdfAccountMismatchDialog.xml mismatchID-menupopup: constructor."); |
---|
216 | const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; |
---|
217 | this.appendChild(document.createElementNS(XUL_NS, "menuseparator")); // create a new XUL menuseparator |
---|
218 | switch (this.getAttribute("type")) { |
---|
219 | case "identity": |
---|
220 | this._addIdentities(); |
---|
221 | break; |
---|
222 | case "smtpid": |
---|
223 | this._addIdentitiesWithSmtp(); |
---|
224 | break; |
---|
225 | } |
---|
226 | ]]> |
---|
227 | </constructor> |
---|
228 | </implementation> |
---|
229 | </binding> |
---|
230 | </bindings> |
---|