diff options
-rw-r--r-- | doc/de/includes/autogen_user_commands.de.adoc | 3 | ||||
-rw-r--r-- | doc/en/includes/autogen_user_commands.en.adoc | 3 | ||||
-rw-r--r-- | doc/fr/includes/autogen_user_commands.fr.adoc | 3 | ||||
-rw-r--r-- | doc/it/includes/autogen_user_commands.it.adoc | 3 | ||||
-rw-r--r-- | doc/ja/includes/autogen_user_commands.ja.adoc | 3 | ||||
-rw-r--r-- | doc/pl/includes/autogen_user_commands.pl.adoc | 3 | ||||
-rw-r--r-- | doc/sr/includes/autogen_user_commands.sr.adoc | 3 | ||||
-rw-r--r-- | po/cs.po | 8 | ||||
-rw-r--r-- | po/de.po | 8 | ||||
-rw-r--r-- | po/es.po | 8 | ||||
-rw-r--r-- | po/fr.po | 16 | ||||
-rw-r--r-- | po/hu.po | 8 | ||||
-rw-r--r-- | po/it.po | 8 | ||||
-rw-r--r-- | po/ja.po | 8 | ||||
-rw-r--r-- | po/pl.po | 8 | ||||
-rw-r--r-- | po/pt.po | 8 | ||||
-rw-r--r-- | po/pt_BR.po | 8 | ||||
-rw-r--r-- | po/ru.po | 8 | ||||
-rw-r--r-- | po/sr.po | 8 | ||||
-rw-r--r-- | po/tr.po | 8 | ||||
-rw-r--r-- | po/weechat.pot | 8 | ||||
-rw-r--r-- | src/plugins/irc/irc-command.c | 17 | ||||
-rw-r--r-- | src/plugins/irc/irc-completion.c | 3 | ||||
-rw-r--r-- | src/plugins/irc/irc-join.c | 110 | ||||
-rw-r--r-- | src/plugins/irc/irc-join.h | 6 | ||||
-rw-r--r-- | tests/unit/plugins/irc/test-irc-join.cpp | 103 |
26 files changed, 312 insertions, 68 deletions
diff --git a/doc/de/includes/autogen_user_commands.de.adoc b/doc/de/includes/autogen_user_commands.de.adoc index 57bcb5a78..f07561132 100644 --- a/doc/de/includes/autogen_user_commands.de.adoc +++ b/doc/de/includes/autogen_user_commands.de.adoc @@ -131,6 +131,7 @@ Beispiele: addraw <channel1>[,<channel2>...] [<key1>[,<key2>...]] del [<channel1> [<channel2>...]] save + sort add: add current channel or a list of channels (with optional keys) to the autojoin option; if you are on the channel and the key is not provided, the key is read in the channel addraw: use the IRC raw format (same as /join command): all channels separated by commas, optional keys separated by commas @@ -138,6 +139,7 @@ Beispiele: channel: channel name key: key for the channel save: save currently joined channels in the autojoin option + sort: sort alphabetically channels in the autojoin option Examples: /autojoin add @@ -147,6 +149,7 @@ Examples: /autojoin del /autojoin del #chan1 /autojoin save + /autojoin sort ---- [[command_irc_ban]] diff --git a/doc/en/includes/autogen_user_commands.en.adoc b/doc/en/includes/autogen_user_commands.en.adoc index 794981923..82eac8a97 100644 --- a/doc/en/includes/autogen_user_commands.en.adoc +++ b/doc/en/includes/autogen_user_commands.en.adoc @@ -131,6 +131,7 @@ Examples: addraw <channel1>[,<channel2>...] [<key1>[,<key2>...]] del [<channel1> [<channel2>...]] save + sort add: add current channel or a list of channels (with optional keys) to the autojoin option; if you are on the channel and the key is not provided, the key is read in the channel addraw: use the IRC raw format (same as /join command): all channels separated by commas, optional keys separated by commas @@ -138,6 +139,7 @@ Examples: channel: channel name key: key for the channel save: save currently joined channels in the autojoin option + sort: sort alphabetically channels in the autojoin option Examples: /autojoin add @@ -147,6 +149,7 @@ Examples: /autojoin del /autojoin del #chan1 /autojoin save + /autojoin sort ---- [[command_irc_ban]] diff --git a/doc/fr/includes/autogen_user_commands.fr.adoc b/doc/fr/includes/autogen_user_commands.fr.adoc index be70fdaa8..5352a6233 100644 --- a/doc/fr/includes/autogen_user_commands.fr.adoc +++ b/doc/fr/includes/autogen_user_commands.fr.adoc @@ -131,6 +131,7 @@ Exemples : addraw <canal1>[,<canal2>...] [<clé1>[,<clé2>...]] del [<canal1> [<canal2>...]] save + sort add : ajouter le canal courant ou une liste de canaux (avec clés facultatives) dans l'option autojoin ; si vous êtes sur le canal et que la clé n'est pas fournie, la clé est lue sur ce canal addraw : utiliser le format brut IRC (identique à la commande /join) : tous les canaux séparés par des virgules, clés facultatives séparées par des virgules @@ -138,6 +139,7 @@ Exemples : channel : nom du canal key : clé pour le canal save : sauver les canaux actuellement joints dans l'option autojoin + sort : trier les canaux de l'option autojoin par ordre alphabétique Exemples : /autojoin add @@ -147,6 +149,7 @@ Exemples : /autojoin del /autojoin del #chan1 /autojoin save + /autojoin sort ---- [[command_irc_ban]] diff --git a/doc/it/includes/autogen_user_commands.it.adoc b/doc/it/includes/autogen_user_commands.it.adoc index 7967f04f4..dc0f67994 100644 --- a/doc/it/includes/autogen_user_commands.it.adoc +++ b/doc/it/includes/autogen_user_commands.it.adoc @@ -131,6 +131,7 @@ Examples: addraw <channel1>[,<channel2>...] [<key1>[,<key2>...]] del [<channel1> [<channel2>...]] save + sort add: add current channel or a list of channels (with optional keys) to the autojoin option; if you are on the channel and the key is not provided, the key is read in the channel addraw: use the IRC raw format (same as /join command): all channels separated by commas, optional keys separated by commas @@ -138,6 +139,7 @@ Examples: channel: channel name key: key for the channel save: save currently joined channels in the autojoin option + sort: sort alphabetically channels in the autojoin option Examples: /autojoin add @@ -147,6 +149,7 @@ Examples: /autojoin del /autojoin del #chan1 /autojoin save + /autojoin sort ---- [[command_irc_ban]] diff --git a/doc/ja/includes/autogen_user_commands.ja.adoc b/doc/ja/includes/autogen_user_commands.ja.adoc index af2962d98..f5c1cdba7 100644 --- a/doc/ja/includes/autogen_user_commands.ja.adoc +++ b/doc/ja/includes/autogen_user_commands.ja.adoc @@ -131,6 +131,7 @@ Examples: addraw <channel1>[,<channel2>...] [<key1>[,<key2>...]] del [<channel1> [<channel2>...]] save + sort add: add current channel or a list of channels (with optional keys) to the autojoin option; if you are on the channel and the key is not provided, the key is read in the channel addraw: use the IRC raw format (same as /join command): all channels separated by commas, optional keys separated by commas @@ -138,6 +139,7 @@ Examples: channel: channel name key: key for the channel save: save currently joined channels in the autojoin option + sort: sort alphabetically channels in the autojoin option Examples: /autojoin add @@ -147,6 +149,7 @@ Examples: /autojoin del /autojoin del #chan1 /autojoin save + /autojoin sort ---- [[command_irc_ban]] diff --git a/doc/pl/includes/autogen_user_commands.pl.adoc b/doc/pl/includes/autogen_user_commands.pl.adoc index f7b9b0049..5cfea8d2b 100644 --- a/doc/pl/includes/autogen_user_commands.pl.adoc +++ b/doc/pl/includes/autogen_user_commands.pl.adoc @@ -131,6 +131,7 @@ Przykłady: addraw <channel1>[,<channel2>...] [<key1>[,<key2>...]] del [<channel1> [<channel2>...]] save + sort add: add current channel or a list of channels (with optional keys) to the autojoin option; if you are on the channel and the key is not provided, the key is read in the channel addraw: use the IRC raw format (same as /join command): all channels separated by commas, optional keys separated by commas @@ -138,6 +139,7 @@ Przykłady: channel: channel name key: key for the channel save: save currently joined channels in the autojoin option + sort: sort alphabetically channels in the autojoin option Examples: /autojoin add @@ -147,6 +149,7 @@ Examples: /autojoin del /autojoin del #chan1 /autojoin save + /autojoin sort ---- [[command_irc_ban]] diff --git a/doc/sr/includes/autogen_user_commands.sr.adoc b/doc/sr/includes/autogen_user_commands.sr.adoc index 12c57a168..a76b59770 100644 --- a/doc/sr/includes/autogen_user_commands.sr.adoc +++ b/doc/sr/includes/autogen_user_commands.sr.adoc @@ -131,6 +131,7 @@ addraw <channel1>[,<channel2>...] [<key1>[,<key2>...]] del [<channel1> [<channel2>...]] save + sort add: add current channel or a list of channels (with optional keys) to the autojoin option; if you are on the channel and the key is not provided, the key is read in the channel addraw: use the IRC raw format (same as /join command): all channels separated by commas, optional keys separated by commas @@ -138,6 +139,7 @@ channel: channel name key: key for the channel save: save currently joined channels in the autojoin option + sort: sort alphabetically channels in the autojoin option Examples: /autojoin add @@ -147,6 +149,7 @@ Examples: /autojoin del /autojoin del #chan1 /autojoin save + /autojoin sort ---- [[command_irc_ban]] @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2022-03-10 21:21+0100\n" +"POT-Creation-Date: 2022-03-11 19:30+0100\n" "PO-Revision-Date: 2022-01-28 09:35+0100\n" "Last-Translator: Ondřej Súkup <mimi.vx@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -6837,7 +6837,7 @@ msgstr "konfigurační nastavení" msgid "" "add [<channel1> [<channel2>...]] || addraw <channel1>[,<channel2>...] " -"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save" +"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save || sort" msgstr "" msgid "" @@ -6851,6 +6851,7 @@ msgid "" "channel: channel name\n" " key: key for the channel\n" " save: save currently joined channels in the autojoin option\n" +" sort: sort alphabetically channels in the autojoin option\n" "\n" "Examples:\n" " /autojoin add\n" @@ -6859,7 +6860,8 @@ msgid "" " /autojoin addraw #chan1,#chan2,#chan3 key1,key2\n" " /autojoin del\n" " /autojoin del #chan1\n" -" /autojoin save" +" /autojoin save\n" +" /autojoin sort" msgstr "" msgid "ban nicks or hosts" @@ -24,7 +24,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2022-03-10 21:21+0100\n" +"POT-Creation-Date: 2022-03-11 19:30+0100\n" "PO-Revision-Date: 2022-01-28 09:35+0100\n" "Last-Translator: Nils Görs <weechatter@arcor.de>\n" "Language-Team: German <kde-i18n-de@kde.org>\n" @@ -8584,7 +8584,7 @@ msgstr "Konfigurationsoptionen" msgid "" "add [<channel1> [<channel2>...]] || addraw <channel1>[,<channel2>...] " -"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save" +"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save || sort" msgstr "" msgid "" @@ -8598,6 +8598,7 @@ msgid "" "channel: channel name\n" " key: key for the channel\n" " save: save currently joined channels in the autojoin option\n" +" sort: sort alphabetically channels in the autojoin option\n" "\n" "Examples:\n" " /autojoin add\n" @@ -8606,7 +8607,8 @@ msgid "" " /autojoin addraw #chan1,#chan2,#chan3 key1,key2\n" " /autojoin del\n" " /autojoin del #chan1\n" -" /autojoin save" +" /autojoin save\n" +" /autojoin sort" msgstr "" msgid "ban nicks or hosts" @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2022-03-10 21:21+0100\n" +"POT-Creation-Date: 2022-03-11 19:30+0100\n" "PO-Revision-Date: 2022-01-28 09:35+0100\n" "Last-Translator: Santiago Forero <santiago@forero.xyz>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -7250,7 +7250,7 @@ msgstr "opciones de configuración" msgid "" "add [<channel1> [<channel2>...]] || addraw <channel1>[,<channel2>...] " -"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save" +"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save || sort" msgstr "" msgid "" @@ -7264,6 +7264,7 @@ msgid "" "channel: channel name\n" " key: key for the channel\n" " save: save currently joined channels in the autojoin option\n" +" sort: sort alphabetically channels in the autojoin option\n" "\n" "Examples:\n" " /autojoin add\n" @@ -7272,7 +7273,8 @@ msgid "" " /autojoin addraw #chan1,#chan2,#chan3 key1,key2\n" " /autojoin del\n" " /autojoin del #chan1\n" -" /autojoin save" +" /autojoin save\n" +" /autojoin sort" msgstr "" msgid "ban nicks or hosts" @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2022-03-10 21:21+0100\n" -"PO-Revision-Date: 2022-03-10 21:22+0100\n" +"POT-Creation-Date: 2022-03-11 19:30+0100\n" +"PO-Revision-Date: 2022-03-11 19:30+0100\n" "Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language: fr\n" @@ -8418,10 +8418,10 @@ msgstr "configurer l'option serveur \"autojoin\"" msgid "" "add [<channel1> [<channel2>...]] || addraw <channel1>[,<channel2>...] " -"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save" +"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save || sort" msgstr "" "add [<canal1> [<canal2>...]] || addraw <canal1>[,<canal2>...] [<clé1>[," -"<clé2>...]] || del [<canal1> [<canal2>...]] || save" +"<clé2>...]] || del [<canal1> [<canal2>...]] || save || sort" msgid "" " add: add current channel or a list of channels (with optional keys) to " @@ -8434,6 +8434,7 @@ msgid "" "channel: channel name\n" " key: key for the channel\n" " save: save currently joined channels in the autojoin option\n" +" sort: sort alphabetically channels in the autojoin option\n" "\n" "Examples:\n" " /autojoin add\n" @@ -8442,7 +8443,8 @@ msgid "" " /autojoin addraw #chan1,#chan2,#chan3 key1,key2\n" " /autojoin del\n" " /autojoin del #chan1\n" -" /autojoin save" +" /autojoin save\n" +" /autojoin sort" msgstr "" " add : ajouter le canal courant ou une liste de canaux (avec clés " "facultatives) dans l'option autojoin ; si vous êtes sur le canal et que la " @@ -8455,6 +8457,7 @@ msgstr "" "channel : nom du canal\n" " key : clé pour le canal\n" " save : sauver les canaux actuellement joints dans l'option autojoin\n" +" sort : trier les canaux de l'option autojoin par ordre alphabétique\n" "\n" "Exemples :\n" " /autojoin add\n" @@ -8463,7 +8466,8 @@ msgstr "" " /autojoin addraw #chan1,#chan2,#chan3 key1,key2\n" " /autojoin del\n" " /autojoin del #chan1\n" -" /autojoin save" +" /autojoin save\n" +" /autojoin sort" msgid "ban nicks or hosts" msgstr "bannir des pseudos ou hôtes" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2022-03-10 21:21+0100\n" +"POT-Creation-Date: 2022-03-11 19:30+0100\n" "PO-Revision-Date: 2021-12-03 12:02+0100\n" "Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -6376,7 +6376,7 @@ msgstr "Nem található az opció\n" msgid "" "add [<channel1> [<channel2>...]] || addraw <channel1>[,<channel2>...] " -"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save" +"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save || sort" msgstr "" msgid "" @@ -6390,6 +6390,7 @@ msgid "" "channel: channel name\n" " key: key for the channel\n" " save: save currently joined channels in the autojoin option\n" +" sort: sort alphabetically channels in the autojoin option\n" "\n" "Examples:\n" " /autojoin add\n" @@ -6398,7 +6399,8 @@ msgid "" " /autojoin addraw #chan1,#chan2,#chan3 key1,key2\n" " /autojoin del\n" " /autojoin del #chan1\n" -" /autojoin save" +" /autojoin save\n" +" /autojoin sort" msgstr "" #, fuzzy @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2022-03-10 21:21+0100\n" +"POT-Creation-Date: 2022-03-11 19:30+0100\n" "PO-Revision-Date: 2022-01-28 09:35+0100\n" "Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -7183,7 +7183,7 @@ msgstr "opzioni di configurazione" msgid "" "add [<channel1> [<channel2>...]] || addraw <channel1>[,<channel2>...] " -"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save" +"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save || sort" msgstr "" msgid "" @@ -7197,6 +7197,7 @@ msgid "" "channel: channel name\n" " key: key for the channel\n" " save: save currently joined channels in the autojoin option\n" +" sort: sort alphabetically channels in the autojoin option\n" "\n" "Examples:\n" " /autojoin add\n" @@ -7205,7 +7206,8 @@ msgid "" " /autojoin addraw #chan1,#chan2,#chan3 key1,key2\n" " /autojoin del\n" " /autojoin del #chan1\n" -" /autojoin save" +" /autojoin save\n" +" /autojoin sort" msgstr "" msgid "ban nicks or hosts" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2022-03-10 21:21+0100\n" +"POT-Creation-Date: 2022-03-11 19:30+0100\n" "PO-Revision-Date: 2022-01-28 09:35+0100\n" "Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n" "Language-Team: Japanese <https://github.com/l/weechat/tree/master/" @@ -8017,7 +8017,7 @@ msgstr "設定オプション" msgid "" "add [<channel1> [<channel2>...]] || addraw <channel1>[,<channel2>...] " -"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save" +"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save || sort" msgstr "" msgid "" @@ -8031,6 +8031,7 @@ msgid "" "channel: channel name\n" " key: key for the channel\n" " save: save currently joined channels in the autojoin option\n" +" sort: sort alphabetically channels in the autojoin option\n" "\n" "Examples:\n" " /autojoin add\n" @@ -8039,7 +8040,8 @@ msgid "" " /autojoin addraw #chan1,#chan2,#chan3 key1,key2\n" " /autojoin del\n" " /autojoin del #chan1\n" -" /autojoin save" +" /autojoin save\n" +" /autojoin sort" msgstr "" msgid "ban nicks or hosts" @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2022-03-10 21:21+0100\n" +"POT-Creation-Date: 2022-03-11 19:30+0100\n" "PO-Revision-Date: 2022-01-28 09:35+0100\n" "Last-Translator: Krzysztof Korościk <soltys@soltys.info>\n" "Language-Team: Polish <kde-i18n-doc@kde.org>\n" @@ -8215,7 +8215,7 @@ msgstr "opcje konfiguracyjne" msgid "" "add [<channel1> [<channel2>...]] || addraw <channel1>[,<channel2>...] " -"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save" +"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save || sort" msgstr "" msgid "" @@ -8229,6 +8229,7 @@ msgid "" "channel: channel name\n" " key: key for the channel\n" " save: save currently joined channels in the autojoin option\n" +" sort: sort alphabetically channels in the autojoin option\n" "\n" "Examples:\n" " /autojoin add\n" @@ -8237,7 +8238,8 @@ msgid "" " /autojoin addraw #chan1,#chan2,#chan3 key1,key2\n" " /autojoin del\n" " /autojoin del #chan1\n" -" /autojoin save" +" /autojoin save\n" +" /autojoin sort" msgstr "" msgid "ban nicks or hosts" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2022-03-10 21:21+0100\n" +"POT-Creation-Date: 2022-03-11 19:30+0100\n" "PO-Revision-Date: 2022-01-28 09:35+0100\n" "Last-Translator: Vasco Almeida <vascomalmeida@sapo.pt>\n" "Language-Team: Portuguese <>\n" @@ -7783,7 +7783,7 @@ msgstr "opções de configuração" msgid "" "add [<channel1> [<channel2>...]] || addraw <channel1>[,<channel2>...] " -"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save" +"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save || sort" msgstr "" msgid "" @@ -7797,6 +7797,7 @@ msgid "" "channel: channel name\n" " key: key for the channel\n" " save: save currently joined channels in the autojoin option\n" +" sort: sort alphabetically channels in the autojoin option\n" "\n" "Examples:\n" " /autojoin add\n" @@ -7805,7 +7806,8 @@ msgid "" " /autojoin addraw #chan1,#chan2,#chan3 key1,key2\n" " /autojoin del\n" " /autojoin del #chan1\n" -" /autojoin save" +" /autojoin save\n" +" /autojoin sort" msgstr "" msgid "ban nicks or hosts" diff --git a/po/pt_BR.po b/po/pt_BR.po index 8efd1ebcb..ff17acf78 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2022-03-10 21:21+0100\n" +"POT-Creation-Date: 2022-03-11 19:30+0100\n" "PO-Revision-Date: 2022-01-28 09:35+0100\n" "Last-Translator: Érico Nogueira <ericonr@disroot.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -7032,7 +7032,7 @@ msgstr "opções de configuração" msgid "" "add [<channel1> [<channel2>...]] || addraw <channel1>[,<channel2>...] " -"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save" +"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save || sort" msgstr "" msgid "" @@ -7046,6 +7046,7 @@ msgid "" "channel: channel name\n" " key: key for the channel\n" " save: save currently joined channels in the autojoin option\n" +" sort: sort alphabetically channels in the autojoin option\n" "\n" "Examples:\n" " /autojoin add\n" @@ -7054,7 +7055,8 @@ msgid "" " /autojoin addraw #chan1,#chan2,#chan3 key1,key2\n" " /autojoin del\n" " /autojoin del #chan1\n" -" /autojoin save" +" /autojoin save\n" +" /autojoin sort" msgstr "" msgid "ban nicks or hosts" @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2022-03-10 21:21+0100\n" +"POT-Creation-Date: 2022-03-11 19:30+0100\n" "PO-Revision-Date: 2021-12-03 12:02+0100\n" "Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -6419,7 +6419,7 @@ msgstr "Не найден параметр\n" msgid "" "add [<channel1> [<channel2>...]] || addraw <channel1>[,<channel2>...] " -"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save" +"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save || sort" msgstr "" msgid "" @@ -6433,6 +6433,7 @@ msgid "" "channel: channel name\n" " key: key for the channel\n" " save: save currently joined channels in the autojoin option\n" +" sort: sort alphabetically channels in the autojoin option\n" "\n" "Examples:\n" " /autojoin add\n" @@ -6441,7 +6442,8 @@ msgid "" " /autojoin addraw #chan1,#chan2,#chan3 key1,key2\n" " /autojoin del\n" " /autojoin del #chan1\n" -" /autojoin save" +" /autojoin save\n" +" /autojoin sort" msgstr "" #, fuzzy @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2022-03-10 21:21+0100\n" +"POT-Creation-Date: 2022-03-11 19:30+0100\n" "PO-Revision-Date: 2022-01-28 09:35+0100\n" "Last-Translator: Ivan Pešić <ivan.pesic@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -8196,7 +8196,7 @@ msgstr "конфигурационе опције" msgid "" "add [<channel1> [<channel2>...]] || addraw <channel1>[,<channel2>...] " -"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save" +"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save || sort" msgstr "" msgid "" @@ -8210,6 +8210,7 @@ msgid "" "channel: channel name\n" " key: key for the channel\n" " save: save currently joined channels in the autojoin option\n" +" sort: sort alphabetically channels in the autojoin option\n" "\n" "Examples:\n" " /autojoin add\n" @@ -8218,7 +8219,8 @@ msgid "" " /autojoin addraw #chan1,#chan2,#chan3 key1,key2\n" " /autojoin del\n" " /autojoin del #chan1\n" -" /autojoin save" +" /autojoin save\n" +" /autojoin sort" msgstr "" msgid "ban nicks or hosts" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2022-03-10 21:21+0100\n" +"POT-Creation-Date: 2022-03-11 19:30+0100\n" "PO-Revision-Date: 2022-01-28 09:35+0100\n" "Last-Translator: Emir SARI <emir_sari@icloud.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -8062,7 +8062,7 @@ msgstr "yapılandırma seçenekleri" msgid "" "add [<channel1> [<channel2>...]] || addraw <channel1>[,<channel2>...] " -"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save" +"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save || sort" msgstr "" msgid "" @@ -8076,6 +8076,7 @@ msgid "" "channel: channel name\n" " key: key for the channel\n" " save: save currently joined channels in the autojoin option\n" +" sort: sort alphabetically channels in the autojoin option\n" "\n" "Examples:\n" " /autojoin add\n" @@ -8084,7 +8085,8 @@ msgid "" " /autojoin addraw #chan1,#chan2,#chan3 key1,key2\n" " /autojoin del\n" " /autojoin del #chan1\n" -" /autojoin save" +" /autojoin save\n" +" /autojoin sort" msgstr "" msgid "ban nicks or hosts" diff --git a/po/weechat.pot b/po/weechat.pot index 8c86c959a..2271ee243 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2022-03-10 21:21+0100\n" +"POT-Creation-Date: 2022-03-11 19:30+0100\n" "PO-Revision-Date: 2014-08-16 10:27+0200\n" "Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -5868,7 +5868,7 @@ msgstr "" msgid "" "add [<channel1> [<channel2>...]] || addraw <channel1>[,<channel2>...] " -"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save" +"[<key1>[,<key2>...]] || del [<channel1> [<channel2>...]] || save || sort" msgstr "" msgid "" @@ -5882,6 +5882,7 @@ msgid "" "channel: channel name\n" " key: key for the channel\n" " save: save currently joined channels in the autojoin option\n" +" sort: sort alphabetically channels in the autojoin option\n" "\n" "Examples:\n" " /autojoin add\n" @@ -5890,7 +5891,8 @@ msgid "" " /autojoin addraw #chan1,#chan2,#chan3 key1,key2\n" " /autojoin del\n" " /autojoin del #chan1\n" -" /autojoin save" +" /autojoin save\n" +" /autojoin sort" msgstr "" msgid "ban nicks or hosts" diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index c02b19234..c2241f34a 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -995,6 +995,13 @@ IRC_COMMAND_CALLBACK(autojoin) goto end; } + /* sort channels */ + if (weechat_strcasecmp (argv[1], "sort") == 0) + { + irc_join_sort_autojoin (ptr_server); + goto end; + } + end: ptr_autojoin = IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_AUTOJOIN); @@ -6784,7 +6791,8 @@ irc_command_init () N_("add [<channel1> [<channel2>...]]" " || addraw <channel1>[,<channel2>...] [<key1>[,<key2>...]]" " || del [<channel1> [<channel2>...]]" - " || save"), + " || save" + " || sort"), N_(" add: add current channel or a list of channels (with optional " "keys) to the autojoin option; if you are on the channel and the " "key is not provided, the key is read in the channel\n" @@ -6795,6 +6803,7 @@ irc_command_init () "channel: channel name\n" " key: key for the channel\n" " save: save currently joined channels in the autojoin option\n" + " sort: sort alphabetically channels in the autojoin option\n" "\n" "Examples:\n" " /autojoin add\n" @@ -6803,11 +6812,13 @@ irc_command_init () " /autojoin addraw #chan1,#chan2,#chan3 key1,key2\n" " /autojoin del\n" " /autojoin del #chan1\n" - " /autojoin save"), + " /autojoin save\n" + " /autojoin sort"), "add %(irc_channels)|%*" " || addraw %(irc_channels) %-" " || del %(irc_channels_autojoin)|%*" - " || save", + " || save" + " || sort", &irc_command_autojoin, NULL, NULL); weechat_hook_command_run ("/away", &irc_command_run_away, NULL, NULL); weechat_hook_command ( diff --git a/src/plugins/irc/irc-completion.c b/src/plugins/irc/irc-completion.c index 289d3779b..8a485dc55 100644 --- a/src/plugins/irc/irc-completion.c +++ b/src/plugins/irc/irc-completion.c @@ -662,7 +662,8 @@ irc_completion_channels_autojoin_cb (const void *pointer, void *data, arraylist = irc_join_split ( ptr_server, - IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_AUTOJOIN)); + IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_AUTOJOIN), + 0); if (!arraylist) return WEECHAT_RC_OK; diff --git a/src/plugins/irc/irc-join.c b/src/plugins/irc/irc-join.c index 7e350b530..4a4a024ea 100644 --- a/src/plugins/irc/irc-join.c +++ b/src/plugins/irc/irc-join.c @@ -33,7 +33,7 @@ /* - * Compares two join channels. + * Compares two join channels (no sort, keyed channels first). */ int @@ -71,6 +71,44 @@ irc_join_compare_cb (void *data, struct t_arraylist *arraylist, } /* + * Compares two join channels (alphabetic sort, keyed channels first). + */ + +int +irc_join_compare_sort_cb (void *data, struct t_arraylist *arraylist, + void *pointer1, void *pointer2) +{ + struct t_irc_server *server; + struct t_irc_join_channel *ptr_join_chan1, *ptr_join_chan2; + int rc; + + /* make C compiler happy */ + (void) arraylist; + + server = (struct t_irc_server *)data; + + ptr_join_chan1 = (struct t_irc_join_channel *)pointer1; + ptr_join_chan2 = (struct t_irc_join_channel *)pointer2; + + /* + * if channel is the same, always consider it's the same, even if the key + * is different + */ + rc = irc_server_strcasecmp (server, ptr_join_chan1->name, + ptr_join_chan2->name); + if (rc == 0) + return 0; + + /* channels with a key are first in list */ + if (ptr_join_chan1->key && !ptr_join_chan2->key) + return -1; + if (!ptr_join_chan1->key && ptr_join_chan2->key) + return 1; + + return rc; +} + +/* * Frees a join channel. */ @@ -122,10 +160,14 @@ irc_join_arraylist_add (struct t_arraylist *arraylist, * command (channels with key first in list), for example: * * #channel1,#channel2,#channel3 key1,key2 + * + * If sort == 1, channels are sorted alphabetically, otherwise in the order + * they are received. + * In all cases, keyed channels are first in list. */ struct t_arraylist * -irc_join_split (struct t_irc_server *server, const char *join) +irc_join_split (struct t_irc_server *server, const char *join, int sort) { struct t_arraylist *arraylist; char **items, **channels, **keys; @@ -171,8 +213,10 @@ irc_join_split (struct t_irc_server *server, const char *join) arraylist = weechat_arraylist_new ( 16, 1, 0, - &irc_join_compare_cb, server, - &irc_join_free_cb, NULL); + (sort) ? &irc_join_compare_sort_cb : &irc_join_compare_cb, + server, + &irc_join_free_cb, + NULL); if (!arraylist) goto end; @@ -282,7 +326,7 @@ irc_join_add_channel (struct t_irc_server *server, if (!channel_name) return NULL; - arraylist = irc_join_split (server, join); + arraylist = irc_join_split (server, join, 0); if (!arraylist) return NULL; @@ -320,11 +364,11 @@ irc_join_add_channels (struct t_irc_server *server, char *new_join; int i, size; - arraylist = irc_join_split (server, join); + arraylist = irc_join_split (server, join, 0); if (!arraylist) return NULL; - arraylist2 = irc_join_split (server, join2); + arraylist2 = irc_join_split (server, join2, 0); if (!arraylist2) { weechat_arraylist_free (arraylist); @@ -424,7 +468,7 @@ irc_join_remove_channel (struct t_irc_server *server, if (!channel_name) return NULL; - arraylist = irc_join_split (server, join); + arraylist = irc_join_split (server, join, 0); if (!arraylist) return NULL; @@ -517,3 +561,53 @@ irc_join_save_channels_to_autojoin (struct t_irc_server *server) weechat_arraylist_free (arraylist); } + +/* + * Sorts channels. + */ + +char * +irc_join_sort_channels (struct t_irc_server *server, const char *join) +{ + struct t_arraylist *arraylist; + char *new_join; + + arraylist = irc_join_split (server, join, 1); + if (!arraylist) + return NULL; + + new_join = irc_join_build_string (arraylist); + + weechat_arraylist_free (arraylist); + + return new_join; +} + +/* + * Sorts channels in autojoin option of a server. + */ + +void +irc_join_sort_autojoin (struct t_irc_server *server) +{ + const char *ptr_autojoin; + char *new_autojoin; + + if (!server) + return; + + ptr_autojoin = IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_AUTOJOIN); + + if (!ptr_autojoin || !ptr_autojoin[0]) + return; + + new_autojoin = irc_join_sort_channels ( + server, + IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_AUTOJOIN)); + if (new_autojoin) + { + weechat_config_option_set (server->options[IRC_SERVER_OPTION_AUTOJOIN], + new_autojoin, 1); + free (new_autojoin); + } +} diff --git a/src/plugins/irc/irc-join.h b/src/plugins/irc/irc-join.h index eb1d396fd..bec30ee60 100644 --- a/src/plugins/irc/irc-join.h +++ b/src/plugins/irc/irc-join.h @@ -29,7 +29,8 @@ struct t_irc_join_channel }; extern struct t_arraylist *irc_join_split (struct t_irc_server *server, - const char *join); + const char *join, + int sort); extern char *irc_join_build_string (struct t_arraylist *arraylist); extern char *irc_join_add_channel (struct t_irc_server *server, const char *join, const char *channel_name, @@ -47,5 +48,8 @@ extern char *irc_join_remove_channel (struct t_irc_server *server, extern void irc_join_remove_channel_from_autojoin (struct t_irc_server *server, const char *channel_name); extern void irc_join_save_channels_to_autojoin (struct t_irc_server *server); +extern char *irc_join_sort_channels (struct t_irc_server *server, + const char *join); +extern void irc_join_sort_autojoin (struct t_irc_server *server); #endif /* WEECHAT_PLUGIN_IRC_JOIN_H */ diff --git a/tests/unit/plugins/irc/test-irc-join.cpp b/tests/unit/plugins/irc/test-irc-join.cpp index 2359ff651..a163b4b0d 100644 --- a/tests/unit/plugins/irc/test-irc-join.cpp +++ b/tests/unit/plugins/irc/test-irc-join.cpp @@ -72,6 +72,19 @@ extern "C" if (str) \ free (str); +#define WEE_CHECK_SORT_CHANNELS(__result, __join) \ + str = irc_join_sort_channels (NULL, __join); \ + if (__result == NULL) \ + { \ + POINTERS_EQUAL(NULL, str); \ + } \ + else \ + { \ + STRCMP_EQUAL(__result, str); \ + } \ + if (str) \ + free (str); + TEST_GROUP(IrcJoin) { }; @@ -91,7 +104,7 @@ TEST(IrcJoin, SplitBuildString) struct t_irc_server *server; char *autojoin; - arraylist = irc_join_split (NULL, NULL); + arraylist = irc_join_split (NULL, NULL, 0); CHECK(arraylist); LONGS_EQUAL(0, arraylist->size); autojoin = irc_join_build_string (arraylist); @@ -103,7 +116,7 @@ TEST(IrcJoin, SplitBuildString) STRCMP_EQUAL("", autojoin); free (autojoin); - arraylist = irc_join_split (NULL, ""); + arraylist = irc_join_split (NULL, "", 0); CHECK(arraylist); LONGS_EQUAL(0, arraylist->size); autojoin = irc_join_build_string (arraylist); @@ -112,7 +125,7 @@ TEST(IrcJoin, SplitBuildString) arraylist_free (arraylist); /* 1 channel, 2 keys (the second is ignored) */ - arraylist = irc_join_split (NULL, "#xyz key_xyz,key_abc"); + arraylist = irc_join_split (NULL, "#xyz key_xyz,key_abc", 0); CHECK(arraylist); LONGS_EQUAL(1, arraylist->size); channels = (struct t_irc_join_channel **)arraylist->data; @@ -125,7 +138,7 @@ TEST(IrcJoin, SplitBuildString) arraylist_free (arraylist); /* 1 channel */ - arraylist = irc_join_split (NULL, "#xyz"); + arraylist = irc_join_split (NULL, "#xyz", 0); CHECK(arraylist); LONGS_EQUAL(1, arraylist->size); channels = (struct t_irc_join_channel **)arraylist->data; @@ -138,7 +151,7 @@ TEST(IrcJoin, SplitBuildString) arraylist_free (arraylist); /* 2 channels */ - arraylist = irc_join_split (NULL, "#xyz,#abc"); + arraylist = irc_join_split (NULL, "#xyz,#abc", 0); CHECK(arraylist); LONGS_EQUAL(2, arraylist->size); channels = (struct t_irc_join_channel **)arraylist->data; @@ -153,7 +166,7 @@ TEST(IrcJoin, SplitBuildString) arraylist_free (arraylist); /* 2 channels, 2 keys */ - arraylist = irc_join_split (NULL, "#xyz,#abc key_xyz,key_abc"); + arraylist = irc_join_split (NULL, "#xyz,#abc key_xyz,key_abc", 0); CHECK(arraylist); LONGS_EQUAL(2, arraylist->size); channels = (struct t_irc_join_channel **)arraylist->data; @@ -168,7 +181,7 @@ TEST(IrcJoin, SplitBuildString) arraylist_free (arraylist); /* 3 channels, 2 keys */ - arraylist = irc_join_split (NULL, "#xyz,#abc,#def key_xyz,key_abc"); + arraylist = irc_join_split (NULL, "#xyz,#abc,#def key_xyz,key_abc", 0); CHECK(arraylist); LONGS_EQUAL(3, arraylist->size); channels = (struct t_irc_join_channel **)arraylist->data; @@ -185,7 +198,7 @@ TEST(IrcJoin, SplitBuildString) arraylist_free (arraylist); /* duplicated channel */ - arraylist = irc_join_split (NULL, "#xyz,#XYZ"); + arraylist = irc_join_split (NULL, "#xyz,#XYZ", 0); CHECK(arraylist); LONGS_EQUAL(1, arraylist->size); channels = (struct t_irc_join_channel **)arraylist->data; @@ -201,7 +214,7 @@ TEST(IrcJoin, SplitBuildString) server = irc_server_alloc ("my_ircd"); CHECK(server); server->casemapping = IRC_SERVER_CASEMAPPING_RFC1459; - arraylist = irc_join_split (server, "#chan[a]^,#CHAN{A}~"); + arraylist = irc_join_split (server, "#chan[a]^,#CHAN{A}~", 0); CHECK(arraylist); LONGS_EQUAL(1, arraylist->size); channels = (struct t_irc_join_channel **)arraylist->data; @@ -218,7 +231,7 @@ TEST(IrcJoin, SplitBuildString) server = irc_server_alloc ("my_ircd"); CHECK(server); server->casemapping = IRC_SERVER_CASEMAPPING_STRICT_RFC1459; - arraylist = irc_join_split (server, "#chan[a]^,#CHAN{A}~"); + arraylist = irc_join_split (server, "#chan[a]^,#CHAN{A}~", 0); CHECK(arraylist); LONGS_EQUAL(2, arraylist->size); channels = (struct t_irc_join_channel **)arraylist->data; @@ -232,6 +245,30 @@ TEST(IrcJoin, SplitBuildString) free (autojoin); arraylist_free (arraylist); irc_server_free (server); + + /* server with casemapping RFC1459, sort channels */ + server = irc_server_alloc ("my_ircd"); + CHECK(server); + server->casemapping = IRC_SERVER_CASEMAPPING_RFC1459; + arraylist = irc_join_split ( + server, "#xyz,#def,#abc,#chan[a]^,#CHAN{A}~ key_xyz", 1); + CHECK(arraylist); + LONGS_EQUAL(4, arraylist->size); + channels = (struct t_irc_join_channel **)arraylist->data; + CHECK(channels[0]); + STRCMP_EQUAL("#xyz", channels[0]->name); + STRCMP_EQUAL("key_xyz", channels[0]->key); + STRCMP_EQUAL("#abc", channels[1]->name); + POINTERS_EQUAL(NULL, channels[1]->key); + STRCMP_EQUAL("#CHAN{A}~", channels[2]->name); + POINTERS_EQUAL(NULL, channels[2]->key); + STRCMP_EQUAL("#def", channels[3]->name); + POINTERS_EQUAL(NULL, channels[3]->key); + autojoin = irc_join_build_string (arraylist); + STRCMP_EQUAL("#xyz,#abc,#CHAN{A}~,#def key_xyz", autojoin); + free (autojoin); + arraylist_free (arraylist); + irc_server_free (server); } /* @@ -325,6 +362,25 @@ TEST(IrcJoin, RemoveChannel) /* * Tests functions: + * irc_join_sort_channels + */ + +TEST(IrcJoin, SortChannels) +{ + char *str; + + WEE_CHECK_SORT_CHANNELS("", NULL); + WEE_CHECK_SORT_CHANNELS("", ""); + + WEE_CHECK_SORT_CHANNELS("#abc", "#abc"); + WEE_CHECK_SORT_CHANNELS("#ABC,#def,#GHI", "#GHI,#def,#ABC"); + WEE_CHECK_SORT_CHANNELS("#xyz,#abc key_xyz", "#xyz,#abc key_xyz"); + WEE_CHECK_SORT_CHANNELS("#xyz,#zzz,#ABC,#def,#ghi key_xyz,key_zzz", + "#zzz,#xyz,#ghi,#def,#ABC key_zzz,key_xyz"); +} + +/* + * Tests functions: * irc_join_add_channel_to_autojoin * irc_join_add_channels_to_autojoin * irc_join_remove_channel_from_autojoin @@ -441,3 +497,30 @@ TEST(IrcJoin, SaveChannelsToAutojoin) irc_server_free (server); } + +/* + * Tests functions: + * irc_join_sort_autojoin_channels + */ + +TEST(IrcJoin, SortAutojoinChannels) +{ + struct t_irc_server *server; + + server = irc_server_alloc ("my_ircd"); + CHECK(server); + + irc_join_add_channel_to_autojoin (server, "#zzz", "key_zzz"); + irc_join_add_channel_to_autojoin (server, "#xyz", "key_xyz"); + irc_join_add_channel_to_autojoin (server, "#ghi", NULL); + irc_join_add_channel_to_autojoin (server, "#def", NULL); + irc_join_add_channel_to_autojoin (server, "#ABC", NULL); + STRCMP_EQUAL("#zzz,#xyz,#ghi,#def,#ABC key_zzz,key_xyz", + CONFIG_STRING(server->options[IRC_SERVER_OPTION_AUTOJOIN])); + + irc_join_sort_autojoin (server); + STRCMP_EQUAL("#xyz,#zzz,#ABC,#def,#ghi key_xyz,key_zzz", + CONFIG_STRING(server->options[IRC_SERVER_OPTION_AUTOJOIN])); + + irc_server_free (server); +} |