chat/protocols/xmpp/xmpp.jsm
author Khushil Mistry <khushil324@gmail.com>
Fri, 08 May 2020 15:42:48 +1200
changeset 39025 f25512b597325260e72b0f45e06d2f6ac9f6dc7b
parent 37697 8d558f7fb2cc3088b6c797354ae164c0012b4ce2
permissions -rw-r--r--
Bug 1635734 - Fix Chat broken in Thunderbird for macOS. r=clokep a=wsmwk

/* 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/. */

var EXPORTED_SYMBOLS = ["XMPPProtocol"];

var { XPCOMUtils, l10nHelper } = ChromeUtils.import(
  "resource:///modules/imXPCOMUtils.jsm"
);
var { GenericProtocolPrototype } = ChromeUtils.import(
  "resource:///modules/jsProtoHelper.jsm"
);
var { XMPPAccountPrototype } = ChromeUtils.import(
  "resource:///modules/xmpp-base.jsm"
);

XPCOMUtils.defineLazyGetter(this, "_", () =>
  l10nHelper("chrome://chat/locale/xmpp.properties")
);

function XMPPAccount(aProtoInstance, aImAccount) {
  this._init(aProtoInstance, aImAccount);
}
XMPPAccount.prototype = XMPPAccountPrototype;

function XMPPProtocol() {
  ChromeUtils.import("resource:///modules/xmpp-commands.jsm", this);
  this.registerCommands();
}
XMPPProtocol.prototype = {
  __proto__: GenericProtocolPrototype,
  get normalizedName() {
    return "jabber";
  },
  get name() {
    return "XMPP";
  },
  get iconBaseURI() {
    return "chrome://prpl-jabber/skin/";
  },
  getAccount(aImAccount) {
    return new XMPPAccount(this, aImAccount);
  },

  usernameSplits: [
    {
      get label() {
        return _("options.domain");
      },
      separator: "@",
      defaultValue: "jabber.org",
      reverse: true,
    },
  ],

  options: {
    resource: {
      get label() {
        return _("options.resource");
      },
      default: "",
    },
    priority: {
      get label() {
        return _("options.priority");
      },
      default: 0,
    },
    connection_security: {
      get label() {
        return _("options.connectionSecurity");
      },
      listValues: {
        get require_tls() {
          return _("options.connectionSecurity.requireEncryption");
        },
        get opportunistic_tls() {
          return _("options.connectionSecurity.opportunisticTLS");
        },
        get allow_unencrypted_plain_auth() {
          return _("options.connectionSecurity.allowUnencryptedAuth");
        },
        // "old_ssl" and "none" are also supported, but not exposed in the UI.
        // Any unknown value will fallback to the opportunistic_tls behavior.
      },
      default: "require_tls",
    },
    server: {
      get label() {
        return _("options.connectServer");
      },
      default: "",
    },
    port: {
      get label() {
        return _("options.connectPort");
      },
      default: 5222,
    },
  },
  get chatHasTopic() {
    return true;
  },
};