Bug 987577 - Use the idle status to display whois idleTime when appropriate. r=clokep
This commit is contained in:
Родитель
8bff30208c
Коммит
2b97a42aa1
|
@ -186,7 +186,9 @@ tooltip.secure=Using a secure connection
|
|||
tooltip.away=Away
|
||||
tooltip.ircOp=IRC Operator
|
||||
tooltip.bot=Bot
|
||||
tooltip.idleTime=Idle for
|
||||
tooltip.lastActivity=Last activity
|
||||
# %S is the timespan elapsed since the last activity.
|
||||
tooltip.timespan=%S ago
|
||||
tooltip.channels=Currently on
|
||||
|
||||
# %1$S is the server name, %2$S is some generic server information (usually a
|
||||
|
|
|
@ -14,6 +14,9 @@ Cu.import("resource:///modules/socket.jsm");
|
|||
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
|
||||
"resource://gre/modules/PluralForm.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "DownloadUtils",
|
||||
"resource://gre/modules/DownloadUtils.jsm");
|
||||
|
||||
/*
|
||||
* Parses a raw IRC message into an object (see section 2.3 of RFC 2812). This
|
||||
* returns an object with the following fields:
|
||||
|
@ -1031,6 +1034,16 @@ ircAccount.prototype = {
|
|||
// Convert booleans into a human-readable form.
|
||||
let normalizeBool = function(aBool) _(aBool ? "yes" : "no");
|
||||
|
||||
// Convert timespan in seconds into a human-readable form.
|
||||
let normalizeTime = function(aTime) {
|
||||
let valuesAndUnits = DownloadUtils.convertTimeUnits(aTime);
|
||||
// If the time is exact to the first set of units, trim off
|
||||
// the subsequent zeroes.
|
||||
if (!valuesAndUnits[2])
|
||||
valuesAndUnits.splice(2, 2);
|
||||
return _("tooltip.timespan", valuesAndUnits.join(" "));
|
||||
};
|
||||
|
||||
// List of the names of the info to actually show in the tooltip and
|
||||
// optionally a transform function to apply to the value. Each field here
|
||||
// maps to tooltip.<fieldname> in irc.properties.
|
||||
|
@ -1044,7 +1057,7 @@ ircAccount.prototype = {
|
|||
secure: normalizeBool,
|
||||
ircOp: normalizeBool,
|
||||
bot: normalizeBool,
|
||||
idleTime: null,
|
||||
lastActivity: normalizeTime,
|
||||
channels: sortChannels
|
||||
};
|
||||
|
||||
|
@ -1058,6 +1071,7 @@ ircAccount.prototype = {
|
|||
}
|
||||
}
|
||||
|
||||
const kSetIdleStatusAfterSeconds = 3600;
|
||||
let statusType = Ci.imIStatusInfo.STATUS_AVAILABLE;
|
||||
let statusText = "";
|
||||
if ("away" in whoisInformation) {
|
||||
|
@ -1066,6 +1080,9 @@ ircAccount.prototype = {
|
|||
}
|
||||
else if ("offline" in whoisInformation)
|
||||
statusType = Ci.imIStatusInfo.STATUS_OFFLINE;
|
||||
else if ("lastActivity" in whoisInformation &&
|
||||
whoisInformation["lastActivity"] > kSetIdleStatusAfterSeconds)
|
||||
statusType = Ci.imIStatusInfo.STATUS_IDLE;
|
||||
tooltipInfo.push(new TooltipInfo(statusType, statusText, true));
|
||||
|
||||
return new nsSimpleEnumerator(tooltipInfo);
|
||||
|
|
|
@ -27,9 +27,6 @@ Cu.import("resource:///modules/ircHandlers.jsm");
|
|||
Cu.import("resource:///modules/ircUtils.jsm");
|
||||
Cu.import("resource:///modules/jsProtoHelper.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "DownloadUtils",
|
||||
"resource://gre/modules/DownloadUtils.jsm");
|
||||
|
||||
function ircRoomInfo(aName, aTopic, aParticipantCount, aAccount) {
|
||||
this.name = aName;
|
||||
this.topic = aTopic;
|
||||
|
@ -737,12 +734,8 @@ var ircBase = {
|
|||
},
|
||||
"317": function(aMessage) { // RPL_WHOISIDLE
|
||||
// <nick> <integer> :seconds idle
|
||||
let valuesAndUnits =
|
||||
DownloadUtils.convertTimeUnits(parseInt(aMessage.params[2]));
|
||||
if (!valuesAndUnits[2])
|
||||
valuesAndUnits.splice(2, 2);
|
||||
return this.setWhois(aMessage.params[1],
|
||||
{idleTime: valuesAndUnits.join(" ")});
|
||||
{lastActivity: parseInt(aMessage.params[2])});
|
||||
},
|
||||
"318": function(aMessage) { // RPL_ENDOFWHOIS
|
||||
// <nick> :End of WHOIS list
|
||||
|
|
Загрузка…
Ссылка в новой задаче