DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (620f6a96cee5)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352
<?xml version="1.0"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->


<!DOCTYPE bindings [
  <!ENTITY % accountsDTD SYSTEM "chrome://chat/locale/accounts.dtd">
  <!ENTITY % certManagerDTD SYSTEM "chrome://pippki/locale/certManager.dtd">
  %accountsDTD;
  %certManagerDTD;
]>

<bindings id="accountBindings"
          xmlns="http://www.mozilla.org/xbl"
          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
          xmlns:xbl="http://www.mozilla.org/xbl">

  <binding id="account" extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
    <content>
      <xul:vbox flex="1">
        <xul:hbox flex="1" align="top">
          <xul:vbox>
            <xul:stack xbl:inherits="tooltiptext=protocol">
              <xul:image xbl:inherits="src=prplicon" class="accountIcon"/>
              <xul:image class="accountStateIcon"/>
            </xul:stack>
            <xul:spacer flex="1"/>
          </xul:vbox>
          <xul:vbox flex="1" align="start">
            <xul:label xbl:inherits="value=name" crop="end" class="accountName"/>
            <xul:label class="connecting" crop="end" anonid="connecting" value="&account.connecting;"/>
            <xul:label class="connected" crop="end" anonid="connected"/>
            <xul:label class="disconnecting" crop="end" value="&account.disconnecting;"/>
            <xul:label class="disconnected" crop="end" value="&account.disconnected;"/>
            <xul:description class="error" anonid="error"/>
            <xul:description class="error" anonid="reconnect"/>
            <xul:label class="addException text-link"
                       onclick="gAccountManager.addException()"
                       value="&certmgr.addException.label;"
                       accesskey="&certmgr.addException.accesskey;"/>
            <xul:spacer flex="1"/>
          </xul:vbox>
          <xul:checkbox label="&account.autoSignOn.label;" dir="reverse"
                        xbl:inherits="checked=autologin" class="autoSignOn"
                        accesskey="&account.autoSignOn.accesskey;"
                        oncommand="gAccountManager.autologin()"/>
        </xul:hbox>
        <xul:hbox flex="1" class="account-buttons" anonid="buttons"
                  xbl:inherits="autologin,name"/>
      </xul:vbox>
    </content>
    <implementation>
      <method name="build">
        <parameter name="aAccount"/>
        <body>
        <![CDATA[
          this._account = aAccount;
          this.setAttribute("name", aAccount.name);
          this.setAttribute("id", aAccount.id);
          var proto = aAccount.protocol;
          this.setAttribute("protocol", proto.name);
          this.setAttribute("prplicon", proto.iconBaseURI + "icon32.png");
          var state = "Unknown";
          if (this._account.connected) {
            state = "connected";
            this.refreshConnectedLabel();
          } else if (this._account.disconnected) {
            state = "disconnected";
            if (this._account.connectionErrorReason != Ci.prplIAccount.NO_ERROR)
              this.updateConnectionError();
            else {
              this.removeAttribute("error");
              this.removeAttribute("certError");
            }
          } else if (this._account.connecting) {
            state = "connecting";
            this.updateConnectionState();
          } else if (this._account.disconnecting) {
            state = "connected";
          }
          this.setAttribute("state", state);
          this.autoLogin = aAccount.autoLogin;
        ]]>
        </body>
      </method>

      <method name="updateConnectionState">
        <body>
        <![CDATA[
          var bundle = document.getElementById("accountsBundle");
          const key = "account.connection.progress";
          var text = this._account.connectionStateMsg;
          text = text ? bundle.getFormattedString(key, [text])
                      : bundle.getString("account.connecting");

          var progress = document.getAnonymousElementByAttribute(this, "anonid",
                                                                 "connecting");
          progress.setAttribute("value", text);
          if (this.reconnectUpdateInterval)
            this._cancelReconnectTimer();

          this.removeAttribute("certError");
        ]]>
        </body>
      </method>

      <method name="updateConnectionError">
        <body>
        <![CDATA[
          var bundle = document.getElementById("accountsBundle");
          const key = "account.connection.error";
          var account = this._account;
          var text;
          let errorReason = account.connectionErrorReason;
          if (errorReason == Ci.imIAccount.ERROR_UNKNOWN_PRPL)
            text = bundle.getFormattedString(key + "UnknownPrpl",
                                             [account.protocol.id]);
          else if (errorReason == Ci.imIAccount.ERROR_MISSING_PASSWORD)
            text = bundle.getString(key + "EnteringPasswordRequired");
          else if (errorReason == Ci.imIAccount.ERROR_CRASHED)
            text = bundle.getString(key + "CrashedAccount");
          else
            text = account.connectionErrorMessage;

          if (errorReason != Ci.imIAccount.ERROR_MISSING_PASSWORD)
            text = bundle.getFormattedString(key, [text]);

          this.setAttribute("error", "true");
          if ((Ci.imIAccount.ERROR_CERT_NOT_PROVIDED <= errorReason &&
               errorReason <= Ci.imIAccount.ERROR_CERT_OTHER_ERROR) &&
              account.prplAccount.connectionTarget)
            this.setAttribute("certError", "true");
          var error = document.getAnonymousElementByAttribute(this, "anonid",
                                                              "error");
          error.textContent = text;

          var updateReconnect = (function() {
            var date = Math.round((account.timeOfNextReconnect - Date.now()) / 1000);
            let reconnect = "";
            if (date > 0) {
              let [val1, unit1, val2, unit2] = DownloadUtils.convertTimeUnits(date);
              if (!val2)
                reconnect = bundle.getFormattedString("account.reconnectInSingle",
                                                      [val1, unit1])
              else
                reconnect = bundle.getFormattedString("account.reconnectInDouble",
                                                      [val1, unit1, val2, unit2])
            }
            document.getAnonymousElementByAttribute(this, "anonid", "reconnect")
                    .textContent = reconnect;
            return reconnect;
          }).bind(this);
          if (updateReconnect() && !this.reconnectUpdateInterval) {
            this.setAttribute("reconnectPending", "true");
            this.reconnectUpdateInterval = setInterval(updateReconnect, 1000);
            gAccountManager.disableCommandItems();
          }
        ]]>
        </body>
      </method>

      <method name="refreshConnectedLabel">
        <body>
        <![CDATA[
          var bundle = document.getElementById("accountsBundle");
          var date =
            60 * Math.floor((Date.now() - this._account.timeOfLastConnect) / 60000);
          let value;
          if (date > 0) {
            let [val1, unit1, val2, unit2] = DownloadUtils.convertTimeUnits(date);
            if (!val2)
              value = bundle.getFormattedString("account.connectedForSingle",
                                                [val1, unit1])
            else
              value = bundle.getFormattedString("account.connectedForDouble",
                                                [val1, unit1, val2, unit2])
          }
          else
            value = bundle.getString("account.connectedForSeconds");
          this.connectedLabel.value = value;
        ]]>
        </body>
      </method>

      <method name="_cancelReconnectTimer">
        <body>
        <![CDATA[
          this.removeAttribute("reconnectPending");
          clearInterval(this.reconnectUpdateInterval);
          delete this.reconnectUpdateInterval;
          gAccountManager.disableCommandItems();
        ]]>
        </body>
      </method>

      <method name="cancelReconnection">
        <body>
        <![CDATA[
          if (this.reconnectUpdateInterval) {
            this._cancelReconnectTimer();
            this._account.cancelReconnection();
          }
        ]]>
        </body>
      </method>

      <method name="restoreItems">
        <body>
        <![CDATA[
          // Called after a removal and reinsertion of the binding
          this._buttons = null;
          this._connectedLabel = null;
          if (this._account.connected)
            this.refreshConnectedLabel();
          else if (this._account.connecting)
            this.updateConnectionState();
          else if (this._account.connectionErrorReason != Ci.prplIAccount.NO_ERROR)
            this.updateConnectionError();
        ]]>
        </body>
      </method>

      <method name="destroy">
        <body>
        <![CDATA[
          // If we have a reconnect timer, stop it:
          // it will throw errors otherwise (see bug 480).
          if (!this.reconnectUpdateInterval)
            return;
          clearInterval(this.reconnectUpdateInterval);
          delete this.reconnectUpdateInterval;
        ]]>
        </body>
      </method>

      <property name="autoLogin">
        <getter>
        <![CDATA[
          return this.hasAttribute("autologin");
        ]]>
        </getter>
        <setter>
        <![CDATA[
          if (val)
            this.setAttribute("autologin", "true");
          else
            this.removeAttribute("autologin");
          if (this._account.autoLogin != val)
            this._account.autoLogin = val;
          return val;
        ]]>
        </setter>
      </property>

      <!-- override the default accessible name -->
      <property name="label" onget="return this.getAttribute('name');"/>

      <property name="account" onget="return this._account;"/>

      <property name="connectedLabel">
        <getter>
        <![CDATA[
          if (!this._connectedLabel)
            this._connectedLabel =
              document.getAnonymousElementByAttribute(this, "anonid", "connected");
          return this._connectedLabel;
        ]]>
        </getter>
      </property>

      <property name="buttons">
        <getter>
        <![CDATA[
          if (!this._buttons)
            this._buttons =
              document.getAnonymousElementByAttribute(this, "anonid", "buttons");
          return this._buttons;
        ]]>
        </getter>
      </property>
    </implementation>
    <handlers>
      <handler event="dblclick">
      <![CDATA[
        if (event.button == 0) {
          // If we double clicked on a widget that has already done
          // something with the first click, we should ignore the event
          var localName = event.originalTarget.localName;
          if (localName != "button" && localName != "checkbox")
            this.buttons.proceedDefaultAction();
        }

        // Prevent from loading an account wizzard
        event.stopPropagation();
      ]]>
      </handler>
    </handlers>
  </binding>

  <binding id="buttons" extends="xul:hbox">
    <content>
      <xul:button class="disconnectButton"
                  command="cmd_disconnect"
                  anonid="disconnect"/>
      <xul:button class="connectButton"
                  command="cmd_connect"
                  anonid="connect"/>
      <xul:spacer flex="1"/>
#ifndef MOZ_THUNDERBIRD
      <xul:button command="cmd_delete"/>
#endif
      <xul:button command="cmd_edit"/>
    </content>
    <implementation>
      <property name="activeButton" readonly="true">
        <getter>
        <![CDATA[
          let action =
            document.getBindingParent(this).account.disconnected ? "connect"
                                                                 : "disconnect";
          return document.getAnonymousElementByAttribute(this, "anonid", action);
        ]]>
        </getter>
      </property>

      <method name="setFocus">
        <body>
        <![CDATA[
          let focusTarget = this.activeButton;
          let accountName = this.getAttribute("name");
          focusTarget.setAttribute("aria-label",
                                   focusTarget.label + " " + accountName);
          if (focusTarget.disabled)
            focusTarget = document.getElementById("accountlist");
          focusTarget.focus();
        ]]>
        </body>
      </method>

      <method name="proceedDefaultAction">
        <body>
        <![CDATA[
          this.activeButton.click();
        ]]>
        </body>
      </method>
    </implementation>
  </binding>

  <binding id="nobuttons" extends="xul:hbox"/>
</bindings>