diff --git a/doc/de/autogen/user/irc_options.txt b/doc/de/autogen/user/irc_options.txt index 47d4af2..c7f17dd 100644 --- a/doc/de/autogen/user/irc_options.txt +++ b/doc/de/autogen/user/irc_options.txt @@ -418,6 +418,11 @@ ** Typ: integer ** Werte: 0 .. 1000000 (Standardwert: `25`) +* [[option_irc.server_default.cap]] *irc.server_default.cap* +** Beschreibung: `comma-separated list of capabilities to enable for server if they are available (example: "multi-prefix,extended-join")` +** Typ: Zeichenkette +** Werte: beliebige Zeichenkette (Standardwert: `""`) + * [[option_irc.server_default.command]] *irc.server_default.command* ** Beschreibung: `Enthält Befehle die nach der Verbindung zum Server ausgeführt werden sollen. Mehrere Befehle müssen durch ein ";" getrennt werden. Möchte man ein Semikolon schreiben muss man "\;" verwenden. Die speziellen Variablen $nick, $channel und $server werden dabei durch den jeweiligen Wert ersetzt` ** Typ: Zeichenkette diff --git a/doc/en/autogen/user/irc_options.txt b/doc/en/autogen/user/irc_options.txt index c8b91b0..a2c5ede 100644 --- a/doc/en/autogen/user/irc_options.txt +++ b/doc/en/autogen/user/irc_options.txt @@ -418,6 +418,11 @@ ** type: integer ** values: 0 .. 1000000 (default value: `25`) +* [[option_irc.server_default.cap]] *irc.server_default.cap* +** description: `comma-separated list of capabilities to enable for server if they are available (example: "multi-prefix,extended-join")` +** type: string +** values: any string (default value: `""`) + * [[option_irc.server_default.command]] *irc.server_default.command* ** description: `command(s) to run when connected to server (many commands should be separated by ";", use "\;" for a semicolon, special variables $nick, $channel and $server are replaced by their value)` ** type: string diff --git a/doc/fr/autogen/user/irc_options.txt b/doc/fr/autogen/user/irc_options.txt index 116bf8d..df12a85 100644 --- a/doc/fr/autogen/user/irc_options.txt +++ b/doc/fr/autogen/user/irc_options.txt @@ -418,6 +418,11 @@ ** type: entier ** valeurs: 0 .. 1000000 (valeur par défaut: `25`) +* [[option_irc.server_default.cap]] *irc.server_default.cap* +** description: `liste séparée par des virgules de capacités ("capabilities") à activer sur le serveur si elles sont disponibles (exemple: "multi-prefix,extended-join")` +** type: chaîne +** valeurs: toute chaîne (valeur par défaut: `""`) + * [[option_irc.server_default.command]] *irc.server_default.command* ** description: `commande(s) à exécuter lorsque connecté au serveur (plusieurs commandes doivent être séparées par ";", utilisez "\;" pour un point-virgule, les variables spéciales $nick, $channel et $server sont remplacées par leur valeur)` ** type: chaîne diff --git a/doc/it/autogen/user/irc_options.txt b/doc/it/autogen/user/irc_options.txt index 35ec0f4..1b54da4 100644 --- a/doc/it/autogen/user/irc_options.txt +++ b/doc/it/autogen/user/irc_options.txt @@ -418,6 +418,11 @@ ** tipo: intero ** valori: 0 .. 1000000 (valore predefinito: `25`) +* [[option_irc.server_default.cap]] *irc.server_default.cap* +** descrizione: `comma-separated list of capabilities to enable for server if they are available (example: "multi-prefix,extended-join")` +** tipo: stringa +** valori: qualsiasi stringa (valore predefinito: `""`) + * [[option_irc.server_default.command]] *irc.server_default.command* ** descrizione: `comando(i) da eseguire quando si è connessi al server (più comandi vanno separati da ":", usare ";" per un punto e virgola, le variabili speciali $nick, $canale e $server vengono sostituite dai loro valori)` ** tipo: stringa diff --git a/po/cs.po b/po/cs.po index 37dc5c4..bd2d003 100644 --- a/po/cs.po +++ b/po/cs.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-01-24 21:20+0100\n" +"POT-Creation-Date: 2012-02-19 10:45+0100\n" "PO-Revision-Date: 2011-12-25 22:56+0100\n" "Last-Translator: Jiri Golembiovsky \n" "Language-Team: weechat-dev \n" @@ -5322,6 +5322,12 @@ msgstr "ověřit, že je ssl spojení zcela důvěryhodné" msgid "password for server" msgstr "heslo pro server" +#. TRANSLATORS: please keep word "capabilities" between brackets if translation is different (see fr.po) +msgid "" +"comma-separated list of capabilities to enable for server if they are " +"available (example: \"multi-prefix,extended-join\")" +msgstr "" + msgid "mechanism for SASL authentication" msgstr "mechanismu pro SASL autentizaci" @@ -6078,8 +6084,8 @@ msgstr "" msgid "%s%s: client capability, server supports: %s" msgstr "%s%s: schopnost klienta, server podporuje: %s" -#, c-format -msgid "%s%s: client capability, requesting: sasl" +#, fuzzy, c-format +msgid "%s%s: client capability, requesting: %s" msgstr "%s%s: schopnost klienta, vyžaduji: sasl" #, c-format diff --git a/po/de.po b/po/de.po index 14db0d3..ce59d5b 100644 --- a/po/de.po +++ b/po/de.po @@ -23,7 +23,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-02-04 11:26+0100\n" +"POT-Creation-Date: 2012-02-19 10:45+0100\n" "PO-Revision-Date: 2012-01-29 14:32+0100\n" "Last-Translator: Nils Görs \n" "Language-Team: German \n" @@ -5679,6 +5679,12 @@ msgstr "Überprüfe ob die SSL-Verbindung vertrauenswürdig ist" msgid "password for server" msgstr "Passwort für den Server" +#. TRANSLATORS: please keep word "capabilities" between brackets if translation is different (see fr.po) +msgid "" +"comma-separated list of capabilities to enable for server if they are " +"available (example: \"multi-prefix,extended-join\")" +msgstr "" + msgid "mechanism for SASL authentication" msgstr "Vorrichtung zur SASL Authentifizierung" @@ -6525,8 +6531,8 @@ msgstr "" msgid "%s%s: client capability, server supports: %s" msgstr "%s%s: Client Fähigkeit, Server unterstützt: %s" -#, c-format -msgid "%s%s: client capability, requesting: sasl" +#, fuzzy, c-format +msgid "%s%s: client capability, requesting: %s" msgstr "%s%s: Client Fähigkeit, Anfrage: SASL" #, c-format diff --git a/po/es.po b/po/es.po index 793a16c..338418e 100644 --- a/po/es.po +++ b/po/es.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-01-24 21:20+0100\n" +"POT-Creation-Date: 2012-02-19 10:45+0100\n" "PO-Revision-Date: 2011-12-25 22:56+0100\n" "Last-Translator: Elián Hanisch \n" "Language-Team: weechat-dev \n" @@ -5504,6 +5504,12 @@ msgstr "verificar que la conexión SSL es confiable completamente" msgid "password for server" msgstr "contraseña del servidor" +#. TRANSLATORS: please keep word "capabilities" between brackets if translation is different (see fr.po) +msgid "" +"comma-separated list of capabilities to enable for server if they are " +"available (example: \"multi-prefix,extended-join\")" +msgstr "" + msgid "mechanism for SASL authentication" msgstr "mecanismo para la autenticación SASL" @@ -6275,8 +6281,8 @@ msgstr "" msgid "%s%s: client capability, server supports: %s" msgstr "%s%s: capabilidad del cliente, el servidor soporta: %s" -#, c-format -msgid "%s%s: client capability, requesting: sasl" +#, fuzzy, c-format +msgid "%s%s: client capability, requesting: %s" msgstr "%s%s: capabilidad del cliente, solicitando: sasl" #, c-format diff --git a/po/fr.po b/po/fr.po index dd0db74..14b4ec2 100644 --- a/po/fr.po +++ b/po/fr.po @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-01-24 21:20+0100\n" -"PO-Revision-Date: 2012-01-24 20:33+0100\n" +"POT-Creation-Date: 2012-02-19 10:45+0100\n" +"PO-Revision-Date: 2012-02-19 10:45+0100\n" "Last-Translator: Sebastien Helleu \n" "Language-Team: weechat-dev \n" "Language: French\n" @@ -5558,6 +5558,15 @@ msgstr "vérifier que la connexion ssl est entièrement de confiance" msgid "password for server" msgstr "mot de passe pour le serveur" +#. TRANSLATORS: please keep word "capabilities" between brackets if translation is different (see fr.po) +msgid "" +"comma-separated list of capabilities to enable for server if they are " +"available (example: \"multi-prefix,extended-join\")" +msgstr "" +"liste séparée par des virgules de capacités (\"capabilities\") à activer sur " +"le serveur si elles sont disponibles (exemple: \"multi-prefix,extended-join" +"\")" + msgid "mechanism for SASL authentication" msgstr "mécanisme pour l'authentification SASL" @@ -6366,8 +6375,8 @@ msgid "%s%s: client capability, server supports: %s" msgstr "%s%s: client capability, le serveur supporte: %s" #, c-format -msgid "%s%s: client capability, requesting: sasl" -msgstr "%s%s: client capability, demande: sasl" +msgid "%s%s: client capability, requesting: %s" +msgstr "%s%s: client capability, demande: %s" #, c-format msgid "%s%s: client capability: sasl not supported" diff --git a/po/hu.po b/po/hu.po index fe344a5..81a8188 100644 --- a/po/hu.po +++ b/po/hu.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-01-24 21:20+0100\n" +"POT-Creation-Date: 2012-02-19 10:45+0100\n" "PO-Revision-Date: 2011-12-25 22:56+0100\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -4921,6 +4921,12 @@ msgstr "" msgid "password for server" msgstr "jelszó az IRC szerveren" +#. TRANSLATORS: please keep word "capabilities" between brackets if translation is different (see fr.po) +msgid "" +"comma-separated list of capabilities to enable for server if they are " +"available (example: \"multi-prefix,extended-join\")" +msgstr "" + #, fuzzy msgid "mechanism for SASL authentication" msgstr "SSL használata a a kapcsolathoz" @@ -5660,9 +5666,9 @@ msgstr "" msgid "%s%s: client capability, server supports: %s" msgstr "" -#, c-format -msgid "%s%s: client capability, requesting: sasl" -msgstr "" +#, fuzzy, c-format +msgid "%s%s: client capability, requesting: %s" +msgstr "Nem sikerült a(z) \"%s\" naplófájlt írni\n" #, c-format msgid "%s%s: client capability: sasl not supported" diff --git a/po/it.po b/po/it.po index 4ae7860..b517dbc 100644 --- a/po/it.po +++ b/po/it.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-02-05 20:05+0100\n" +"POT-Creation-Date: 2012-02-19 10:45+0100\n" "PO-Revision-Date: 2012-02-05 22:24+0100\n" "Last-Translator: Marco Paolone \n" "Language-Team: weechat-dev \n" @@ -5503,6 +5503,12 @@ msgstr "verifica che la connessione ssl sia totalmente fidata" msgid "password for server" msgstr "password per il server" +#. TRANSLATORS: please keep word "capabilities" between brackets if translation is different (see fr.po) +msgid "" +"comma-separated list of capabilities to enable for server if they are " +"available (example: \"multi-prefix,extended-join\")" +msgstr "" + msgid "mechanism for SASL authentication" msgstr "meccanismo per l'autenticazione SASL" @@ -6309,8 +6315,8 @@ msgstr "" msgid "%s%s: client capability, server supports: %s" msgstr "%s%s: capacità del client, il server supporta: %s" -#, c-format -msgid "%s%s: client capability, requesting: sasl" +#, fuzzy, c-format +msgid "%s%s: client capability, requesting: %s" msgstr "%s%s: capacità del client, richiesta in corso: sasl" #, c-format diff --git a/po/pl.po b/po/pl.po index 482dad4..3f34d0a 100644 --- a/po/pl.po +++ b/po/pl.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-01-24 21:20+0100\n" +"POT-Creation-Date: 2012-02-19 10:45+0100\n" "PO-Revision-Date: 2011-12-25 22:56+0100\n" "Last-Translator: Krzysztof Korościk \n" "Language-Team: weechat-dev \n" @@ -5472,6 +5472,12 @@ msgstr "sprawdź czy połączenie ssl jest w pełni zaufane" msgid "password for server" msgstr "hasło dla serwera" +#. TRANSLATORS: please keep word "capabilities" between brackets if translation is different (see fr.po) +msgid "" +"comma-separated list of capabilities to enable for server if they are " +"available (example: \"multi-prefix,extended-join\")" +msgstr "" + msgid "mechanism for SASL authentication" msgstr "mechanizm uwierzytelniania SASL" @@ -6235,8 +6241,8 @@ msgstr "" msgid "%s%s: client capability, server supports: %s" msgstr "%s%s: możliwości klienta, serwer wspiera: %s" -#, c-format -msgid "%s%s: client capability, requesting: sasl" +#, fuzzy, c-format +msgid "%s%s: client capability, requesting: %s" msgstr "%s%s: możliwości klienta, żądanie: sasl" #, c-format diff --git a/po/pt_BR.po b/po/pt_BR.po index 8059c78..b0917f6 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-01-24 21:20+0100\n" +"POT-Creation-Date: 2012-02-19 10:45+0100\n" "PO-Revision-Date: 2011-12-25 22:56+0100\n" "Last-Translator: Sergio Durigan Junior \n" "Language-Team: weechat-dev \n" @@ -5075,6 +5075,12 @@ msgstr "verificar que a conexão SSL é totalmente confiável" msgid "password for server" msgstr "senha para o servidor" +#. TRANSLATORS: please keep word "capabilities" between brackets if translation is different (see fr.po) +msgid "" +"comma-separated list of capabilities to enable for server if they are " +"available (example: \"multi-prefix,extended-join\")" +msgstr "" + msgid "mechanism for SASL authentication" msgstr "mecanismo para autenticação SASL" @@ -5797,7 +5803,7 @@ msgid "%s%s: client capability, server supports: %s" msgstr "" #, c-format -msgid "%s%s: client capability, requesting: sasl" +msgid "%s%s: client capability, requesting: %s" msgstr "" #, c-format diff --git a/po/ru.po b/po/ru.po index 7c7bacc..a9c8c76 100644 --- a/po/ru.po +++ b/po/ru.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-01-24 21:20+0100\n" +"POT-Creation-Date: 2012-02-19 10:45+0100\n" "PO-Revision-Date: 2012-01-07 09:24+0100\n" "Last-Translator: Aleksey V Zapparov AKA ixti \n" "Language-Team: weechat-dev \n" @@ -4940,6 +4940,12 @@ msgstr "" msgid "password for server" msgstr "пароль, используемый при подключении к IRC серверу" +#. TRANSLATORS: please keep word "capabilities" between brackets if translation is different (see fr.po) +msgid "" +"comma-separated list of capabilities to enable for server if they are " +"available (example: \"multi-prefix,extended-join\")" +msgstr "" + #, fuzzy msgid "mechanism for SASL authentication" msgstr "использовать SSL при связи с сервером" @@ -5684,9 +5690,9 @@ msgstr "" msgid "%s%s: client capability, server supports: %s" msgstr "" -#, c-format -msgid "%s%s: client capability, requesting: sasl" -msgstr "" +#, fuzzy, c-format +msgid "%s%s: client capability, requesting: %s" +msgstr "Не могу записать лог-файл \"%s\"\n" #, c-format msgid "%s%s: client capability: sasl not supported" diff --git a/po/weechat.pot b/po/weechat.pot index aba9fdd..07a4652 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: 2012-01-24 21:20+0100\n" +"POT-Creation-Date: 2012-02-19 10:45+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -4243,6 +4243,12 @@ msgstr "" msgid "password for server" msgstr "" +#. TRANSLATORS: please keep word "capabilities" between brackets if translation is different (see fr.po) +msgid "" +"comma-separated list of capabilities to enable for server if they are " +"available (example: \"multi-prefix,extended-join\")" +msgstr "" + msgid "mechanism for SASL authentication" msgstr "" @@ -4897,7 +4903,7 @@ msgid "%s%s: client capability, server supports: %s" msgstr "" #, c-format -msgid "%s%s: client capability, requesting: sasl" +msgid "%s%s: client capability, requesting: %s" msgstr "" #, c-format diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index 9367dec..aed31fe 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -1446,6 +1446,21 @@ irc_config_server_new_option (struct t_config_file *config_file, callback_change, callback_change_data, NULL, NULL); break; + case IRC_SERVER_OPTION_CAP: + new_option = weechat_config_new_option ( + config_file, section, + option_name, "string", + /* TRANSLATORS: please keep word "capabilities" between brackets if translation is different (see fr.po) */ + N_("comma-separated list of capabilities to enable for server " + "if they are available (example: " + "\"multi-prefix,extended-join\")"), + NULL, 0, 0, + default_value, value, + null_value_allowed, + callback_check_value, callback_check_value_data, + callback_change, callback_change_data, + NULL, NULL); + break; case IRC_SERVER_OPTION_SASL_MECHANISM: new_option = weechat_config_new_option ( config_file, section, diff --git a/src/plugins/irc/irc-display.c b/src/plugins/irc/irc-display.c index b65576c..ef16f07 100644 --- a/src/plugins/irc/irc-display.c +++ b/src/plugins/irc/irc-display.c @@ -253,6 +253,14 @@ irc_display_server (struct t_irc_server *server, int with_detail) weechat_printf (NULL, " password . . . . . . : %s%s", IRC_COLOR_CHAT_VALUE, _("(hidden)")); + /* cap (capabilities) */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_CAP])) + weechat_printf (NULL, " cap. . . . . . . . . : ('%s')", + IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_CAP)); + else + weechat_printf (NULL, " cap. . . . . . . . . : %s'%s'", + IRC_COLOR_CHAT_VALUE, + weechat_config_string (server->options[IRC_SERVER_OPTION_CAP])); /* sasl_mechanism */ if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SASL_MECHANISM])) weechat_printf (NULL, " sasl_mechanism . . . : ('%s')", diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index b3bcb0c..c1eb192 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -196,8 +196,10 @@ IRC_PROTOCOL_CALLBACK(authenticate) IRC_PROTOCOL_CALLBACK(cap) { - char *ptr_caps, **items; - int num_items, sasl, i, timeout; + char *ptr_caps, **caps_supported, **caps_requested, *cap_option, *cap_req; + const char *ptr_cap_option; + int num_caps_supported, num_caps_requested, sasl_requested, sasl_to_do; + int i, j, timeout, length; /* * CAP message looks like: @@ -218,35 +220,79 @@ IRC_PROTOCOL_CALLBACK(cap) weechat_prefix ("network"), IRC_PLUGIN_NAME, ptr_caps); - sasl = 0; - items = weechat_string_split (ptr_caps, " ", 0, 0, &num_items); - if (items) + + /* auto-enable capabilities only when connecting to server */ + if (!server->is_connected) { - for (i = 0; i < num_items; i++) + sasl_requested = irc_server_sasl_enabled (server); + sasl_to_do = 0; + ptr_cap_option = IRC_SERVER_OPTION_STRING(server, + IRC_SERVER_OPTION_CAP); + length = ((ptr_cap_option && ptr_cap_option[0]) ? strlen (ptr_cap_option) : 0) + 16; + cap_option = malloc (length); + cap_req = malloc (length); + if (cap_option && cap_req) { - if (strcmp (items[i], "sasl") == 0) + cap_option[0] = '\0'; + if (ptr_cap_option && ptr_cap_option[0]) + strcat (cap_option, ptr_cap_option); + if (sasl_requested) { - sasl = 1; - break; + if (cap_option[0]) + strcat (cap_option, ","); + strcat (cap_option, "sasl"); + } + cap_req[0] = '\0'; + caps_requested = weechat_string_split (cap_option, ",", 0, 0, + &num_caps_requested); + caps_supported = weechat_string_split (ptr_caps, " ", 0, 0, + &num_caps_supported); + if (caps_requested && caps_supported) + { + for (i = 0; i < num_caps_requested; i++) + { + for (j = 0; j < num_caps_supported; j++) + { + if (weechat_strcasecmp (caps_requested[i], + caps_supported[j]) == 0) + { + if (strcmp (caps_requested[i], "sasl") == 0) + sasl_to_do = 1; + if (cap_req[0]) + strcat (cap_req, " "); + strcat (cap_req, caps_supported[j]); + } + } + } + } + if (caps_requested) + weechat_string_free_split (caps_requested); + if (caps_supported) + weechat_string_free_split (caps_supported); + if (cap_req[0]) + { + weechat_printf (server->buffer, + _("%s%s: client capability, requesting: %s"), + weechat_prefix ("network"), + IRC_PLUGIN_NAME, + cap_req); + irc_server_sendf (server, 0, NULL, + "CAP REQ :%s", cap_req); + } + if (!sasl_to_do) + irc_server_sendf (server, 0, NULL, "CAP END"); + if (sasl_requested && !sasl_to_do) + { + weechat_printf (server->buffer, + _("%s%s: client capability: sasl not supported"), + weechat_prefix ("network"), + IRC_PLUGIN_NAME); } } - weechat_string_free_split (items); - } - if (sasl) - { - weechat_printf (server->buffer, - _("%s%s: client capability, requesting: sasl"), - weechat_prefix ("network"), - IRC_PLUGIN_NAME); - irc_server_sendf (server, 0, NULL, "CAP REQ :sasl"); - } - else - { - weechat_printf (server->buffer, - _("%s%s: client capability: sasl not supported"), - weechat_prefix ("network"), - IRC_PLUGIN_NAME); - irc_server_sendf (server, 0, NULL, "CAP END"); + if (cap_option) + free (cap_option); + if (cap_req) + free (cap_req); } } } @@ -259,7 +305,21 @@ IRC_PROTOCOL_CALLBACK(cap) _("%s%s: client capability, enabled: %s"), weechat_prefix ("network"), IRC_PLUGIN_NAME, ptr_caps); - if (strcmp (ptr_caps, "sasl") == 0) + sasl_to_do = 0; + caps_supported = weechat_string_split (ptr_caps, " ", 0, 0, + &num_caps_supported); + if (caps_supported) + { + for (i = 0; i < num_caps_supported; i++) + { + if (strcmp (caps_supported[i], "sasl") == 0) + { + sasl_to_do = 1; + break; + } + } + } + if (sasl_to_do) { switch (IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_SASL_MECHANISM)) diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index 0ad2415..8a2ef5a 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -68,7 +68,8 @@ struct t_irc_message *irc_msgq_last_msg = NULL; char *irc_server_option_string[IRC_SERVER_NUM_OPTIONS] = { "addresses", "proxy", "ipv6", "ssl", "ssl_cert", "ssl_priorities", "ssl_dhkey_size", "ssl_verify", - "password", "sasl_mechanism", "sasl_username", "sasl_password", "sasl_timeout", + "password", "cap", + "sasl_mechanism", "sasl_username", "sasl_password", "sasl_timeout", "autoconnect", "autoreconnect", "autoreconnect_delay", "nicks", "username", "realname", "local_hostname", "command", "command_delay", "autojoin", "autorejoin", "autorejoin_delay", @@ -82,7 +83,8 @@ char *irc_server_option_string[IRC_SERVER_NUM_OPTIONS] = char *irc_server_option_default[IRC_SERVER_NUM_OPTIONS] = { "", "", "off", "off", "", "NORMAL", "2048", "on", - "", "plain", "", "", "15", + "", "", + "plain", "", "", "15", "off", "on", "10", "", "", "", "", "", "0", "", "off", "30", @@ -2707,11 +2709,12 @@ irc_server_reconnect_schedule (struct t_irc_server *server) void irc_server_login (struct t_irc_server *server) { - const char *password, *username, *realname; + const char *password, *username, *realname, *cap; password = IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_PASSWORD); username = IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_USERNAME); realname = IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_REALNAME); + cap = IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_CAP); if (password && password[0]) irc_server_sendf (server, 0, NULL, "PASS %s", password); @@ -2726,7 +2729,7 @@ irc_server_login (struct t_irc_server *server) else server->nick_first_tried = irc_server_get_nick_index (server); - if (irc_server_sasl_enabled (server)) + if (irc_server_sasl_enabled (server) || (cap && cap[0])) { irc_server_sendf (server, 0, NULL, "CAP LS"); } @@ -4305,6 +4308,9 @@ irc_server_add_to_infolist (struct t_infolist *infolist, if (!weechat_infolist_new_var_string (ptr_item, "password", IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_PASSWORD))) return 0; + if (!weechat_infolist_new_var_string (ptr_item, "cap", + IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_CAP))) + return 0; if (!weechat_infolist_new_var_integer (ptr_item, "sasl_mechanism", IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_SASL_MECHANISM))) return 0; @@ -4522,6 +4528,13 @@ irc_server_print_log () weechat_log_printf (" password . . . . . . : null"); else weechat_log_printf (" password . . . . . . : (hidden)"); + /* cap (capabilities) */ + if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_CAP])) + weechat_log_printf (" cap. . . . . . . . . : null ('%s')", + IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_CAP)); + else + weechat_log_printf (" cap. . . . . . . . . : '%s'", + weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_CAP])); /* sasl_mechanism */ if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SASL_MECHANISM])) weechat_log_printf (" sasl_mechanism . . . : null ('%s')", diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h index 8a60539..9c347de 100644 --- a/src/plugins/irc/irc-server.h +++ b/src/plugins/irc/irc-server.h @@ -42,6 +42,7 @@ enum t_irc_server_option IRC_SERVER_OPTION_SSL_DHKEY_SIZE, /* Diffie Hellman key size */ IRC_SERVER_OPTION_SSL_VERIFY, /* check if the connection is trusted */ IRC_SERVER_OPTION_PASSWORD, /* password for server */ + IRC_SERVER_OPTION_CAP, /* capabilities to enable on server */ IRC_SERVER_OPTION_SASL_MECHANISM,/* mechanism for SASL authentication */ IRC_SERVER_OPTION_SASL_USERNAME, /* username for SASL authentication */ IRC_SERVER_OPTION_SASL_PASSWORD, /* password for SASL authentication */