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"];
95 else if (client
.host
== "Songbird")
97 // Songbird has a browser, but only supports a single browser window
98 gotos
= ["goto-url", "goto-url-newtab",
99 "goto-url-newtab", "goto-url-newtab"];
102 // Set up default nickname, if possible.
103 var defaultNick
= DEFAULT_NICK
;
104 var en
= getService("@mozilla.org/process/environment;1", "nsIEnvironment");
107 /* Get the enviroment variables used by various OSes:
108 * USER - Linux, Mac OSX and other *nix-types.
109 * USERNAME - Windows.
110 * LOGNAME - *nix again.
112 const vars
= ["USER", "USERNAME", "LOGNAME"];
114 for (var i
= 0; i
< vars
.length
; i
++)
116 var nick
= en
.get(vars
[i
]);
125 // Set a property so network ident prefs get the same group later:
126 client
.prefManager
.identGroup
= ".connect";
127 // Linux and OS X won't let non-root listen on port 113.
128 if ((client
.platform
== "Linux") || (client
.platform
== "Mac"))
129 client
.prefManager
.identGroup
= "hidden";
133 ["activityFlashDelay", 200, "hidden"],
134 ["aliases", [], "lists.aliases"],
135 ["autoAwayCap", 300, "global"],
136 ["autoAwayPeriod", 2, "appearance.misc"],
137 ["autoRejoin", false, ".connect"],
138 ["away", "", "hidden"],
139 ["awayNick", "", ".ident"],
140 ["awayIdleTime", 0, ".ident"],
141 ["awayIdleMsg", "", ".ident"],
142 ["bugURL", "https://bugzilla.mozilla.org/show_bug.cgi?id=%s",
144 ["bugURL.comment", "#c%s", "appearance.misc"],
145 ["channelHeader", true, "global.header"],
146 ["channelLog", false, "global.log"],
147 ["channelMaxLines", 500, "global.maxLines"],
148 ["charset", "utf-8", ".connect"],
149 ["clientMaxLines", 200, "global.maxLines"],
150 ["collapseActions", true, "appearance.misc"],
151 ["collapseMsgs", false, "appearance.misc"],
152 ["conference.limit", 150, "appearance.misc"],
153 ["connectTries", -1, ".connect"],
154 ["copyMessages", true, "global"],
155 ["dccUserHeader", true, "global.header"],
156 ["dccUserLog", false, "global.log"],
157 ["dccUserMaxLines", 500, "global.maxLines"],
158 ["dcc.enabled", true, "dcc"],
159 ["dcc.autoAccept.delay", 10000, "hidden"],
160 ["dcc.downloadsFolder", getURLSpecFromFile(downloadsPath
.path
), "dcc"],
161 ["dcc.listenPorts", [], "dcc.ports"],
162 ["dcc.useServerIP", true, "dcc"],
163 ["debugMode", "", "hidden"],
164 ["defaultQuitMsg", "", ".connect"],
165 ["desc", "New Now Know How", ".ident"],
166 ["deleteOnPart", true, "global"],
167 ["displayHeader", true, "appearance.misc"],
168 ["guessCommands", true, "hidden"],
169 ["hasPrefs", false, "hidden"],
170 ["font.family", "default", "appearance.misc"],
171 ["font.size", 0, "appearance.misc"],
172 ["identd.enabled", false, client
.prefManager
.identGroup
],
173 ["initialURLs", [], "startup.initialURLs"],
174 ["initialScripts", [getURLSpecFromFile(scriptPath
.path
)],
175 "startup.initialScripts"],
176 ["instrumentation.key", 0, "hidden"],
177 ["instrumentation.inst1", 0, "hidden"],
178 ["link.focus", true, "global.links"],
179 ["log", false, ".log"],
180 ["logFileName", makeLogNameClient
, "hidden"],
181 ["logFile.client", "client.$y-$m-$d.log", "hidden"],
182 ["logFile.network", "$(network)/$(network).$y-$m-$d.log", "hidden"],
183 ["logFile.channel", "$(network)/channels/$(channel).$y-$m-$d.log",
185 ["logFile.user", "$(network)/users/$(user).$y-$m-$d.log",
187 ["logFile.dccuser", "dcc/$(user)/$(user).$y-$m-$d.log", "hidden"],
188 ["logFolder", getURLSpecFromFile(logPath
.path
), ".log"],
189 ["messages.click", gotos
[0], "global.links"],
190 ["messages.ctrlClick", gotos
[1], "global.links"],
191 ["messages.metaClick", gotos
[2], "global.links"],
192 ["messages.middleClick", gotos
[3], "global.links"],
193 ["motif.dark", "chrome://chatzilla/skin/output-dark.css",
195 ["motif.light", "chrome://chatzilla/skin/output-light.css",
197 ["motif.default", "chrome://chatzilla/skin/output-default.css",
199 ["motif.current", "chrome://chatzilla/skin/output-default.css",
201 //["msgBeep", "beep beep", "global.sounds"],
202 ["multiline", false, "hidden"],
203 ["munger.bold", true, "munger"],
204 ["munger.bugzilla-link", true, "munger"],
205 ["munger.channel-link",true, "munger"],
206 ["munger.colorCodes", true, "munger"],
207 ["munger.ctrl-char", true, "munger"],
208 ["munger.face", true, "munger"],
209 ["munger.italic", true, "munger"],
210 ["munger.link", true, "munger"],
211 ["munger.mailto", true, "munger"],
212 ["munger.quote", true, "munger"],
213 ["munger.rheet", true, "munger"],
214 ["munger.talkback-link", true, "munger"],
215 ["munger.teletype", true, "munger"],
216 ["munger.underline", true, "munger"],
217 ["munger.word-hyphenator", true, "munger"],
218 ["networkHeader", true, "global.header"],
219 ["networkLog", false, "global.log"],
220 ["networkMaxLines", 200, "global.maxLines"],
221 ["newTabLimit", 15, "global"],
222 ["notify.aggressive", true, "global"],
223 ["nickCompleteStr", ":", "global"],
224 ["nickname", defaultNick
, ".ident"],
225 ["nicknameList", [], "lists.nicknameList"],
226 ["outgoing.colorCodes", false, "global"],
227 ["outputWindowURL", "chrome://chatzilla/content/output-window.html",
229 ["proxy.typeOverride", "", ".connect"],
230 ["sortUsersByMode", true, "appearance.userlist"],
231 //["queryBeep", "beep", "global.sounds"],
232 ["reconnect", true, ".connect"],
233 ["showModeSymbols", false, "appearance.userlist"],
234 //["stalkBeep", "beep", "global.sounds"],
235 ["stalkWholeWords", true, "lists.stalkWords"],
236 ["stalkWords", [], "lists.stalkWords"],
237 // Start == When view it opened.
238 // Event == "Superfluous" activity.
239 // Chat == "Activity" activity.
240 // Stalk == "Attention" activity.
241 ["sound.enabled", true, "global.sounds"],
242 ["sound.overlapDelay", 2000, "global.sounds"],
243 //["sound.surpressActive",false, "global.sounds"],
244 ["sound.channel.start", "", "global.soundEvts"],
245 ["sound.channel.event", "", "global.soundEvts"],
246 ["sound.channel.chat", "", "global.soundEvts"],
247 ["sound.channel.stalk", "beep", "global.soundEvts"],
248 ["sound.user.start", "beep beep", "global.soundEvts"],
249 ["sound.user.stalk", "beep", "global.soundEvts"],
250 ["inputSpellcheck", true, "global"],
251 ["timestamps", false, "appearance.timestamps"],
252 ["timestamps.display", "[%H:%M]", "appearance.timestamps"],
253 ["timestamps.log", "[%Y-%m-%d %H:%M:%S]", "hidden"],
254 ["urls.list", [], "hidden"],
255 ["urls.store.max", 100, "global"],
256 ["urls.display", 10, "hidden"],
257 ["username", "chatzilla", ".ident"],
258 ["usermode", "+i", ".ident"],
259 ["userHeader", true, "global.header"],
260 ["userlistLeft", true, "appearance.userlist"],
261 ["userLog", false, "global.log"],
262 ["userMaxLines", 200, "global.maxLines"],
263 ["warnOnClose", true, "global"]
266 client
.prefManager
.addPrefs(prefs
);
267 client
.prefManager
.addObserver({ onPrefChanged
: onPrefChanged
});
269 CIRCNetwork
.prototype.stayingPower
= client
.prefs
["reconnect"];
270 CIRCNetwork
.prototype.MAX_CONNECT_ATTEMPTS
= client
.prefs
["connectTries"];
271 CIRCNetwork
.prototype.INITIAL_NICK
= client
.prefs
["nickname"];
272 CIRCNetwork
.prototype.INITIAL_NAME
= client
.prefs
["username"];
273 CIRCNetwork
.prototype.INITIAL_DESC
= client
.prefs
["desc"];
274 CIRCNetwork
.prototype.INITIAL_UMODE
= client
.prefs
["usermode"];
275 CIRCNetwork
.prototype.MAX_MESSAGES
= client
.prefs
["networkMaxLines"];
276 CIRCNetwork
.prototype.PROXY_TYPE_OVERRIDE
= client
.prefs
["proxy.typeOverride"];
277 CIRCChannel
.prototype.MAX_MESSAGES
= client
.prefs
["channelMaxLines"];
278 CIRCChanUser
.prototype.MAX_MESSAGES
= client
.prefs
["userMaxLines"];
279 var dccUserMaxLines
= client
.prefs
["dccUserMaxLines"];
280 CIRCDCCChat
.prototype.MAX_MESSAGES
= dccUserMaxLines
;
281 CIRCDCCFileTransfer
.prototype.MAX_MESSAGES
= dccUserMaxLines
;
282 CIRCDCC
.prototype.listenPorts
= client
.prefs
["dcc.listenPorts"];
283 client
.MAX_MESSAGES
= client
.prefs
["clientMaxLines"];
284 client
.charset
= client
.prefs
["charset"];
289 function makeLogName(obj
, type
)
291 function replaceNonPrintables(ch
) {
292 var rv
= ch
.charCodeAt().toString(16);
295 else if (rv
.length
== 3)
297 else if (rv
.length
== 4)
303 function encode(text
)
305 text
= text
.replace(/[^-A-Z0-9_#!.,'@~\[\]{}()%$"]/gi, replaceNonPrintables
);
307 return encodeURIComponent(text
);
310 /* /\$\(([^)]+)\)|\$(\w)/g *
312 * longName shortName *
314 function replaceParam(match
, longName
, shortName
)
316 if (typeof longName
!= "undefined" && longName
)
318 // Remember to encode these, don't want some dodgy # breaking stuff.
319 if (longName
in longCodes
)
320 return encode(longCodes
[longName
]);
322 dd("Unknown long code: " + longName
);
324 else if (typeof shortName
!= "undefined" && shortName
)
326 if (shortName
in shortCodes
)
327 return encode(shortCodes
[shortName
]);
329 dd("Unknown short code: " + shortName
);
333 dd("Unknown match: " + match
);
339 var base
= client
.prefs
["logFolder"];
340 var specific
= client
.prefs
["logFile." + type
];
342 // Make sure we got ourselves a slash, or we'll be in trouble with the
344 if (!base
.match(/\/$/))
346 var file
= base
+ specific
;
348 // Get details for $-replacement variables.
349 var info
= getObjectDetails(obj
);
351 // Store the most specific time short code on the object.
352 obj
.smallestLogInterval
= "";
353 if (file
.indexOf("$y") != -1)
354 obj
.smallestLogInterval
= "y";
355 if (file
.indexOf("$m") != -1)
356 obj
.smallestLogInterval
= "m";
357 if (file
.indexOf("$d") != -1)
358 obj
.smallestLogInterval
= "d";
359 if (file
.indexOf("$h") != -1)
360 obj
.smallestLogInterval
= "h";
362 // Three longs codes: $(network), $(channel) and $(user).
363 // Each is available only if appropriate for the object.
364 var longCodes
= new Object();
366 longCodes
["network"] = info
.network
.unicodeName
;
368 longCodes
["channel"] = info
.channel
.unicodeName
;
370 longCodes
["user"] = info
.user
.unicodeName
;
372 // 4 short codes: $y, $m, $d, $h.
373 // These are time codes, each replaced with a fixed-length number.
375 var shortCodes
= { y
: padNumber(d
.getFullYear(), 4),
376 m
: padNumber(d
.getMonth() + 1, 2),
377 d
: padNumber(d
.getDate(), 2),
378 h
: padNumber(d
.getHours(), 2)
381 // Replace all $-variables in one go.
382 file
= file
.replace(/\$\(([^)]+)\)|\$(\w)/g, replaceParam
);
384 // Convert from file: URL to local OS format.
387 file
= getFileFromURLSpec(file
).path
;
391 dd("Error converting '" + base
+ specific
+ "' to a local file path.");
397 function pref_mungeName(name
)
399 var safeName
= name
.replace(/\./g, "-").replace(/:/g
, "_").toLowerCase();
400 return ecmaEscape(safeName
);
403 function getNetworkPrefManager(network
)
405 function defer(prefName
)
407 return client
.prefs
[prefName
];
410 function makeLogNameNetwork()
412 return makeLogName(network
, "network");
415 function onPrefChanged(prefName
, newValue
, oldValue
)
417 onNetworkPrefChanged (network
, prefName
, newValue
, oldValue
);
420 var logDefault
= client
.prefManager
.logPath
.clone();
421 logDefault
.append(escapeFileName(pref_mungeName(network
.encodedName
)) + ".log");
425 ["autoAwayPeriod", defer
, "appearance.misc"],
426 ["autoRejoin", defer
, ".connect"],
427 ["away", defer
, "hidden"],
428 ["awayNick", defer
, ".ident"],
429 ["bugURL", defer
, "appearance.misc"],
430 ["bugURL.comment", defer
, "appearance.misc"],
431 ["charset", defer
, ".connect"],
432 ["collapseActions", defer
, "appearance.misc"],
433 ["collapseMsgs", defer
, "appearance.misc"],
434 ["conference.limit", defer
, "appearance.misc"],
435 ["connectTries", defer
, ".connect"],
436 ["dcc.useServerIP", defer
, "dcc"],
437 ["dcc.downloadsFolder", defer
, "dcc"],
438 ["dcc.autoAccept.list", [], "dcc.autoAccept"],
439 ["defaultQuitMsg", defer
, ".connect"],
440 ["desc", defer
, ".ident"],
441 ["displayHeader", client
.prefs
["networkHeader"],
443 ["font.family", defer
, "appearance.misc"],
444 ["font.size", defer
, "appearance.misc"],
445 ["hasPrefs", false, "hidden"],
446 ["identd.enabled", defer
, client
.prefManager
.identGroup
],
447 ["ignoreList", [], "hidden"],
448 ["log", client
.prefs
["networkLog"], ".log"],
449 ["logFileName", makeLogNameNetwork
, "hidden"],
450 ["motif.current", defer
, "appearance.motif"],
451 ["nickname", defer
, ".ident"],
452 ["nicknameList", defer
, "lists.nicknameList"],
453 ["notifyList", [], "lists.notifyList"],
454 ["outputWindowURL", defer
, "hidden"],
455 ["proxy.typeOverride", defer
, ".connect"],
456 ["reconnect", defer
, ".connect"],
457 ["timestamps", defer
, "appearance.timestamps"],
458 ["timestamps.display", defer
, "appearance.timestamps"],
459 ["timestamps.log", defer
, "hidden"],
460 ["username", defer
, ".ident"],
461 ["usermode", defer
, ".ident"],
462 ["autoperform", [], "lists.autoperform"]
465 var branch
= "extensions.irc.networks." + pref_mungeName(network
.encodedName
) +
467 var prefManager
= new PrefManager(branch
, client
.defaultBundle
);
468 prefManager
.addPrefs(prefs
);
469 prefManager
.addObserver({ onPrefChanged
: onPrefChanged
});
470 client
.prefManager
.addObserver(prefManager
);
472 var value
= prefManager
.prefs
["nickname"];
473 if (value
!= CIRCNetwork
.prototype.INITIAL_NICK
)
474 network
.INITIAL_NICK
= value
;
476 value
= prefManager
.prefs
["username"];
477 if (value
!= CIRCNetwork
.prototype.INITIAL_NAME
)
478 network
.INITIAL_NAME
= value
;
480 value
= prefManager
.prefs
["desc"];
481 if (value
!= CIRCNetwork
.prototype.INITIAL_DESC
)
482 network
.INITIAL_DESC
= value
;
484 value
= prefManager
.prefs
["usermode"];
485 if (value
!= CIRCNetwork
.prototype.INITIAL_UMODE
)
486 network
.INITIAL_UMODE
= value
;
488 value
= prefManager
.prefs
["proxy.typeOverride"];
489 if (value
!= CIRCNetwork
.prototype.PROXY_TYPE_OVERRIDE
)
490 network
.PROXY_TYPE_OVERRIDE
= value
;
492 network
.stayingPower
= prefManager
.prefs
["reconnect"];
493 network
.MAX_CONNECT_ATTEMPTS
= prefManager
.prefs
["connectTries"];
495 client
.prefManagers
.push(prefManager
);
500 function getChannelPrefManager(channel
)
502 var network
= channel
.parent
.parent
;
504 function defer(prefName
)
506 return network
.prefs
[prefName
];
509 function makeLogNameChannel()
511 return makeLogName(channel
, "channel");
514 function onPrefChanged(prefName
, newValue
, oldValue
)
516 onChannelPrefChanged (channel
, prefName
, newValue
, oldValue
);
519 var logDefault
= client
.prefManager
.logPath
.clone();
520 var filename
= pref_mungeName(network
.encodedName
) + "," +
521 pref_mungeName(channel
.encodedName
);
523 logDefault
.append(escapeFileName(filename
) + ".log");
527 ["autoRejoin", defer
, ".connect"],
528 ["bugURL", defer
, "appearance.misc"],
529 ["bugURL.comment", defer
, "appearance.misc"],
530 ["charset", defer
, ".connect"],
531 ["collapseActions", defer
, "appearance.misc"],
532 ["collapseMsgs", defer
, "appearance.misc"],
533 ["conference.enabled", false, "hidden"],
534 ["conference.limit", defer
, "appearance.misc"],
535 ["displayHeader", client
.prefs
["channelHeader"],
537 ["font.family", defer
, "appearance.misc"],
538 ["font.size", defer
, "appearance.misc"],
539 ["hasPrefs", false, "hidden"],
540 ["log", client
.prefs
["channelLog"], ".log"],
541 ["logFileName", makeLogNameChannel
, "hidden"],
542 ["motif.current", defer
, "appearance.motif"],
543 ["timestamps", defer
, "appearance.timestamps"],
544 ["timestamps.display", defer
, "appearance.timestamps"],
545 ["timestamps.log", defer
, "hidden"],
546 ["outputWindowURL", defer
, "hidden"]
549 var branch
= "extensions.irc.networks." + pref_mungeName(network
.encodedName
) +
550 ".channels." + pref_mungeName(channel
.encodedName
) + "."
551 var prefManager
= new PrefManager(branch
, client
.defaultBundle
);
552 prefManager
.addPrefs(prefs
);
553 prefManager
.addObserver({ onPrefChanged
: onPrefChanged
});
554 network
.prefManager
.addObserver(prefManager
);
556 client
.prefManagers
.push(prefManager
);
561 function getUserPrefManager(user
)
563 var network
= user
.parent
.parent
;
565 function defer(prefName
)
567 return network
.prefs
[prefName
];
570 function makeLogNameUser()
572 return makeLogName(user
, "user");
575 function onPrefChanged(prefName
, newValue
, oldValue
)
577 onUserPrefChanged (user
, prefName
, newValue
, oldValue
);
580 var logDefault
= client
.prefManager
.logPath
.clone();
581 var filename
= pref_mungeName(network
.encodedName
);
582 filename
+= "," + pref_mungeName(user
.encodedName
);
583 logDefault
.append(escapeFileName(filename
) + ".log");
587 ["charset", defer
, ".connect"],
588 ["collapseActions", defer
, "appearance.misc"],
589 ["collapseMsgs", defer
, "appearance.misc"],
590 ["displayHeader", client
.prefs
["userHeader"], "appearance.misc"],
591 ["font.family", defer
, "appearance.misc"],
592 ["font.size", defer
, "appearance.misc"],
593 ["hasPrefs", false, "hidden"],
594 ["motif.current", defer
, "appearance.motif"],
595 ["outputWindowURL", defer
, "hidden"],
596 ["log", client
.prefs
["userLog"], ".log"],
597 ["logFileName", makeLogNameUser
, "hidden"],
598 ["timestamps", defer
, "appearance.timestamps"],
599 ["timestamps.display", defer
, "appearance.timestamps"],
600 ["timestamps.log", defer
, "hidden"]
603 var branch
= "extensions.irc.networks." + pref_mungeName(network
.encodedName
) +
604 ".users." + pref_mungeName(user
.encodedName
) + ".";
605 var prefManager
= new PrefManager(branch
, client
.defaultBundle
);
606 prefManager
.addPrefs(prefs
);
607 prefManager
.addObserver({ onPrefChanged
: onPrefChanged
});
608 network
.prefManager
.addObserver(prefManager
);
610 client
.prefManagers
.push(prefManager
);
615 function getDCCUserPrefManager(user
)
617 function defer(prefName
)
619 return client
.prefs
[prefName
];
622 function makeLogNameUser()
624 return makeLogName(user
, "dccuser");
627 function onPrefChanged(prefName
, newValue
, oldValue
)
629 onDCCUserPrefChanged(user
, prefName
, newValue
, oldValue
);
634 ["charset", defer
, ".connect"],
635 ["collapseMsgs", defer
, "appearance.misc"],
636 ["displayHeader", client
.prefs
["dccUserHeader"], "appearance.misc"],
637 ["font.family", defer
, "appearance.misc"],
638 ["font.size", defer
, "appearance.misc"],
639 ["hasPrefs", false, "hidden"],
640 ["motif.current", defer
, "appearance.motif"],
641 ["outputWindowURL", defer
, "hidden"],
642 ["log", client
.prefs
["dccUserLog"], ".log"],
643 ["logFileName", makeLogNameUser
, "hidden"],
644 ["timestamps", defer
, "appearance.timestamps"],
645 ["timestamps.display", defer
, "appearance.timestamps"],
646 ["timestamps.log", defer
, "hidden"]
649 var branch
= "extensions.irc.dcc.users." +
650 pref_mungeName(user
.canonicalName
) + ".";
651 var prefManager
= new PrefManager(branch
, client
.defaultBundle
);
652 prefManager
.addPrefs(prefs
);
653 prefManager
.addObserver({ onPrefChanged
: onPrefChanged
});
654 client
.prefManager
.addObserver(prefManager
);
656 client
.prefManagers
.push(prefManager
);
661 function destroyPrefs()
663 if ("prefManagers" in client
)
665 for (var i
= 0; i
< client
.prefManagers
.length
; ++i
)
666 client
.prefManagers
[i
].destroy();
667 client
.prefManagers
= [];
671 function onPrefChanged(prefName
, newValue
, oldValue
)
676 uninitIdleAutoAway(oldValue
);
677 initIdleAutoAway(newValue
);
680 case "channelMaxLines":
681 CIRCChannel
.prototype.MAX_MESSAGES
= newValue
;
685 client
.charset
= newValue
;
688 case "clientMaxLines":
689 client
.MAX_MESSAGES
= newValue
;
693 CIRCNetwork
.prototype.MAX_CONNECT_ATTEMPTS
= newValue
;
696 case "dcc.listenPorts":
697 CIRCDCC
.prototype.listenPorts
= newValue
;
700 case "dccUserMaxLines":
701 CIRCDCCFileTransfer
.prototype.MAX_MESSAGES
= newValue
;
702 CIRCDCCChat
.prototype.MAX_MESSAGES
= newValue
;
707 client
.dispatch("sync-font");
710 case "instrumentation.inst1":
711 if ((oldValue
== 0) && (newValue
== 1))
712 runInstrumentation("inst1", true);
714 runInstrumentation("inst1", false);
717 case "proxy.typeOverride":
718 CIRCNetwork
.prototype.PROXY_TYPE_OVERRIDE
= newValue
;
722 CIRCNetwork
.prototype.stayingPower
= newValue
;
725 case "showModeSymbols":
727 setListMode("symbol");
729 setListMode("graphic");
733 CIRCNetwork
.prototype.INITIAL_NICK
= newValue
;
737 CIRCNetwork
.prototype.INITIAL_NAME
= newValue
;
741 CIRCNetwork
.prototype.INITIAL_UMODE
= newValue
;
745 CIRCChanUser
.prototype.MAX_MESSAGES
= newValue
;
749 updateUserlistSide(newValue
);
753 setDebugMode(newValue
);
757 CIRCNetwork
.prototype.INITIAL_DESC
= newValue
;
760 case "stalkWholeWords":
762 updateAllStalkExpressions();
765 case "sortUsersByMode":
766 if (client
.currentObject
.TYPE
== "IRCChannel")
769 case "motif.current":
770 client
.dispatch("sync-motif");
774 multilineInputMode(newValue
);
777 case "munger.colorCodes":
778 client
.enableColors
= newValue
;
781 case "networkMaxLines":
782 CIRCNetwork
.prototype.MAX_MESSAGES
= newValue
;
785 case "outputWindowURL":
786 client
.dispatch("sync-window");
789 case "displayHeader":
790 client
.dispatch("sync-header");
794 case "timestamps.display":
795 case "collapseActions":
797 client
.dispatch("sync-timestamp");
801 client
.dispatch("sync-log");
808 case "inputSpellcheck":
809 updateSpellcheck(newValue
);
813 // Make munger prefs apply without a restart
815 if ((m
= prefName
.match(/^munger\.(\S+)$/)) &&
816 (rule
= client
.munger
.getRule(m
[1])))
818 rule
.enabled
= newValue
;
823 function onNetworkPrefChanged(network
, prefName
, newValue
, oldValue
)
825 if (network
!= client
.networks
[network
.canonicalName
])
827 /* this is a stale observer, remove it */
828 network
.prefManager
.destroy();
832 network
.updateHeader();
837 network
.INITIAL_NICK
= newValue
;
841 network
.INITIAL_NAME
= newValue
;
845 network
.INITIAL_UMODE
= newValue
;
846 if (network
.isConnected())
848 network
.primServ
.sendData("mode " + network
.server
.me
+ " :" +
854 network
.INITIAL_DESC
= newValue
;
857 case "proxy.typeOverride":
858 network
.PROXY_TYPE_OVERRIDE
= newValue
;
862 network
.stayingPower
= newValue
;
867 network
.dispatch("sync-font");
870 case "motif.current":
871 network
.dispatch("sync-motif");
874 case "outputWindowURL":
875 network
.dispatch("sync-window");
878 case "displayHeader":
879 network
.dispatch("sync-header");
883 case "timestamps.display":
884 case "collapseActions":
886 network
.dispatch("sync-timestamp");
890 network
.dispatch("sync-log");
894 network
.MAX_CONNECT_ATTEMPTS
= newValue
;
899 function onChannelPrefChanged(channel
, prefName
, newValue
, oldValue
)
901 var network
= channel
.parent
.parent
;
903 if (network
!= client
.networks
[network
.canonicalName
] ||
904 channel
.parent
!= network
.primServ
||
905 channel
!= network
.primServ
.channels
[channel
.canonicalName
])
907 /* this is a stale observer, remove it */
908 channel
.prefManager
.destroy();
912 channel
.updateHeader();
916 case "conference.enabled":
917 // Wouldn't want to display a message to a hidden view.
918 if ("messages" in channel
)
921 channel
.display(MSG_CONF_MODE_ON
);
923 channel
.display(MSG_CONF_MODE_OFF
);
927 case "conference.limit":
928 channel
._updateConferenceMode();
933 channel
.dispatch("sync-font");
936 case "motif.current":
937 channel
.dispatch("sync-motif");
940 case "outputWindowURL":
941 channel
.dispatch("sync-window");
944 case "displayHeader":
945 channel
.dispatch("sync-header");
949 case "timestamps.display":
950 case "collapseActions":
952 channel
.dispatch("sync-timestamp");
956 channel
.dispatch("sync-log");
961 function onUserPrefChanged(user
, prefName
, newValue
, oldValue
)
963 var network
= user
.parent
.parent
;
965 if (network
!= client
.networks
[network
.canonicalName
] ||
966 user
.parent
!= network
.primServ
||
967 user
!= network
.primServ
.users
[user
.canonicalName
])
969 /* this is a stale observer, remove it */
970 user
.prefManager
.destroy();
980 user
.dispatch("sync-font");
983 case "motif.current":
984 user
.dispatch("sync-motif");
987 case "outputWindowURL":
988 user
.dispatch("sync-window");
991 case "displayHeader":
992 user
.dispatch("sync-header");
996 case "timestamps.display":
997 case "collapseActions":
999 user
.dispatch("sync-timestamp");
1003 user
.dispatch("sync-log");
1008 function onDCCUserPrefChanged(user
, prefName
, newValue
, oldValue
)
1010 if (client
.dcc
.users
[user
.key
] != user
)
1012 /* this is a stale observer, remove it */
1013 user
.prefManager
.destroy();
1017 // DCC Users are a pain, they can have multiple views!
1018 function updateDCCView(view
)
1024 view
.dispatch("sync-font");
1027 case "motif.current":
1028 view
.dispatch("sync-motif");
1031 case "outputWindowURL":
1032 view
.dispatch("sync-window");
1035 case "displayHeader":
1036 view
.dispatch("sync-header");
1040 case "timestamps.display":
1041 case "collapseActions":
1042 case "collapseMsgs":
1043 view
.dispatch("sync-timestamp");
1047 view
.dispatch("sync-log");
1052 for (var i
= 0; client
.dcc
.chats
.length
; i
++)
1054 var chat
= client
.dcc
.chats
[i
];
1055 if (chat
.user
== user
)
1056 updateDCCView(chat
);
1060 function initAliases()
1062 var aliasDefs
= client
.prefs
["aliases"];
1064 for (var i
= 0; i
< aliasDefs
.length
; ++i
)
1066 var ary
= aliasDefs
[i
].match(/^(.*?)\s*=\s*(.*)$/);
1072 client
.commandManager
.defineCommand(name
, list
);
1076 dd("Malformed alias: " + aliasDefs
[i
]);