summaryrefslogtreecommitdiff
path: root/src/fe-common
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2000-07-18 23:35:04 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2000-07-18 23:35:04 +0000
commitd7e017a819e731a469214f2916172e131bf2d9c2 (patch)
treef0c985449296af29a0d82121554e566c0e019021 /src/fe-common
parent8828b8cedd16a6d3bb405efef08895ef2c09048d (diff)
downloadirssi-d7e017a819e731a469214f2916172e131bf2d9c2.zip
When using status window and query windows, /whois to some queried nick
displyed all replies in query window except idle line in status window. Also added "x days" to idle line. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@490 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-common')
-rw-r--r--src/fe-common/irc/fe-events-numeric.c61
-rw-r--r--src/fe-common/irc/module-formats.c4
2 files changed, 35 insertions, 30 deletions
diff --git a/src/fe-common/irc/fe-events-numeric.c b/src/fe-common/irc/fe-events-numeric.c
index caceb4c5..fdfc55ee 100644
--- a/src/fe-common/irc/fe-events-numeric.c
+++ b/src/fe-common/irc/fe-events-numeric.c
@@ -369,37 +369,42 @@ static void event_whois(const char *data, IRC_SERVER_REC *server)
g_free(params);
}
-static void event_whois_idle(gchar *data, IRC_SERVER_REC *server)
+static void event_whois_idle(const char *data, IRC_SERVER_REC *server)
{
- gchar *params, *nick, *secstr, *signon, *rest;
- glong secs, lsignon;
- gint h, m, s;
+ char *params, *nick, *secstr, *signonstr, *rest;
+ long days, hours, mins, secs;
+ time_t signon;
- g_return_if_fail(data != NULL);
-
- params = event_get_params(data, 5 | PARAM_FLAG_GETREST, NULL, &nick, &secstr, &signon, &rest);
- if (sscanf(secstr, "%ld", &secs) == 0) secs = 0;
- lsignon = 0;
- if (strstr(rest, ", signon time") != NULL)
- sscanf(signon, "%ld", &lsignon);
+ g_return_if_fail(data != NULL);
- h = secs/3600; m = (secs%3600)/60; s = secs%60;
- if (lsignon == 0)
- printformat(server, NULL, MSGLEVEL_CRAP, IRCTXT_WHOIS_IDLE, nick, h, m, s);
- else
- {
- gchar *timestr;
- struct tm *tim;
- time_t t;
-
- t = (time_t) lsignon;
- tim = localtime(&t);
- timestr = g_strdup(asctime(tim));
- if (timestr[strlen(timestr)-1] == '\n') timestr[strlen(timestr)-1] = '\0';
- printformat(server, nick, MSGLEVEL_CRAP, IRCTXT_WHOIS_IDLE_SIGNON, nick, h, m, s, timestr);
- g_free(timestr);
- }
- g_free(params);
+ params = event_get_params(data, 5 | PARAM_FLAG_GETREST, NULL,
+ &nick, &secstr, &signonstr, &rest);
+
+ secs = atol(secstr);
+ signon = strstr(rest, "signon time") == NULL ? 0 :
+ (time_t) atol(signonstr);
+
+ days = secs/3600/24;
+ hours = (secs%(3600*24))/3600;
+ mins = (secs%3600)/60;
+ secs %= 60;
+
+ if (signonstr == 0)
+ printformat(server, nick, MSGLEVEL_CRAP, IRCTXT_WHOIS_IDLE,
+ nick, days, hours, mins, secs);
+ else {
+ char *timestr;
+ struct tm *tim;
+
+ tim = localtime(&signon);
+ timestr = g_strdup(asctime(tim));
+ if (timestr[strlen(timestr)-1] == '\n')
+ timestr[strlen(timestr)-1] = '\0';
+ printformat(server, nick, MSGLEVEL_CRAP, IRCTXT_WHOIS_IDLE_SIGNON,
+ nick, days, hours, mins, secs, timestr);
+ g_free(timestr);
+ }
+ g_free(params);
}
static void event_whois_server(const char *data, IRC_SERVER_REC *server)
diff --git a/src/fe-common/irc/module-formats.c b/src/fe-common/irc/module-formats.c
index 283d95cf..2d9164e4 100644
--- a/src/fe-common/irc/module-formats.c
+++ b/src/fe-common/irc/module-formats.c
@@ -125,8 +125,8 @@ FORMAT_REC fecommon_irc_formats[] = {
{ "whois", "%_$0%_ %K[%n$1@$2%K]%n%: ircname : $3", 4, { 0, 0, 0, 0 } },
{ "whowas", "%_$0%_ %K[%n$1@$2%K]%n%: ircname : $3", 4, { 0, 0, 0, 0 } },
- { "whois_idle", " idle : $1 hours $2 mins $3 secs", 4, { 0, 1, 1, 1 } },
- { "whois_idle_signon", " idle : $1 hours $2 mins $3 secs %K[%nsignon: $4%K]", 5, { 0, 1, 1, 1, 0 } },
+ { "whois_idle", " idle : $1 days $2 hours $3 mins $4 secs", 5, { 0, 1, 1, 1, 1 } },
+ { "whois_idle_signon", " idle : $1 days $2 hours $3 mins $4 secs %K[%nsignon: $5%K]", 6, { 0, 1, 1, 1, 1, 0 } },
{ "whois_server", " server : $1 %K[%n$2%K]", 3, { 0, 0, 0 } },
{ "whois_oper", " : %_IRC operator%_", 1, { 0 } },
{ "whois_channels", " channels : $1", 2, { 0, 0 } },