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
|
/* 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/. */
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
import { l10nHelper } from "resource:///modules/imXPCOMUtils.sys.mjs";
import { GenericProtocolPrototype } from "resource:///modules/jsProtoHelper.sys.mjs";
const lazy = {};
XPCOMUtils.defineLazyGetter(lazy, "_", () =>
l10nHelper("chrome://chat/locale/xmpp.properties")
);
ChromeUtils.defineESModuleGetters(lazy, {
XMPPAccountPrototype: "resource:///modules/xmpp-base.sys.mjs",
XMPPSession: "resource:///modules/xmpp-session.sys.mjs",
});
XPCOMUtils.defineLazyGetter(lazy, "OdnoklassnikiAccount", () => {
function OdnoklassnikiAccount(aProtoInstance, aImAccount) {
this._init(aProtoInstance, aImAccount);
}
OdnoklassnikiAccount.prototype = {
__proto__: lazy.XMPPAccountPrototype,
get canJoinChat() {
return false;
},
connect() {
if (!this.name.includes("@")) {
// TODO: Do not use the default resource value if the user has not
// specified it and let the service generate it.
let jid =
this.name +
"@odnoklassniki.ru/" +
Services.strings
.createBundle("chrome://branding/locale/brand.properties")
.GetStringFromName("brandShortName");
this._jid = this._parseJID(jid);
} else {
this._jid = this._parseJID(this.name);
if (this._jid.domain != "odnoklassniki.ru") {
// We can't use this.onError because this._connection doesn't exist.
this.reportDisconnecting(
Ci.prplIAccount.ERROR_INVALID_USERNAME,
lazy._("connection.error.invalidUsername")
);
this.reportDisconnected();
return;
}
}
this._connection = new lazy.XMPPSession(
"xmpp.odnoklassniki.ru",
5222,
"require_tls",
this._jid,
this.imAccount.password,
this
);
},
};
return OdnoklassnikiAccount;
});
export function OdnoklassnikiProtocol() {}
OdnoklassnikiProtocol.prototype = {
__proto__: GenericProtocolPrototype,
get normalizedName() {
return "odnoklassniki";
},
get name() {
return lazy._("odnoklassniki.protocolName");
},
get iconBaseURI() {
return "chrome://prpl-odnoklassniki/skin/";
},
get usernameEmptyText() {
return lazy._("odnoklassniki.usernameHint");
},
getAccount(aImAccount) {
return new lazy.OdnoklassnikiAccount(this, aImAccount);
},
};
|