diff --git a/mozilla/extensions/irc/js/lib/irc.js b/mozilla/extensions/irc/js/lib/irc.js index 7dc35942359..d40bb67d82b 100644 --- a/mozilla/extensions/irc/js/lib/irc.js +++ b/mozilla/extensions/irc/js/lib/irc.js @@ -264,16 +264,28 @@ function net_quit (reason) CIRCNetwork.prototype.cancel = function net_cancel() { + // We're online, pull the plug on the current connection, or... if (this.state == NET_ONLINE) { - // Pull the plug on the current connection, or... this.quit(); } - else if ((this.state == NET_CONNECTING) || (this.state == NET_WAITING)) + // We're waiting for the 001, too late to throw a reconnect, or... + else if (this.state == NET_CONNECTING) { this.state = NET_CANCELLING; - - // ...try a reconnect (which will fail us). + this.primServ.connection.disconnect(); + // Throw the necessary error events: + ev = new CEvent ("network", "error", this, "onError"); + ev.server = this; + ev.debug = "Connect sequence was cancelled."; + ev.errorCode = JSIRC_ERR_CANCELLED; + this.eventPump.addEvent(ev); + } + // We're waiting for onDoConnect, so try a reconnect (which will fail us) + else if (this.state == NET_WAITING) + { + this.state = NET_CANCELLING; + // onDoConnect will throw the error events for us, as it will fail this.immediateConnect(); } else @@ -980,7 +992,7 @@ function serv_disconnect(e) CIRCServer.prototype.onSendData = function serv_onsenddata (e) { - if (!this.isConnected) + if (!this.isConnected || (this.parent.state == NET_CANCELLING)) { dd ("Can't send to disconnected socket"); this.flushSendQueue(); @@ -1046,7 +1058,8 @@ function serv_poll(e) try { - line = this.connection.readData(this.READ_TIMEOUT); + if (this.parent.state != NET_CANCELLING) + line = this.connection.readData(this.READ_TIMEOUT); } catch (ex) { diff --git a/mozilla/extensions/irc/xul/content/commands.js b/mozilla/extensions/irc/xul/content/commands.js index 976807c0cc4..d4ee478d71d 100644 --- a/mozilla/extensions/irc/xul/content/commands.js +++ b/mozilla/extensions/irc/xul/content/commands.js @@ -863,6 +863,9 @@ function cmdCancel(e) (network.state == NET_WAITING)) { // We're trying to connect to a network, and want to cancel. Do so: + if (e.deleteWhenDone) + e.network.deleteWhenDone = true; + display(getMsg(MSG_CANCELLING, network.unicodeName)); network.cancel(); } @@ -1485,9 +1488,18 @@ function cmdDeleteView(e) e.view = e.sourceObject; if (e.view.TYPE == "IRCChannel" && e.view.active) - e.view.part(); + { + e.view.dispatch("part", { deleteWhenDone: true }); + return; + } if (e.view.TYPE == "IRCDCCChat" && e.view.active) e.view.disconnect(); + if (e.view.TYPE == "IRCNetwork" && (e.view.state == NET_CONNECTING || + e.view.state == NET_WAITING)) + { + e.view.dispatch("cancel", { deleteWhenDone: true }); + return; + } if (client.viewsArray.length < 2) { @@ -1659,7 +1671,7 @@ function cmdRejoin(e) { if (!e.reason) e.reason = ""; - e.channel.dispatch("part", { reason: e.reason, noDelete: true }); + e.channel.dispatch("part", { reason: e.reason, deleteWhenDone: false }); } e.channel.join(e.channel.mode.key); @@ -2280,13 +2292,15 @@ function cmdLeave(e) } } + if (!("deleteWhenDone" in e)) + e.deleteWhenDone = client.prefs["deleteOnPart"]; + /* If it's not active, we're not actually in it, even though the view is * still here. */ if (e.channel.active) { - if (e.noDelete) - e.channel.noDelete = true; + e.channel.deleteWhenDone = e.deleteWhenDone; if (!e.reason) e.reason = ""; @@ -2296,8 +2310,8 @@ function cmdLeave(e) } else { - if (!e.noDelete && client.prefs["deleteOnPart"]) - e.channel.dispatch("delete"); + if (e.deleteWhenDone) + e.channel.dispatch("delete-view"); } } diff --git a/mozilla/extensions/irc/xul/content/handlers.js b/mozilla/extensions/irc/xul/content/handlers.js index df86f54e198..b43f36ae8a5 100644 --- a/mozilla/extensions/irc/xul/content/handlers.js +++ b/mozilla/extensions/irc/xul/content/handlers.js @@ -1807,7 +1807,14 @@ function my_neterror (e) updateProgress(); } + this.display(msg, type); + + if (this.deleteWhenDone) + this.dispatch("delete-view"); + + delete this.deleteWhenDone; + } @@ -1874,10 +1881,11 @@ function my_netdisconnect (e) { this.busy = false; updateProgress(); - - this.displayHere(msg, msgType); + if (this.state != NET_CANCELLING) + this.displayHere(msg, msgType); } - else + // Don't do anything if we're cancelling. + else if (this.state != NET_CANCELLING) { for (var v in client.viewsArray) { @@ -2258,10 +2266,10 @@ function my_cpart (e) /* redisplay the tree */ client.rdf.setTreeRoot("user-list", this.getGraphResource()); - if ("noDelete" in this) - delete this.noDelete; - else if (client.prefs["deleteOnPart"]) - this.dispatch("delete"); + if (this.deleteWhenDone) + this.dispatch("delete-view"); + + delete this.deleteWhenDone; } else { diff --git a/mozilla/extensions/irc/xul/locale/en-US/chatzilla.properties b/mozilla/extensions/irc/xul/locale/en-US/chatzilla.properties index 204840f4446..31ce547502d 100644 --- a/mozilla/extensions/irc/xul/locale/en-US/chatzilla.properties +++ b/mozilla/extensions/irc/xul/locale/en-US/chatzilla.properties @@ -456,7 +456,7 @@ cmd.label-user.help = cmd.leave.format = Leave $channelName cmd.leave.label = &Leave cmd.leave.params = [ []] -cmd.leave.help = Leaves the current channel. Use /delete to force the view to go away, losing its contents, or /hide to temporarily hide it, preserving its contents. Many servers do not support the optional parameter. If you are dispatching this command from a script, you may also specify the parameter. If this is provided and is |true|, |on|, |yes|, or |1|, the tab will not be deleted. +cmd.leave.help = Leaves the current channel. Use /delete to force the view to go away, losing its contents, or /hide to temporarily hide it, preserving its contents. Many servers do not support the optional parameter. Your preferences are used to determine whether to delete the tab. If you are dispatching this command from a script, you may override this behaviour with the parameter. cmd.links.help = Displays the "links" to the current server. This is a list of the other servers in the network which are directly connected to the one you are connected to.