mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 05:15:45 +00:00
Bug 281706 - Add /reconnect, /reconnect-all, /disconnect-all and /rejoin commands.
ChatZilla only. r=silver@warwickcompsoc.co.uk p=gijskruitbosch@gmail.com (Gijs "Hannibal" Kruitbosch)
This commit is contained in:
parent
2e3f294fa6
commit
decb95bd89
@ -190,8 +190,8 @@ function net_connect(requireSecurity)
|
||||
this.state = NET_CONNECTING;
|
||||
this.connectAttempt = 0;
|
||||
this.nextHost = 0;
|
||||
this.requireSecurity = requireSecurity || false;
|
||||
var ev = new CEvent("network", "do-connect", this, "onDoConnect");
|
||||
ev.requireSecurity = requireSecurity;
|
||||
ev.password = null;
|
||||
this.eventPump.addEvent(ev);
|
||||
}
|
||||
@ -285,7 +285,7 @@ function net_doconnect(e)
|
||||
host = 0;
|
||||
}
|
||||
|
||||
if (this.serverList[host].isSecure || !e.requireSecurity)
|
||||
if (this.serverList[host].isSecure || !this.requireSecurity)
|
||||
{
|
||||
ev = new CEvent ("network", "startconnect", this, "onStartConnect");
|
||||
ev.debug = "Connecting to " + this.serverList[host].unicodeName + ":" +
|
||||
@ -303,7 +303,6 @@ function net_doconnect(e)
|
||||
{
|
||||
/* connect failed, try again */
|
||||
ev = new CEvent ("network", "do-connect", this, "onDoConnect");
|
||||
ev.requireSecurity = e.requireSecurity;
|
||||
this.eventPump.addEvent (ev);
|
||||
}
|
||||
}
|
||||
@ -324,7 +323,6 @@ function net_doconnect(e)
|
||||
{
|
||||
/* server doesn't use SSL as requested, try next one. */
|
||||
ev = new CEvent ("network", "do-connect", this, "onDoConnect");
|
||||
ev.requireSecurity = e.requireSecurity;
|
||||
this.eventPump.addEvent (ev);
|
||||
}
|
||||
|
||||
@ -892,6 +890,8 @@ function serv_disconnect(e)
|
||||
e.set = "network";
|
||||
e.destObject = this.parent;
|
||||
|
||||
e.quitting = this.quitting;
|
||||
|
||||
for (var c in this.channels)
|
||||
{
|
||||
this.channels[c].users = new Object();
|
||||
@ -2683,9 +2683,12 @@ function chan_join (key)
|
||||
}
|
||||
|
||||
CIRCChannel.prototype.part =
|
||||
function chan_part ()
|
||||
function chan_part (reason)
|
||||
{
|
||||
this.parent.sendData ("PART " + this.encodedName + "\n");
|
||||
if (!reason)
|
||||
reason = "";
|
||||
this.parent.sendData ("PART " + this.encodedName + " :" +
|
||||
fromUnicode(reason, this) + "\n");
|
||||
this.users = new Object();
|
||||
return true;
|
||||
}
|
||||
|
@ -984,6 +984,66 @@ function confirm(msg, parent, title)
|
||||
return ps.confirm (parent, title, msg);
|
||||
}
|
||||
|
||||
function confirmEx(msg, buttons, defaultButton, checkText,
|
||||
checkVal, parent, title)
|
||||
{
|
||||
/* Note that on versions before Mozilla 0.9, using 3 buttons,
|
||||
* the revert or dontsave button, or custom button titles will NOT work.
|
||||
*
|
||||
* The buttons should be listed in the 'accept', 'cancel' and 'extra' order,
|
||||
* and the exact button order is host app- and platform-dependant.
|
||||
* For example, on Windows this is usually [button 1] [button 3] [button 2],
|
||||
* and on Linux [button 3] [button 2] [button 1].
|
||||
*/
|
||||
var PROMPT_CTRID = "@mozilla.org/embedcomp/prompt-service;1";
|
||||
var nsIPromptService = Components.interfaces.nsIPromptService;
|
||||
var ps = Components.classes[PROMPT_CTRID].getService(nsIPromptService);
|
||||
|
||||
var buttonConstants = {
|
||||
ok: ps.BUTTON_TITLE_OK,
|
||||
cancel: ps.BUTTON_TITLE_CANCEL,
|
||||
yes: ps.BUTTON_TITLE_YES,
|
||||
no: ps.BUTTON_TITLE_NO,
|
||||
save: ps.BUTTON_TITLE_SAVE,
|
||||
revert: ps.BUTTON_TITLE_REVERT,
|
||||
dontsave: ps.BUTTON_TITLE_DONT_SAVE
|
||||
};
|
||||
var buttonFlags = 0;
|
||||
var buttonText = [null, null, null];
|
||||
|
||||
if (!isinstance(buttons, Array))
|
||||
throw "buttons parameter must be an Array";
|
||||
if ((buttons.length < 1) || (buttons.length > 3))
|
||||
throw "the buttons array must have 1, 2 or 3 elements";
|
||||
|
||||
for (var i = 0; i < buttons.length; i++)
|
||||
{
|
||||
var buttonFlag = ps.BUTTON_TITLE_IS_STRING;
|
||||
if ((buttons[i][0] == "!") && (buttons[i].substr(1) in buttonConstants))
|
||||
buttonFlag = buttonConstants[buttons[i].substr(1)];
|
||||
else
|
||||
buttonText[i] = buttons[i];
|
||||
|
||||
buttonFlags += ps["BUTTON_POS_" + i] * buttonFlag;
|
||||
}
|
||||
|
||||
// ignore anything but a proper number
|
||||
var defaultIsNumber = (typeof defaultButton == "number");
|
||||
if (defaultIsNumber && arrayHasElementAt(buttons, defaultButton))
|
||||
buttonFlags += ps["BUTTON_POS_" + defaultButton + "_DEFAULT"];
|
||||
|
||||
if (!parent)
|
||||
parent = window;
|
||||
if (!title)
|
||||
title = MSG_CONFIRM;
|
||||
if (!checkVal)
|
||||
checkVal = new Object();
|
||||
|
||||
rv = ps.confirmEx(parent, title, msg, buttonFlags, buttonText[0],
|
||||
buttonText[1], buttonText[2], checkText, checkVal);
|
||||
return rv;
|
||||
}
|
||||
|
||||
function prompt(msg, initial, parent, title)
|
||||
{
|
||||
var PROMPT_CTRID = "@mozilla.org/embedcomp/prompt-service;1";
|
||||
|
@ -92,6 +92,7 @@ function initCommands()
|
||||
["delete-view", cmdDeleteView, CMD_CONSOLE],
|
||||
["disable-plugin", cmdAblePlugin, CMD_CONSOLE],
|
||||
["disconnect", cmdDisconnect, CMD_NEED_SRV | CMD_CONSOLE],
|
||||
["disconnect-all", cmdDisconnectAll, CMD_CONSOLE],
|
||||
["echo", cmdEcho, CMD_CONSOLE],
|
||||
["enable-plugin", cmdAblePlugin, CMD_CONSOLE],
|
||||
["eval", cmdEval, CMD_CONSOLE],
|
||||
@ -144,6 +145,10 @@ function initCommands()
|
||||
["quote", cmdQuote, CMD_NEED_SRV | CMD_CONSOLE],
|
||||
["reload-plugin", cmdReload, CMD_CONSOLE],
|
||||
["rlist", cmdRlist, CMD_NEED_SRV | CMD_CONSOLE],
|
||||
["reconnect", cmdReconnect, CMD_NEED_NET | CMD_CONSOLE],
|
||||
["reconnect-all", cmdReconnectAll, CMD_CONSOLE],
|
||||
["rejoin", cmdRejoin,
|
||||
CMD_NEED_SRV | CMD_NEED_CHAN | CMD_CONSOLE],
|
||||
["reload-ui", cmdReloadUI, 0],
|
||||
["save", cmdSave, CMD_CONSOLE],
|
||||
["say", cmdSay, CMD_NEED_SRV | CMD_CONSOLE],
|
||||
@ -1383,6 +1388,25 @@ function cmdDisconnect(e)
|
||||
e.network.quit(e.reason);
|
||||
}
|
||||
|
||||
function cmdDisconnectAll(e)
|
||||
{
|
||||
if (confirmEx(MSG_CONFIRM_DISCONNECT_ALL, ["!yes", "!no"]) != 0)
|
||||
return;
|
||||
|
||||
var conNetworks = client.getConnectedNetworks();
|
||||
if (conNetworks.length <= 0)
|
||||
{
|
||||
display(MSG_NO_CONNECTED_NETS, MT_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof e.reason != "string")
|
||||
e.reason = client.userAgent;
|
||||
|
||||
for (var i = 0; i < conNetworks.length; i++)
|
||||
conNetworks[i].quit(e.reason);
|
||||
}
|
||||
|
||||
function cmdDeleteView(e)
|
||||
{
|
||||
if (!e.view)
|
||||
@ -1488,6 +1512,51 @@ function cmdNames(e)
|
||||
e.server.sendData("NAMES " + e.channel.encodedName + "\n");
|
||||
}
|
||||
|
||||
function cmdReconnect(e)
|
||||
{
|
||||
if (e.network.isConnected())
|
||||
{
|
||||
// Set reconnect flag
|
||||
e.network.reconnect = true;
|
||||
if (typeof e.reason != "string")
|
||||
e.reason = MSG_RECONNECTING;
|
||||
// Now we disconnect.
|
||||
e.network.quit(e.reason);
|
||||
}
|
||||
else
|
||||
{
|
||||
e.network.connect(e.network.requireSecurity);
|
||||
}
|
||||
}
|
||||
|
||||
function cmdReconnectAll(e)
|
||||
{
|
||||
var reconnected = false;
|
||||
for (var net in client.networks)
|
||||
{
|
||||
if (client.networks[net].isConnected() ||
|
||||
("messages" in client.networks[net]))
|
||||
{
|
||||
client.networks[net].dispatch("reconnect", { reason: e.reason });
|
||||
reconnected = true;
|
||||
}
|
||||
}
|
||||
if (!reconnected)
|
||||
display(MSG_NO_RECONNECTABLE_NETS, MT_ERROR);
|
||||
}
|
||||
|
||||
function cmdRejoin(e)
|
||||
{
|
||||
if (e.channel.joined)
|
||||
{
|
||||
if (!e.reason)
|
||||
e.reason = "";
|
||||
e.channel.part(e.reason);
|
||||
}
|
||||
|
||||
e.channel.join(e.channel.mode.key);
|
||||
}
|
||||
|
||||
function cmdTogglePref (e)
|
||||
{
|
||||
var state = !client.prefs[e.prefName];
|
||||
@ -2015,7 +2084,7 @@ function cmdLeave(e)
|
||||
/* Their channel name was invalid, but we have a channel
|
||||
* view, so we'll assume they did "/leave part msg".
|
||||
*/
|
||||
e.reason = e.channelName + " " + e.reason;
|
||||
e.reason = e.channelName + (e.reason ? " " + e.reason : "");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1590,6 +1590,7 @@ CIRCNetwork.prototype.onDisconnect =
|
||||
function my_netdisconnect (e)
|
||||
{
|
||||
var msg;
|
||||
var msgType = "ERROR";
|
||||
|
||||
if (typeof e.disconnectStatus != "undefined")
|
||||
{
|
||||
@ -1634,6 +1635,13 @@ function my_netdisconnect (e)
|
||||
[this.getURL(), e.server.getURL()]);
|
||||
}
|
||||
|
||||
// e.quitting signals the disconnect was intended: use "INFO", not "ERROR".
|
||||
if (e.quitting)
|
||||
{
|
||||
msgType = "INFO";
|
||||
msg = getMsg(MSG_CONNECTION_QUIT, [this.getURL(), e.server.getURL()]);
|
||||
}
|
||||
|
||||
/* If we were only /trying/ to connect, and failed, just put an error on
|
||||
* the network tab. If we were actually connected ok, put it on all tabs.
|
||||
*/
|
||||
@ -1642,7 +1650,7 @@ function my_netdisconnect (e)
|
||||
this.busy = false;
|
||||
updateProgress();
|
||||
|
||||
this.displayHere(msg, "ERROR");
|
||||
this.displayHere(msg, msgType);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1653,7 +1661,7 @@ function my_netdisconnect (e)
|
||||
{
|
||||
var details = getObjectDetails(obj);
|
||||
if ("server" in details && details.server == e.server)
|
||||
obj.displayHere(msg, "ERROR");
|
||||
obj.displayHere(msg, msgType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1671,6 +1679,12 @@ function my_netdisconnect (e)
|
||||
if ("userClose" in client && client.userClose &&
|
||||
client.getConnectionCount() == 0)
|
||||
window.close();
|
||||
|
||||
if (("reconnect" in this) && this.reconnect)
|
||||
{
|
||||
this.connect(this.requireSecurity);
|
||||
delete this.reconnect;
|
||||
}
|
||||
}
|
||||
|
||||
CIRCNetwork.prototype.onCTCPReplyPing =
|
||||
|
@ -106,7 +106,10 @@ function initMenus()
|
||||
]
|
||||
};
|
||||
|
||||
var notInChannel = "((cx.TYPE == 'IRCChannel') and !cx.channel.active)";
|
||||
var inChannel = "((cx.TYPE == 'IRCChannel') and cx.channel.active)";
|
||||
var netConnected = "cx.network and cx.network.isConnected()";
|
||||
var netDisconnected = "cx.network and !cx.network.isConnected()";
|
||||
|
||||
client.menuSpecs["mainmenu:file"] = {
|
||||
label: MSG_MNU_FILE,
|
||||
@ -121,8 +124,10 @@ function initMenus()
|
||||
//["manage-plugins"],
|
||||
["-"],
|
||||
["leave", {visibleif: inChannel}],
|
||||
["rejoin", {visibleif: notInChannel}],
|
||||
["delete-view", {visibleif: "!" + inChannel}],
|
||||
["disconnect"],
|
||||
["disconnect", {visibleif: netConnected}],
|
||||
["reconnect", {visibleif: netDisconnected}],
|
||||
["-"],
|
||||
["print"],
|
||||
["-"],
|
||||
@ -349,8 +354,10 @@ function initMenus()
|
||||
["version", {visibleif: "cx.nickname"}],
|
||||
["-"],
|
||||
["leave", {visibleif: inChannel}],
|
||||
["rejoin", {visibleif: notInChannel}],
|
||||
["delete-view", {visibleif: "!" + inChannel}],
|
||||
["disconnect"],
|
||||
["disconnect", {visibleif: netConnected}],
|
||||
["reconnect", {visibleif: netDisconnected}],
|
||||
["-"],
|
||||
["toggle-text-dir"]
|
||||
]
|
||||
@ -367,8 +374,10 @@ function initMenus()
|
||||
checkedif: "isStartupURL(cx.sourceObject.getURL())"}],
|
||||
["-"],
|
||||
["leave", {visibleif: inChannel}],
|
||||
["rejoin", {visibleif: notInChannel}],
|
||||
["delete-view", {visibleif: "!" + inChannel}],
|
||||
["disconnect"],
|
||||
["disconnect", {visibleif: netConnected}],
|
||||
["reconnect", {visibleif: netDisconnected}],
|
||||
["-"],
|
||||
["toggle-text-dir"]
|
||||
]
|
||||
|
@ -642,6 +642,18 @@ function isVisible (id)
|
||||
return (e.getAttribute ("collapsed") != "true");
|
||||
}
|
||||
|
||||
client.getConnectedNetworks =
|
||||
function getConnectedNetworks()
|
||||
{
|
||||
var rv = [];
|
||||
for (var n in client.networks)
|
||||
{
|
||||
if (client.networks[n].isConnected())
|
||||
rv.push(client.networks[n]);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
function insertLink (matchText, containerTag)
|
||||
{
|
||||
var href;
|
||||
|
@ -210,6 +210,11 @@ cmd.disconnect.label = &Disconnect
|
||||
cmd.disconnect.params = [<reason>]
|
||||
cmd.disconnect.help = Disconnects from the server represented by the active view when the command is executed providing the reason <reason> or the default reason if <reason> is not specified.
|
||||
|
||||
cmd.disconnect-all.label = &Disconnect From All Networks
|
||||
cmd.disconnect-all.params = [<reason>]
|
||||
cmd.disconnect-all.key = accel D
|
||||
cmd.disconnect-all.help = Disconnects from all networks providing the reason <reason> or the default reason if <reason> is not specified.
|
||||
|
||||
cmd.echo.params = <message>
|
||||
cmd.echo.help = Displays <message> in the current view, but does not send it to the server.
|
||||
|
||||
@ -300,6 +305,15 @@ cmd.hop.label = Give Half-operator Status
|
||||
cmd.hop.params = <nickname> [<...>]
|
||||
cmd.hop.help = Gives half-operator status to <nickname> on current channel. Requires operator status.
|
||||
|
||||
cmd.reconnect.format = Reconnect To $networkName
|
||||
cmd.reconnect.label = &Reconnect
|
||||
cmd.reconnect.params = [<reason>]
|
||||
cmd.reconnect.help = Reconnects to the network represented by the active view when the command is executed providing the reason <reason> when disconnecting, or the default reason if <reason> is not specified.
|
||||
|
||||
cmd.reconnect-all.label = &Reconnect To All Networks
|
||||
cmd.reconnect-all.params = [<reason>]
|
||||
cmd.reconnect-all.help = Reconnects to all networks providing the reason <reason> when disconnecting, or the default reason if <reason> is not specified.
|
||||
|
||||
cmd.toggle-ui.params = <thing>
|
||||
cmd.toggle-ui.help = Toggles the visibility of various pieces of the user interface. <thing> must be one of: tabstrip, userlist, header, status.
|
||||
|
||||
@ -493,6 +507,11 @@ cmd.quit-mozilla.help = Quit Mozilla.
|
||||
cmd.quote.params = <irc-command>
|
||||
cmd.quote.help = Sends a raw command to the IRC server, not a good idea if you don't know what you're doing. see IRC RFC1459 <http://www.irchelp.org/irchelp/rfc1459.html> for complete details.
|
||||
|
||||
cmd.rejoin.params = [<reason>]
|
||||
cmd.rejoin.help = Rejoins the channel displayed in the current view. Only works from a channel view.
|
||||
cmd.rejoin.format = Rejoin $channelName
|
||||
cmd.rejoin.label = Rejoin
|
||||
|
||||
cmd.server.params = <hostname> [<port> [<password>]]
|
||||
cmd.server.help = Connects to server <hostname> on <port>, or 6667 if <port> is not specified. Provides the password <password> if specified. If you are already connected, the view for <hostname> is made current. If that view has been deleted, it is recreated.
|
||||
|
||||
@ -947,8 +966,14 @@ msg.connection.timeout = Connection to %S (%S) timed out.
|
||||
msg.unknown.host = Unknown host ``%S'' connecting to %S (%S).
|
||||
msg.connection.closed = Connection to %S (%S) closed.
|
||||
msg.connection.reset = Connection to %S (%S) reset.
|
||||
msg.connection.quit = Disconnected from %S (%S).
|
||||
msg.close.status = Connection to %S (%S) closed with status %S.
|
||||
|
||||
msg.reconnecting = Reconnecting...
|
||||
msg.confirm.disconnect.all = Are you sure you want to disconnect from ALL networks?
|
||||
msg.no.connected.nets = You are not connected to any networks.
|
||||
msg.no.reconnectable.nets = There are no networks to reconnect to.
|
||||
|
||||
msg.ping.reply = Ping reply from %S in %S"
|
||||
msg.prefix.response = "%S, your result is,
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user