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
|
/* 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/irc.properties")
);
ChromeUtils.defineESModuleGetters(lazy, {
ircAccount: "resource:///modules/ircAccount.sys.mjs",
});
export function ircProtocol() {
// ircCommands.jsm exports one variable: commands. Import this directly into
// the protocol object.
this.commands = ChromeUtils.importESModule(
"resource:///modules/ircCommands.sys.mjs"
).commands;
this.registerCommands();
}
ircProtocol.prototype = {
__proto__: GenericProtocolPrototype,
get name() {
return "IRC";
},
get normalizedName() {
return "irc";
},
get iconBaseURI() {
return "chrome://prpl-irc/skin/";
},
get usernameEmptyText() {
return lazy._("irc.usernameHint");
},
usernameSplits: [
{
get label() {
return lazy._("options.server");
},
separator: "@",
defaultValue: "irc.libera.chat",
},
],
splitUsername(aName) {
let splitter = aName.lastIndexOf("@");
if (splitter === -1) {
return [];
}
return [aName.slice(0, splitter), aName.slice(splitter + 1)];
},
options: {
port: {
get label() {
return lazy._("options.port");
},
default: 6697,
},
ssl: {
get label() {
return lazy._("options.ssl");
},
default: true,
},
// TODO We should attempt to auto-detect encoding instead.
encoding: {
get label() {
return lazy._("options.encoding");
},
default: "UTF-8",
},
quitmsg: {
get label() {
return lazy._("options.quitMessage");
},
get default() {
return Services.prefs.getCharPref("chat.irc.defaultQuitMessage");
},
},
partmsg: {
get label() {
return lazy._("options.partMessage");
},
default: "",
},
showServerTab: {
get label() {
return lazy._("options.showServerTab");
},
default: false,
},
alternateNicks: {
get label() {
return lazy._("options.alternateNicks");
},
default: "",
},
},
get chatHasTopic() {
return true;
},
get slashCommandsNative() {
return true;
},
// Passwords in IRC are optional, and are needed for certain functionality.
get passwordOptional() {
return true;
},
getAccount(aImAccount) {
return new lazy.ircAccount(this, aImAccount);
},
};
|