diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | doc/de/autogen/user/irc_options.txt | 9 | ||||
-rw-r--r-- | doc/en/autogen/user/irc_options.txt | 9 | ||||
-rw-r--r-- | doc/fr/autogen/user/irc_options.txt | 9 | ||||
-rw-r--r-- | doc/it/autogen/user/irc_options.txt | 9 | ||||
-rw-r--r-- | po/cs.po | 10 | ||||
-rw-r--r-- | po/de.po | 10 | ||||
-rw-r--r-- | po/es.po | 10 | ||||
-rw-r--r-- | po/fr.po | 18 | ||||
-rw-r--r-- | po/hu.po | 10 | ||||
-rw-r--r-- | po/it.po | 10 | ||||
-rw-r--r-- | po/pl.po | 10 | ||||
-rw-r--r-- | po/pt_BR.po | 10 | ||||
-rw-r--r-- | po/ru.po | 10 | ||||
-rw-r--r-- | po/weechat.pot | 10 | ||||
-rw-r--r-- | src/plugins/irc/irc-channel.c | 42 | ||||
-rw-r--r-- | src/plugins/irc/irc-command.c | 52 | ||||
-rw-r--r-- | src/plugins/irc/irc-command.h | 3 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.c | 19 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.h | 3 | ||||
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 6 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.c | 44 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.h | 1 |
23 files changed, 256 insertions, 63 deletions
@@ -1,7 +1,7 @@ WeeChat ChangeLog ================= Sébastien Helleu <flashcode@flashtux.org> -v0.3.5-dev, 2011-03-15 +v0.3.5-dev, 2011-03-16 Version 0.3.5 (under dev!) @@ -36,7 +36,8 @@ Version 0.3.5 (under dev!) being added with command "/color") * core: allow background for nick colors (using ":") * api: add new function buffer_match_list -* irc: add new option irc.look.buffer_auto_switch_on_join (task #8542) +* irc: add new options irc.look.buffer_switch_autojoin and + irc.look.buffer_switch_join (task #8542, task #10506) * irc: add new option irc.look.smart_filter_nick * irc: ignore join if nick is not self nick and if channel buffer does not exist (bug #32667) diff --git a/doc/de/autogen/user/irc_options.txt b/doc/de/autogen/user/irc_options.txt index 9bbcfafae..a7835e93e 100644 --- a/doc/de/autogen/user/irc_options.txt +++ b/doc/de/autogen/user/irc_options.txt @@ -73,8 +73,13 @@ ** Typ: Farbe ** Werte: ein Farbname für WeeChat (default, black, (dark)gray, white, (light)red, (light)green, brown, yellow, (light)blue, (light)magenta, (light)cyan), eine Terminal-Farbnummer oder ein Alias; Attribute werden vor einer Farbe gesetzt (ausschließlich für die Textfarbe und nicht für den Hintergrund): "*" für fett, "!" für invertiert, "_" für unterstrichen (Standardwert: `default`) -* *irc.look.buffer_auto_switch_on_join* -** Beschreibung: `auto switch to channel buffer on join` +* *irc.look.buffer_switch_autojoin* +** Beschreibung: `auto switch to channel buffer when it is auto joined (with server option "autojoin")` +** Typ: boolesch +** Werte: on, off (Standardwert: `on`) + +* *irc.look.buffer_switch_join* +** Beschreibung: `auto switch to channel buffer when it is manually joined (with /join command)` ** Typ: boolesch ** Werte: on, off (Standardwert: `on`) diff --git a/doc/en/autogen/user/irc_options.txt b/doc/en/autogen/user/irc_options.txt index 7ee11252a..7e41948f2 100644 --- a/doc/en/autogen/user/irc_options.txt +++ b/doc/en/autogen/user/irc_options.txt @@ -73,8 +73,13 @@ ** type: color ** values: a WeeChat color name (default, black, (dark)gray, white, (light)red, (light)green, brown, yellow, (light)blue, (light)magenta, (light)cyan), a terminal color number or an alias; attributes are allowed before color (for text color only, not background): "*" for bold, "!" for reverse, "_" for underline (default value: `default`) -* *irc.look.buffer_auto_switch_on_join* -** description: `auto switch to channel buffer on join` +* *irc.look.buffer_switch_autojoin* +** description: `auto switch to channel buffer when it is auto joined (with server option "autojoin")` +** type: boolean +** values: on, off (default value: `on`) + +* *irc.look.buffer_switch_join* +** description: `auto switch to channel buffer when it is manually joined (with /join command)` ** type: boolean ** values: on, off (default value: `on`) diff --git a/doc/fr/autogen/user/irc_options.txt b/doc/fr/autogen/user/irc_options.txt index a3bbdea91..7c84d81f1 100644 --- a/doc/fr/autogen/user/irc_options.txt +++ b/doc/fr/autogen/user/irc_options.txt @@ -73,8 +73,13 @@ ** type: couleur ** valeurs: un nom de couleur WeeChat (default, black, (dark)gray, white, (light)red, (light)green, brown, yellow, (light)blue, (light)magenta, (light)cyan), un numéro de couleur du terminal ou un alias; des attributs sont autorisés avant la couleur (seulement pour la couleur du texte, pas le fond) : "*" pour du gras, "!" pour la vidéo inverse, "_" pour du souligné (valeur par défaut: `default`) -* *irc.look.buffer_auto_switch_on_join* -** description: `basculer automatiquement vers le tampon du canal sur un join` +* *irc.look.buffer_switch_autojoin* +** description: `basculer automatiquement vers le tampon du canal lorsqu'il est automatiquement rejoint (avec l'option du serveur "autojoin")` +** type: booléen +** valeurs: on, off (valeur par défaut: `on`) + +* *irc.look.buffer_switch_join* +** description: `basculer automatiquement vers le tampon du canal lorsqu'il est manuellement rejoint (avec la commande /join)` ** type: booléen ** valeurs: on, off (valeur par défaut: `on`) diff --git a/doc/it/autogen/user/irc_options.txt b/doc/it/autogen/user/irc_options.txt index af998952c..39ab4f1e5 100644 --- a/doc/it/autogen/user/irc_options.txt +++ b/doc/it/autogen/user/irc_options.txt @@ -73,8 +73,13 @@ ** tipo: colore ** valori: a WeeChat color name (default, black, (dark)gray, white, (light)red, (light)green, brown, yellow, (light)blue, (light)magenta, (light)cyan), a terminal color number or an alias; attributes are allowed before color (for text color only, not background): "*" for bold, "!" for reverse, "_" for underline (valore predefinito: `default`) -* *irc.look.buffer_auto_switch_on_join* -** descrizione: `auto switch to channel buffer on join` +* *irc.look.buffer_switch_autojoin* +** descrizione: `auto switch to channel buffer when it is auto joined (with server option "autojoin")` +** tipo: bool +** valori: on, off (valore predefinito: `on`) + +* *irc.look.buffer_switch_join* +** descrizione: `auto switch to channel buffer when it is manually joined (with /join command)` ** tipo: bool ** valori: on, off (valore predefinito: `on`) @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.5-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-03-15 11:39+0100\n" +"POT-Creation-Date: 2011-03-16 09:26+0100\n" "PO-Revision-Date: 2011-02-07 17:29+0100\n" "Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -4918,7 +4918,13 @@ msgstr "%s%s: chyba při vytváření serveru \"%s\"" msgid "%s%s: error creating server option \"%s\"" msgstr "%s%s: chyba při vytváření volby serveru \"%s\"" -msgid "auto switch to channel buffer on join" +msgid "" +"auto switch to channel buffer when it is auto joined (with server option " +"\"autojoin\")" +msgstr "" + +msgid "" +"auto switch to channel buffer when it is manually joined (with /join command)" msgstr "" msgid "" @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.5-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-03-15 11:39+0100\n" +"POT-Creation-Date: 2011-03-16 09:26+0100\n" "PO-Revision-Date: 2011-03-12 10:15+0100\n" "Last-Translator: Nils G.\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -5129,7 +5129,13 @@ msgstr "%s%s: Fehler bei der Erstellung des Servers \"%s\"" msgid "%s%s: error creating server option \"%s\"" msgstr "%s%s: Fehler bei der Erstellung der Server-Option \"%s\"" -msgid "auto switch to channel buffer on join" +msgid "" +"auto switch to channel buffer when it is auto joined (with server option " +"\"autojoin\")" +msgstr "" + +msgid "" +"auto switch to channel buffer when it is manually joined (with /join command)" msgstr "" msgid "" @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.5-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-03-15 11:39+0100\n" +"POT-Creation-Date: 2011-03-16 09:26+0100\n" "PO-Revision-Date: 2011-02-07 17:29+0100\n" "Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -5030,7 +5030,13 @@ msgstr "%s%s: error al crear el servidor \"%s\"" msgid "%s%s: error creating server option \"%s\"" msgstr "%s%s: error al crear la opción \"%s\" del servidor" -msgid "auto switch to channel buffer on join" +msgid "" +"auto switch to channel buffer when it is auto joined (with server option " +"\"autojoin\")" +msgstr "" + +msgid "" +"auto switch to channel buffer when it is manually joined (with /join command)" msgstr "" msgid "" @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.5-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-03-15 11:39+0100\n" -"PO-Revision-Date: 2011-03-15 11:40+0100\n" +"POT-Creation-Date: 2011-03-16 09:26+0100\n" +"PO-Revision-Date: 2011-03-15 15:31+0100\n" "Last-Translator: Sebastien Helleu <flashcode@flashtux.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language: French\n" @@ -5032,8 +5032,18 @@ msgstr "%s%s: erreur de création du serveur \"%s\"" msgid "%s%s: error creating server option \"%s\"" msgstr "%s%s: erreur de création de l'option serveur \"%s\"" -msgid "auto switch to channel buffer on join" -msgstr "basculer automatiquement vers le tampon du canal sur un join" +msgid "" +"auto switch to channel buffer when it is auto joined (with server option " +"\"autojoin\")" +msgstr "" +"basculer automatiquement vers le tampon du canal lorsqu'il est " +"automatiquement rejoint (avec l'option du serveur \"autojoin\")" + +msgid "" +"auto switch to channel buffer when it is manually joined (with /join command)" +msgstr "" +"basculer automatiquement vers le tampon du canal lorsqu'il est manuellement " +"rejoint (avec la commande /join)" msgid "" "use nick color in output of /names (or list of nicks displayed when joining " @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.5-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-03-15 11:39+0100\n" +"POT-Creation-Date: 2011-03-16 09:26+0100\n" "PO-Revision-Date: 2011-02-07 17:29+0100\n" "Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -4598,7 +4598,13 @@ msgstr "%s nincs elég memória az információs pult üzenethez\n" msgid "%s%s: error creating server option \"%s\"" msgstr "%s nincs elég memória az információs pult üzenethez\n" -msgid "auto switch to channel buffer on join" +msgid "" +"auto switch to channel buffer when it is auto joined (with server option " +"\"autojoin\")" +msgstr "" + +msgid "" +"auto switch to channel buffer when it is manually joined (with /join command)" msgstr "" msgid "" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.5-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-03-15 11:39+0100\n" +"POT-Creation-Date: 2011-03-16 09:26+0100\n" "PO-Revision-Date: 2011-03-09 09:29+0100\n" "Last-Translator: Marco Paolone <marcopaolone@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -4945,7 +4945,13 @@ msgstr "%s%s: errore durante la creazione del server \"%s\"" msgid "%s%s: error creating server option \"%s\"" msgstr "%s%s: errore durante la creazione dell'opzione del server \"%s\"" -msgid "auto switch to channel buffer on join" +msgid "" +"auto switch to channel buffer when it is auto joined (with server option " +"\"autojoin\")" +msgstr "" + +msgid "" +"auto switch to channel buffer when it is manually joined (with /join command)" msgstr "" msgid "" @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.5-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-03-15 11:39+0100\n" +"POT-Creation-Date: 2011-03-16 09:26+0100\n" "PO-Revision-Date: 2011-02-07 17:29+0100\n" "Last-Translator: Krzysztof Koroscik <soltys@szluug.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -5010,7 +5010,13 @@ msgstr "%s%s: błąd podczas tworzenia serwera \"%s\"" msgid "%s%s: error creating server option \"%s\"" msgstr "%s%s: błąd podczas tworzenia opcji dla serwera \"%s\"" -msgid "auto switch to channel buffer on join" +msgid "" +"auto switch to channel buffer when it is auto joined (with server option " +"\"autojoin\")" +msgstr "" + +msgid "" +"auto switch to channel buffer when it is manually joined (with /join command)" msgstr "" msgid "" diff --git a/po/pt_BR.po b/po/pt_BR.po index e506c79a7..8b84b1473 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.5-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-03-15 11:39+0100\n" +"POT-Creation-Date: 2011-03-16 09:26+0100\n" "PO-Revision-Date: 2011-02-07 17:30+0100\n" "Last-Translator: Ivan Sichmann Freitas <ivansichfreitas@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -4441,7 +4441,13 @@ msgstr "" msgid "%s%s: error creating server option \"%s\"" msgstr "" -msgid "auto switch to channel buffer on join" +msgid "" +"auto switch to channel buffer when it is auto joined (with server option " +"\"autojoin\")" +msgstr "" + +msgid "" +"auto switch to channel buffer when it is manually joined (with /join command)" msgstr "" msgid "" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.5-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-03-15 11:39+0100\n" +"POT-Creation-Date: 2011-03-16 09:26+0100\n" "PO-Revision-Date: 2011-02-07 17:30+0100\n" "Last-Translator: Pavel Shevchuk <stlwrt@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -4605,7 +4605,13 @@ msgstr "%s недостаточно памяти для сообщения в с msgid "%s%s: error creating server option \"%s\"" msgstr "%s недостаточно памяти для сообщения в строке информации\n" -msgid "auto switch to channel buffer on join" +msgid "" +"auto switch to channel buffer when it is auto joined (with server option " +"\"autojoin\")" +msgstr "" + +msgid "" +"auto switch to channel buffer when it is manually joined (with /join command)" msgstr "" msgid "" diff --git a/po/weechat.pot b/po/weechat.pot index 335891cd1..cfcee6906 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: 2011-03-15 11:39+0100\n" +"POT-Creation-Date: 2011-03-16 09:26+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -3907,7 +3907,13 @@ msgstr "" msgid "%s%s: error creating server option \"%s\"" msgstr "" -msgid "auto switch to channel buffer on join" +msgid "" +"auto switch to channel buffer when it is auto joined (with server option " +"\"autojoin\")" +msgstr "" + +msgid "" +"auto switch to channel buffer when it is manually joined (with /join command)" msgstr "" msgid "" diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c index aee6330a2..a551b584e 100644 --- a/src/plugins/irc/irc-channel.c +++ b/src/plugins/irc/irc-channel.c @@ -150,8 +150,8 @@ irc_channel_new (struct t_irc_server *server, int channel_type, { struct t_irc_channel *new_channel; struct t_gui_buffer *new_buffer; - int i, buffer_created, current_buffer_number, buffer_position; - char *buffer_name, str_number[32], str_group[32]; + int i, buffer_created, current_buffer_number, buffer_position, manual_join; + char *buffer_name, str_number[32], str_group[32], *channel_name_lower; const char *prefix_modes; /* alloc memory for new channel */ @@ -283,14 +283,40 @@ irc_channel_new (struct t_irc_server *server, int channel_type, server->channels = new_channel; server->last_channel = new_channel; - if (switch_to_channel - && ((channel_type != IRC_CHANNEL_TYPE_CHANNEL) - || weechat_config_boolean (irc_config_look_buffer_auto_switch_on_join))) + manual_join = 0; + channel_name_lower = NULL; + if (channel_type == IRC_CHANNEL_TYPE_CHANNEL) { - weechat_buffer_set (new_buffer, "display", - (auto_switch) ? "auto" : "1"); + channel_name_lower = strdup (channel_name); + if (channel_name_lower) + { + weechat_string_tolower (channel_name_lower); + manual_join = weechat_hashtable_has_key (server->manual_joins, + channel_name_lower); + } } + if (switch_to_channel) + { + if (channel_type == IRC_CHANNEL_TYPE_CHANNEL) + { + if ((manual_join && !weechat_config_boolean (irc_config_look_buffer_switch_join)) + || (!manual_join && !weechat_config_boolean (irc_config_look_buffer_switch_autojoin))) + switch_to_channel = 0; + } + + if (switch_to_channel) + { + weechat_buffer_set (new_buffer, "display", + (auto_switch) ? "auto" : "1"); + } + } + + if (manual_join) + weechat_hashtable_remove (server->manual_joins, channel_name_lower); + if (channel_name_lower) + free (channel_name_lower); + weechat_hook_signal_send ((channel_type == IRC_CHANNEL_TYPE_CHANNEL) ? "irc_channel_opened" : "irc_pv_opened", WEECHAT_HOOK_SIGNAL_POINTER, new_buffer); @@ -654,7 +680,7 @@ irc_channel_rejoin (struct t_irc_server *server, struct t_irc_channel *channel) (channel->key) ? " " : "", (channel->key) ? channel->key : ""); - irc_command_join_server (server, join_args); + irc_command_join_server (server, join_args, 0); } /* diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index 6b1d3c64c..1523daa9b 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -1757,8 +1757,13 @@ irc_command_ison (void *data, struct t_gui_buffer *buffer, int argc, */ void -irc_command_join_server (struct t_irc_server *server, const char *arguments) +irc_command_join_server (struct t_irc_server *server, const char *arguments, + int manual_join) { + char *args, **channels, *pos_space; + int i, length, num_channels; + int time_now; + if (server->sock < 0) { weechat_printf (NULL, @@ -1766,19 +1771,42 @@ irc_command_join_server (struct t_irc_server *server, const char *arguments) "connected irc server"), weechat_prefix ("error"), IRC_PLUGIN_NAME, "join"); + return; } + + if (irc_channel_is_channel (arguments)) + args = strdup (arguments); else { - if (irc_channel_is_channel (arguments)) - { - irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, - "JOIN %s", arguments); - } - else + length = 1 + strlen (arguments) + 1; + args = malloc (length); + if (args) + snprintf (args, length, "#%s", arguments); + } + if (args) + { + irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, + "JOIN %s", args); + if (manual_join) { - irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, - "JOIN #%s", arguments); + pos_space = strchr (args, ' '); + if (pos_space) + pos_space[0] = '\0'; + channels = weechat_string_split (args, ",", 0, 0, &num_channels); + if (channels) + { + time_now = (int)time (NULL); + for (i = 0; i < num_channels; i++) + { + weechat_string_tolower (channels[i]); + weechat_hashtable_set (server->manual_joins, + channels[i], + &time_now); + } + weechat_string_free_split (channels); + } } + free (args); } } @@ -1802,13 +1830,13 @@ irc_command_join (void *data, struct t_gui_buffer *buffer, int argc, ptr_server = irc_server_search (argv[2]); if (!ptr_server) return WEECHAT_RC_ERROR; - irc_command_join_server (ptr_server, argv_eol[3]); + irc_command_join_server (ptr_server, argv_eol[3], 1); } else { if (!ptr_server) return WEECHAT_RC_ERROR; - irc_command_join_server (ptr_server, argv_eol[1]); + irc_command_join_server (ptr_server, argv_eol[1], 1); } } else @@ -1816,7 +1844,7 @@ irc_command_join (void *data, struct t_gui_buffer *buffer, int argc, if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL) && !ptr_channel->nicks) { - irc_command_join_server (ptr_server, ptr_channel->name); + irc_command_join_server (ptr_server, ptr_channel->name, 1); } else { diff --git a/src/plugins/irc/irc-command.h b/src/plugins/irc/irc-command.h index 5c3c4d7e6..8c762ddd8 100644 --- a/src/plugins/irc/irc-command.h +++ b/src/plugins/irc/irc-command.h @@ -54,7 +54,8 @@ extern void irc_command_away_server (struct t_irc_server *server, const char *arguments, int reset_unread_marker); extern void irc_command_join_server (struct t_irc_server *server, - const char *arguments); + const char *arguments, + int manual_join); extern void irc_command_mode_server (struct t_irc_server *server, struct t_irc_channel *channel, const char *arguments); diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index 45ad4dca0..5a1fb26d7 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -50,7 +50,8 @@ struct t_config_section *irc_config_section_server = NULL; /* IRC config, look section */ -struct t_config_option *irc_config_look_buffer_auto_switch_on_join; +struct t_config_option *irc_config_look_buffer_switch_autojoin; +struct t_config_option *irc_config_look_buffer_switch_join; struct t_config_option *irc_config_look_color_nicks_in_names; struct t_config_option *irc_config_look_color_nicks_in_nicklist; struct t_config_option *irc_config_look_color_nicks_in_server_messages; @@ -1793,11 +1794,19 @@ irc_config_init () weechat_config_free (irc_config_file); return 0; } - - irc_config_look_buffer_auto_switch_on_join = weechat_config_new_option ( + + irc_config_look_buffer_switch_autojoin = weechat_config_new_option ( + irc_config_file, ptr_section, + "buffer_switch_autojoin", "boolean", + N_("auto switch to channel buffer when it is auto joined (with " + "server option \"autojoin\")"), + NULL, 0, 0, "on", NULL, 0, NULL, NULL, + NULL, NULL, NULL, NULL); + irc_config_look_buffer_switch_join = weechat_config_new_option ( irc_config_file, ptr_section, - "buffer_auto_switch_on_join", "boolean", - N_("auto switch to channel buffer on join"), + "buffer_switch_join", "boolean", + N_("auto switch to channel buffer when it is manually joined " + "(with /join command)"), NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_color_nicks_in_names = weechat_config_new_option ( diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h index cc99b0933..1f505460e 100644 --- a/src/plugins/irc/irc-config.h +++ b/src/plugins/irc/irc-config.h @@ -75,7 +75,8 @@ extern struct t_config_section *irc_config_section_ctcp; extern struct t_config_section *irc_config_section_server_default; extern struct t_config_section *irc_config_section_server; -extern struct t_config_option *irc_config_look_buffer_auto_switch_on_join; +extern struct t_config_option *irc_config_look_buffer_switch_autojoin; +extern struct t_config_option *irc_config_look_buffer_switch_join; extern struct t_config_option *irc_config_look_color_nicks_in_names; extern struct t_config_option *irc_config_look_color_nicks_in_nicklist; extern struct t_config_option *irc_config_look_color_nicks_in_server_messages; diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 741d30cf6..a81854f39 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -1258,14 +1258,14 @@ IRC_PROTOCOL_CALLBACK(part) snprintf (join_string, join_length, "%s %s", ptr_channel->name, ptr_channel->key); - irc_command_join_server (server, join_string); + irc_command_join_server (server, join_string, 1); free (join_string); } else - irc_command_join_server (server, ptr_channel->name); + irc_command_join_server (server, ptr_channel->name, 1); } else - irc_command_join_server (server, ptr_channel->name); + irc_command_join_server (server, ptr_channel->name, 1); } else { diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index d39a0cf17..87a86c482 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -98,6 +98,8 @@ char *irc_server_prefix_chars_default = "~&@%+-"; const char *irc_server_send_default_tags = NULL; /* default tags when */ /* sending a message */ +time_t irc_server_last_check_manual_joins = 0; + void irc_server_reconnect (struct t_irc_server *server); void irc_server_free_data (struct t_irc_server *server); @@ -656,6 +658,11 @@ irc_server_alloc (const char *name) new_server->last_redirect = NULL; new_server->notify_list = NULL; new_server->last_notify = NULL; + new_server->manual_joins = weechat_hashtable_new (4, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_INTEGER, + NULL, + NULL); new_server->buffer = NULL; new_server->buffer_as_string = NULL; new_server->channels = NULL; @@ -1095,6 +1102,7 @@ irc_server_free_data (struct t_irc_server *server) irc_server_outqueue_free_all (server, i); } irc_notify_free_all (server); + weechat_hashtable_free (server->manual_joins); irc_redirect_free_all (server); if (server->channels) irc_channel_free_all (server); @@ -2187,6 +2195,26 @@ irc_server_timer_sasl_cb (void *data, int remaining_calls) } /* + * irc_server_check_manual_joins_cb: callback called for each manual join of a + * server, it will delete old channels in + * this hashtable + */ + +void +irc_server_check_manual_joins_cb (void *data, struct t_hashtable *hashtable, + const void *key, const void *value) +{ + struct t_irc_server *server; + + server = (struct t_irc_server *)data; + if (server) + { + if (*((int *)value) + 60 < time (NULL)) + weechat_hashtable_remove (hashtable, key); + } +} + +/* * irc_server_timer_cb: timer called each second to perform some operations * on servers */ @@ -2298,6 +2326,14 @@ irc_server_timer_cb (void *data, int remaining_calls) ptr_redirect = ptr_next_redirect; } + + /* remove old channels in "manual_joins" (each 60 seconds) */ + if (current_time > irc_server_last_check_manual_joins + 60) + { + weechat_hashtable_map (ptr_server->manual_joins, + &irc_server_check_manual_joins_cb, + ptr_server); + } } } } @@ -2374,6 +2410,9 @@ irc_server_close_connection (struct t_irc_server *server) /* remove all redirects */ irc_redirect_free_all (server); + /* remove all manual joins */ + weechat_hashtable_remove_all (server->manual_joins); + /* server is now disconnected */ server->is_connected = 0; server->ssl_connected = 0; @@ -3484,7 +3523,7 @@ irc_server_autojoin_channels (struct t_irc_server *server) /* auto-join when connecting to server for first time */ autojoin = IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_AUTOJOIN); if (!server->disable_autojoin && autojoin && autojoin[0]) - irc_command_join_server (server, autojoin); + irc_command_join_server (server, autojoin, 0); } server->disable_autojoin = 0; @@ -4317,6 +4356,9 @@ irc_server_print_log () weechat_log_printf (" last_redirect. . . . : 0x%lx", ptr_server->last_redirect); weechat_log_printf (" notify_list. . . . . : 0x%lx", ptr_server->notify_list); weechat_log_printf (" last_notify. . . . . : 0x%lx", ptr_server->last_notify); + weechat_log_printf (" manual_joins . . . . : 0x%lx (hashtable: '%s')", + ptr_server->manual_joins, + weechat_hashtable_get_string (ptr_server->manual_joins, "keys_values")); weechat_log_printf (" buffer . . . . . . . : 0x%lx", ptr_server->buffer); weechat_log_printf (" buffer_as_string . . : 0x%lx", ptr_server->buffer_as_string); weechat_log_printf (" channels . . . . . . : 0x%lx", ptr_server->channels); diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h index 3aac8e425..6891f9fbc 100644 --- a/src/plugins/irc/irc-server.h +++ b/src/plugins/irc/irc-server.h @@ -176,6 +176,7 @@ struct t_irc_server struct t_irc_redirect *last_redirect; /* last command redirection */ struct t_irc_notify *notify_list; /* list of notify */ struct t_irc_notify *last_notify; /* last notify */ + struct t_hashtable *manual_joins; /* manual joins pending */ struct t_gui_buffer *buffer; /* GUI buffer allocated for server */ char *buffer_as_string; /* used to return buffer info */ struct t_irc_channel *channels; /* opened channels on server */ |