Bug 284149 - Cope better with trying to connect to a network using SSL when there are no servers, and make our own disconnect messages look like the errors they used to be.

r=rginda
a=asa
p=gijskruitbosch@gmail.com (Gijs "Hannibal" Kruitbosch)
This commit is contained in:
silver%warwickcompsoc.co.uk 2005-04-21 20:12:28 +00:00
parent 778d1ba7ba
commit 931a243c33
8 changed files with 54 additions and 9 deletions

View File

@ -40,6 +40,7 @@
const JSIRC_ERR_NO_SOCKET = "JSIRCE:NS";
const JSIRC_ERR_EXHAUSTED = "JSIRCE:E";
const JSIRC_ERR_CANCELLED = "JSIRCE:C";
const JSIRC_ERR_NO_SECURE = "JSIRCE:NO_SECURE";
const JSIRC_ERR_OFFLINE = "JSIRCE:OFFLINE";
function userIsMe (user)
@ -181,12 +182,39 @@ function net_addsrv(host, port, isSecure, password)
this.serverList.push(new CIRCServer(this, host, port, isSecure, password));
}
// Checks if a network has a secure server in its list.
CIRCNetwork.prototype.hasSecureServer =
function net_hasSecure()
{
for (var i = 0; i < this.serverList.length; i++)
{
if (this.serverList[i].isSecure)
return true;
}
return false;
}
CIRCNetwork.prototype.connect =
function net_connect(requireSecurity)
{
if ("primServ" in this && this.primServ.isConnected)
return;
// We need to test for secure servers in the network object here,
// because without them all connection attempts will fail anyway.
if (requireSecurity && !this.hasSecureServer())
{
// No secure server, cope.
ev = new CEvent ("network", "error", this, "onError");
ev.server = this;
ev.debug = "No connection attempted: no secure servers in list";
ev.errorCode = JSIRC_ERR_NO_SECURE;
this.eventPump.addEvent(ev);
return false;
}
this.state = NET_CONNECTING;
this.connectAttempt = 0;
this.nextHost = 0;
@ -194,6 +222,7 @@ function net_connect(requireSecurity)
var ev = new CEvent("network", "do-connect", this, "onDoConnect");
ev.password = null;
this.eventPump.addEvent(ev);
return true;
}
CIRCNetwork.prototype.quit =
@ -321,7 +350,9 @@ function net_doconnect(e)
}
else
{
/* server doesn't use SSL as requested, try next one. */
/* Server doesn't use SSL as requested, try next one.
* In the meantime, correct the connection attempt counter */
this.connectAttempt--;
ev = new CEvent ("network", "do-connect", this, "onDoConnect");
this.eventPump.addEvent (ev);
}

View File

@ -1570,6 +1570,10 @@ function my_neterror (e)
msg = MSG_ERR_OFFLINE;
break;
case JSIRC_ERR_NO_SECURE:
msg = getMsg(MSG_ERR_NO_SECURE, this.unicodeName);
break;
case JSIRC_ERR_CANCELLED:
msg = MSG_ERR_CANCELLED;
type = "INFO";
@ -1641,10 +1645,10 @@ function my_netdisconnect (e)
[this.getURL(), e.server.getURL()]);
}
// e.quitting signals the disconnect was intended: use "INFO", not "ERROR".
// e.quitting signals the disconnect was intended: don't use "ERROR".
if (e.quitting)
{
msgType = "INFO";
msgType = "DISCONNECT";
msg = getMsg(MSG_CONNECTION_QUIT, [this.getURL(), e.server.getURL()]);
}

View File

@ -55,6 +55,7 @@ function initMessages()
"INFO": MSG_RSP_INFO,
"EVAL-IN": MSG_RSP_EVIN,
"EVAL-OUT": MSG_RSP_EVOUT,
"DISCONNECT": MSG_RSP_DISCONNECT,
"JOIN": "-->|",
"PART": "<--|",
"QUIT": "|<--",

View File

@ -358,7 +358,9 @@ function initApplicationCompatibility()
function initNetworks()
{
client.addNetwork("moznet",[{name: "irc.mozilla.org", port: 6667}]);
client.addNetwork("moznet",
[{name: "irc.mozilla.org", port:6667},
{name: "irc.mozilla.org", port:6697, isSecure:true}]);
client.addNetwork("hybridnet", [{name: "irc.ssc.net", port: 6667}]);
client.addNetwork("slashnet", [{name: "irc.slashnet.org", port:6667}]);
client.addNetwork("dalnet", [{name: "irc.dal.net", port:6667}]);
@ -366,7 +368,8 @@ function initNetworks()
client.addNetwork("webbnet", [{name: "irc.webbnet.info", port:6667}]);
client.addNetwork("quakenet", [{name: "irc.quakenet.org", port:6667}]);
client.addNetwork("freenode", [{name: "irc.freenode.net", port:6667}]);
client.addNetwork("serenia", [{name: "chat.serenia.net", port:9999, isSecure:true}]);
client.addNetwork("serenia",
[{name: "chat.serenia.net", port:9999, isSecure:true}]);
client.addNetwork("efnet",
[{name: "irc.prison.net", port: 6667},
{name: "irc.magic.ca", port: 6667}]);

View File

@ -625,6 +625,7 @@ msg.err.no.default = No default action for objects of type ``%S''.
msg.err.no.match = No match for ``%S''.
msg.err.no.socket = Error creating socket.
msg.err.exhausted = Connection attempts exhausted, giving up.
msg.err.no.secure = The network ``%S'' has no secure servers defined.
msg.err.cancelled = Connection process canceled.
msg.err.offline = The host software platform (e.g. Mozilla, Firefox) is in ``offline mode''. No network connections can be made in this mode.
msg.err.badalias = Malformed alias: %S"
@ -714,6 +715,7 @@ msg.rsp.warn = [WARNING]
msg.rsp.info = [INFO]
msg.rsp.evin = [EVAL-IN]
msg.rsp.evout = [EVAL-OUT]
msg.rsp.disconnect = [QUIT]
msg.mnu.showhide = Sho&w/Hide
msg.mnu.file = &File

View File

@ -154,7 +154,8 @@ a.chatzilla-link:visited {
color: yellow;
}
.msg[msg-type="ERROR"] .msg-data {
.msg[msg-type="ERROR"] .msg-data,
.msg[msg-type="DISCONNECT"] .msg-data {
background: red;
color: white;
}

View File

@ -109,7 +109,8 @@ a.chatzilla-link {
color: #11c411;
}
.msg[msg-type="ERROR"] .msg-data a.chatzilla-link {
.msg[msg-type="ERROR"] .msg-data a.chatzilla-link,
.msg[msg-type="DISCONNECT"] .msg-data a.chatzilla-link {
font-weight: bold;
color: white;
}
@ -183,7 +184,8 @@ a.chatzilla-link {
font-weight: bold;
}
.msg[msg-type="ERROR"] .msg-data {
.msg[msg-type="ERROR"] .msg-data,
.msg[msg-type="DISCONNECT"] .msg-data {
-moz-border-radius: 5px 5px 5px 5px;
background: #a8221e;
color: white;

View File

@ -141,7 +141,8 @@ body {
}
.msg-data[msgtype="ERROR"] {
.msg-data[msgtype="ERROR"],
.msg-data[msgtype="DISCONNECT"] {
background: red;
color: white;