Bug 1012660 - Remove _chatRoomFieldsList from IRC code. r=aleth

This commit is contained in:
Patrick Cloke 2014-05-20 19:03:18 -04:00
Родитель 44921da2ac
Коммит 12ddc6ae00
4 изменённых файлов: 42 добавлений и 48 удалений

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

@ -109,7 +109,7 @@ message.parted=%1$S has left the room (Part%2$S).
message.parted.reason=: %S message.parted.reason=: %S
# %1$S is the user's nick, %2$S is message.quit2 if a quit message is given. # %1$S is the user's nick, %2$S is message.quit2 if a quit message is given.
message.quit=%1$S has left the room (Quit%2$S). message.quit=%1$S has left the room (Quit%2$S).
# The paramter is the quit message given by the user. # The parameter is the quit message given by the user.
message.quit2=: %S message.quit2=: %S
# %1$S is the nickname of the user that invited us, %2$S is the conversation # %1$S is the nickname of the user that invited us, %2$S is the conversation
# name. # name.
@ -161,8 +161,12 @@ error.mode.wrongUser=You cannot change modes for other users.
error.noSuchNick=%S is not online. error.noSuchNick=%S is not online.
error.wasNoSuchNick=There was no nickname: %S error.wasNoSuchNick=There was no nickname: %S
error.noSuchChannel=There is no channel: %S. error.noSuchChannel=There is no channel: %S.
error.unavailable=%S is temporarily unavailable.
# %S is the channel name. # %S is the channel name.
error.channelBanned=You have been banned from %S.
error.cannotSendToChannel=You cannot send messages to %S. error.cannotSendToChannel=You cannot send messages to %S.
error.channelFull=The channel %S is full.
error.inviteOnly=You must be invited to join %S.
error.nonUniqueTarget=%S is not a unique user@host or shortname or you have tried to join too many channels at once. error.nonUniqueTarget=%S is not a unique user@host or shortname or you have tried to join too many channels at once.
error.notChannelOp=You are not a channel operator on %S. error.notChannelOp=You are not a channel operator on %S.
error.notChannelOwner=You are not a channel owner of %S. error.notChannelOwner=You are not a channel owner of %S.

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

@ -795,7 +795,6 @@ function ircAccount(aProtocol, aImAccount) {
this.trackQueue = []; this.trackQueue = [];
this.pendingIsOnQueue = []; this.pendingIsOnQueue = [];
this.whoisInformation = new NormalizedMap(this.normalizeNick.bind(this)); this.whoisInformation = new NormalizedMap(this.normalizeNick.bind(this));
this._chatRoomFieldsList = {};
this._caps = []; this._caps = [];
this._roomInfoCallbacks = new Set(); this._roomInfoCallbacks = new Set();
@ -1428,10 +1427,6 @@ ircAccount.prototype = {
createConversation: function(aName) this.getConversation(aName), createConversation: function(aName) this.getConversation(aName),
// Temporarily stores the prplIChatRoomFieldValues passed to joinChat for
// each channel to enable later reconnections.
_chatRoomFieldsList: {},
// aComponents implements prplIChatRoomFieldValues. // aComponents implements prplIChatRoomFieldValues.
joinChat: function(aComponents) { joinChat: function(aComponents) {
let channel = aComponents.getValue("channel"); let channel = aComponents.getValue("channel");
@ -1439,6 +1434,7 @@ ircAccount.prototype = {
this.ERROR("joinChat called without a channel name."); this.ERROR("joinChat called without a channel name.");
return null; return null;
} }
// A channel prefix is required. If the user didn't include one, // A channel prefix is required. If the user didn't include one,
// we prepend # automatically to match the behavior of other // we prepend # automatically to match the behavior of other
// clients. Not doing it used to cause user confusion. // clients. Not doing it used to cause user confusion.
@ -1457,13 +1453,13 @@ ircAccount.prototype = {
if (key) if (key)
params.push(key); params.push(key);
let defaultName = key ? channel + " " + key : channel; let defaultName = key ? channel + " " + key : channel;
this._chatRoomFieldsList[this.normalize(channel)] =
this.getChatRoomDefaultFieldValues(defaultName);
// Send the join command, but don't log the channel key. // Send the join command, but don't log the channel key.
this.sendMessage("JOIN", params, this.sendMessage("JOIN", params,
"JOIN " + channel + (key ? " <key not logged>" : "")); "JOIN " + channel + (key ? " <key not logged>" : ""));
// Open conversation early for better responsiveness. // Open conversation early for better responsiveness.
let conv = this.getConversation(channel); let conv = this.getConversation(channel);
// Store the prplIChatRoomFieldValues to enable later reconnections.
conv._chatRoomFields = this.getChatRoomDefaultFieldValues(defaultName);
conv.joining = true; conv.joining = true;
return conv; return conv;
}, },

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

@ -186,12 +186,7 @@ var ircBase = {
delete conversation._firstJoin; delete conversation._firstJoin;
// Ensure chatRoomFields information is available for reconnection. // Ensure chatRoomFields information is available for reconnection.
let nName = this.normalize(channelName); if (!conversation._chatRoomFields) {
if (hasOwnProperty(this._chatRoomFieldsList, nName)) {
conversation._chatRoomFields = this._chatRoomFieldsList[nName];
delete this._chatRoomFieldsList[nName];
}
else {
this.WARN("Opening a MUC without storing its " + this.WARN("Opening a MUC without storing its " +
"prplIChatRoomFieldValues first."); "prplIChatRoomFieldValues first.");
conversation._chatRoomFields = conversation._chatRoomFields =
@ -199,7 +194,7 @@ var ircBase = {
} }
} }
else { else {
// Don't worry about adding ourself, RPL_NAMES takes care of that // Don't worry about adding ourself, RPL_NAMREPLY takes care of that
// case. // case.
conversation.getParticipant(aMessage.nickname, true); conversation.getParticipant(aMessage.nickname, true);
let msg = _("message.join", aMessage.nickname, aMessage.source || ""); let msg = _("message.join", aMessage.nickname, aMessage.source || "");
@ -1086,8 +1081,8 @@ var ircBase = {
}, },
"403": function(aMessage) { // ERR_NOSUCHCHANNEL "403": function(aMessage) { // ERR_NOSUCHCHANNEL
// <channel name> :No such channel // <channel name> :No such channel
delete this._chatRoomFieldsList[this.normalize(aMessage.params[1])]; return conversationErrorMessage(this, aMessage, "error.noChannel", true,
return conversationErrorMessage(this, aMessage, "error.noChannel"); false);
}, },
"404": function(aMessage) { // ERR_CANNOTSENDTOCHAN "404": function(aMessage) { // ERR_CANNOTSENDTOCHAN
// <channel name> :Cannot send to channel // <channel name> :Cannot send to channel
@ -1097,9 +1092,8 @@ var ircBase = {
}, },
"405": function(aMessage) { // ERR_TOOMANYCHANNELS "405": function(aMessage) { // ERR_TOOMANYCHANNELS
// <channel name> :You have joined too many channels // <channel name> :You have joined too many channels
delete this._chatRoomFieldsList[this.normalize(aMessage.params[1])]; return conversationErrorMessage(this, aMessage, "error.tooManyChannels",
return serverErrorMessage(this, aMessage, true);
_("error.tooManyChannels", aMessage.params[1]));
}, },
"406": function(aMessage) { // ERR_WASNOSUCHNICK "406": function(aMessage) { // ERR_WASNOSUCHNICK
// <nickname> :There was no such nickname // <nickname> :There was no such nickname
@ -1109,8 +1103,8 @@ var ircBase = {
}, },
"407": function(aMessage) { // ERR_TOOMANYTARGETS "407": function(aMessage) { // ERR_TOOMANYTARGETS
// <target> :<error code> recipients. <abort message> // <target> :<error code> recipients. <abort message>
delete this._chatRoomFieldsList[this.normalize(aMessage.params[1])]; return conversationErrorMessage(this, aMessage, "error.nonUniqueTarget",
return conversationErrorMessage(this, aMessage, "error.nonUniqueTarget"); false, false);
}, },
"408": function(aMessage) { // ERR_NOSUCHSERVICE "408": function(aMessage) { // ERR_NOSUCHSERVICE
// <service name> :No such service // <service name> :No such service
@ -1205,9 +1199,8 @@ var ircBase = {
}, },
"437": function(aMessage) { // ERR_UNAVAILRESOURCE "437": function(aMessage) { // ERR_UNAVAILRESOURCE
// <nick/channel> :Nick/channel is temporarily unavailable // <nick/channel> :Nick/channel is temporarily unavailable
// TODO return conversationErrorMessage(this, aMessage, "error.unavailable",
delete this._chatRoomFieldsList[this.normalize(aMessage.params[1])]; true);
return false;
}, },
"441": function(aMessage) { // ERR_USERNOTINCHANNEL "441": function(aMessage) { // ERR_USERNOTINCHANNEL
// <nick> <channel> :They aren't on that channel // <nick> <channel> :They aren't on that channel
@ -1291,9 +1284,8 @@ var ircBase = {
}, },
"471": function(aMessage) { // ERR_CHANNELISFULL "471": function(aMessage) { // ERR_CHANNELISFULL
// <channel> :Cannot join channel (+l) // <channel> :Cannot join channel (+l)
// TODO return conversationErrorMessage(this, aMessage, "error.channelFull",
delete this._chatRoomFieldsList[this.normalize(aMessage.params[1])]; true);
return false;
}, },
"472": function(aMessage) { // ERR_UNKNOWNMODE "472": function(aMessage) { // ERR_UNKNOWNMODE
// <char> :is unknown mode char to me for <channel> // <char> :is unknown mode char to me for <channel>
@ -1302,35 +1294,22 @@ var ircBase = {
}, },
"473": function(aMessage) { // ERR_INVITEONLYCHAN "473": function(aMessage) { // ERR_INVITEONLYCHAN
// <channel> :Cannot join channel (+i) // <channel> :Cannot join channel (+i)
// TODO return conversationErrorMessage(this, aMessage, "error.inviteOnly",
delete this._chatRoomFieldsList[this.normalize(aMessage.params[1])]; true, false);
return false;
}, },
"474": function(aMessage) { // ERR_BANNEDFROMCHAN "474": function(aMessage) { // ERR_BANNEDFROMCHAN
// <channel> :Cannot join channel (+b) // <channel> :Cannot join channel (+b)
// TODO return conversationErrorMessage(this, aMessage, "error.channelBanned",
delete this._chatRoomFieldsList[this.normalize(aMessage.params[1])]; true, false);
return false;
}, },
"475": function(aMessage) { // ERR_BADCHANNELKEY "475": function(aMessage) { // ERR_BADCHANNELKEY
// <channel> :Cannot join channel (+k) // <channel> :Cannot join channel (+k)
let channelName = aMessage.params[1]; return conversationErrorMessage(this, aMessage, "error.wrongKey",
true, false);
// Display an error message to the user.
let msg = _("error.wrongKey", channelName);
let conversation = this.getConversation(channelName);
conversation.writeMessage(aMessage.servername, msg, {system: true});
// The stored information is out of date, remove it.
delete conversation._chatRoomFields;
delete this._chatRoomFieldsList[this.normalize(channelName)];
return true;
}, },
"476": function(aMessage) { // ERR_BADCHANMASK "476": function(aMessage) { // ERR_BADCHANMASK
// <channel> :Bad Channel Mask // <channel> :Bad Channel Mask
// TODO // TODO
delete this._chatRoomFieldsList[this.normalize(aMessage.params[1])];
return false; return false;
}, },
"477": function(aMessage) { // ERR_NOCHANMODES "477": function(aMessage) { // ERR_NOCHANMODES

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

@ -216,10 +216,25 @@ function mIRCColoring(aStack, aInput) {
return [stack, output, length]; return [stack, output, length];
} }
function conversationErrorMessage(aAccount, aMessage, aError) { // Print an error message into a conversation, optionally mark the conversation
// as not joined and/or not rejoinable.
function conversationErrorMessage(aAccount, aMessage, aError,
aJoinFailed = false, aRejoinable = true) {
let conv = aAccount.getConversation(aMessage.params[1]); let conv = aAccount.getConversation(aMessage.params[1]);
conv.writeMessage(aMessage.servername, _(aError, aMessage.params[1]), conv.writeMessage(aMessage.servername, _(aError, aMessage.params[1]),
{error: true, system: true}); {error: true, system: true});
delete conv._pendingMessage; delete conv._pendingMessage;
// Channels have a couple extra things that can be done to them.
if (aAccount.isMUCName(aMessage.params[1])) {
// If a value for joining is explictly given, mark it.
if (aJoinFailed)
conv.joining = false;
// If the conversation cannot be rejoined automatically, delete
// _chatRoomFields.
if (!aRejoinable)
delete conv._chatRoomFields;
}
return true; return true;
} }