source: content/bindings/vI_debugBox.xml @ 021dbf

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

start implementation of new logging (not finished)

  • Property mode set to 100644
File size: 5.0 KB
Line 
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        let prefroot = Components.classes["@mozilla.org/preferences-service;1"]
17          .getService(Components.interfaces.nsIPrefService)
18          .getBranch(null).QueryInterface(Components.interfaces.nsIPrefBranch2);
19        prefroot.addObserver("extensions.virtualIdentity.debug_notification", this, false);
20        this.observe();
21      ]]></constructor>
22      <destructor><![CDATA[
23        let prefroot = Components.classes["@mozilla.org/preferences-service;1"]
24          .getService(Components.interfaces.nsIPrefService)
25          .getBranch(null).QueryInterface(Components.interfaces.nsIPrefBranch2);
26        prefroot.removeObserver("extensions.virtualIdentity.debug_notification", this);
27      ]]></destructor>
28      <field name="_content">document.getAnonymousElementByAttribute(this, "anonid", "vI_debugBoxContent")</field>
29      <property name="splitter" />
30      <method name="observe">
31        <body><![CDATA[
32          this.clear();
33          let showDebugArea = Components.classes["@mozilla.org/preferences-service;1"]
34            .getService(Components.interfaces.nsIPrefService)
35            .getBranch("extensions.virtualIdentity.")
36            .getBoolPref("debug_notification");
37          if (showDebugArea) {
38            this.removeAttribute("hidden");
39            this.parentNode.insertBefore(this.splitter, this);
40          }
41          else {
42            this.setAttribute("hidden", "true");
43            try {
44              this.parentNode.removeChild(this.splitter);
45            } catch (e) { };
46          }
47        ]]></body>
48      </method>
49       <method name="clear">
50        <body><![CDATA[
51          if (this.getAttribute("hidden")) return;
52          while (this._content.inputField.firstChild)
53            this._content.inputField.removeChild(this._content.inputField.firstChild);
54          this.dump_app_version();
55        ]]></body>
56      </method>
57      <method name="dump">
58        <parameter name="text" />
59        <body><![CDATA[
60          if (this.getAttribute("hidden")) return;
61          let new_text = document.createTextNode(text);
62          var new_br = document.createElementNS("http://www.w3.org/1999/xhtml", 'br');
63          this._content.inputField.appendChild(new_text);
64          this._content.inputField.appendChild(new_br);
65          this._content.inputField.scrollTop =
66            this._content.inputField.scrollHeight - this._content.inputField.clientHeight
67        ]]></body>
68      </method>
69      <method name="dump_app_version">
70        <body><![CDATA[
71          if (this.getAttribute("hidden")) return;
72          this.dump("--------------------------------------------------------------------------------\n")
73          // add some information about the mail-client and the extensions installed
74          if ("@mozilla.org/xre/app-info;1" in Components.classes) {
75            var appInfo = Components.classes["@mozilla.org/xre/app-info;1"]
76              .getService(Components.interfaces.nsIXULAppInfo);
77            var protohandler = Components.classes["@mozilla.org/network/protocol;1?name=http"]
78              .getService(Components.interfaces.nsIHttpProtocolHandler);
79            this.dump(appInfo.name + " " + appInfo.version + " (" + appInfo.appBuildID + "; " + protohandler.oscpu + ")\n");
80          }
81          else
82            this.dump("mail-client seems not supported by Virtual Identity Extension")
83         
84          this.dump_extension_list(this.dump);
85          this.dump("--------------------------------------------------------------------------------\n")
86        ]]></body>
87      </method>
88      <method name="dump_extension_list">
89        <parameter name="callback" />
90        <body><![CDATA[
91          if (this.getAttribute("hidden")) return;
92          self = this;
93          Components.utils.import("resource://gre/modules/AddonManager.jsm");
94          AddonManager.getAllAddons(function(addons) {
95            var strings = addons.map(function(addon) {
96                return "addon: " + addon.name + " " + addon.version
97                + (addon.userDisabled || addon.appDisabled ? " [DISABLED]" : "");
98            });
99            self.dump("--------------------------------------------------------------------------------\n" +
100                      strings.join("\n") +
101                      "\n--------------------------------------------------------------------------------\n");
102          });
103        ]]></body>
104      </method>
105    </implementation>
106  </binding>
107</bindings>
Note: See TracBrowser for help on using the repository browser.