bug 206639, "land latest chatzilla", a=asa

Changes between 0.8.26 and 0.8.31 are:

* bug 119746: it is now possible to change character sets per channel.
* bug 206066: auto-connect networks now open in correct order
* bug 193246: fixed /list problem on some servers
This commit is contained in:
rginda%netscape.com 2003-05-22 21:28:13 +00:00
Родитель 06133b6d3c
Коммит 81f8daa616
6 изменённых файлов: 235 добавлений и 91 удалений

Просмотреть файл

@ -364,16 +364,18 @@ function serv_logout(reason)
this.quitting = true;
this.connection.sendData ("QUIT :" + reason + "\n");
this.connection.sendData ("QUIT :" + fromUnicode(reason) + "\n");
this.connection.disconnect();
}
CIRCServer.prototype.addChannel =
function serv_addchan (name)
function serv_addchan (name, charset)
{
return new CIRCChannel (this, name);
var encodedName = fromUnicode(name + " ", charset);
encodedName = encodedName.substr(0, encodedName.length -1);
return new CIRCChannel (this, encodedName, charset);
}
@ -801,7 +803,7 @@ function serv_topic (e)
e.channel = new CIRCChannel (this, e.params[1]);
e.channel.topicBy = e.user.nick;
e.channel.topicDate = new Date();
e.channel.topic = e.params[2];
e.channel.topic = toUnicode(e.params[2], e.channel.charset);
e.destObject = e.channel;
e.set = "channel";
@ -846,7 +848,7 @@ function serv_332 (e)
{
e.channel = new CIRCChannel (this, e.params[2]);
e.channel.topic = e.params[3];
e.channel.topic = toUnicode(e.params[3], e.channel.charset);
e.destObject = e.channel;
e.set = "channel";
@ -1273,6 +1275,7 @@ function serv_nick (e)
CIRCServer.prototype.onQuit =
function serv_quit (e)
{
e.params[1] = toUnicode(e.params[1]);
for (var c in e.server.channels)
{
@ -1439,11 +1442,13 @@ function serv_privmsg (e)
e.user = new CIRCChanUser (e.channel, e.user.nick);
e.replyTo = e.channel;
e.set = "channel";
e.params[2] = toUnicode(e.params[2], e.channel.charset);
}
else
{
e.set = "user";
e.replyTo = e.user; /* send replys to the user who sent the message */
e.params[2] = toUnicode(e.params[2]);
}
if (e.params[2].search (/\x01.*\x01/i) != -1)
@ -1671,22 +1676,20 @@ function serv_dccsend (e)
* channel
*/
function CIRCChannel (parent, name)
function CIRCChannel (parent, name, charset)
{
var encodedName = name;
var unicodeName = toUnicode(name, charset);
name = name.toLowerCase();
var encodedName = fromUnicode(name + " ");
/* bug 114923 */
encodedName = encodedName.substr(0,encodedName.length -1);
var unicodeName = toUnicode(encodedName);
name = encodedName.toLowerCase();
if (name in parent.channels)
return parent.channels[name];
this.parent = parent;
this.name = name; // used internally, lowercased
this.name = name; // used internally, lowercased
this.unicodeName = unicodeName; // converted to unicode for display
this.encodedName = encodedName; // encoded for communication with server
this.charset = charset;
this.users = new Object();
this.bans = new Object();
@ -2059,7 +2062,6 @@ function CIRCUser (parent, nick, name, host)
this.properNick = properNick;
this.name = name;
this.host = host;
parent.users[nick] = this;
return this;
@ -2136,7 +2138,6 @@ function usr_ctcp (code, msg, type)
CIRCUser.prototype.whois =
function usr_whois ()
{
this.parent.whois (this.nick);
}

Просмотреть файл

@ -155,7 +155,7 @@
<hbox>
<tabs class="tabs-bottom" id="views-tbar-inner" flex="1" crop="right">
<tab collapsed="true"/> <!-- dummy tab to keep the freaking xbl from
<tab collapsed="true"/> <!-- dummy tab to keep the freaking xbl from
causing an exception -->
</tabs>
</hbox>

Просмотреть файл

@ -37,6 +37,7 @@ function addCommands(commandObject)
add ("away", "onInputAway");
add ("cancel", "onInputCancel");
add ("charset", "onInputCharset");
add ("channel-charset", "onInputChannelCharset");
add ("clear", "onInputClear");
add ("client", "onInputClient");
add ("commands", "onInputCommands");
@ -56,6 +57,8 @@ function addCommands(commandObject)
add ("infobar", "onInputInfobar");
add ("invite", "onInputInvite");
add ("join", "onInputJoin");
add ("j", "onInputJoin");
add ("join-charset", "onInputJoinCharset");
add ("kick", "onInputKick");
add ("leave", "onInputLeave");
add ("list", "onInputList");

Просмотреть файл

@ -58,7 +58,8 @@ function onTopicKeyPress (e)
if (e.keyCode == 13)
{
var line = stringTrim(e.target.value);
client.currentObject.setTopic (fromUnicode(line));
var charset = client.currentObject.charset;
client.currentObject.setTopic (fromUnicode(line, charset));
onTopicEditEnd();
}
}
@ -1047,10 +1048,34 @@ function cli_icharset (e)
"ERROR");
return false;
}
}
}
client.currentObject.display (getMsg("cli_currentCharset", client.CHARSET),
client.currentObject.display (getMsg("cli_currentCharset",
client.CHARSET),
"INFO");
return true;
}
client.onInputChannelCharset =
function cli_ichancharset (e)
{
if (e.inputData)
{
if(!checkCharset(e.inputData))
{
client.currentObject.display (getMsg("cli_charsetError",
e.inputData),
"ERROR");
return false;
}
client.currentObject.charset = e.inputData;
}
client.currentObject.display (getMsg("cli_currentCharset",
client.currentObject.charset),
"INFO");
return true;
}
@ -1548,7 +1573,7 @@ function cli_quit (e)
client.onInputExit =
function cli_exit (e)
{
client.quit(e.inputData);
client.quit(fromUnicode(e.inputData));
window.close();
return true;
}
@ -1814,7 +1839,7 @@ function cli_imsg (e)
var msg = filterOutput(ary[2], "PRIVMSG", "ME!");
client.currentObject.display (msg, "PRIVMSG", "ME!", usr);
usr.say (fromUnicode(ary[2]));
usr.say (fromUnicode(ary[2], client.currentObject.charset));
return true;
@ -1872,7 +1897,7 @@ function cli_iquote (e)
return false;
}
e.server.sendData (e.inputData + "\n");
e.server.sendData (fromUnicode(e.inputData) + "\n");
return true;
@ -1928,22 +1953,10 @@ function cli_ictcp (e)
}
client.onInputJoin =
function cli_ijoin (e)
{
if (!e.network || !e.network.isConnected())
{
if (!e.network)
client.currentObject.display (getMsg("cli_ijoinMsg"), "ERROR");
else
client.currentObject.display (getMsg("cli_ijoinMsg2",
e.network.name1), "ERROR");
return false;
}
var ary = e.inputData.match(/(((\S+), *)*(\S+)) *(\S+)?/);
var name;
var key = "";
var namelist;
@ -1956,7 +1969,7 @@ function cli_ijoin (e)
else
{
if (client.currentObject.TYPE == "IRCChannel")
namelist = [client.currentObject.name];
namelist = [client.currentObject.unicodeName];
else
return false;
@ -1964,18 +1977,50 @@ function cli_ijoin (e)
key = client.currentObject.mode.key
}
for (i in namelist)
{
name = namelist[i];
if ((name[0] != "#") && (name[0] != "&") && (name[0] != "+") &&
(name[0] != "!"))
name = "#" + name;
return joinChannel(e, namelist, key, client.CHARSET);
}
e.channel = e.server.addChannel (name);
e.channel.join(key);
client.onInputJoinCharset =
function cli_ijoincharset (e)
{
var ary = e.inputData.match(/(((\S+), *)*(\S+)) *(\S+) *(\S+)?/);
var key = "";
var namelist;
var charset;
if (ary)
{
namelist = ary[1].split(/, */);
if (5 in ary)
charset = ary[5];
else
return false;
if (!checkCharset(charset))
{
client.currentObject.display (getMsg("cli_charsetError",
charset),
"ERROR");
return false;
}
if (6 in ary)
key = ary[6];
}
else
{
if (client.currentObject.TYPE == "IRCChannel")
namelist = [client.currentObject.unicodeName];
else
return false;
charset = client.CHARSET;
if (client.currentObject.mode.key)
key = client.currentObject.mode.key
}
return true;
return joinChannel(e, namelist, key, charset);
}
client.onInputLeave =
@ -2072,7 +2117,7 @@ function cli_itopic (e)
}
else
{
if (!e.channel.setTopic(fromUnicode(e.inputData)))
if (!e.channel.setTopic(fromUnicode(e.inputData, e.channel.charset)))
client.currentObject.display (getMsg("cli_itopicMsg2"), "ERROR");
}
@ -2102,7 +2147,7 @@ function cli_iaway (e)
}
else
{
e.server.sendData ("AWAY :" + e.inputData + "\n");
e.server.sendData ("AWAY :" + fromUnicode(e.inputData) + "\n");
}
return true;
@ -2682,7 +2727,7 @@ function my_ctcprunk (e)
CIRCNetwork.prototype.onNotice =
function my_notice (e)
{
this.display (e.params[2], "NOTICE", this, e.server.me);
this.display (toUnicode(e.params[2]), "NOTICE", this, e.server.me);
}
CIRCNetwork.prototype.on303 = /* ISON (aka notify) reply */
@ -2747,8 +2792,8 @@ function my_303 (e)
}
CIRCNetwork.prototype.on321 = /* LIST reply header */
function my_321 (e)
CIRCNetwork.prototype.listInit =
function my_list_init ()
{
function checkEndList (network)
@ -2801,7 +2846,6 @@ function my_321 (e)
this.list = new Array();
this.list.regexp = null;
}
this.displayHere (e.params[2] + " " + e.params[3], "321");
if (client.currentObject != this)
client.currentObject.display (getMsg("my_321", this.name), "INFO");
this.list.lastLength = 0;
@ -2812,6 +2856,14 @@ function my_321 (e)
this.list.endTimeout = setTimeout(checkEndList, 1500, this);
}
CIRCNetwork.prototype.on321 = /* LIST reply header */
function my_321 (e)
{
this.listInit();
this.displayHere (e.params[2] + " " + e.params[3], "321");
}
CIRCNetwork.prototype.on323 = /* end of LIST reply */
function my_323 (e)
{
@ -2827,12 +2879,14 @@ function my_323 (e)
CIRCNetwork.prototype.on322 = /* LIST reply */
function my_listrply (e)
{
if (!("list" in this))
this.listInit();
++this.list.count;
e.params[2] = toUnicode(e.params[2]);
if (!(this.list.regexp) || e.params[2].match(this.list.regexp)
|| e.params[4].match(this.list.regexp))
{
this.list.push([e.params[2], e.params[3], e.params[4]]);
this.list.push([e.params[2], e.params[3], toUnicode(e.params[4])]);
}
}
@ -2898,7 +2952,8 @@ function my_whoisreply (e)
{
case 311:
text = getMsg("my_whoisreplyMsg",
[nick, e.params[3], e.params[4], e.params[6]]);
[nick, e.params[3], e.params[4],
toUnicode(e.params[6])]);
break;
case 319:
@ -3125,12 +3180,12 @@ function my_cprivmsg (e)
}
catch (ex)
{
this.say (fromUnicode(e.user.nick + ": " + String(ex)));
this.say (fromUnicode(e.user.nick + ": " + String(ex), this.charset));
return false;
}
if (typeof (v) != "undefined")
{
{
if (v != null)
v = String(v);
else
@ -3144,7 +3199,7 @@ function my_cprivmsg (e)
rsp += " ";
this.display (rsp + v, "PRIVMSG", e.server.me, this);
this.say (fromUnicode(rsp + v));
this.say (fromUnicode(rsp + v, this.charset));
}
}
@ -3222,7 +3277,8 @@ function my_topic (e)
CIRCChannel.prototype.onNotice =
function my_notice (e)
{
this.display (e.params[2], "NOTICE", e.user, this);
this.display (toUnicode(e.params[2], this.charset),
"NOTICE", e.user, this);
}
CIRCChannel.prototype.onCTCPAction =
@ -3249,19 +3305,17 @@ function my_cjoin (e)
if (userIsMe (e.user))
{
if (!("messages" in this))
{
this.display (getMsg("cli_ijoinMsg3", this.unicodeName),
"INFO");
}
this.display (getMsg("my_cjoinMsg", e.channel.unicodeName), "JOIN",
e.server.me, this);
setCurrentObject(this);
}
else
{
this.display(getMsg("my_cjoinmsg2", [e.user.properNick, e.user.name,
e.user.host, e.channel.unicodeName]),
e.user.host,
e.channel.unicodeName]),
"JOIN", e.user, this);
}
this._addUserToGraph (e.user);
@ -3340,9 +3394,14 @@ function my_cmode (e)
{
if ("user" in e)
{
var msg = toUnicode(e.params.slice(1).join(" "),
e.channel.charset);
this.display (getMsg("my_cmodeMsg",
[toUnicode(e.params.slice(1).join(" ")),
//[e.params.slice(1).join(" "),
[msg,
e.user.properNick]), "MODE", e.user, this);
}
for (var u in e.usersAffected)
e.usersAffected[u].updateGraphResource();
@ -3431,7 +3490,8 @@ function my_unick (e)
CIRCUser.prototype.onNotice =
function my_notice (e)
{
this.display (e.params[2], "NOTICE", this, e.server.me);
this.display (toUnicode(e.params[2], this.charset),
"NOTICE", this, e.server.me);
}
CIRCUser.prototype.onCTCPAction =

Просмотреть файл

@ -36,7 +36,7 @@ const MSG_UNKNOWN = getMsg ("unknown");
client.defaultNick = getMsg("defaultNick");
client.version = "0.8.26";
client.version = "0.8.31";
client.TYPE = "IRCClient";
client.COMMAND_CHAR = "/";
@ -132,20 +132,16 @@ function ()
scrollDown(client.deck.childNodes[i], true);
}
function ucConvertIncomingMessage (e)
{
var length = e.params.length;
e.params[length - 1] = toUnicode(e.params[length - 1]);
return true;
}
function toUnicode (msg)
function toUnicode (msg, charset)
{
if (!("ucConverter" in client))
return msg;
/* XXX set charset again to force the encoder to reset, see bug 114923 */
client.ucConverter.charset = client.CHARSET;
if (typeof charset == "undefined")
client.ucConverter.charset = client.CHARSET;
else
client.ucConverter.charset = charset;
try
{
return client.ucConverter.ConvertToUnicode(msg);
@ -153,22 +149,50 @@ function toUnicode (msg)
catch (ex)
{
dd ("caught exception " + ex + " converting " + msg + " to charset " +
client.CHARSET);
charset);
}
return msg;
}
function fromUnicode (msg)
function fromUnicode (msg, charset)
{
if (!("ucConverter" in client))
return msg;
/* XXX set charset again to force the encoder to reset, see bug 114923 */
client.ucConverter.charset = client.CHARSET;
if (typeof charset == "undefined")
client.ucConverter.charset = client.CHARSET;
else
client.ucConverter.charset = charset;
return client.ucConverter.ConvertFromUnicode(msg);
}
function checkCharset (charset)
{
var ex;
var converter;
try
{
const UC_CTRID = "@mozilla.org/intl/scriptableunicodeconverter";
const nsIUnicodeConverter =
Components.interfaces.nsIScriptableUnicodeConverter;
converter =
Components.classes[UC_CTRID].getService(nsIUnicodeConverter);
converter.charset = charset;
}
catch (ex)
{
dd ("Caught exception setting charset to " + charset + "\n" + ex);
return false;
}
return true;
}
function setCharset (charset)
{
client.CHARSET = charset;
@ -196,11 +220,6 @@ function setCharset (charset)
client.ucConverter.charset = charset;
if (!client.eventPump.getHook("uc-hook"))
{
client.eventPump.addHook ([{type: "parseddata", set: "server"}],
ucConvertIncomingMessage, "uc-hook");
}
}
catch (ex)
{
@ -309,7 +328,7 @@ function processStartupURLs()
if (!wentSomewhere)
{
/* if we had nowhere else to go, connect to any default urls */
var ary = client.INITIAL_URLS.split(/\s*;\s*/).reverse();
var ary = client.INITIAL_URLS.split(/\s*;\s*/);
for (var i in ary)
{
if (ary[i] && ary[i] != "irc://")
@ -1146,6 +1165,39 @@ function setupMungerMenu(munger)
}
}
}
function joinChannel(e, namelist, key, charset)
{
if (!e.network || !e.network.isConnected())
{
if (!e.network)
client.currentObject.display (getMsg("cli_ijoinMsg"), "ERROR");
else
client.currentObject.display (getMsg("cli_ijoinMsg2",
e.network.name1), "ERROR");
return false;
}
var name;
for (i in namelist)
{
name = namelist[i];
if (name[0].search(/[#&+!]/) != 0)
name = "#" + name;
e.channel = e.server.addChannel (name, charset);
e.channel.join(key);
if (!("messages" in e.channel))
{
this.display (getMsg("cli_ijoinMsg3", e.channel.unicodeName),
"INFO");
}
setCurrentObject(e.channel);
}
return true;
}
var testURLs =
["irc:", "irc://", "irc:///", "irc:///help", "irc:///help,needkey",
@ -1305,6 +1357,10 @@ function parseIRCURL (url)
rv.needkey = true;
rv.key = unescape(arg[1]).replace ("\n", "\\n");
break;
case "charset":
rv.charset = unescape(arg[1]).replace ("\n", "\\n");
break;
}
}
}
@ -1373,7 +1429,7 @@ function gotoIRCURL (url)
net = client.networks[url.host];
if (!("pendingURLs" in net))
net.pendingURLs = new Array();
net.pendingURLs.push (url);
net.pendingURLs.unshift (url);
return;
}
}
@ -1390,7 +1446,7 @@ function gotoIRCURL (url)
client.connectToNetwork (url.host, pass);
if (!("pendingURLs" in net))
net.pendingURLs = new Array();
net.pendingURLs.push (url);
net.pendingURLs.unshift (url);
return;
}
}
@ -1426,10 +1482,20 @@ function gotoIRCURL (url)
else
key = window.prompt (getMsg("gotoIRCURLMsg3", url.spec));
}
var charset;
if ("charset" in url)
{
if (checkCharset(url.charset))
charset = url.charset;
else
display (getMsg("cli_charsetError", url.charset), "ERROR");
}
ev = {inputData: url.target + " " + key,
network: net, server: net.primServ};
client.onInputJoin (ev);
joinChannel(ev, [url.target], key, charset)
targetObject = ev.channel;
}
@ -2302,7 +2368,12 @@ function cli_say(msg)
msg = filterOutput (msg, "PRIVMSG");
client.currentObject.display (msg, "PRIVMSG", "ME!",
client.currentObject);
client.currentObject.say (fromUnicode(msg));
if (client.currentObject.TYPE == "IRCChannel") {
var charset = client.currentObject.charset;
client.currentObject.say (fromUnicode(msg, charset));
} else {
client.currentObject.say (fromUnicode(msg));
}
break;
case "IRCClient":
@ -2391,7 +2462,7 @@ function __display(message, msgtype, sourceObj, destObj)
var me;
if ("server" in o && "me" in o.server)
{
me = o.server.me; /* get the object representing the user */
me = o.server.me; /* get the object representing the user */
}
if (sourceObj == "ME!") sourceObj = me; /* if the caller to passes "ME!"*/
if (destObj == "ME!") destObj = me; /* substitute the actual object */

Просмотреть файл

@ -43,6 +43,9 @@ cancelHelp=Cancels a /attach or /server command. Use /cancel when ChatZilla is
charsetUsage=[<charset>]
charsetHelp=Sets the character encoding mode to <charset>, or displays the current character encoding mode if <charset> is not provided.
channel-charsetUsage=[<charset>]
channel-charsetHelp=Sets the character encoding mode to <charset>, or displays the current character encoding mode if <charset> is not provided.
clearUsage=
clearHelp=Clear the current view, discarding *all* content.
@ -97,9 +100,15 @@ infobarHelp=Toggles the visibility of the username list.
inviteUsage=<nick> [<channel>]
inviteHelp=Invites <nick> to <channel> or current channel if not supplied. Requires operator status if +i is set.
jUsage=[#|&|+]<channel-name> [<key>]
jHelp=This command is an alias for /join.
joinUsage=[#|&|+]<channel-name> [<key>]
joinHelp=Joins a the global (name starts with #), local (name starts with &), or modeless (name starts with a +) channel named <channel-name>. If no prefix is given, # is assumed. Provides the key <key> if specified.
join-charsetUsage=[#|&|+]<channel-name> <charset> [<key>]
join-charsetHelp=Joins a the global (name starts with #), local (name starts with &), or modeless (name starts with a +) channel named <channel-name>. Messages will be encoded and decoded according for the character set specified by <charset>. The <charset> parameter is independent of the default character set, which can be selected with the /charset command. If no prefix is given, # is assumed. Provides the key <key> if specified.
kickUsage=[<channel>] <nick>
kickHelp=Kicks <nick> from <channel> or current channel if not supplied. Requires operator status.