diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2006-08-17 13:23:31 +0000 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2006-08-17 13:23:31 +0000 |
commit | 487d776b87cdefa42430dce650bac4be215af5a6 (patch) | |
tree | 2d6856f657acb96879f6fe6a6913a43e430dc4ca /src | |
parent | 9f88f68e3b350256fe964ba73175400e0e8572e3 (diff) | |
download | weechat-487d776b87cdefa42430dce650bac4be215af5a6.zip |
Added IRC command 329 (channel creation date)
Diffstat (limited to 'src')
-rw-r--r-- | src/common/session.c | 4 | ||||
-rw-r--r-- | src/common/session.h | 3 | ||||
-rw-r--r-- | src/irc/irc-channel.c | 32 | ||||
-rw-r--r-- | src/irc/irc-commands.c | 2 | ||||
-rw-r--r-- | src/irc/irc-recv.c | 70 | ||||
-rw-r--r-- | src/irc/irc.h | 2 |
6 files changed, 97 insertions, 16 deletions
diff --git a/src/common/session.c b/src/common/session.c index 788d1bda8..59156dfa4 100644 --- a/src/common/session.c +++ b/src/common/session.c @@ -176,6 +176,7 @@ session_save_channel (FILE *file, t_irc_channel *channel) rc = rc && (session_write_str (file, SESSION_CHAN_AWAY_MESSAGE, channel->away_message)); rc = rc && (session_write_int (file, SESSION_CHAN_CYCLE, channel->cycle)); rc = rc && (session_write_int (file, SESSION_CHAN_CLOSE, channel->close)); + rc = rc && (session_write_int (file, SESSION_CHAN_DISPLAY_CREATION_DATE, channel->display_creation_date)); rc = rc && (session_write_id (file, SESSION_CHAN_END)); if (!rc) @@ -1072,6 +1073,9 @@ session_load_channel (FILE *file) case SESSION_CHAN_CLOSE: rc = rc && (session_read_int (file, &(session_current_channel->close))); break; + case SESSION_CHAN_DISPLAY_CREATION_DATE: + rc = rc && (session_read_int (file, &(session_current_channel->display_creation_date))); + break; default: weechat_log_printf (_("session: warning: ignoring value from " "channel (object id: %d)\n")); diff --git a/src/common/session.h b/src/common/session.h index 604c98405..62129ca25 100644 --- a/src/common/session.h +++ b/src/common/session.h @@ -107,7 +107,8 @@ enum t_session_channel SESSION_CHAN_CHECKING_AWAY, SESSION_CHAN_AWAY_MESSAGE, SESSION_CHAN_CYCLE, - SESSION_CHAN_CLOSE + SESSION_CHAN_CLOSE, + SESSION_CHAN_DISPLAY_CREATION_DATE }; enum t_session_nick diff --git a/src/irc/irc-channel.c b/src/irc/irc-channel.c index 0def12c92..63f0849eb 100644 --- a/src/irc/irc-channel.c +++ b/src/irc/irc-channel.c @@ -69,6 +69,7 @@ channel_new (t_irc_server *server, int channel_type, char *channel_name) new_channel->away_message = NULL; new_channel->cycle = 0; new_channel->close = 0; + new_channel->display_creation_date = 0; new_channel->nicks = NULL; new_channel->last_nick = NULL; @@ -547,19 +548,20 @@ void channel_print_log (t_irc_channel *channel) { weechat_log_printf ("=> channel %s (addr:0x%X)]\n", channel->name, channel); - weechat_log_printf (" type . . . . : %d\n", channel->type); - weechat_log_printf (" dcc_chat . . : 0x%X\n", channel->dcc_chat); - weechat_log_printf (" topic. . . . : '%s'\n", channel->topic); - weechat_log_printf (" modes. . . . : '%s'\n", channel->modes); - weechat_log_printf (" limit. . . . : %d\n", channel->limit); - weechat_log_printf (" key. . . . . : '%s'\n", channel->key); - weechat_log_printf (" checking_away: %d\n", channel->checking_away); - weechat_log_printf (" away_message : '%s'\n", channel->away_message); - weechat_log_printf (" cycle. . . . : %d\n", channel->cycle); - weechat_log_printf (" close. . . . : %d\n", channel->close); - weechat_log_printf (" nicks. . . . : 0x%X\n", channel->nicks); - weechat_log_printf (" last_nick. . : 0x%X\n", channel->last_nick); - weechat_log_printf (" buffer . . . : 0x%X\n", channel->buffer); - weechat_log_printf (" prev_channel : 0x%X\n", channel->prev_channel); - weechat_log_printf (" next_channel : 0x%X\n", channel->next_channel); + weechat_log_printf (" type . . . . . . . . : %d\n", channel->type); + weechat_log_printf (" dcc_chat . . . . . . : 0x%X\n", channel->dcc_chat); + weechat_log_printf (" topic. . . . . . . . : '%s'\n", channel->topic); + weechat_log_printf (" modes. . . . . . . . : '%s'\n", channel->modes); + weechat_log_printf (" limit. . . . . . . . : %d\n", channel->limit); + weechat_log_printf (" key. . . . . . . . . : '%s'\n", channel->key); + weechat_log_printf (" checking_away. . . . : %d\n", channel->checking_away); + weechat_log_printf (" away_message . . . . : '%s'\n", channel->away_message); + weechat_log_printf (" cycle. . . . . . . . : %d\n", channel->cycle); + weechat_log_printf (" close. . . . . . . . : %d\n", channel->close); + weechat_log_printf (" display_creation_date: %d\n", channel->close); + weechat_log_printf (" nicks. . . . . . . . : 0x%X\n", channel->nicks); + weechat_log_printf (" last_nick. . . . . . : 0x%X\n", channel->last_nick); + weechat_log_printf (" buffer . . . . . . . : 0x%X\n", channel->buffer); + weechat_log_printf (" prev_channel . . . . : 0x%X\n", channel->prev_channel); + weechat_log_printf (" next_channel . . . . : 0x%X\n", channel->next_channel); } diff --git a/src/irc/irc-commands.c b/src/irc/irc-commands.c index d2b97ff1c..dd6befc40 100644 --- a/src/irc/irc-commands.c +++ b/src/irc/irc-commands.c @@ -351,6 +351,8 @@ t_irc_command irc_commands[] = NULL, 0, 0, 0, 1, NULL, NULL, irc_cmd_recv_324 }, { "326", N_("whois (has oper privs)"), "", "", NULL, 0, 0, 0, 1, NULL, NULL, irc_cmd_recv_whois_nick_msg }, + { "329", N_("channel creation date"), "", "", + NULL, 0, 0, 0, 1, NULL, NULL, irc_cmd_recv_329 }, { "331", N_("no topic for channel"), "", "", NULL, 0, 0, 0, 1, NULL, NULL, irc_cmd_recv_331 }, { "332", N_("topic of channel"), diff --git a/src/irc/irc-recv.c b/src/irc/irc-recv.c index cb6744007..7027eaca2 100644 --- a/src/irc/irc-recv.c +++ b/src/irc/irc-recv.c @@ -474,6 +474,7 @@ irc_cmd_recv_join (t_irc_server *server, char *host, char *nick, char *arguments GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), arguments); } + ptr_channel->display_creation_date = 1; ptr_nick = nick_new (server, ptr_channel, nick, 0, 0, 0, 0, 0); if (ptr_nick) ptr_nick->host = strdup ((pos) ? pos + 1 : host); @@ -3362,6 +3363,75 @@ irc_cmd_recv_324 (t_irc_server *server, char *host, char *nick, char *arguments) } /* + * irc_cmd_recv_329: '329' command received (channel creation date) + */ + +int +irc_cmd_recv_329 (t_irc_server *server, char *host, char *nick, char *arguments) +{ + char *pos_channel, *pos_date; + t_irc_channel *ptr_channel; + time_t datetime; + + /* make gcc happy */ + (void) host; + (void) nick; + + pos_channel = strchr (arguments, ' '); + if (pos_channel) + { + while (pos_channel[0] == ' ') + pos_channel++; + pos_date = strchr (pos_channel, ' '); + if (pos_date) + { + pos_date[0] = '\0'; + pos_date++; + while (pos_date[0] == ' ') + pos_date++; + + ptr_channel = channel_search (server, pos_channel); + if (!ptr_channel) + { + irc_display_prefix (server, server->buffer, PREFIX_ERROR); + gui_printf_nolog (server->buffer, + _("%s channel \"%s\" not found for \"%s\" command\n"), + WEECHAT_ERROR, pos_channel, "329"); + return -1; + } + + command_ignored |= ignore_check (host, "329", + pos_channel, server->name); + if (!command_ignored && (ptr_channel->display_creation_date)) + { + datetime = (time_t)(atol (pos_date)); + irc_display_prefix (server, ptr_channel->buffer, PREFIX_INFO); + gui_printf (ptr_channel->buffer, _("Channel created on %s"), + ctime (&datetime)); + } + ptr_channel->display_creation_date = 0; + } + else + { + irc_display_prefix (server, server->buffer, PREFIX_ERROR); + gui_printf_nolog (server->buffer, + _("%s cannot identify date/time for \"%s\" command\n"), + WEECHAT_ERROR, "329"); + return -1; + } + } + else + { + irc_display_prefix (server, server->buffer, PREFIX_ERROR); + gui_printf_nolog (server->buffer, + _("%s cannot identify channel for \"%s\" command\n"), + WEECHAT_ERROR, "329"); + return -1; + } + return 0; +} + +/* * irc_cmd_recv_331: '331' command received (no topic for channel) */ diff --git a/src/irc/irc.h b/src/irc/irc.h index 1c356b410..e7dfa863a 100644 --- a/src/irc/irc.h +++ b/src/irc/irc.h @@ -101,6 +101,7 @@ struct t_irc_channel char *away_message; /* to display away only once in private */ int cycle; /* currently cycling (/part then /join) */ int close; /* close request (/buffer close) */ + int display_creation_date; /* 1 if creation date should be displayed */ t_irc_nick *nicks; /* nicks on the channel */ t_irc_nick *last_nick; /* last nick on the channel */ t_gui_buffer *buffer; /* GUI buffer allocated for channel */ @@ -543,6 +544,7 @@ extern int irc_cmd_recv_321 (t_irc_server *, char *, char *, char *); extern int irc_cmd_recv_322 (t_irc_server *, char *, char *, char *); extern int irc_cmd_recv_323 (t_irc_server *, char *, char *, char *); extern int irc_cmd_recv_324 (t_irc_server *, char *, char *, char *); +extern int irc_cmd_recv_329 (t_irc_server *, char *, char *, char *); extern int irc_cmd_recv_331 (t_irc_server *, char *, char *, char *); extern int irc_cmd_recv_332 (t_irc_server *, char *, char *, char *); extern int irc_cmd_recv_333 (t_irc_server *, char *, char *, char *); |