From 051788f7317487a6ca752f143d8a7270f693acd5 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Mon, 20 Sep 2010 22:49:11 +0200 Subject: [PATCH] Send channel topic to relay client when joining a channel --- doc/de/autogen/plugin_api/infolists.txt | 2 +- doc/en/autogen/plugin_api/infolists.txt | 2 +- doc/fr/autogen/plugin_api/infolists.txt | 2 +- doc/it/autogen/plugin_api/infolists.txt | 2 +- po/cs.po | 6 ++- po/de.po | 6 ++- po/es.po | 6 ++- po/fr.po | 7 ++- po/hu.po | 6 ++- po/it.po | 6 ++- po/pl.po | 6 ++- po/ru.po | 6 ++- po/weechat.pot | 5 +- src/plugins/irc/irc-info.c | 64 +++++++++++++++++-------- src/plugins/relay/relay-client-irc.c | 25 ++++++++-- 15 files changed, 115 insertions(+), 36 deletions(-) diff --git a/doc/de/autogen/plugin_api/infolists.txt b/doc/de/autogen/plugin_api/infolists.txt index f62366599..a767fc686 100644 --- a/doc/de/autogen/plugin_api/infolists.txt +++ b/doc/de/autogen/plugin_api/infolists.txt @@ -4,7 +4,7 @@ | alias | alias | Liste der Alias | Alias Pointer (optional) | Alias Name (darf mit einem "*" als Platzhalter beginnen oder enden) (optional) -| irc | irc_channel | Liste der Channels eines IRC-Servers | Channel Pointer (optional) | Servername +| irc | irc_channel | Liste der Channels eines IRC-Servers | Channel Pointer (optional) | server,channel (channel is optional) | irc | irc_ignore | Liste von ignorierten IRCs | Ignore Pointer (optional) | - diff --git a/doc/en/autogen/plugin_api/infolists.txt b/doc/en/autogen/plugin_api/infolists.txt index 9eee2fec8..ddbd46de1 100644 --- a/doc/en/autogen/plugin_api/infolists.txt +++ b/doc/en/autogen/plugin_api/infolists.txt @@ -4,7 +4,7 @@ | alias | alias | list of aliases | alias pointer (optional) | alias name (can start or end with "*" as wildcard) (optional) -| irc | irc_channel | list of channels for an IRC server | channel pointer (optional) | server name +| irc | irc_channel | list of channels for an IRC server | channel pointer (optional) | server,channel (channel is optional) | irc | irc_ignore | list of IRC ignores | ignore pointer (optional) | - diff --git a/doc/fr/autogen/plugin_api/infolists.txt b/doc/fr/autogen/plugin_api/infolists.txt index 616d0e2ff..a203d3311 100644 --- a/doc/fr/autogen/plugin_api/infolists.txt +++ b/doc/fr/autogen/plugin_api/infolists.txt @@ -4,7 +4,7 @@ | alias | alias | liste des alias | pointeur vers l'alias (optionnel) | nom d'alias (peut démarrer ou se terminer par "*" comme joker) (optionnel) -| irc | irc_channel | liste des canaux pour un serveur IRC | pointeur vers le canal (optionnel) | nom de serveur +| irc | irc_channel | liste des canaux pour un serveur IRC | pointeur vers le canal (optionnel) | serveur,canal (le canal est optionnel) | irc | irc_ignore | liste des ignores IRC | pointeur vers l'ignore (optionnel) | - diff --git a/doc/it/autogen/plugin_api/infolists.txt b/doc/it/autogen/plugin_api/infolists.txt index f960d8b4c..8da17e5e9 100644 --- a/doc/it/autogen/plugin_api/infolists.txt +++ b/doc/it/autogen/plugin_api/infolists.txt @@ -4,7 +4,7 @@ | alias | alias | elenco di alias | puntatore all'alias (opzionale) | nome alias (può iniziare o terminare con "*" come carattere jolly) (opzionale) -| irc | irc_channel | elenco dei canali per un server IRC | puntatore al canale (opzionale) | nome server +| irc | irc_channel | elenco dei canali per un server IRC | puntatore al canale (opzionale) | server,channel (channel is optional) | irc | irc_ignore | elenco di ignore IRC | puntatore all'ignore (opzionale) | - diff --git a/po/cs.po b/po/cs.po index 71f09c0b3..5271ce16c 100644 --- a/po/cs.po +++ b/po/cs.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-09-18 09:24+0200\n" +"POT-Creation-Date: 2010-09-20 22:26+0200\n" "PO-Revision-Date: 2010-08-07 10:46+0200\n" "Last-Translator: Jiri Golembiovsky \n" "Language-Team: weechat-dev \n" @@ -4873,6 +4873,10 @@ msgstr "seznam kanálů pro IRC server" msgid "channel pointer (optional)" msgstr "ukazatel kanálu (volitelné)" +#, fuzzy +msgid "server,channel (channel is optional)" +msgstr "server,kanál,přezdívka (kanál a přezdívka jsou volitelné)" + msgid "list of nicks for an IRC channel" msgstr "seznam uživatelů pro IRC kanál" diff --git a/po/de.po b/po/de.po index d45e750b2..4be447568 100644 --- a/po/de.po +++ b/po/de.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.3-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-09-18 09:24+0200\n" +"POT-Creation-Date: 2010-09-20 22:26+0200\n" "PO-Revision-Date: 2010-09-08 22:15+0200\n" "Last-Translator: Nils G.\n" "Language-Team: weechat-dev \n" @@ -5081,6 +5081,10 @@ msgstr "Liste der Channels eines IRC-Servers" msgid "channel pointer (optional)" msgstr "Channel Pointer (optional)" +#, fuzzy +msgid "server,channel (channel is optional)" +msgstr "server,channel,nick (Channel und Nicks sind optional)" + msgid "list of nicks for an IRC channel" msgstr "Liste der Nicks im IRC-Channel" diff --git a/po/es.po b/po/es.po index 8eb8f36d6..38a6cba48 100644 --- a/po/es.po +++ b/po/es.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-09-18 09:24+0200\n" +"POT-Creation-Date: 2010-09-20 22:26+0200\n" "PO-Revision-Date: 2010-08-07 10:46+0200\n" "Last-Translator: Elián Hanisch \n" "Language-Team: weechat-dev \n" @@ -4938,6 +4938,10 @@ msgstr "lista de canales de un servidor IRC" msgid "channel pointer (optional)" msgstr "puntero del canal (opcional)" +#, fuzzy +msgid "server,channel (channel is optional)" +msgstr "servidor,canal,apodo (canal y apodo es opcional)" + msgid "list of nicks for an IRC channel" msgstr "lista de apodos de un canal IRC" diff --git a/po/fr.po b/po/fr.po index 6f74c4cc9..a3a76ed92 100644 --- a/po/fr.po +++ b/po/fr.po @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-09-18 09:24+0200\n" -"PO-Revision-Date: 2010-09-18 09:21+0200\n" +"POT-Creation-Date: 2010-09-20 22:26+0200\n" +"PO-Revision-Date: 2010-09-20 22:26+0200\n" "Last-Translator: Sebastien Helleu \n" "Language-Team: weechat-dev \n" "Language: French\n" @@ -4983,6 +4983,9 @@ msgstr "liste des canaux pour un serveur IRC" msgid "channel pointer (optional)" msgstr "pointeur vers le canal (optionnel)" +msgid "server,channel (channel is optional)" +msgstr "serveur,canal (le canal est optionnel)" + msgid "list of nicks for an IRC channel" msgstr "liste des pseudos pour un canal IRC" diff --git a/po/hu.po b/po/hu.po index 30dc320fd..f0a9470ce 100644 --- a/po/hu.po +++ b/po/hu.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-09-18 09:24+0200\n" +"POT-Creation-Date: 2010-09-20 22:26+0200\n" "PO-Revision-Date: 2010-08-07 10:46+0200\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -4657,6 +4657,10 @@ msgstr "szobák listája ahová be akarunk lépni csatlakozás után" msgid "channel pointer (optional)" msgstr "" +#, fuzzy +msgid "server,channel (channel is optional)" +msgstr "szoba: szoba neve" + #, fuzzy msgid "list of nicks for an IRC channel" msgstr "felhasználók listája a szobában" diff --git a/po/it.po b/po/it.po index 6442dd540..9d77131d2 100644 --- a/po/it.po +++ b/po/it.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-09-18 09:24+0200\n" +"POT-Creation-Date: 2010-09-20 22:26+0200\n" "PO-Revision-Date: 2010-08-07 10:46+0200\n" "Last-Translator: Marco Paolone \n" "Language-Team: weechat-dev \n" @@ -4947,6 +4947,10 @@ msgstr "elenco dei canali per un server IRC" msgid "channel pointer (optional)" msgstr "puntatore al canale (opzionale)" +#, fuzzy +msgid "server,channel (channel is optional)" +msgstr "server,canale,nick (canale e nick sono opzionali)" + msgid "list of nicks for an IRC channel" msgstr "elenco dei nick per un canale IRC" diff --git a/po/pl.po b/po/pl.po index 704d7a352..96543a682 100644 --- a/po/pl.po +++ b/po/pl.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-09-18 09:24+0200\n" +"POT-Creation-Date: 2010-09-20 22:26+0200\n" "PO-Revision-Date: 2010-08-07 10:46+0200\n" "Last-Translator: Krzysztof Koroscik \n" "Language-Team: weechat-dev \n" @@ -4911,6 +4911,10 @@ msgstr "lista kanałów IRC" msgid "channel pointer (optional)" msgstr "wskaźnik kanału (opcjonalne)" +#, fuzzy +msgid "server,channel (channel is optional)" +msgstr "serwer,kanał,nick (kanał oraz nick są opcjonalne)" + msgid "list of nicks for an IRC channel" msgstr "lista nicków na kanale IRC" diff --git a/po/ru.po b/po/ru.po index 3c341335d..06b43490d 100644 --- a/po/ru.po +++ b/po/ru.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-09-18 09:24+0200\n" +"POT-Creation-Date: 2010-09-20 22:26+0200\n" "PO-Revision-Date: 2010-08-07 10:46+0200\n" "Last-Translator: Pavel Shevchuk \n" "Language-Team: weechat-dev \n" @@ -4665,6 +4665,10 @@ msgstr "Список каналов, на которые заходить при msgid "channel pointer (optional)" msgstr "" +#, fuzzy +msgid "server,channel (channel is optional)" +msgstr "канал: название канала" + #, fuzzy msgid "list of nicks for an IRC channel" msgstr "список ников на канале" diff --git a/po/weechat.pot b/po/weechat.pot index 273754ac2..c4c3ae9ac 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-09-18 09:24+0200\n" +"POT-Creation-Date: 2010-09-20 22:26+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -3984,6 +3984,9 @@ msgstr "" msgid "channel pointer (optional)" msgstr "" +msgid "server,channel (channel is optional)" +msgstr "" + msgid "list of nicks for an IRC channel" msgstr "" diff --git a/src/plugins/irc/irc-info.c b/src/plugins/irc/irc-info.c index 0026954c0..9efe59419 100644 --- a/src/plugins/irc/irc-info.c +++ b/src/plugins/irc/irc-info.c @@ -324,39 +324,65 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name, { if (arguments && arguments[0]) { - ptr_server = irc_server_search (arguments); - if (ptr_server) + ptr_server = NULL; + ptr_channel = NULL; + argv = weechat_string_split (arguments, ",", 0, 0, &argc); + if (argv) { - if (pointer && !irc_channel_valid (ptr_server, pointer)) - return NULL; - - ptr_infolist = weechat_infolist_new (); - if (ptr_infolist) + if (argc >= 1) { - if (pointer) + ptr_server = irc_server_search (argv[0]); + if (!ptr_server) { - /* build list with only one channel */ - if (!irc_channel_add_to_infolist (ptr_infolist, pointer)) + weechat_string_free_split (argv); + return NULL; + } + if (!pointer && (argc >= 2)) + { + pointer = irc_channel_search (ptr_server, argv[1]); + if (!pointer) { - weechat_infolist_free (ptr_infolist); + weechat_string_free_split (argv); return NULL; } - return ptr_infolist; } - else + } + weechat_string_free_split (argv); + if (ptr_server) + { + if (pointer && !irc_channel_valid (ptr_server, pointer)) + return NULL; + + ptr_infolist = weechat_infolist_new (); + if (ptr_infolist) { - /* build list with all channels of server */ - for (ptr_channel = ptr_server->channels; ptr_channel; - ptr_channel = ptr_channel->next_channel) + if (pointer) { + /* build list with only one channel */ if (!irc_channel_add_to_infolist (ptr_infolist, - ptr_channel)) + pointer)) { weechat_infolist_free (ptr_infolist); return NULL; } + return ptr_infolist; + } + else + { + /* build list with all channels of server */ + for (ptr_channel = ptr_server->channels; + ptr_channel; + ptr_channel = ptr_channel->next_channel) + { + if (!irc_channel_add_to_infolist (ptr_infolist, + ptr_channel)) + { + weechat_infolist_free (ptr_infolist); + return NULL; + } + } + return ptr_infolist; } - return ptr_infolist; } } } @@ -539,7 +565,7 @@ irc_info_init () weechat_hook_infolist ("irc_channel", N_("list of channels for an IRC server"), N_("channel pointer (optional)"), - N_("server name"), + N_("server,channel (channel is optional)"), &irc_info_get_infolist_cb, NULL); weechat_hook_infolist ("irc_nick", N_("list of nicks for an IRC channel"), diff --git a/src/plugins/relay/relay-client-irc.c b/src/plugins/relay/relay-client-irc.c index 1a36ef3a2..2cb5e058d 100644 --- a/src/plugins/relay/relay-client-irc.c +++ b/src/plugins/relay/relay-client-irc.c @@ -444,10 +444,10 @@ relay_client_irc_send_join (struct t_relay_client *client, const char *channel) { char *infolist_name, *nicks; - const char *nick, *prefix; + const char *nick, *prefix, *topic; char *host; int length, length_nicks; - struct t_infolist *infolist_nick, *infolist_nicks; + struct t_infolist *infolist_nick, *infolist_channel, *infolist_nicks; length = strlen (client->protocol_args) + 1 + strlen (channel) + 1 + strlen (RELAY_IRC_DATA(client, nick)) + 1; @@ -481,7 +481,26 @@ relay_client_irc_send_join (struct t_relay_client *client, snprintf (infolist_name, length, "%s,%s", client->protocol_args, channel); - infolist_nicks = weechat_infolist_get ("irc_nick", NULL, infolist_name); + infolist_channel = weechat_infolist_get ("irc_channel", NULL, + infolist_name); + if (infolist_channel) + { + if (weechat_infolist_next (infolist_channel)) + { + topic = weechat_infolist_string (infolist_channel, "topic"); + if (topic && topic[0]) + { + relay_client_irc_sendf (client, + ":%s 332 %s %s :%s", + RELAY_IRC_DATA(client, address), + RELAY_IRC_DATA(client, nick), + channel, topic); + } + } + weechat_infolist_free (infolist_channel); + } + infolist_nicks = weechat_infolist_get ("irc_nick", NULL, + infolist_name); if (infolist_nicks) { length_nicks = 0;