diff options
author | Diogo Sousa <diogogsousa@gmail.com> | 2013-06-22 23:48:17 +0100 |
---|---|---|
committer | Diogo Sousa <diogogsousa@gmail.com> | 2013-06-28 16:04:32 +0100 |
commit | d1725e3f443f0133c113f417b6a594f79c6831e7 (patch) | |
tree | c6f720d97fd809f3a7b40139acff0f31d69d9931 /src/common/proto-irc.c | |
parent | 42da8fe3efb3d6bb7e3fb14169e7cc362e21921a (diff) |
server-time for all numerical messages.
Diffstat (limited to 'src/common/proto-irc.c')
-rw-r--r-- | src/common/proto-irc.c | 199 |
1 files changed, 116 insertions, 83 deletions
diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c index d111bd22..3c9a63e5 100644 --- a/src/common/proto-irc.c +++ b/src/common/proto-irc.c @@ -444,12 +444,14 @@ irc_raw (server *serv, char *raw) static void -channel_date (session *sess, char *chan, char *timestr) +channel_date (session *sess, char *chan, char *timestr, + const message_tags_data *tags_data) { time_t timestamp = (time_t) atol (timestr); char *tim = ctime (×tamp); tim[24] = 0; /* get rid of the \n */ - EMIT_SIGNAL (XP_TE_CHANDATE, sess, chan, tim, NULL, NULL, 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_CHANDATE, sess, chan, tim, NULL, NULL, 0, + tags_data->timestamp); } static void @@ -480,7 +482,7 @@ process_numeric (session * sess, int n, { serv->use_who = FALSE; if (prefs.hex_dcc_ip_from_server) - inbound_foundip (sess, strrchr(word[10], '@')+1); + inbound_foundip (sess, strrchr(word[10], '@')+1, tags_data); } goto def; @@ -502,7 +504,7 @@ process_numeric (session * sess, int n, goto def; case 5: - inbound_005 (serv, word); + inbound_005 (serv, word, tags_data); goto def; case 263: /*Server load is temporarily too heavy */ @@ -530,7 +532,7 @@ process_numeric (session * sess, int n, { char *at = strrchr (eq + 1, '@'); if (at) - inbound_foundip (sess, at + 1); + inbound_foundip (sess, at + 1, tags_data); } } @@ -541,39 +543,42 @@ process_numeric (session * sess, int n, case 303: word[4]++; - notify_markonline (serv, word); + notify_markonline (serv, word, tags_data); break; case 305: - inbound_uback (serv); + inbound_uback (serv, tags_data); goto def; case 306: - inbound_uaway (serv); + inbound_uaway (serv, tags_data); goto def; case 312: if (!serv->skip_next_whois) - EMIT_SIGNAL (XP_TE_WHOIS3, whois_sess, word[4], word_eol[5], NULL, NULL, 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS3, whois_sess, word[4], word_eol[5], + NULL, NULL, 0, tags_data->timestamp); else - inbound_user_info (sess, NULL, NULL, NULL, word[5], word[4], NULL, NULL, 0xff); + inbound_user_info (sess, NULL, NULL, NULL, word[5], word[4], NULL, NULL, + 0xff, tags_data); break; case 311: /* WHOIS 1st line */ serv->inside_whois = 1; - inbound_user_info_start (sess, word[4]); + inbound_user_info_start (sess, word[4], tags_data); if (!serv->skip_next_whois) - EMIT_SIGNAL (XP_TE_WHOIS1, whois_sess, word[4], word[5], - word[6], word_eol[8] + 1, 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS1, whois_sess, word[4], word[5], + word[6], word_eol[8] + 1, 0, tags_data->timestamp); else inbound_user_info (sess, NULL, word[5], word[6], NULL, word[4], - word_eol[8][0] == ':' ? word_eol[8] + 1 : word_eol[8], NULL, 0xff); + word_eol[8][0] == ':' ? word_eol[8] + 1 : word_eol[8], + NULL, 0xff, tags_data); break; case 314: /* WHOWAS */ - inbound_user_info_start (sess, word[4]); - EMIT_SIGNAL (XP_TE_WHOIS1, whois_sess, word[4], word[5], - word[6], word_eol[8] + 1, 0); + inbound_user_info_start (sess, word[4], tags_data); + EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS1, whois_sess, word[4], word[5], + word[6], word_eol[8] + 1, 0, tags_data->timestamp); break; case 317: @@ -588,22 +593,22 @@ process_numeric (session * sess, int n, "%02ld:%02ld:%02ld", idle / 3600, (idle / 60) % 60, idle % 60); if (timestamp == 0) - EMIT_SIGNAL (XP_TE_WHOIS4, whois_sess, word[4], - outbuf, NULL, NULL, 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS4, whois_sess, word[4], + outbuf, NULL, NULL, 0, tags_data->timestamp); else { tim = ctime (×tamp); tim[19] = 0; /* get rid of the \n */ - EMIT_SIGNAL (XP_TE_WHOIS4T, whois_sess, word[4], - outbuf, tim, NULL, 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS4T, whois_sess, word[4], + outbuf, tim, NULL, 0, tags_data->timestamp); } } break; case 318: /* END OF WHOIS */ if (!serv->skip_next_whois) - EMIT_SIGNAL (XP_TE_WHOIS6, whois_sess, word[4], NULL, - NULL, NULL, 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS6, whois_sess, word[4], NULL, + NULL, NULL, 0, tags_data->timestamp); serv->skip_next_whois = 0; serv->inside_whois = 0; break; @@ -611,20 +616,23 @@ process_numeric (session * sess, int n, case 313: case 319: if (!serv->skip_next_whois) - EMIT_SIGNAL (XP_TE_WHOIS2, whois_sess, word[4], - word_eol[5] + 1, NULL, NULL, 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS2, whois_sess, word[4], + word_eol[5] + 1, NULL, NULL, 0, + tags_data->timestamp); break; case 307: /* dalnet version */ case 320: /* :is an identified user */ if (!serv->skip_next_whois) - EMIT_SIGNAL (XP_TE_WHOIS_ID, whois_sess, word[4], - word_eol[5] + 1, NULL, NULL, 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS_ID, whois_sess, word[4], + word_eol[5] + 1, NULL, NULL, 0, + tags_data->timestamp); break; case 321: if (!fe_is_chanwindow (sess->server)) - EMIT_SIGNAL (XP_TE_CHANLISTHEAD, serv->server_session, NULL, NULL, NULL, NULL, 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_CHANLISTHEAD, serv->server_session, NULL, + NULL, NULL, NULL, 0, tags_data->timestamp); break; case 322: @@ -633,14 +641,16 @@ process_numeric (session * sess, int n, fe_add_chan_list (sess->server, word[4], word[5], word_eol[6] + 1); } else { - PrintTextf (serv->server_session, "%-16s %-7d %s\017\n", - word[4], atoi (word[5]), word_eol[6] + 1); + PrintTextTimeStampf (serv->server_session, tags_data->timestamp, + "%-16s %-7d %s\017\n", word[4], atoi (word[5]), + word_eol[6] + 1); } break; case 323: if (!fe_is_chanwindow (sess->server)) - EMIT_SIGNAL (XP_TE_SERVTEXT, serv->server_session, text, word[1], word[2], NULL, 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVTEXT, serv->server_session, text, + word[1], word[2], NULL, 0, tags_data->timestamp); else fe_chan_list_end (sess->server); break; @@ -652,8 +662,8 @@ process_numeric (session * sess, int n, if (sess->ignore_mode) sess->ignore_mode = FALSE; else - EMIT_SIGNAL (XP_TE_CHANMODES, sess, word[4], word_eol[5], - NULL, NULL, 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_CHANMODES, sess, word[4], word_eol[5], + NULL, NULL, 0, tags_data->timestamp); fe_update_mode_buttons (sess, 't', '-'); fe_update_mode_buttons (sess, 'n', '-'); fe_update_mode_buttons (sess, 's', '-'); @@ -672,36 +682,40 @@ process_numeric (session * sess, int n, if (sess->ignore_date) sess->ignore_date = FALSE; else - channel_date (sess, word[4], word[5]); + channel_date (sess, word[4], word[5], tags_data); } break; case 330: if (!serv->skip_next_whois) - EMIT_SIGNAL (XP_TE_WHOIS_AUTH, whois_sess, word[4], - word_eol[6] + 1, word[5], NULL, 0); - inbound_user_info (sess, NULL, NULL, NULL, NULL, word[4], NULL, word[5], 0xff); + EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS_AUTH, whois_sess, word[4], + word_eol[6] + 1, word[5], NULL, 0, + tags_data->timestamp); + inbound_user_info (sess, NULL, NULL, NULL, NULL, word[4], NULL, word[5], + 0xff, tags_data); break; case 332: inbound_topic (serv, word[4], - (word_eol[5][0] == ':') ? word_eol[5] + 1 : word_eol[5]); + (word_eol[5][0] == ':') ? word_eol[5] + 1 : word_eol[5], + tags_data); break; case 333: - inbound_topictime (serv, word[4], word[5], atol (word[6])); + inbound_topictime (serv, word[4], word[5], atol (word[6]), tags_data); break; #if 0 case 338: /* Undernet Real user@host, Real IP */ - EMIT_SIGNAL (XP_TE_WHOIS_REALHOST, sess, word[4], word[5], word[6], - (word_eol[7][0]==':') ? word_eol[7]+1 : word_eol[7], 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS_REALHOST, sess, word[4], word[5], word[6], + (word_eol[7][0]==':') ? word_eol[7]+1 : word_eol[7], + 0, tags_data->timestamp); break; #endif case 341: /* INVITE ACK */ - EMIT_SIGNAL (XP_TE_UINVITE, sess, word[4], word[5], serv->servername, - NULL, 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_UINVITE, sess, word[4], word[5], + serv->servername, NULL, 0, tags_data->timestamp); break; case 352: /* WHO */ @@ -713,12 +727,13 @@ process_numeric (session * sess, int n, away = 1; inbound_user_info (sess, word[4], word[5], word[6], word[7], - word[8], word_eol[11], NULL, away); + word[8], word_eol[11], NULL, away, + tags_data); /* try to show only user initiated whos */ if (!who_sess || !who_sess->doing_who) - EMIT_SIGNAL (XP_TE_SERVTEXT, serv->server_session, text, word[1], - word[2], NULL, 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVTEXT, serv->server_session, text, word[1], + word[2], NULL, 0, tags_data->timestamp); } break; @@ -737,12 +752,14 @@ process_numeric (session * sess, int n, /* :server 354 yournick 152 #channel ~ident host servname nick H account :realname */ inbound_user_info (sess, word[5], word[6], word[7], word[8], - word[9], word_eol[12]+1, word[11], away); + word[9], word_eol[12]+1, word[11], away, + tags_data); /* try to show only user initiated whos */ if (!who_sess || !who_sess->doing_who) - EMIT_SIGNAL (XP_TE_SERVTEXT, serv->server_session, text, - word[1], word[2], NULL, 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVTEXT, serv->server_session, text, + word[1], word[2], NULL, 0, + tags_data->timestamp); } else goto def; } @@ -755,21 +772,23 @@ process_numeric (session * sess, int n, if (who_sess) { if (!who_sess->doing_who) - EMIT_SIGNAL (XP_TE_SERVTEXT, serv->server_session, text, - word[1], word[2], NULL, 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVTEXT, serv->server_session, text, + word[1], word[2], NULL, 0, + tags_data->timestamp); who_sess->doing_who = FALSE; } else { if (!serv->doing_dns) - EMIT_SIGNAL (XP_TE_SERVTEXT, serv->server_session, text, - word[1], word[2], NULL, 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVTEXT, serv->server_session, text, + word[1], word[2], NULL, 0, tags_data->timestamp); serv->doing_dns = FALSE; } } break; case 346: /* +I-list entry */ - if (!inbound_banlist (sess, atol (word[7]), word[4], word[5], word[6], 346)) + if (!inbound_banlist (sess, atol (word[7]), word[4], word[5], word[6], 346, + tags_data)) goto def; break; @@ -779,7 +798,8 @@ process_numeric (session * sess, int n, break; case 348: /* +e-list entry */ - if (!inbound_banlist (sess, atol (word[7]), word[4], word[5], word[6], 348)) + if (!inbound_banlist (sess, atol (word[7]), word[4], word[5], word[6], 348, + tags_data)) goto def; break; @@ -796,16 +816,18 @@ process_numeric (session * sess, int n, case 353: /* NAMES */ inbound_nameslist (serv, word[5], - (word_eol[6][0] == ':') ? word_eol[6] + 1 : word_eol[6]); + (word_eol[6][0] == ':') ? word_eol[6] + 1 : word_eol[6], + tags_data); break; case 366: - if (!inbound_nameslist_end (serv, word[4])) + if (!inbound_nameslist_end (serv, word[4], tags_data)) goto def; break; case 367: /* banlist entry */ - if (!inbound_banlist (sess, atol (word[7]), word[4], word[5], word[6], 367)) + if (!inbound_banlist (sess, atol (word[7]), word[4], word[5], word[6], 367, + tags_data)) goto def; break; @@ -822,20 +844,21 @@ process_numeric (session * sess, int n, case 369: /* WHOWAS end */ case 406: /* WHOWAS error */ - EMIT_SIGNAL (XP_TE_SERVTEXT, whois_sess, text, word[1], word[2], NULL, 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVTEXT, whois_sess, text, word[1], word[2], + NULL, 0, tags_data->timestamp); serv->inside_whois = 0; break; case 372: /* motd text */ case 375: /* motd start */ if (!prefs.hex_irc_skip_motd || serv->motd_skipped) - EMIT_SIGNAL (XP_TE_MOTD, serv->server_session, text, NULL, NULL, - NULL, 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_MOTD, serv->server_session, text, NULL, + NULL, NULL, 0, tags_data->timestamp); break; case 376: /* end of motd */ case 422: /* motd file is missing */ - inbound_login_end (sess, text); + inbound_login_end (sess, text, tags_data); break; case 432: /* erroneous nickname */ @@ -843,7 +866,7 @@ process_numeric (session * sess, int n, { goto def; } - inbound_next_nick (sess, word[4], 1); + inbound_next_nick (sess, word[4], 1, tags_data); break; case 433: /* nickname in use */ @@ -851,48 +874,53 @@ process_numeric (session * sess, int n, { goto def; } - inbound_next_nick (sess, word[4], 0); + inbound_next_nick (sess, word[4], 0, tags_data); break; case 437: if (serv->end_of_motd || is_channel (serv, word[4])) goto def; - inbound_next_nick (sess, word[4], 0); + inbound_next_nick (sess, word[4], 0, tags_data); break; case 471: - EMIT_SIGNAL (XP_TE_USERLIMIT, sess, word[4], NULL, NULL, NULL, 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_USERLIMIT, sess, word[4], NULL, NULL, NULL, 0, + tags_data->timestamp); break; case 473: - EMIT_SIGNAL (XP_TE_INVITE, sess, word[4], NULL, NULL, NULL, 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_INVITE, sess, word[4], NULL, NULL, NULL, 0, + tags_data->timestamp); break; case 474: - EMIT_SIGNAL (XP_TE_BANNED, sess, word[4], NULL, NULL, NULL, 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_BANNED, sess, word[4], NULL, NULL, NULL, 0, + tags_data->timestamp); break; case 475: - EMIT_SIGNAL (XP_TE_KEYWORD, sess, word[4], NULL, NULL, NULL, 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_KEYWORD, sess, word[4], NULL, NULL, NULL, 0, + tags_data->timestamp); break; case 601: - notify_set_offline (serv, word[4], FALSE); + notify_set_offline (serv, word[4], FALSE, tags_data); break; case 605: - notify_set_offline (serv, word[4], TRUE); + notify_set_offline (serv, word[4], TRUE, tags_data); break; case 600: case 604: - notify_set_online (serv, word[4]); + notify_set_online (serv, word[4], tags_data); break; case 728: /* +q-list entry */ /* NOTE: FREENODE returns these results inconsistent with e.g. +b */ /* Who else has imlemented MODE_QUIET, I wonder? */ - if (!inbound_banlist (sess, atol (word[8]), word[4], word[6], word[7], 728)) + if (!inbound_banlist (sess, atol (word[8]), word[4], word[6], word[7], 728, + tags_data)) goto def; break; @@ -905,25 +933,29 @@ process_numeric (session * sess, int n, ex = strchr (word[4], '!'); /* only send the nick */ if (ex) ex[0] = 0; - notify_set_online (serv, word[4] + 1); + notify_set_online (serv, word[4] + 1, tags_data); break; case 731: /* RPL_MONOFFLINE */ ex = strchr (word[4], '!'); /* only send the nick */ if (ex) ex[0] = 0; - notify_set_offline (serv, word[4] + 1, FALSE); + notify_set_offline (serv, word[4] + 1, FALSE, tags_data); break; case 900: /* successful SASL 'logged in as ' */ - EMIT_SIGNAL (XP_TE_SERVTEXT, serv->server_session, word_eol[6]+1, word[1], word[2], NULL, 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVTEXT, serv->server_session, + word_eol[6]+1, word[1], word[2], NULL, 0, + tags_data->timestamp); break; case 903: /* successful SASL auth */ case 904: /* aborted SASL auth */ case 905: /* failed SASL auth */ case 906: /* registration completes before SASL auth */ case 907: /* attempting to re-auth after a successful auth */ - EMIT_SIGNAL (XP_TE_SASLRESPONSE, serv->server_session, word[1], word[2], word[3], ++word_eol[4], 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_SASLRESPONSE, serv->server_session, word[1], + word[2], word[3], ++word_eol[4], 0, + tags_data->timestamp); tcp_send_len (serv, "CAP END\r\n", 9); break; @@ -933,9 +965,9 @@ process_numeric (session * sess, int n, { /* some unknown WHOIS reply, ircd coders make them up weekly */ if (!serv->skip_next_whois) - EMIT_SIGNAL (XP_TE_WHOIS_SPECIAL, whois_sess, word[4], - (word_eol[5][0] == ':') ? word_eol[5] + 1 : word_eol[5], - word[2], NULL, 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS_SPECIAL, whois_sess, word[4], + (word_eol[5][0] == ':') ? word_eol[5] + 1 : word_eol[5], + word[2], NULL, 0, tags_data->timestamp); return; } @@ -954,7 +986,8 @@ process_numeric (session * sess, int n, else sess=serv->server_session; - EMIT_SIGNAL (XP_TE_SERVTEXT, sess, text, word[1], word[2], NULL, 0); + EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVTEXT, sess, text, word[1], word[2], + NULL, 0, tags_data->timestamp); } } } @@ -1351,7 +1384,7 @@ handle_message_tag_time (const char *time, message_tags_data *tags_data) * * See http://ircv3.atheme.org/specification/message-tags-3.2 */ -/* TODO: we should ignore capabilities not enabled! */ +/* TODO:orium: we should ignore capabilities not enabled! */ static void handle_message_tags (const char *tags_str, message_tags_data *tags_data) { @@ -1462,7 +1495,7 @@ irc_inline (server *serv, char *buf, int len) if (*text == ':') text++; - process_numeric (sess, atoi (word[2]), word, word_eol, text, &tags_data); // TODO (data tags) + process_numeric (sess, atoi (word[2]), word, word_eol, text, &tags_data); // TODO:orium (data tags) } else { process_named_msg (sess, type, word, word_eol, &tags_data); |