Bug 282680 - Store all channel modes on the channel (as defined by RPL_ISUPPORTS), and display them in the header.
ChatZilla only. r=samuel p=gijskruitbosch+bugs@gmail.com (Gijs Kruitbosch) git-svn-id: svn://10.0.0.236/trunk@186676 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -501,6 +501,58 @@ CIRCServer.prototype.PRUNE_OLD_USERS = -1;
|
||||
|
||||
CIRCServer.prototype.TYPE = "IRCServer";
|
||||
|
||||
// Define functions to set modes so they're easily readable.
|
||||
// name is the name used on the CIRCChanMode object
|
||||
// getValue is a function returning the value the canonicalmode should be set to
|
||||
// given a certain modifier and appropriate data.
|
||||
CIRCServer.prototype.canonicalChanModes = {
|
||||
i: {
|
||||
name: "invite",
|
||||
getValue: function (modifier) { return (modifier == "+"); }
|
||||
},
|
||||
m: {
|
||||
name: "moderated",
|
||||
getValue: function (modifier) { return (modifier == "+"); }
|
||||
},
|
||||
n: {
|
||||
name: "publicMessages",
|
||||
getValue: function (modifier) { return (modifier == "-"); }
|
||||
},
|
||||
t: {
|
||||
name: "publicTopic",
|
||||
getValue: function (modifier) { return (modifier == "-"); }
|
||||
},
|
||||
s: {
|
||||
name: "secret",
|
||||
getValue: function (modifier) { return (modifier == "+"); }
|
||||
},
|
||||
p: {
|
||||
name: "pvt",
|
||||
getValue: function (modifier) { return (modifier == "+"); }
|
||||
},
|
||||
k: {
|
||||
name: "key",
|
||||
getValue: function (modifier, data)
|
||||
{
|
||||
if (modifier == "+")
|
||||
return data;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
},
|
||||
l: {
|
||||
name: "limit",
|
||||
getValue: function (modifier, data)
|
||||
{
|
||||
// limit is special - we return -1 if there is no limit.
|
||||
if (modifier == "-")
|
||||
return -1;
|
||||
else
|
||||
return data;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
CIRCServer.prototype.toLowerCase =
|
||||
function serv_tolowercase(str)
|
||||
{
|
||||
@@ -1931,7 +1983,10 @@ function serv_chanmode (e)
|
||||
|
||||
var nick;
|
||||
var user;
|
||||
var mList = this.userModes;
|
||||
var umList = this.userModes;
|
||||
var cmList = this.channelModes;
|
||||
var modeMap = this.canonicalChanModes;
|
||||
var canonicalModeValue;
|
||||
|
||||
for (var i = 0; i < mode_str.length ; i++)
|
||||
{
|
||||
@@ -1943,13 +1998,13 @@ function serv_chanmode (e)
|
||||
}
|
||||
|
||||
var done = false;
|
||||
for (var m in mList)
|
||||
for (var m in umList)
|
||||
{
|
||||
if ((mode_str[i] == mList[m].mode) && (modifier != ""))
|
||||
if ((mode_str[i] == umList[m].mode) && (modifier != ""))
|
||||
{
|
||||
nick = e.params[BASE_PARAM + params_eaten];
|
||||
user = new CIRCChanUser(e.channel, null, nick,
|
||||
[ modifier + mList[m].mode ]);
|
||||
[ modifier + umList[m].mode ]);
|
||||
params_eaten++;
|
||||
e.usersAffected.push (user);
|
||||
done = true;
|
||||
@@ -1959,102 +2014,68 @@ function serv_chanmode (e)
|
||||
if (done)
|
||||
continue;
|
||||
|
||||
switch (mode_str[i])
|
||||
// Update legacy canonical modes if necessary.
|
||||
if (mode_str[i] in modeMap)
|
||||
{
|
||||
/* user modes */
|
||||
case "b": /* ban */
|
||||
var ban = e.params[BASE_PARAM + params_eaten];
|
||||
params_eaten++;
|
||||
// Get the data in case we need it, but don't increment the counter.
|
||||
var datacounter = BASE_PARAM + params_eaten;
|
||||
var data = (datacounter in e.params) ? e.params[datacounter] : null;
|
||||
canonicalModeValue = modeMap[mode_str[i]].getValue(modifier, data);
|
||||
e.channel.mode[modeMap[mode_str[i]].name] = canonicalModeValue;
|
||||
}
|
||||
|
||||
if ((modifier == "+") &&
|
||||
(typeof e.channel.bans[ban] == "undefined"))
|
||||
if (arrayContains(cmList.a, mode_str[i]))
|
||||
{
|
||||
var data = e.params[BASE_PARAM + params_eaten++];
|
||||
if (modifier == "+")
|
||||
{
|
||||
e.channel.mode.modeA[data] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data in e.channel.mode.modeA)
|
||||
{
|
||||
e.channel.bans[ban] = {host: ban};
|
||||
var ban_evt = new CEvent ("channel", "ban", e.channel,
|
||||
"onBan");
|
||||
ban_evt.channel = e.channel;
|
||||
ban_evt.ban = ban;
|
||||
ban_evt.source = e.user;
|
||||
this.parent.eventPump.addEvent (e);
|
||||
delete e.channel.mode.modeA[data];
|
||||
}
|
||||
else
|
||||
if (modifier == "-")
|
||||
delete e.channel.bans[ban];
|
||||
break;
|
||||
|
||||
|
||||
/* channel modes */
|
||||
case "l": /* limit */
|
||||
if (modifier == "+")
|
||||
{
|
||||
var limit = e.params[BASE_PARAM + params_eaten];
|
||||
params_eaten++;
|
||||
e.channel.mode.limit = limit;
|
||||
dd("** Trying to remove channel mode '" + mode_str[i] +
|
||||
"'/'" + data + "' which does not exist in list.");
|
||||
}
|
||||
else
|
||||
if (modifier == "-")
|
||||
e.channel.mode.limit = -1;
|
||||
break;
|
||||
|
||||
case "k": /* key */
|
||||
var key = e.params[BASE_PARAM + params_eaten];
|
||||
params_eaten++;
|
||||
|
||||
if (modifier == "+")
|
||||
e.channel.mode.key = key;
|
||||
else
|
||||
if (modifier == "-")
|
||||
e.channel.mode.key = "";
|
||||
break;
|
||||
|
||||
case "m": /* moderated */
|
||||
if (modifier == "+")
|
||||
e.channel.mode.moderated = true;
|
||||
else
|
||||
if (modifier == "-")
|
||||
e.channel.mode.moderated = false;
|
||||
break;
|
||||
|
||||
case "n": /* no outside messages */
|
||||
if (modifier == "+")
|
||||
e.channel.mode.publicMessages = false;
|
||||
else
|
||||
if (modifier == "-")
|
||||
e.channel.mode.publicMessages = true;
|
||||
break;
|
||||
|
||||
case "t": /* topic */
|
||||
if (modifier == "+")
|
||||
e.channel.mode.publicTopic = false;
|
||||
else
|
||||
if (modifier == "-")
|
||||
e.channel.mode.publicTopic = true;
|
||||
break;
|
||||
|
||||
case "i": /* invite */
|
||||
if (modifier == "+")
|
||||
e.channel.mode.invite = true;
|
||||
else
|
||||
if (modifier == "-")
|
||||
e.channel.mode.invite = false;
|
||||
break;
|
||||
|
||||
case "s": /* secret */
|
||||
if (modifier == "+")
|
||||
e.channel.mode.secret = true;
|
||||
else
|
||||
if (modifier == "-")
|
||||
e.channel.mode.secret = false;
|
||||
break;
|
||||
|
||||
case "p": /* private */
|
||||
if (modifier == "+")
|
||||
e.channel.mode.pvt = true;
|
||||
else
|
||||
if (modifier == "-")
|
||||
e.channel.mode.pvt = false;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
else if (arrayContains(cmList.b, mode_str[i]))
|
||||
{
|
||||
var data = e.params[BASE_PARAM + params_eaten++];
|
||||
if (modifier == "+")
|
||||
{
|
||||
e.channel.mode.modeB[mode_str[i]] = data;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Save 'null' even though we have some data.
|
||||
e.channel.mode.modeB[mode_str[i]] = null;
|
||||
}
|
||||
}
|
||||
else if (arrayContains(cmList.c, mode_str[i]))
|
||||
{
|
||||
if (modifier == "+")
|
||||
{
|
||||
var data = e.params[BASE_PARAM + params_eaten++];
|
||||
e.channel.mode.modeC[mode_str[i]] = data;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.channel.mode.modeC[mode_str[i]] = null;
|
||||
}
|
||||
}
|
||||
else if (arrayContains(cmList.d, mode_str[i]))
|
||||
{
|
||||
e.channel.mode.modeD[mode_str[i]] = (modifier == "+");
|
||||
}
|
||||
else
|
||||
{
|
||||
dd("** UNKNOWN mode symbol '" + mode_str[i] + "' in ChanMode event **");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2862,14 +2883,20 @@ function chan_inviteuser (nick)
|
||||
function CIRCChanMode (parent)
|
||||
{
|
||||
this.parent = parent;
|
||||
this.limit = -1;
|
||||
this.key = "";
|
||||
|
||||
this.modeA = new Object();
|
||||
this.modeB = new Object();
|
||||
this.modeC = new Object();
|
||||
this.modeD = new Object();
|
||||
|
||||
this.invite = false;
|
||||
this.moderated = false;
|
||||
this.publicMessages = true;
|
||||
this.publicTopic = true;
|
||||
this.invite = false;
|
||||
this.secret = false;
|
||||
this.pvt = false;
|
||||
this.key = "";
|
||||
this.limit = -1;
|
||||
}
|
||||
|
||||
CIRCChanMode.prototype.TYPE = "IRCChanMode";
|
||||
@@ -2878,26 +2905,34 @@ CIRCChanMode.prototype.getModeStr =
|
||||
function chan_modestr (f)
|
||||
{
|
||||
var str = "";
|
||||
var modeCparams = "";
|
||||
|
||||
if (this.invite)
|
||||
str += "i";
|
||||
if (this.moderated)
|
||||
str += "m";
|
||||
if (!this.publicMessages)
|
||||
str += "n";
|
||||
if (!this.publicTopic)
|
||||
str += "t";
|
||||
if (this.secret)
|
||||
str += "s";
|
||||
if (this.pvt)
|
||||
str += "p";
|
||||
if (this.key)
|
||||
str += "k";
|
||||
if (this.limit != -1)
|
||||
str += "l " + this.limit;
|
||||
/* modeA are 'list' ones, and so should not be shown.
|
||||
* modeB are 'param' ones, like +k key, so we wont show them either.
|
||||
* modeC are 'on-param' ones, like +l limit, which we will show.
|
||||
* modeD are 'boolean' ones, which we will definately show.
|
||||
*/
|
||||
|
||||
// Add modeD:
|
||||
for (var m in this.modeD)
|
||||
{
|
||||
if (this.modeD[m])
|
||||
str += m;
|
||||
}
|
||||
|
||||
// Add modeC, save parameters for adding all the way at the end:
|
||||
for (var m in this.modeC)
|
||||
{
|
||||
if (this.modeC[m])
|
||||
{
|
||||
str += m;
|
||||
modeCparams += " " + this.modeC[m];
|
||||
}
|
||||
}
|
||||
|
||||
// Add parameters:
|
||||
if (str)
|
||||
str = "+" + str;
|
||||
str = "+" + str + modeCparams;
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user