Bug 382085 - ChatZilla should have support for auto-away

r=silver@warwickcompsoc.co.uk (James Ross)
ChatZilla Only. NPOTFFB.


git-svn-id: svn://10.0.0.236/trunk@242453 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
gijskruitbosch%gmail.com 2008-01-05 17:02:35 +00:00
parent c93fe15f98
commit a913db8c9c
5 changed files with 118 additions and 11 deletions

View File

@ -743,7 +743,7 @@ msg.err.no.match = No match for ``%S''.
msg.err.no.socket = Error creating socket.
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.offline = &brandShortName; is in ``offline mode''. No network connections can be made in this mode.
msg.err.badalias = Malformed alias: %S"
msg.err.no.ctcp.cmd = %S is not a valid CTCP function for this client
msg.err.no.ctcp.help = %S does not have any help information
@ -754,6 +754,7 @@ msg.err.invalid.mode = The mode string you entered (``%S'') is invalid. A valid
msg.err.away.save = Saving the list of away messages failed (%S).
msg.err.invalid.url = ``%S'' is not a valid url nor an alias for a url, and therefor could not be loaded.
msg.err.no.channel = When running the ``%S'' command, you should either provide a channel name, or run the command in the context of a channel.
msg.err.no.idleservice = ChatZilla can't determine when you're away in your version of &brandShortName;. The auto-away feature will now be disabled.
# Specific bug messages.
msg.bug318419.warning = ChatZilla has detected a potential abnormality in its internal data. You will not be able to send any form of communication at this time, although it might appear you can. The most likely cause is Mozilla Bug 318419 <https://bugzilla.mozilla.org/show_bug.cgi?id=318419>. You are strongly advised to restart the host application (&brandShortName;) to prevent further problems.
@ -1055,7 +1056,7 @@ msg.dcc.accepted.matches = "%S DCC connections matched.
msg.dcc.matches.help = You must specify enough of the user's nickname to uniquely identify the request, or include the request type and even the filename if necessary.
msg.dcc.not.enabled = DCC is disabled. If you need DCC functionality, you may turn it on from the Preferences window.
msg.dcc.not.possible = DCC is unavailable in this version of the host software platform (e.g. Mozilla, Firefox) - the feature "scriptable server sockets" is missing. Mozilla builds after 2003-11-15 should contain this feature (e.g. Mozilla 1.6 or later).
msg.dcc.not.possible = DCC is unavailable in this version of &brandShortName; - the feature "scriptable server sockets" is missing. Mozilla builds after 2003-11-15 should contain this feature (e.g. Mozilla 1.6 or later).
msg.dcc.err.nouser = Must specify |nickname| or run the command from a query view.
msg.dcc.err.accept.time = You cannot use the short form of |/dcc-accept| within the first 10 seconds of receiving a DCC request.
msg.dcc.err.nochat = Must specify |nickname| or run the command from a DCC Chat view.
@ -1115,7 +1116,7 @@ msg.si.speed.4 = TiB/s
msg.si.speed.5 = PiB/s
msg.si.speed.6 = EiB/s
msg.ident.server.not.possible = Ident Server is unavailable in this version of the host software platform (e.g. Mozilla, Firefox) - the feature "scriptable server sockets" is missing. Mozilla builds after 2003-11-15 should contain this feature (e.g. Mozilla 1.6 or later).
msg.ident.server.not.possible = Ident Server is unavailable in this version of &brandShortName; - the feature "scriptable server sockets" is missing. Mozilla builds after 2003-11-15 should contain this feature (e.g. Mozilla 1.6 or later).
msg.host.password = Enter a password for the server %S:
msg.url.key = Enter key for url %S:
@ -1235,7 +1236,8 @@ msg.mode.changed = Mode %S by %S"
msg.away.on = You are now marked as away (%S). Click the nickname button or use the |/back| command to return from being away.
msg.away.off = You are no longer marked as away.
msg.away.prompt = Enter an away message to use:
msg.away.default = User is away.
msg.away.default = I'm not here right now.
msg.away.idle.default = I'm not here right now.
msg.you.quit = YOU (%S) have left %S (%S)
msg.someone.quit = "%S has left %S (%S)
@ -1385,6 +1387,10 @@ pref.autoRejoin.label = Rejoin when kicked
pref.autoRejoin.help = If this is turned on, ChatZilla will try (only once) to rejoin a channel you got kicked from. Note, some channels dislike auto-rejoin, and will ban you, so be careful.
pref.away.label = Away status
pref.away.help =
pref.awayIdleTime.label = Auto-away timeout
pref.awayIdleTime.help = After how many minutes of inactivity ChatZilla will set your status to "away". This only works on newer versions of &brandShortName;. Set to 0 to disable it.
pref.awayIdleMsg.label = Auto-away message
pref.awayIdleMsg.help = The away message ChatZilla will use when you go away.
pref.awayNick.label = Nickname (away)
pref.awayNick.help = This nickname will automatically be used when you mark yourself away, if different from 'Nickname'. You may leave this blank to not change nickname when going away.
pref.bugURL.label = Bugzilla URL

View File

@ -119,6 +119,8 @@ function initCommands()
["goto-url-external", cmdGotoURL, 0],
["help", cmdHelp, CMD_CONSOLE],
["hide-view", cmdHideView, CMD_CONSOLE],
["idle-away", cmdAway, 0],
["idle-back", cmdAway, 0],
["ignore", cmdIgnore, CMD_NEED_NET | CMD_CONSOLE],
["input-text-direction", cmdInputTextDirection, 0],
["invite", cmdInvite, CMD_NEED_SRV | CMD_CONSOLE],
@ -2772,15 +2774,25 @@ function cmdAway(e)
{
for (var n in client.networks)
{
if (client.networks[n].primServ &&
(client.networks[n].state == NET_ONLINE))
var net = client.networks[n];
if (net.primServ && (net.state == NET_ONLINE))
{
client.networks[n].dispatch(command, { reason: reason });
// If we can override the network's away state, or they are
// already idly-away, or they're not away to begin with:
if (overrideAway || net.isIdleAway || !net.prefs["away"])
{
net.dispatch(command, {reason: reason });
net.isIdleAway = (e.command.name == "idle-away");
}
}
}
};
if ((e.command.name == "away") || (e.command.name == "custom-away"))
// Idle away shouldn't override away state set by the user.
var overrideAway = (e.command.name.indexOf("idle") != 0);
if ((e.command.name == "away") || (e.command.name == "custom-away") ||
(e.command.name == "idle-away"))
{
/* going away */
if (e.command.name == "custom-away")
@ -2826,6 +2838,7 @@ function cmdAway(e)
display(getMsg(MSG_ERR_AWAY_SAVE, formatException(ex)), MT_ERROR);
}
// Actually do away stuff, is this on a specific network?
if (e.server)
{
var normalNick = e.network.prefs["nickname"];
@ -2844,10 +2857,13 @@ function cmdAway(e)
}
else
{
client.prefs["away"] = e.reason;
// Client view, do command for all networks.
sendToAllNetworks("away", e.reason);
display(getMsg(MSG_AWAY_ON, e.reason));
client.prefs["away"] = e.reason;
if (("frame" in client) && client.frame)
client.display(getMsg(MSG_AWAY_ON, e.reason));
else
display(getMsg(MSG_AWAY_ON, e.reason));
}
}
else
@ -2873,7 +2889,10 @@ function cmdAway(e)
client.prefs["away"] = "";
// Client view, do command for all networks.
sendToAllNetworks("back");
display(MSG_AWAY_OFF);
if (("frame" in client) && client.frame)
client.display(MSG_AWAY_OFF);
else
display(MSG_AWAY_OFF);
}
}
}

View File

@ -143,6 +143,7 @@ function onUnload()
{
dd("Shutting down ChatZilla.");
uninitOfflineIcon();
uninitIdleAutoAway(client.prefs["idleAutoAway"]);
destroy();
}
@ -1081,6 +1082,7 @@ function my_showtonet (e)
this.dispatch(cmdary[i]);
}
this.isIdleAway = client.isIdleAway;
if (this.prefs["away"])
this.dispatch("away", { reason: this.prefs["away"] });

View File

@ -131,6 +131,8 @@ function initPrefs()
["autoRejoin", false, ".connect"],
["away", "", "hidden"],
["awayNick", "", ".ident"],
["awayIdleTime", 0, ".ident"],
["awayIdleMsg", "", ".ident"],
["bugURL", "https://bugzilla.mozilla.org/show_bug.cgi?id=%s",
"appearance.misc"],
["bugURL.comment", "#c%s", "appearance.misc"],
@ -663,6 +665,11 @@ function onPrefChanged(prefName, newValue, oldValue)
{
switch (prefName)
{
case "awayIdleTime":
uninitIdleAutoAway(oldValue);
initIdleAutoAway(newValue);
break;
case "channelMaxLines":
CIRCChannel.prototype.MAX_MESSAGES = newValue;
break;

View File

@ -205,6 +205,8 @@ function init()
client.busy = false;
updateProgress();
initOfflineIcon();
client.isIdleAway = false;
initIdleAutoAway(client.prefs["awayIdleTime"]);
client.initialized = true;
@ -2118,6 +2120,77 @@ function uninitOfflineIcon()
}
}
client.idleObserver = {
QueryInterface: function io_qi(iid)
{
if (!iid || (!iid.equals(Components.interfaces.nsIObserver) &&
!iid.equals(Components.interfaces.nsISupports)))
{
throw Components.results.NS_ERROR_NO_INTERFACE;
}
return this;
},
observe: function io_observe(subject, topic, data)
{
if ((topic == "idle") && !client.prefs["away"])
{
if (!client.prefs["awayIdleMsg"])
client.prefs["awayIdleMsg"] = MSG_AWAY_IDLE_DEFAULT;
client.dispatch("idle-away", {reason: client.prefs["awayIdleMsg"]});
client.isIdleAway = true;
}
else if ((topic == "back") && client.isIdleAway)
{
client.dispatch("idle-back");
client.isIdleAway = false;
}
}
};
function initIdleAutoAway(timeout)
{
// Don't try to do anything if we are disabled
if (!timeout)
return;
var is = getService("@mozilla.org/widget/idleservice;1", "nsIIdleService");
if (!is)
{
display(MSG_ERR_NO_IDLESERVICE, MT_WARN);
client.prefs["autoIdleTime"] = 0;
return;
}
try
{
is.addIdleObserver(client.idleObserver, timeout * 60);
}
catch (ex)
{
display(formatException(ex), MT_ERROR);
}
}
function uninitIdleAutoAway(timeout)
{
// Don't try to do anything if we were disabled before
if (!timeout)
return;
var is = getService("@mozilla.org/widget/idleservice;1", "nsIIdleService");
if (!is)
return;
try
{
is.removeIdleObserver(client.idleObserver, timeout * 60);
}
catch (ex)
{
display(formatException(ex), MT_ERROR);
}
}
function updateAppMotif(motifURL)
{
var node = document.firstChild;