зеркало из https://github.com/mozilla/gecko-dev.git
Bug 166929 - ChatZilla doesn't have online/offline icon.
r=silver@warwickcompsoc.co.uk (James Ross) ChatZilla Only.
This commit is contained in:
Родитель
6b4b537275
Коммит
72346fbb5d
|
@ -99,6 +99,8 @@ chatzilla.jar:
|
|||
skin/modern/chatzilla/images/input-send.png (xul/skin/images/input-send.png)
|
||||
skin/modern/chatzilla/images/secure.png (xul/skin/images/secure.png)
|
||||
skin/modern/chatzilla/images/secure-broken.png (xul/skin/images/secure-broken.png)
|
||||
skin/modern/chatzilla/images/online.png (xul/skin/images/online.png)
|
||||
skin/modern/chatzilla/images/offline.png (xul/skin/images/offline.png)
|
||||
locale/en-US/chatzilla/chatzillaOverlay.dtd (xul/locale/en-US/chatzillaOverlay.dtd)
|
||||
locale/en-US/chatzilla/browserOverlay.dtd (xul/locale/en-US/browserOverlay.dtd)
|
||||
locale/en-US/chatzilla/pref-irc.dtd (xul/locale/en-US/pref-irc.dtd)
|
||||
|
|
|
@ -47,6 +47,10 @@ const NS_ERROR_NET_RESET = NS_ERROR_MODULE_NETWORK + 20;
|
|||
const NS_ERROR_UNKNOWN_PROXY_HOST = NS_ERROR_MODULE_NETWORK + 42;
|
||||
const NS_ERROR_PROXY_CONNECTION_REFUSED = NS_ERROR_MODULE_NETWORK + 72;
|
||||
|
||||
// Offline error constants:
|
||||
const NS_ERROR_BINDING_ABORTED = NS_ERROR_MODULE_NETWORK + 2;
|
||||
const NS_ERROR_ABORT = 0x80004004;
|
||||
|
||||
const NS_NET_STATUS_RESOLVING_HOST = NS_ERROR_MODULE_NETWORK + 3;
|
||||
const NS_NET_STATUS_CONNECTED_TO = NS_ERROR_MODULE_NETWORK + 4;
|
||||
const NS_NET_STATUS_SENDING_TO = NS_ERROR_MODULE_NETWORK + 5;
|
||||
|
|
|
@ -734,6 +734,9 @@ function serv_sockdiscon(status)
|
|||
var ev = new CEvent ("server", "disconnect", this, "onDisconnect");
|
||||
ev.server = this;
|
||||
ev.disconnectStatus = status;
|
||||
if (ev.disconnectStatus == NS_ERROR_BINDING_ABORTED)
|
||||
ev.disconnectStatus = NS_ERROR_ABORT;
|
||||
|
||||
this.parent.eventPump.addEvent (ev);
|
||||
}
|
||||
|
||||
|
@ -1025,10 +1028,12 @@ function serv_disconnect(e)
|
|||
network.delayedConnect();
|
||||
};
|
||||
|
||||
if ((this.parent.state == NET_CONNECTING) ||
|
||||
// Don't reconnect if our connection was aborted.
|
||||
var wasAborted = (e.disconnectStatus == NS_ERROR_ABORT);
|
||||
if (((this.parent.state == NET_CONNECTING) && !wasAborted) ||
|
||||
/* fell off while connecting, try again */
|
||||
(this.parent.primServ == this) && (this.parent.state == NET_ONLINE) &&
|
||||
(!("quitting" in this) && this.parent.stayingPower))
|
||||
(!("quitting" in this) && this.parent.stayingPower && !wasAborted))
|
||||
{ /* fell off primary server, reconnect to any host in the serverList */
|
||||
setTimeout(delayedConnectFn, 0, this.parent);
|
||||
}
|
||||
|
@ -1097,6 +1102,7 @@ function serv_onsenddata (e)
|
|||
ev.server = this;
|
||||
ev.reason = "error";
|
||||
ev.exception = ex;
|
||||
ev.disconnectStatus = NS_ERROR_ABORT;
|
||||
this.parent.eventPump.addEvent(ev);
|
||||
|
||||
return false;
|
||||
|
@ -1144,6 +1150,7 @@ function serv_poll(e)
|
|||
ev.server = this;
|
||||
ev.reason = "error";
|
||||
ev.exception = ex;
|
||||
ev.disconnectStatus = NS_ERROR_ABORT;
|
||||
this.parent.eventPump.addEvent (ev);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -142,6 +142,7 @@ function onClose()
|
|||
function onUnload()
|
||||
{
|
||||
dd("Shutting down ChatZilla.");
|
||||
uninitOfflineIcon();
|
||||
destroy();
|
||||
}
|
||||
|
||||
|
@ -1944,6 +1945,20 @@ function my_netdisconnect (e)
|
|||
msg = MSG_PROXY_CONNECTION_REFUSED;
|
||||
break;
|
||||
|
||||
case NS_ERROR_ABORT:
|
||||
if (client.iosvc.offline)
|
||||
{
|
||||
msg = getMsg(MSG_CONNECTION_ABORT_OFFLINE,
|
||||
[this.getURL(), e.server.getURL()]);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = getMsg(MSG_CONNECTION_ABORT_UNKNOWN,
|
||||
[this.getURL(), e.server.getURL(),
|
||||
formatException(e.exception)]);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
msg = getMsg(MSG_CLOSE_STATUS,
|
||||
[this.getURL(), e.server.getURL(),
|
||||
|
@ -1964,6 +1979,12 @@ function my_netdisconnect (e)
|
|||
msg = getMsg(MSG_CONNECTION_QUIT, [this.getURL(), e.server.getURL()]);
|
||||
msgNetwork = msg;
|
||||
}
|
||||
// We won't reconnect if the error was really bad.
|
||||
else if ((typeof e.disconnectStatus != "undefined") &&
|
||||
(e.disconnectStatus == NS_ERROR_ABORT))
|
||||
{
|
||||
msgNetwork = msg;
|
||||
}
|
||||
else
|
||||
{
|
||||
var delayStr = formatDateOffset(this.getReconnectDelayMs() / 1000);
|
||||
|
|
|
@ -140,10 +140,7 @@
|
|||
<label id="security-button-label"/>
|
||||
<image id="security-button-image"/>
|
||||
</statusbarpanel>
|
||||
<!--
|
||||
<statusbarpanel class="statusbarpanel-iconic" id="offline-status"
|
||||
hidden="true" offline="true"/>
|
||||
-->
|
||||
<statusbarpanel class="statusbarpanel-iconic" id="offline-status"/>
|
||||
</statusbar>
|
||||
</overlaytarget>
|
||||
|
||||
|
|
|
@ -208,6 +208,7 @@ function init()
|
|||
|
||||
client.busy = false;
|
||||
updateProgress();
|
||||
initOfflineIcon();
|
||||
|
||||
client.initialized = true;
|
||||
|
||||
|
@ -2018,6 +2019,182 @@ function updateSecurityIcon()
|
|||
}
|
||||
}
|
||||
|
||||
function initOfflineIcon()
|
||||
{
|
||||
const IOSVC2_CID = "@mozilla.org/network/io-service;1";
|
||||
const PRBool_CID = "@mozilla.org/supports-PRBool;1";
|
||||
const OS_CID = "@mozilla.org/observer-service;1";
|
||||
const nsISupportsPRBool = Components.interfaces.nsISupportsPRBool;
|
||||
|
||||
client.offlineObserver = {
|
||||
_element: document.getElementById("offline-status"),
|
||||
_getNewIOSvc: function offline_getNewIOSvc()
|
||||
{
|
||||
try
|
||||
{
|
||||
return getService(IOSVC2_CID, "nsIIOService2");
|
||||
}
|
||||
catch (ex) {}
|
||||
|
||||
// If it failed, it's probably just not there. We don't care.
|
||||
return null;
|
||||
},
|
||||
state: function offline_state()
|
||||
{
|
||||
return (client.iosvc.offline ? "offline" : "online");
|
||||
},
|
||||
observe: function offline_observe(subject, topic, state)
|
||||
{
|
||||
if ((topic == "offline-requested") &&
|
||||
(client.getConnectionCount() > 0))
|
||||
{
|
||||
var buttonAry = [MSG_REALLY_GO_OFFLINE, MSG_DONT_GO_OFFLINE];
|
||||
var rv = confirmEx(MSG_GOING_OFFLINE, buttonAry);
|
||||
if (rv == 1) // Don't go offline, please!
|
||||
{
|
||||
subject.QueryInterface(nsISupportsPRBool);
|
||||
subject.data = true;
|
||||
}
|
||||
}
|
||||
else if (topic == "network:offline-status-changed")
|
||||
{
|
||||
this.updateOfflineUI();
|
||||
}
|
||||
},
|
||||
updateOfflineUI: function offline_uiUpdate()
|
||||
{
|
||||
this._element.setAttribute("offlinestate", this.state());
|
||||
var tooltipMsgId = "MSG_OFFLINESTATE_" + this.state().toUpperCase();
|
||||
this._element.setAttribute("tooltiptext", window[tooltipMsgId]);
|
||||
},
|
||||
toggleOffline: function offline_toggle()
|
||||
{
|
||||
// Check whether people are OK with us going offline:
|
||||
if (!client.iosvc.offline && !this.canGoOffline())
|
||||
return;
|
||||
|
||||
// Stop automatic management of the offline status, if existing.
|
||||
try
|
||||
{
|
||||
var ioSvc2 = this._getNewIOSvc();
|
||||
if (ioSvc2 && ("manageOfflineStatus" in ioSvc2))
|
||||
ioSvc2.manageOfflineStatus = false;
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
dd("Turning off managed offline status failed!\n" + ex);
|
||||
}
|
||||
|
||||
// Actually change the offline state.
|
||||
client.iosvc.offline = !client.iosvc.offline;
|
||||
// Update the pref:
|
||||
this.updatePrefFromOffline();
|
||||
},
|
||||
canGoOffline: function offline_check()
|
||||
{
|
||||
try
|
||||
{
|
||||
var os = getService(OS_CID, "nsIObserverService");
|
||||
var canGoOffline = newObject(PRBool_CID, "nsISupportsPRBool");
|
||||
os.notifyObservers(canGoOffline, "offline-requested", null);
|
||||
// Someone called for a halt
|
||||
if (canGoOffline.data)
|
||||
return false;
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
dd("Exception when trying to ask if we could go offline:" + ex);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
updateOfflineFromPref: function offline_syncFromPref()
|
||||
{
|
||||
// On toolkit, we might have smart management of offline mode.
|
||||
// Don't interfere.
|
||||
var ioSvc2 = this._getNewIOSvc();
|
||||
if (ioSvc2 && ioSvc2.manageOfflineStatus)
|
||||
return;
|
||||
|
||||
// This is app-managed, or should be, on startup:
|
||||
if (client.host == "Mozilla")
|
||||
return;
|
||||
|
||||
var isOffline = false;
|
||||
var prefSvc = getService("@mozilla.org/preferences-service;1",
|
||||
"nsIPrefBranch");
|
||||
// Let the app-specific hacks begin:
|
||||
try {
|
||||
if ((client.host == "Firefox") || (client.host == "Flock"))
|
||||
isOffline = prefSvc.getBoolPref("browser.offline");
|
||||
else if (client.host == "XULrunner")
|
||||
isOffline = !prefSvc.getBoolPref("network.online");
|
||||
}
|
||||
catch (ex) { /* Whatever. */ }
|
||||
|
||||
// Actually do it:
|
||||
client.iosvc.offline = isOffline;
|
||||
},
|
||||
updatePrefFromOffline: function offline_syncToPref()
|
||||
{
|
||||
// This is app-managed, or should be.
|
||||
if (client.host == "Mozilla")
|
||||
return;
|
||||
|
||||
var isOffline = client.iosvc.offline;
|
||||
var prefSvc = getService("@mozilla.org/preferences-service;1",
|
||||
"nsIPrefBranch");
|
||||
// Let the app-specific hacks begin:
|
||||
try {
|
||||
if ((client.host == "Firefox") || (client.host == "Flock"))
|
||||
prefSvc.setBoolPref("browser.offline", isOffline);
|
||||
else if (client.host == "XULrunner")
|
||||
prefSvc.setBoolPref("network.online", !isOffline);
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
dd("Couldn't set offline pref! Error:" + ex);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var os = getService(OS_CID, "nsIObserverService");
|
||||
os.addObserver(client.offlineObserver, "offline-requested", false);
|
||||
os.addObserver(client.offlineObserver,
|
||||
"network:offline-status-changed", false);
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
dd("Exception when trying to register offline observers: " + ex);
|
||||
}
|
||||
|
||||
var elem = client.offlineObserver._element;
|
||||
elem.setAttribute("onclick", "client.offlineObserver.toggleOffline()");
|
||||
client.offlineObserver.updateOfflineFromPref();
|
||||
client.offlineObserver.updateOfflineUI();
|
||||
|
||||
// Don't leak:
|
||||
delete os;
|
||||
delete elem;
|
||||
}
|
||||
|
||||
function uninitOfflineIcon()
|
||||
{
|
||||
const OS_CID = "@mozilla.org/observer-service;1";
|
||||
try
|
||||
{
|
||||
var os = getService(OS_CID, "nsIObserverService");
|
||||
os.removeObserver(client.offlineObserver, "offline-requested", false);
|
||||
os.removeObserver(client.offlineObserver,
|
||||
"network:offline-status-changed", false);
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
dd("Exception when trying to unregister offline observers: " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
function updateAppMotif(motifURL)
|
||||
{
|
||||
var node = document.firstChild;
|
||||
|
|
|
@ -897,6 +897,11 @@ msg.not.connected = "%S: Not connected.
|
|||
msg.insecure.server = Your connection to the server ``%S'' is not secure.
|
||||
msg.secure.connection = Signed by %S"
|
||||
msg.security.info = Displays security information about the current connection
|
||||
msg.going.offline = &brandShortName; is trying to go into offline mode. This will disconnect you from ALL the networks and channels you're connected to.
|
||||
msg.really.go.offline = Go Offline
|
||||
msg.dont.go.offline = Don't Go Offline
|
||||
msg.offlinestate.offline = You are offline. Click the icon to go online.
|
||||
msg.offlinestate.online = You are online. Click the icon to go offline.
|
||||
msg.member = Member
|
||||
msg.operator = Operator member
|
||||
msg.voiced = Voiced member
|
||||
|
@ -1176,6 +1181,8 @@ msg.who.match = User %S, (%S@%S) ``%S'' (%S), member of %S, is connected to
|
|||
|
||||
msg.connection.attempt = Connecting to %S (%S)...
|
||||
msg.connection.refused = Connection to %S (%S) refused.
|
||||
msg.connection.abort.offline = The connection to %S (%S) was aborted because you went into offline mode.
|
||||
msg.connection.abort.unknown = The connection to %S (%S) was aborted with error %S.
|
||||
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.
|
||||
|
|
|
@ -315,3 +315,10 @@ progressmeter[mode="undetermined"] {
|
|||
display: none;
|
||||
}
|
||||
|
||||
#offline-status[offlinestate="offline"] {
|
||||
list-style-image: url("chrome://chatzilla/skin/images/offline.png");
|
||||
}
|
||||
|
||||
#offline-status[offlinestate="online"] {
|
||||
list-style-image: url("chrome://chatzilla/skin/images/online.png");
|
||||
}
|
||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 896 B |
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 701 B |
Загрузка…
Ссылка в новой задаче