1 | <?xml version="1.0"?> |
---|
2 | |
---|
3 | <bindings id="vI_notificationBindings" |
---|
4 | xmlns="http://www.mozilla.org/xbl" |
---|
5 | xmlns:xbl="http://www.mozilla.org/xbl" |
---|
6 | xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
---|
7 | |
---|
8 | <binding id="vI_debugBox"> |
---|
9 | <content> |
---|
10 | <xul:textbox anonid="vI_debugBoxContent" multiline="true" readonly="true" |
---|
11 | DOMAttrModified="if(event.attrName == 'value') this.value = event.newValue; return true;" flex="1"/> |
---|
12 | </content> |
---|
13 | <implementation implements="nsIObserver"> |
---|
14 | <constructor><![CDATA[ |
---|
15 | this.splitter = document.createElement("splitter"); |
---|
16 | Components.utils.import("resource://v_identity/vI_prefs.js", virtualIdentityExtension); |
---|
17 | virtualIdentityExtension.vIprefs.addObserver("debug_notification", this.observe, this); |
---|
18 | this.observe(this); |
---|
19 | ]]></constructor> |
---|
20 | <destructor><![CDATA[ |
---|
21 | virtualIdentityExtension.vIprefs.removeObserver("debug_notification", this.observe); |
---|
22 | ]]></destructor> |
---|
23 | <field name="_content">document.getAnonymousElementByAttribute(this, "anonid", "vI_debugBoxContent")</field> |
---|
24 | <property name="splitter" /> |
---|
25 | <method name="observe"> |
---|
26 | <parameter name="self" /> |
---|
27 | <body><![CDATA[ |
---|
28 | self.clear(); |
---|
29 | if (virtualIdentityExtension.vIprefs.get("debug_notification")) { |
---|
30 | self.removeAttribute("hidden"); |
---|
31 | self.parentNode.insertBefore(self.splitter, self); |
---|
32 | } |
---|
33 | else { |
---|
34 | self.setAttribute("hidden", "true"); |
---|
35 | try { |
---|
36 | self.parentNode.removeChild(self.splitter); |
---|
37 | } catch (e) { }; |
---|
38 | } |
---|
39 | ]]></body> |
---|
40 | </method> |
---|
41 | <method name="clear"> |
---|
42 | <body><![CDATA[ |
---|
43 | if (this.getAttribute("hidden")) return; |
---|
44 | while (this._content.inputField.firstChild) |
---|
45 | this._content.inputField.removeChild(this._content.inputField.firstChild); |
---|
46 | this.dump_app_version(); |
---|
47 | ]]></body> |
---|
48 | </method> |
---|
49 | <method name="dump"> |
---|
50 | <parameter name="text" /> |
---|
51 | <body><![CDATA[ |
---|
52 | if (this.getAttribute("hidden")) return; |
---|
53 | let new_text = document.createTextNode(text); |
---|
54 | var new_br = document.createElementNS("http://www.w3.org/1999/xhtml", 'br'); |
---|
55 | this._content.inputField.appendChild(new_text); |
---|
56 | this._content.inputField.appendChild(new_br); |
---|
57 | this._content.inputField.scrollTop = |
---|
58 | this._content.inputField.scrollHeight - this._content.inputField.clientHeight |
---|
59 | ]]></body> |
---|
60 | </method> |
---|
61 | <method name="dump_app_version"> |
---|
62 | <body><![CDATA[ |
---|
63 | if (this.getAttribute("hidden")) return; |
---|
64 | this.dump("--------------------------------------------------------------------------------\n") |
---|
65 | // add some information about the mail-client and the extensions installed |
---|
66 | if ("@mozilla.org/xre/app-info;1" in Components.classes) { |
---|
67 | var appInfo = Components.classes["@mozilla.org/xre/app-info;1"] |
---|
68 | .getService(Components.interfaces.nsIXULAppInfo); |
---|
69 | var protohandler = Components.classes["@mozilla.org/network/protocol;1?name=http"] |
---|
70 | .getService(Components.interfaces.nsIHttpProtocolHandler); |
---|
71 | this.dump(appInfo.name + " " + appInfo.version + " (" + appInfo.appBuildID + "; " + protohandler.oscpu + ")\n"); |
---|
72 | } |
---|
73 | else |
---|
74 | this.dump("mail-client seems not supported by Virtual Identity Extension") |
---|
75 | |
---|
76 | this.dump_extension_list(this.dump); |
---|
77 | this.dump("--------------------------------------------------------------------------------\n") |
---|
78 | ]]></body> |
---|
79 | </method> |
---|
80 | <method name="dump_extension_list"> |
---|
81 | <parameter name="callback" /> |
---|
82 | <body><![CDATA[ |
---|
83 | if (this.getAttribute("hidden")) return; |
---|
84 | self = this; |
---|
85 | Components.utils.import("resource://gre/modules/AddonManager.jsm"); |
---|
86 | AddonManager.getAllAddons(function(addons) { |
---|
87 | var strings = addons.map(function(addon) { |
---|
88 | return (addon.userDisabled || addon.appDisabled ? "" : "addon: " + addon.name + " " + addon.version + "\n"); |
---|
89 | }); |
---|
90 | self.dump("--------------------------------------------------------------------------------\n" + |
---|
91 | strings.join("") + |
---|
92 | "--------------------------------------------------------------------------------\n"); |
---|
93 | }); |
---|
94 | ]]></body> |
---|
95 | </method> |
---|
96 | </implementation> |
---|
97 | </binding> |
---|
98 | </bindings> |
---|