1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is ChatZilla.
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1998
21 * the Initial Developer. All Rights Reserved.
24 * Robert Ginda, <rginda@netscape.com>, original author
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 const DEFAULT_NICK
= "IRCMonkey"
44 function makeLogNameClient()
46 return makeLogName(client
, "client");
49 client
.prefManager
= new PrefManager("extensions.irc.",
50 client
.defaultBundle
);
51 client
.prefManagers
= [client
.prefManager
];
53 client
.prefs
= client
.prefManager
.prefs
;
55 var profilePath
= getSpecialDirectory("ProfD");
56 profilePath
.append("chatzilla");
58 client
.prefManager
.addPref("profilePath", profilePath
.path
, null, null,
61 profilePath
= new nsLocalFile(client
.prefs
["profilePath"]);
63 if (!profilePath
.exists())
66 client
.prefManager
.profilePath
= profilePath
;
68 var scriptPath
= profilePath
.clone();
69 scriptPath
.append("scripts");
70 if (!scriptPath
.exists())
72 client
.prefManager
.scriptPath
= scriptPath
;
74 var logPath
= profilePath
.clone();
75 logPath
.append("logs");
76 if (!logPath
.exists())
78 client
.prefManager
.logPath
= logPath
;
80 var downloadsPath
= profilePath
.clone();
81 downloadsPath
.append("downloads");
82 if (!downloadsPath
.exists())
85 var logDefault
= client
.prefManager
.logPath
.clone();
86 logDefault
.append(escapeFileName("client.log"));
88 var gotos
= ["goto-url", "goto-url-newwin",
89 "goto-url-newtab", "goto-url-newtab"];
90 if (client
.host
== "XULrunner")
92 gotos
= ["goto-url-external", "goto-url-external",
93 "goto-url-external", "goto-url-external"];
96 // Set up default nickname, if possible.
97 var defaultNick
= DEFAULT_NICK
;
98 var en
= getService("@mozilla.org/process/environment;1", "nsIEnvironment");
101 /* Get the enviroment variables used by various OSes:
102 * USER - Linux, Mac OSX and other *nix-types.
103 * USERNAME - Windows.
104 * LOGNAME - *nix again.
106 const vars
= ["USER", "USERNAME", "LOGNAME"];
108 for (var i
= 0; i
< vars
.length
; i
++)
110 var nick
= en
.get(vars
[i
]);
119 // Set a property so network ident prefs get the same group later:
120 client
.prefManager
.identGroup
= ".connect";
121 // Linux and OS X won't let non-root listen on port 113.
122 if ((client
.platform
== "Linux") || (client
.platform
== "Mac"))
123 client
.prefManager
.identGroup
= "hidden";
127 ["activityFlashDelay", 200, "hidden"],
128 ["aliases", [], "lists.aliases"],
129 ["autoAwayCap", 300, "global"],
130 ["autoAwayPeriod", 2, "appearance.misc"],
131 ["autoRejoin", false, ".connect"],
132 ["away", "", "hidden"],
133 ["awayNick", "", ".ident"],
134 ["awayIdleTime", 0, ".ident"],
135 ["awayIdleMsg", "", ".ident"],
136 ["bugURL", "https://bugzilla.mozilla.org/show_bug.cgi?id=%s",
138 ["bugURL.comment", "#c%s", "appearance.misc"],
139 ["channelHeader", true, "global.header"],
140 ["channelLog", false, "global.log"],
141 ["channelMaxLines", 500, "global.maxLines"],
142 ["charset", "utf-8", ".connect"],
143 ["clientMaxLines", 200, "global.maxLines"],
144 ["collapseActions", true, "appearance.misc"],
145 ["collapseMsgs", false, "appearance.misc"],
146 ["conference.limit", 150, "appearance.misc"],
147 ["connectTries", -1, ".connect"],
148 ["copyMessages", true, "global"],
149 ["dccUserHeader", true, "global.header"],
150 ["dccUserLog", false, "global.log"],
151 ["dccUserMaxLines", 500, "global.maxLines"],
152 ["dcc.enabled", true, "dcc"],
153 ["dcc.autoAccept.delay", 10000, "hidden"],
154 ["dcc.downloadsFolder", getURLSpecFromFile(downloadsPath
.path
), "dcc"],
155 ["dcc.listenPorts", [], "dcc.ports"],
156 ["dcc.useServerIP", true, "dcc"],
157 ["debugMode", "", "hidden"],
158 ["defaultQuitMsg", "", ".connect"],
159 ["desc", "New Now Know How", ".ident"],
160 ["deleteOnPart", true, "global"],
161 ["displayHeader", true, "appearance.misc"],
162 ["guessCommands", true, "hidden"],
163 ["hasPrefs", false, "hidden"],
164 ["font.family", "default", "appearance.misc"],
165 ["font.size", 0, "appearance.misc"],
166 ["identd.enabled", false, client
.prefManager
.identGroup
],
167 ["initialURLs", [], "startup.initialURLs"],
168 ["initialScripts", [getURLSpecFromFile(scriptPath
.path
)],
169 "startup.initialScripts"],
170 ["instrumentation.key", 0, "hidden"],
171 ["instrumentation.inst1", 0, "hidden"],
172 ["link.focus", true, "global.links"],
173 ["log", false, ".log"],
174 ["logFileName", makeLogNameClient
, "hidden"],
175 ["logFile.client", "client.$y-$m-$d.log", "hidden"],
176 ["logFile.network", "$(network)/$(network).$y-$m-$d.log", "hidden"],
177 ["logFile.channel", "$(network)/channels/$(channel).$y-$m-$d.log",
179 ["logFile.user", "$(network)/users/$(user).$y-$m-$d.log",
181 ["logFile.dccuser", "dcc/$(user)/$(user).$y-$m-$d.log", "hidden"],
182 ["logFolder", getURLSpecFromFile(logPath
.path
), ".log"],
183 ["messages.click", gotos
[0], "global.links"],
184 ["messages.ctrlClick", gotos
[1], "global.links"],
185 ["messages.metaClick", gotos
[2], "global.links"],
186 ["messages.middleClick", gotos
[3], "global.links"],
187 ["motif.dark", "chrome://chatzilla/skin/output-dark.css",
189 ["motif.light", "chrome://chatzilla/skin/output-light.css",
191 ["motif.default", "chrome://chatzilla/skin/output-default.css",
193 ["motif.current", "chrome://chatzilla/skin/output-default.css",
195 //["msgBeep", "beep beep", "global.sounds"],
196 ["multiline", false, "hidden"],
197 ["munger.bold", true, "munger"],
198 ["munger.bugzilla-link", true, "munger"],
199 ["munger.channel-link",true, "munger"],
200 ["munger.colorCodes", true, "munger"],
201 ["munger.ctrl-char", true, "munger"],
202 ["munger.face", true, "munger"],
203 ["munger.italic", true, "munger"],
204 ["munger.link", true, "munger"],
205 ["munger.mailto", true, "munger"],
206 ["munger.quote", true, "munger"],
207 ["munger.rheet", true, "munger"],
208 ["munger.talkback-link", true, "munger"],
209 ["munger.teletype", true, "munger"],
210 ["munger.underline", true, "munger"],
211 ["munger.word-hyphenator", true, "munger"],
212 ["networkHeader", true, "global.header"],
213 ["networkLog", false, "global.log"],
214 ["networkMaxLines", 200, "global.maxLines"],
215 ["newTabLimit", 15, "global"],
216 ["notify.aggressive", true, "global"],
217 ["nickCompleteStr", ":", "global"],
218 ["nickname", defaultNick
, ".ident"],
219 ["nicknameList", [], "lists.nicknameList"],
220 ["outgoing.colorCodes", false, "global"],
221 ["outputWindowURL", "chrome://chatzilla/content/output-window.html",
223 ["proxy.typeOverride", "", ".connect"],
224 ["sortUsersByMode", true, "appearance.userlist"],
225 //["queryBeep", "beep", "global.sounds"],
226 ["reconnect", true, ".connect"],
227 ["showModeSymbols", false, "appearance.userlist"],
228 //["stalkBeep", "beep", "global.sounds"],
229 ["stalkWholeWords", true, "lists.stalkWords"],
230 ["stalkWords", [], "lists.stalkWords"],
231 // Start == When view it opened.
232 // Event == "Superfluous" activity.
233 // Chat == "Activity" activity.
234 // Stalk == "Attention" activity.
235 ["sound.enabled", true, "global.sounds"],
236 ["sound.overlapDelay", 2000, "global.sounds"],
237 //["sound.surpressActive",false, "global.sounds"],
238 ["sound.channel.start", "", "global.soundEvts"],
239 ["sound.channel.event", "", "global.soundEvts"],
240 ["sound.channel.chat", "", "global.soundEvts"],
241 ["sound.channel.stalk", "beep", "global.soundEvts"],
242 ["sound.user.start", "beep beep", "global.soundEvts"],
243 ["sound.user.stalk", "beep", "global.soundEvts"],
244 ["inputSpellcheck", true, "global"],
245 ["timestamps", false, "appearance.timestamps"],
246 ["timestamps.display", "[%H:%M]", "appearance.timestamps"],
247 ["timestamps.log", "[%Y-%m-%d %H:%M:%S]", "hidden"],
248 ["urls.list", [], "hidden"],
249 ["urls.store.max", 100, "global"],
250 ["urls.display", 10, "hidden"],
251 ["username", "chatzilla", ".ident"],
252 ["usermode", "+i", ".ident"],
253 ["userHeader", true, "global.header"],
254 ["userlistLeft", true, "appearance.userlist"],
255 ["userLog", false, "global.log"],
256 ["userMaxLines", 200, "global.maxLines"],
257 ["warnOnClose", true, "global"]
260 client
.prefManager
.addPrefs(prefs
);
261 client
.prefManager
.addObserver({ onPrefChanged
: onPrefChanged
});
263 CIRCNetwork
.prototype.stayingPower
= client
.prefs
["reconnect"];
264 CIRCNetwork
.prototype.MAX_CONNECT_ATTEMPTS
= client
.prefs
["connectTries"];
265 CIRCNetwork
.prototype.INITIAL_NICK
= client
.prefs
["nickname"];
266 CIRCNetwork
.prototype.INITIAL_NAME
= client
.prefs
["username"];
267 CIRCNetwork
.prototype.INITIAL_DESC
= client
.prefs
["desc"];
268 CIRCNetwork
.prototype.INITIAL_UMODE
= client
.prefs
["usermode"];
269 CIRCNetwork
.prototype.MAX_MESSAGES
= client
.prefs
["networkMaxLines"];
270 CIRCNetwork
.prototype.PROXY_TYPE_OVERRIDE
= client
.prefs
["proxy.typeOverride"];
271 CIRCChannel
.prototype.MAX_MESSAGES
= client
.prefs
["channelMaxLines"];
272 CIRCChanUser
.prototype.MAX_MESSAGES
= client
.prefs
["userMaxLines"];
273 var dccUserMaxLines
= client
.prefs
["dccUserMaxLines"];
274 CIRCDCCChat
.prototype.MAX_MESSAGES
= dccUserMaxLines
;
275 CIRCDCCFileTransfer
.prototype.MAX_MESSAGES
= dccUserMaxLines
;
276 CIRCDCC
.prototype.listenPorts
= client
.prefs
["dcc.listenPorts"];
277 client
.MAX_MESSAGES
= client
.prefs
["clientMaxLines"];
278 client
.charset
= client
.prefs
["charset"];
283 function makeLogName(obj
, type
)
285 function replaceNonPrintables(ch
) {
286 var rv
= ch
.charCodeAt().toString(16);
289 else if (rv
.length
== 3)
291 else if (rv
.length
== 4)
297 function encode(text
)
299 text
= text
.replace(/[^-A-Z0-9_#!.,'@~\[\]{}()%$"]/gi, replaceNonPrintables
);
301 return encodeURIComponent(text
);
304 /* /\$\(([^)]+)\)|\$(\w)/g *
306 * longName shortName *
308 function replaceParam(match
, longName
, shortName
)
310 if (typeof longName
!= "undefined" && longName
)
312 // Remember to encode these, don't want some dodgy # breaking stuff.
313 if (longName
in longCodes
)
314 return encode(longCodes
[longName
]);
316 dd("Unknown long code: " + longName
);
318 else if (typeof shortName
!= "undefined" && shortName
)
320 if (shortName
in shortCodes
)
321 return encode(shortCodes
[shortName
]);
323 dd("Unknown short code: " + shortName
);
327 dd("Unknown match: " + match
);
333 var base
= client
.prefs
["logFolder"];
334 var specific
= client
.prefs
["logFile." + type
];
336 // Make sure we got ourselves a slash, or we'll be in trouble with the
338 if (!base
.match(/\/$/))
340 var file
= base
+ specific
;
342 // Get details for $-replacement variables.
343 var info
= getObjectDetails(obj
);
345 // Store the most specific time short code on the object.
346 obj
.smallestLogInterval
= "";
347 if (file
.indexOf("$y") != -1)
348 obj
.smallestLogInterval
= "y";
349 if (file
.indexOf("$m") != -1)
350 obj
.smallestLogInterval
= "m";
351 if (file
.indexOf("$d") != -1)
352 obj
.smallestLogInterval
= "d";
353 if (file
.indexOf("$h") != -1)
354 obj
.smallestLogInterval
= "h";
356 // Three longs codes: $(network), $(channel) and $(user).
357 // Each is available only if appropriate for the object.
358 var longCodes
= new Object();
360 longCodes
["network"] = info
.network
.unicodeName
;
362 longCodes
["channel"] = info
.channel
.unicodeName
;
364 longCodes
["user"] = info
.user
.unicodeName
;
366 // 4 short codes: $y, $m, $d, $h.
367 // These are time codes, each replaced with a fixed-length number.
369 var shortCodes
= { y
: padNumber(d
.getFullYear(), 4),
370 m
: padNumber(d
.getMonth() + 1, 2),
371 d
: padNumber(d
.getDate(), 2),
372 h
: padNumber(d
.getHours(), 2)
375 // Replace all $-variables in one go.
376 file
= file
.replace(/\$\(([^)]+)\)|\$(\w)/g, replaceParam
);
378 // Convert from file: URL to local OS format.
381 file
= getFileFromURLSpec(file
).path
;
385 dd("Error converting '" + base
+ specific
+ "' to a local file path.");
391 function pref_mungeName(name
)
393 var safeName
= name
.replace(/\./g, "-").replace(/:/g
, "_").toLowerCase();
394 return ecmaEscape(safeName
);
397 function getNetworkPrefManager(network
)
399 function defer(prefName
)
401 return client
.prefs
[prefName
];
404 function makeLogNameNetwork()
406 return makeLogName(network
, "network");
409 function onPrefChanged(prefName
, newValue
, oldValue
)
411 onNetworkPrefChanged (network
, prefName
, newValue
, oldValue
);
414 var logDefault
= client
.prefManager
.logPath
.clone();
415 logDefault
.append(escapeFileName(pref_mungeName(network
.encodedName
)) + ".log");
419 ["autoAwayPeriod", defer
, "appearance.misc"],
420 ["autoRejoin", defer
, ".connect"],
421 ["away", defer
, "hidden"],
422 ["awayNick", defer
, ".ident"],
423 ["bugURL", defer
, "appearance.misc"],
424 ["bugURL.comment", defer
, "appearance.misc"],
425 ["charset", defer
, ".connect"],
426 ["collapseActions", defer
, "appearance.misc"],
427 ["collapseMsgs", defer
, "appearance.misc"],
428 ["conference.limit", defer
, "appearance.misc"],
429 ["connectTries", defer
, ".connect"],
430 ["dcc.useServerIP", defer
, "dcc"],
431 ["dcc.downloadsFolder", defer
, "dcc"],
432 ["dcc.autoAccept.list", [], "dcc.autoAccept"],
433 ["defaultQuitMsg", defer
, ".connect"],
434 ["desc", defer
, ".ident"],
435 ["displayHeader", client
.prefs
["networkHeader"],
437 ["font.family", defer
, "appearance.misc"],
438 ["font.size", defer
, "appearance.misc"],
439 ["hasPrefs", false, "hidden"],
440 ["identd.enabled", defer
, client
.prefManager
.identGroup
],
441 ["ignoreList", [], "hidden"],
442 ["log", client
.prefs
["networkLog"], ".log"],
443 ["logFileName", makeLogNameNetwork
, "hidden"],
444 ["motif.current", defer
, "appearance.motif"],
445 ["nickname", defer
, ".ident"],
446 ["nicknameList", defer
, "lists.nicknameList"],
447 ["notifyList", [], "lists.notifyList"],
448 ["outputWindowURL", defer
, "hidden"],
449 ["proxy.typeOverride", defer
, ".connect"],
450 ["reconnect", defer
, ".connect"],
451 ["timestamps", defer
, "appearance.timestamps"],
452 ["timestamps.display", defer
, "appearance.timestamps"],
453 ["timestamps.log", defer
, "hidden"],
454 ["username", defer
, ".ident"],
455 ["usermode", defer
, ".ident"],
456 ["autoperform", [], "lists.autoperform"]
459 var branch
= "extensions.irc.networks." + pref_mungeName(network
.encodedName
) +
461 var prefManager
= new PrefManager(branch
, client
.defaultBundle
);
462 prefManager
.addPrefs(prefs
);
463 prefManager
.addObserver({ onPrefChanged
: onPrefChanged
});
464 client
.prefManager
.addObserver(prefManager
);
466 var value
= prefManager
.prefs
["nickname"];
467 if (value
!= CIRCNetwork
.prototype.INITIAL_NICK
)
468 network
.INITIAL_NICK
= value
;
470 value
= prefManager
.prefs
["username"];
471 if (value
!= CIRCNetwork
.prototype.INITIAL_NAME
)
472 network
.INITIAL_NAME
= value
;
474 value
= prefManager
.prefs
["desc"];
475 if (value
!= CIRCNetwork
.prototype.INITIAL_DESC
)
476 network
.INITIAL_DESC
= value
;
478 value
= prefManager
.prefs
["usermode"];
479 if (value
!= CIRCNetwork
.prototype.INITIAL_UMODE
)
480 network
.INITIAL_UMODE
= value
;
482 value
= prefManager
.prefs
["proxy.typeOverride"];
483 if (value
!= CIRCNetwork
.prototype.PROXY_TYPE_OVERRIDE
)
484 network
.PROXY_TYPE_OVERRIDE
= value
;
486 network
.stayingPower
= prefManager
.prefs
["reconnect"];
487 network
.MAX_CONNECT_ATTEMPTS
= prefManager
.prefs
["connectTries"];
489 client
.prefManagers
.push(prefManager
);
494 function getChannelPrefManager(channel
)
496 var network
= channel
.parent
.parent
;
498 function defer(prefName
)
500 return network
.prefs
[prefName
];
503 function makeLogNameChannel()
505 return makeLogName(channel
, "channel");
508 function onPrefChanged(prefName
, newValue
, oldValue
)
510 onChannelPrefChanged (channel
, prefName
, newValue
, oldValue
);
513 var logDefault
= client
.prefManager
.logPath
.clone();
514 var filename
= pref_mungeName(network
.encodedName
) + "," +
515 pref_mungeName(channel
.encodedName
);
517 logDefault
.append(escapeFileName(filename
) + ".log");
521 ["autoRejoin", defer
, ".connect"],
522 ["bugURL", defer
, "appearance.misc"],
523 ["bugURL.comment", defer
, "appearance.misc"],
524 ["charset", defer
, ".connect"],
525 ["collapseActions", defer
, "appearance.misc"],
526 ["collapseMsgs", defer
, "appearance.misc"],
527 ["conference.enabled", false, "hidden"],
528 ["conference.limit", defer
, "appearance.misc"],
529 ["displayHeader", client
.prefs
["channelHeader"],
531 ["font.family", defer
, "appearance.misc"],
532 ["font.size", defer
, "appearance.misc"],
533 ["hasPrefs", false, "hidden"],
534 ["log", client
.prefs
["channelLog"], ".log"],
535 ["logFileName", makeLogNameChannel
, "hidden"],
536 ["motif.current", defer
, "appearance.motif"],
537 ["timestamps", defer
, "appearance.timestamps"],
538 ["timestamps.display", defer
, "appearance.timestamps"],
539 ["timestamps.log", defer
, "hidden"],
540 ["outputWindowURL", defer
, "hidden"]
543 var branch
= "extensions.irc.networks." + pref_mungeName(network
.encodedName
) +
544 ".channels." + pref_mungeName(channel
.encodedName
) + "."
545 var prefManager
= new PrefManager(branch
, client
.defaultBundle
);
546 prefManager
.addPrefs(prefs
);
547 prefManager
.addObserver({ onPrefChanged
: onPrefChanged
});
548 network
.prefManager
.addObserver(prefManager
);
550 client
.prefManagers
.push(prefManager
);
555 function getUserPrefManager(user
)
557 var network
= user
.parent
.parent
;
559 function defer(prefName
)
561 return network
.prefs
[prefName
];
564 function makeLogNameUser()
566 return makeLogName(user
, "user");
569 function onPrefChanged(prefName
, newValue
, oldValue
)
571 onUserPrefChanged (user
, prefName
, newValue
, oldValue
);
574 var logDefault
= client
.prefManager
.logPath
.clone();
575 var filename
= pref_mungeName(network
.encodedName
);
576 filename
+= "," + pref_mungeName(user
.encodedName
);
577 logDefault
.append(escapeFileName(filename
) + ".log");
581 ["charset", defer
, ".connect"],
582 ["collapseActions", defer
, "appearance.misc"],
583 ["collapseMsgs", defer
, "appearance.misc"],
584 ["displayHeader", client
.prefs
["userHeader"], "appearance.misc"],
585 ["font.family", defer
, "appearance.misc"],
586 ["font.size", defer
, "appearance.misc"],
587 ["hasPrefs", false, "hidden"],
588 ["motif.current", defer
, "appearance.motif"],
589 ["outputWindowURL", defer
, "hidden"],
590 ["log", client
.prefs
["userLog"], ".log"],
591 ["logFileName", makeLogNameUser
, "hidden"],
592 ["timestamps", defer
, "appearance.timestamps"],
593 ["timestamps.display", defer
, "appearance.timestamps"],
594 ["timestamps.log", defer
, "hidden"]
597 var branch
= "extensions.irc.networks." + pref_mungeName(network
.encodedName
) +
598 ".users." + pref_mungeName(user
.encodedName
) + ".";
599 var prefManager
= new PrefManager(branch
, client
.defaultBundle
);
600 prefManager
.addPrefs(prefs
);
601 prefManager
.addObserver({ onPrefChanged
: onPrefChanged
});
602 network
.prefManager
.addObserver(prefManager
);
604 client
.prefManagers
.push(prefManager
);
609 function getDCCUserPrefManager(user
)
611 function defer(prefName
)
613 return client
.prefs
[prefName
];
616 function makeLogNameUser()
618 return makeLogName(user
, "dccuser");
621 function onPrefChanged(prefName
, newValue
, oldValue
)
623 onDCCUserPrefChanged(user
, prefName
, newValue
, oldValue
);
628 ["charset", defer
, ".connect"],
629 ["collapseMsgs", defer
, "appearance.misc"],
630 ["displayHeader", client
.prefs
["dccUserHeader"], "appearance.misc"],
631 ["font.family", defer
, "appearance.misc"],
632 ["font.size", defer
, "appearance.misc"],
633 ["hasPrefs", false, "hidden"],
634 ["motif.current", defer
, "appearance.motif"],
635 ["outputWindowURL", defer
, "hidden"],
636 ["log", client
.prefs
["dccUserLog"], ".log"],
637 ["logFileName", makeLogNameUser
, "hidden"],
638 ["timestamps", defer
, "appearance.timestamps"],
639 ["timestamps.display", defer
, "appearance.timestamps"],
640 ["timestamps.log", defer
, "hidden"]
643 var branch
= "extensions.irc.dcc.users." +
644 pref_mungeName(user
.canonicalName
) + ".";
645 var prefManager
= new PrefManager(branch
, client
.defaultBundle
);
646 prefManager
.addPrefs(prefs
);
647 prefManager
.addObserver({ onPrefChanged
: onPrefChanged
});
648 client
.prefManager
.addObserver(prefManager
);
650 client
.prefManagers
.push(prefManager
);
655 function destroyPrefs()
657 if ("prefManagers" in client
)
659 for (var i
= 0; i
< client
.prefManagers
.length
; ++i
)
660 client
.prefManagers
[i
].destroy();
661 client
.prefManagers
= [];
665 function onPrefChanged(prefName
, newValue
, oldValue
)
670 uninitIdleAutoAway(oldValue
);
671 initIdleAutoAway(newValue
);
674 case "channelMaxLines":
675 CIRCChannel
.prototype.MAX_MESSAGES
= newValue
;
679 client
.charset
= newValue
;
682 case "clientMaxLines":
683 client
.MAX_MESSAGES
= newValue
;
687 CIRCNetwork
.prototype.MAX_CONNECT_ATTEMPTS
= newValue
;
690 case "dcc.listenPorts":
691 CIRCDCC
.prototype.listenPorts
= newValue
;
694 case "dccUserMaxLines":
695 CIRCDCCFileTransfer
.prototype.MAX_MESSAGES
= newValue
;
696 CIRCDCCChat
.prototype.MAX_MESSAGES
= newValue
;
701 client
.dispatch("sync-font");
704 case "instrumentation.inst1":
705 if ((oldValue
== 0) && (newValue
== 1))
706 runInstrumentation("inst1", true);
708 runInstrumentation("inst1", false);
711 case "proxy.typeOverride":
712 CIRCNetwork
.prototype.PROXY_TYPE_OVERRIDE
= newValue
;
716 CIRCNetwork
.prototype.stayingPower
= newValue
;
719 case "showModeSymbols":
721 setListMode("symbol");
723 setListMode("graphic");
727 CIRCNetwork
.prototype.INITIAL_NICK
= newValue
;
731 CIRCNetwork
.prototype.INITIAL_NAME
= newValue
;
735 CIRCNetwork
.prototype.INITIAL_UMODE
= newValue
;
739 CIRCChanUser
.prototype.MAX_MESSAGES
= newValue
;
743 updateUserlistSide(newValue
);
747 setDebugMode(newValue
);
751 CIRCNetwork
.prototype.INITIAL_DESC
= newValue
;
754 case "stalkWholeWords":
756 updateAllStalkExpressions();
759 case "sortUsersByMode":
760 if (client
.currentObject
.TYPE
== "IRCChannel")
763 case "motif.current":
764 client
.dispatch("sync-motif");
768 multilineInputMode(newValue
);
771 case "munger.colorCodes":
772 client
.enableColors
= newValue
;
775 case "networkMaxLines":
776 CIRCNetwork
.prototype.MAX_MESSAGES
= newValue
;
779 case "outputWindowURL":
780 client
.dispatch("sync-window");
783 case "displayHeader":
784 client
.dispatch("sync-header");
788 case "timestamps.display":
789 client
.dispatch("sync-timestamp");
793 client
.dispatch("sync-log");
800 case "inputSpellcheck":
801 updateSpellcheck(newValue
);
805 // Make munger prefs apply without a restart
807 if ((m
= prefName
.match(/^munger\.(\S+)$/)) &&
808 (rule
= client
.munger
.getRule(m
[1])))
810 rule
.enabled
= newValue
;
815 function onNetworkPrefChanged(network
, prefName
, newValue
, oldValue
)
817 if (network
!= client
.networks
[network
.canonicalName
])
819 /* this is a stale observer, remove it */
820 network
.prefManager
.destroy();
824 network
.updateHeader();
829 network
.INITIAL_NICK
= newValue
;
833 network
.INITIAL_NAME
= newValue
;
837 network
.INITIAL_UMODE
= newValue
;
838 if (network
.isConnected())
840 network
.primServ
.sendData("mode " + network
.server
.me
+ " :" +
846 network
.INITIAL_DESC
= newValue
;
849 case "proxy.typeOverride":
850 network
.PROXY_TYPE_OVERRIDE
= newValue
;
854 network
.stayingPower
= newValue
;
859 network
.dispatch("sync-font");
862 case "motif.current":
863 network
.dispatch("sync-motif");
866 case "outputWindowURL":
867 network
.dispatch("sync-window");
870 case "displayHeader":
871 network
.dispatch("sync-header");
875 case "timestamps.display":
876 network
.dispatch("sync-timestamp");
880 network
.dispatch("sync-log");
884 network
.MAX_CONNECT_ATTEMPTS
= newValue
;
889 function onChannelPrefChanged(channel
, prefName
, newValue
, oldValue
)
891 var network
= channel
.parent
.parent
;
893 if (network
!= client
.networks
[network
.canonicalName
] ||
894 channel
.parent
!= network
.primServ
||
895 channel
!= network
.primServ
.channels
[channel
.canonicalName
])
897 /* this is a stale observer, remove it */
898 channel
.prefManager
.destroy();
902 channel
.updateHeader();
906 case "conference.enabled":
907 // Wouldn't want to display a message to a hidden view.
908 if ("messages" in channel
)
911 channel
.display(MSG_CONF_MODE_ON
);
913 channel
.display(MSG_CONF_MODE_OFF
);
917 case "conference.limit":
918 channel
._updateConferenceMode();
923 channel
.dispatch("sync-font");
926 case "motif.current":
927 channel
.dispatch("sync-motif");
930 case "outputWindowURL":
931 channel
.dispatch("sync-window");
934 case "displayHeader":
935 channel
.dispatch("sync-header");
939 case "timestamps.display":
940 channel
.dispatch("sync-timestamp");
944 channel
.dispatch("sync-log");
949 function onUserPrefChanged(user
, prefName
, newValue
, oldValue
)
951 var network
= user
.parent
.parent
;
953 if (network
!= client
.networks
[network
.canonicalName
] ||
954 user
.parent
!= network
.primServ
||
955 user
!= network
.primServ
.users
[user
.canonicalName
])
957 /* this is a stale observer, remove it */
958 user
.prefManager
.destroy();
968 user
.dispatch("sync-font");
971 case "motif.current":
972 user
.dispatch("sync-motif");
975 case "outputWindowURL":
976 user
.dispatch("sync-window");
979 case "displayHeader":
980 user
.dispatch("sync-header");
984 case "timestamps.display":
985 user
.dispatch("sync-timestamp");
989 user
.dispatch("sync-log");
994 function onDCCUserPrefChanged(user
, prefName
, newValue
, oldValue
)
996 if (client
.dcc
.users
[user
.key
] != user
)
998 /* this is a stale observer, remove it */
999 user
.prefManager
.destroy();
1003 // DCC Users are a pain, they can have multiple views!
1004 function updateDCCView(view
)
1010 view
.dispatch("sync-font");
1013 case "motif.current":
1014 view
.dispatch("sync-motif");
1017 case "outputWindowURL":
1018 view
.dispatch("sync-window");
1021 case "displayHeader":
1022 view
.dispatch("sync-header");
1026 case "timestamps.display":
1027 view
.dispatch("sync-timestamp");
1031 view
.dispatch("sync-log");
1036 for (var i
= 0; client
.dcc
.chats
.length
; i
++)
1038 var chat
= client
.dcc
.chats
[i
];
1039 if (chat
.user
== user
)
1040 updateDCCView(chat
);
1044 function initAliases()
1046 var aliasDefs
= client
.prefs
["aliases"];
1048 for (var i
= 0; i
< aliasDefs
.length
; ++i
)
1050 var ary
= aliasDefs
[i
].match(/^(.*?)\s*=\s*(.*)$/);
1056 client
.commandManager
.defineCommand(name
, list
);
1060 dd("Malformed alias: " + aliasDefs
[i
]);