diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2020-03-20 20:42:05 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2020-03-20 20:42:05 +0100 |
commit | c29b45a0f2ef86fde6e6a28317ba13d5d873ee5d (patch) | |
tree | 31ceab57d66eecad367c5ca674afa6900dfbd6d3 | |
parent | c05cb595dc83f0691227e004fc74017dc9b5fad9 (diff) | |
download | weechat-c29b45a0f2ef86fde6e6a28317ba13d5d873ee5d.zip |
api: add info "auto_connect" (closes #1453)
-rw-r--r-- | ChangeLog.adoc | 1 | ||||
-rw-r--r-- | ReleaseNotes.adoc | 34 | ||||
-rw-r--r-- | doc/de/autogen/plugin_api/infos.adoc | 2 | ||||
-rw-r--r-- | doc/en/autogen/plugin_api/infos.adoc | 2 | ||||
-rw-r--r-- | doc/fr/autogen/plugin_api/infos.adoc | 2 | ||||
-rw-r--r-- | doc/it/autogen/plugin_api/infos.adoc | 2 | ||||
-rw-r--r-- | doc/ja/autogen/plugin_api/infos.adoc | 2 | ||||
-rw-r--r-- | doc/pl/autogen/plugin_api/infos.adoc | 2 | ||||
-rw-r--r-- | po/cs.po | 7 | ||||
-rw-r--r-- | po/de.po | 7 | ||||
-rw-r--r-- | po/es.po | 7 | ||||
-rw-r--r-- | po/fr.po | 11 | ||||
-rw-r--r-- | po/hu.po | 7 | ||||
-rw-r--r-- | po/it.po | 7 | ||||
-rw-r--r-- | po/ja.po | 7 | ||||
-rw-r--r-- | po/pl.po | 7 | ||||
-rw-r--r-- | po/pt.po | 7 | ||||
-rw-r--r-- | po/pt_BR.po | 7 | ||||
-rw-r--r-- | po/ru.po | 7 | ||||
-rw-r--r-- | po/tr.po | 7 | ||||
-rw-r--r-- | po/weechat.pot | 7 | ||||
-rw-r--r-- | src/core/weechat.c | 3 | ||||
-rw-r--r-- | src/core/weechat.h | 1 | ||||
-rw-r--r-- | src/plugins/irc/irc.c | 16 | ||||
-rw-r--r-- | src/plugins/plugin-api-info.c | 26 | ||||
-rw-r--r-- | src/plugins/plugin.c | 30 |
26 files changed, 187 insertions, 31 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 51950e48e..bbd8c3955 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -23,6 +23,7 @@ New features:: * core: add variable "old_full_name" in buffer, set during buffer renaming (issue #1428) * core: add debug option "-d" in command /eval (issue #1434) * api: add functions crypto_hash and crypto_hash_pbkdf2 + * api: add info "auto_connect" (issue #1453) * api: add info "weechat_headless" (issue #1433) * buflist: add pointer "window" in bar item evaluation * irc: add support of fake servers (no I/O, for testing purposes) diff --git a/ReleaseNotes.adoc b/ReleaseNotes.adoc index 122862437..fa490aedf 100644 --- a/ReleaseNotes.adoc +++ b/ReleaseNotes.adoc @@ -17,6 +17,40 @@ https://weechat.org/files/changelog/ChangeLog-devel.html[ChangeLog] (file _ChangeLog.adoc_ in sources). +[[v2.8]] +== Version 2.8 (under dev) + +[[v2.8_auto_connection_to_servers]] +=== Auto connection to servers + +The command line option `-a` (or `--no-connect`), which can also be used in the +`/plugin` command, is now used to set a new info called `auto_connect` +(see the function "info_get" in the Plugin API reference). + +Therefore, the option is not sent any more to the function `weechat_plugin_init` +of plugins. + +The plugins using this option must now get the info `auto_connect` and check +if the value is "1" (a string with just `1`). + +The purpose of this change is to allow scripts as well to check this info on +startup, and connect or not, depending on the value (see issue #1453). + +To be compatible with WeeChat ≤ 2.7, the script can do this, for example +in Python: + +[source,python] +---- +auto_connect = weechat.info_get("auto_connect", "") != "0" +---- + +The variable `auto_connect` will be set like that, depending on the WeeChat +version: + +* WeeChat ≤ 2.7: always `True` because the info is an empty string (it does not + exist), which is different from "0", +* WeeChat ≥ 2.8: `True` by default, and `False` if `-a` or `--no-connect` is + given by the user (either on command line or when loading the plugin). + [[v2.7.1]] == Version 2.7.1 (2020-02-20) diff --git a/doc/de/autogen/plugin_api/infos.adoc b/doc/de/autogen/plugin_api/infos.adoc index a0d251a16..f4f8c3f5e 100644 --- a/doc/de/autogen/plugin_api/infos.adoc +++ b/doc/de/autogen/plugin_api/infos.adoc @@ -80,6 +80,8 @@ | tcl | tcl_version | Version des verwendeten Interpreters | - +| weechat | auto_connect | 1 if automatic connection to servers is enabled, 0 if it has been disabled by the user (option "-a" or "--no-connect") | - + | weechat | charset_internal | Interner WeeChat Zeichensatz | - | weechat | charset_terminal | Terminal Zeichensatz | - diff --git a/doc/en/autogen/plugin_api/infos.adoc b/doc/en/autogen/plugin_api/infos.adoc index 1bb0c2ea7..63f1f3b9b 100644 --- a/doc/en/autogen/plugin_api/infos.adoc +++ b/doc/en/autogen/plugin_api/infos.adoc @@ -80,6 +80,8 @@ | tcl | tcl_version | version of the interpreter used | - +| weechat | auto_connect | 1 if automatic connection to servers is enabled, 0 if it has been disabled by the user (option "-a" or "--no-connect") | - + | weechat | charset_internal | WeeChat internal charset | - | weechat | charset_terminal | terminal charset | - diff --git a/doc/fr/autogen/plugin_api/infos.adoc b/doc/fr/autogen/plugin_api/infos.adoc index cba4b3075..8b2fd684c 100644 --- a/doc/fr/autogen/plugin_api/infos.adoc +++ b/doc/fr/autogen/plugin_api/infos.adoc @@ -80,6 +80,8 @@ | tcl | tcl_version | version de l'interpréteur utilisé | - +| weechat | auto_connect | 1 si la connexion automatique aux serveurs est activée, 0 si elle a été désactivée par l'utilisateur (option "-a" ou "--no-connect") | - + | weechat | charset_internal | charset interne à WeeChat | - | weechat | charset_terminal | charset du terminal | - diff --git a/doc/it/autogen/plugin_api/infos.adoc b/doc/it/autogen/plugin_api/infos.adoc index 163edb926..b6ec11c50 100644 --- a/doc/it/autogen/plugin_api/infos.adoc +++ b/doc/it/autogen/plugin_api/infos.adoc @@ -80,6 +80,8 @@ | tcl | tcl_version | version of the interpreter used | - +| weechat | auto_connect | 1 if automatic connection to servers is enabled, 0 if it has been disabled by the user (option "-a" or "--no-connect") | - + | weechat | charset_internal | set caratteri interno di WeeChat | - | weechat | charset_terminal | set caratteri terminale | - diff --git a/doc/ja/autogen/plugin_api/infos.adoc b/doc/ja/autogen/plugin_api/infos.adoc index 209d22f8e..617c56ac9 100644 --- a/doc/ja/autogen/plugin_api/infos.adoc +++ b/doc/ja/autogen/plugin_api/infos.adoc @@ -80,6 +80,8 @@ | tcl | tcl_version | 使用中のインタプリタのバージョン | - +| weechat | auto_connect | 1 if automatic connection to servers is enabled, 0 if it has been disabled by the user (option "-a" or "--no-connect") | - + | weechat | charset_internal | WeeChat 内部文字セット | - | weechat | charset_terminal | 端末の文字セット | - diff --git a/doc/pl/autogen/plugin_api/infos.adoc b/doc/pl/autogen/plugin_api/infos.adoc index 48eb4a626..5c4d28001 100644 --- a/doc/pl/autogen/plugin_api/infos.adoc +++ b/doc/pl/autogen/plugin_api/infos.adoc @@ -80,6 +80,8 @@ | tcl | tcl_version | wersja użytego interpretera | - +| weechat | auto_connect | 1 if automatic connection to servers is enabled, 0 if it has been disabled by the user (option "-a" or "--no-connect") | - + | weechat | charset_internal | wewnętrzne kodowanie WeeChat | - | weechat | charset_terminal | kodowanie terminala | - @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-03-08 14:21+0100\n" +"POT-Creation-Date: 2020-03-20 12:21+0100\n" "PO-Revision-Date: 2020-03-08 14:22+0100\n" "Last-Translator: Ondřej Súkup <mimi.vx@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -10184,6 +10184,11 @@ msgstr "1 pokud se WeeChat aktualizuje (příkaz `/upgrade`)" msgid "1 if WeeChat is running headless" msgstr "1 pokud se WeeChat aktualizuje (příkaz `/upgrade`)" +msgid "" +"1 if automatic connection to servers is enabled, 0 if it has been disabled " +"by the user (option \"-a\" or \"--no-connect\")" +msgstr "" + msgid "terminal charset" msgstr "znaková sada terminálu" @@ -24,7 +24,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-03-08 14:21+0100\n" +"POT-Creation-Date: 2020-03-20 12:21+0100\n" "PO-Revision-Date: 2020-03-14 21:11+0100\n" "Last-Translator: Nils Görs <weechatter@arcor.de>\n" "Language-Team: German <kde-i18n-de@kde.org>\n" @@ -12054,6 +12054,11 @@ msgstr "1 falls WeeChat ein Upgrade durchführt (Befehl `/upgrade`)" msgid "1 if WeeChat is running headless" msgstr "1, falls WeeChat im Hintergrundmodus ausgeführt wird" +msgid "" +"1 if automatic connection to servers is enabled, 0 if it has been disabled " +"by the user (option \"-a\" or \"--no-connect\")" +msgstr "" + msgid "terminal charset" msgstr "Terminal Zeichensatz" @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-03-08 14:21+0100\n" +"POT-Creation-Date: 2020-03-20 12:21+0100\n" "PO-Revision-Date: 2020-03-08 14:22+0100\n" "Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -10497,6 +10497,11 @@ msgstr "1 si WeeChat se está actualizando (comando `/upgrade`)" msgid "1 if WeeChat is running headless" msgstr "1 si WeeChat se está actualizando (comando `/upgrade`)" +msgid "" +"1 if automatic connection to servers is enabled, 0 if it has been disabled " +"by the user (option \"-a\" or \"--no-connect\")" +msgstr "" + msgid "terminal charset" msgstr "set de caracteres de la terminal" @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-03-08 14:21+0100\n" -"PO-Revision-Date: 2020-03-08 14:22+0100\n" +"POT-Creation-Date: 2020-03-20 12:21+0100\n" +"PO-Revision-Date: 2020-03-20 20:22+0100\n" "Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language: fr\n" @@ -11781,6 +11781,13 @@ msgstr "1 si WeeChat est en cours de mise à jour (commande `/upgrade`)" msgid "1 if WeeChat is running headless" msgstr "1 si WeeChat tourne sans interface" +msgid "" +"1 if automatic connection to servers is enabled, 0 if it has been disabled " +"by the user (option \"-a\" or \"--no-connect\")" +msgstr "" +"1 si la connexion automatique aux serveurs est activée, 0 si elle a été " +"désactivée par l'utilisateur (option \"-a\" ou \"--no-connect\")" + msgid "terminal charset" msgstr "charset du terminal" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-03-08 14:21+0100\n" +"POT-Creation-Date: 2020-03-20 12:21+0100\n" "PO-Revision-Date: 2020-03-08 14:22+0100\n" "Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -9538,6 +9538,11 @@ msgstr "" msgid "1 if WeeChat is running headless" msgstr "" +msgid "" +"1 if automatic connection to servers is enabled, 0 if it has been disabled " +"by the user (option \"-a\" or \"--no-connect\")" +msgstr "" + #, fuzzy msgid "terminal charset" msgstr "pufferek kezelése" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-03-08 14:21+0100\n" +"POT-Creation-Date: 2020-03-20 12:21+0100\n" "PO-Revision-Date: 2020-03-08 14:22+0100\n" "Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -10682,6 +10682,11 @@ msgstr "1 se si sta aggiornando WeeChat (comando `/upgrade`)" msgid "1 if WeeChat is running headless" msgstr "1 se si sta aggiornando WeeChat (comando `/upgrade`)" +msgid "" +"1 if automatic connection to servers is enabled, 0 if it has been disabled " +"by the user (option \"-a\" or \"--no-connect\")" +msgstr "" + msgid "terminal charset" msgstr "set caratteri terminale" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-03-08 14:21+0100\n" +"POT-Creation-Date: 2020-03-20 12:21+0100\n" "PO-Revision-Date: 2020-03-08 14:22+0100\n" "Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n" "Language-Team: Japanese <https://github.com/l/weechat/tree/master/" @@ -11309,6 +11309,11 @@ msgstr "WeeChat がアップグレード中は 1 (コマンド `/upgrade`)" msgid "1 if WeeChat is running headless" msgstr "WeeChat をヘッドレスモードで実行中 (Ctrl-C で終了します)。" +msgid "" +"1 if automatic connection to servers is enabled, 0 if it has been disabled " +"by the user (option \"-a\" or \"--no-connect\")" +msgstr "" + msgid "terminal charset" msgstr "端末の文字セット" @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-03-08 14:21+0100\n" +"POT-Creation-Date: 2020-03-20 12:21+0100\n" "PO-Revision-Date: 2020-03-08 14:22+0100\n" "Last-Translator: Krzysztof Korościk <soltys@soltys.info>\n" "Language-Team: Polish <kde-i18n-doc@kde.org>\n" @@ -11517,6 +11517,11 @@ msgstr "1 jeżeli WeeChat jest aktualizowany (komenda `/upgrade`)" msgid "1 if WeeChat is running headless" msgstr "WeeChat działa w trybie bez interfejsu (naciśnij Ctrl-C żeby wyjść)." +msgid "" +"1 if automatic connection to servers is enabled, 0 if it has been disabled " +"by the user (option \"-a\" or \"--no-connect\")" +msgstr "" + msgid "terminal charset" msgstr "kodowanie terminala" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-03-08 14:21+0100\n" +"POT-Creation-Date: 2020-03-20 12:21+0100\n" "PO-Revision-Date: 2020-03-08 14:22+0100\n" "Last-Translator: Vasco Almeida <vascomalmeida@sapo.pt>\n" "Language-Team: Portuguese <>\n" @@ -11144,6 +11144,11 @@ msgstr "1 se o WeeChat está a atualizar (comando `/upgrade`)" msgid "1 if WeeChat is running headless" msgstr "1 se o WeeChat está a atualizar (comando `/upgrade`)" +msgid "" +"1 if automatic connection to servers is enabled, 0 if it has been disabled " +"by the user (option \"-a\" or \"--no-connect\")" +msgstr "" + msgid "terminal charset" msgstr "charset do termianl" diff --git a/po/pt_BR.po b/po/pt_BR.po index 37f6da094..4bd4260dc 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: 2020-03-08 14:21+0100\n" +"POT-Creation-Date: 2020-03-20 12:21+0100\n" "PO-Revision-Date: 2019-11-03 08:38+0100\n" "Last-Translator: Eduardo Elias <camponez@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -9984,6 +9984,11 @@ msgstr "1 se o WeeChat está sendo atualizado (comando `/upgrade`)" msgid "1 if WeeChat is running headless" msgstr "1 se o WeeChat está sendo atualizado (comando `/upgrade`)" +msgid "" +"1 if automatic connection to servers is enabled, 0 if it has been disabled " +"by the user (option \"-a\" or \"--no-connect\")" +msgstr "" + msgid "terminal charset" msgstr "charset do terminar" @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-03-08 14:21+0100\n" +"POT-Creation-Date: 2020-03-20 12:21+0100\n" "PO-Revision-Date: 2020-03-08 14:22+0100\n" "Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -9574,6 +9574,11 @@ msgstr "" msgid "1 if WeeChat is running headless" msgstr "" +msgid "" +"1 if automatic connection to servers is enabled, 0 if it has been disabled " +"by the user (option \"-a\" or \"--no-connect\")" +msgstr "" + #, fuzzy msgid "terminal charset" msgstr "управление буферами" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-03-08 14:21+0100\n" +"POT-Creation-Date: 2020-03-20 12:21+0100\n" "PO-Revision-Date: 2019-11-03 08:38+0100\n" "Last-Translator: Hasan Kiran <sunder67@hotmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -8705,6 +8705,11 @@ msgstr "" msgid "1 if WeeChat is running headless" msgstr "" +msgid "" +"1 if automatic connection to servers is enabled, 0 if it has been disabled " +"by the user (option \"-a\" or \"--no-connect\")" +msgstr "" + msgid "terminal charset" msgstr "" diff --git a/po/weechat.pot b/po/weechat.pot index 23eedbc1a..0304f9b90 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: 2020-03-08 14:21+0100\n" +"POT-Creation-Date: 2020-03-20 12:21+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" @@ -8566,6 +8566,11 @@ msgstr "" msgid "1 if WeeChat is running headless" msgstr "" +msgid "" +"1 if automatic connection to servers is enabled, 0 if it has been disabled " +"by the user (option \"-a\" or \"--no-connect\")" +msgstr "" + msgid "terminal charset" msgstr "" diff --git a/src/core/weechat.c b/src/core/weechat.c index e88988eff..04b09da0c 100644 --- a/src/core/weechat.c +++ b/src/core/weechat.c @@ -114,6 +114,7 @@ int weechat_no_gcrypt = 0; /* remove init/deinit of gcrypt */ /* (useful with valgrind) */ struct t_weelist *weechat_startup_commands = NULL; /* startup commands */ /* (option -r) */ +int weechat_auto_connect = 1; /* auto-connect to servers */ /* @@ -256,7 +257,7 @@ weechat_parse_args (int argc, char *argv[]) switch (opt) { case 'a': /* -a / --no-connect */ - /* option ignored, it will be used by the irc plugin */ + /* option ignored, it will be used by plugins/scripts */ break; case 'c': /* -c / --colors */ gui_color_display_terminal_colors (); diff --git a/src/core/weechat.h b/src/core/weechat.h index 2fab8044d..274d54392 100644 --- a/src/core/weechat.h +++ b/src/core/weechat.h @@ -116,6 +116,7 @@ extern int weechat_plugin_no_dlclose; extern int weechat_no_gnutls; extern int weechat_no_gcrypt; extern struct t_weelist *weechat_startup_commands; +extern int weechat_auto_connect; extern void weechat_term_check (); extern void weechat_shutdown (int return_code, int crash); diff --git a/src/plugins/irc/irc.c b/src/plugins/irc/irc.c index b838d4ea5..ad1bc7357 100644 --- a/src/plugins/irc/irc.c +++ b/src/plugins/irc/irc.c @@ -165,6 +165,7 @@ int weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) { int i, auto_connect; + char *info_auto_connect; weechat_plugin = plugin; @@ -217,16 +218,17 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) irc_bar_item_init (); + /* check if auto-connect is enabled */ + info_auto_connect = weechat_info_get ("auto_connect", NULL); + auto_connect = (info_auto_connect && (strcmp (info_auto_connect, "1") == 0)) ? + 1 : 0; + if (info_auto_connect) + free (info_auto_connect); + /* look at arguments */ - auto_connect = 1; for (i = 0; i < argc; i++) { - if ((weechat_strcasecmp (argv[i], "-a") == 0) - || (weechat_strcasecmp (argv[i], "--no-connect") == 0)) - { - auto_connect = 0; - } - else if ((weechat_strncasecmp (argv[i], IRC_PLUGIN_NAME, 3) == 0)) + if ((weechat_strncasecmp (argv[i], IRC_PLUGIN_NAME, 3) == 0)) { if (!irc_server_alloc_with_url (argv[i])) { diff --git a/src/plugins/plugin-api-info.c b/src/plugins/plugin-api-info.c index e97913b0e..2dc32cadc 100644 --- a/src/plugins/plugin-api-info.c +++ b/src/plugins/plugin-api-info.c @@ -338,6 +338,27 @@ plugin_api_info_weechat_headless_cb (const void *pointer, void *data, } /* + * Returns WeeChat info "auto_connect". + */ + +char * +plugin_api_info_auto_connect_cb (const void *pointer, void *data, + const char *info_name, + const char *arguments) +{ + char value[32]; + + /* make C compiler happy */ + (void) pointer; + (void) data; + (void) info_name; + (void) arguments; + + snprintf (value, sizeof (value), "%d", weechat_auto_connect); + return strdup (value); +} + +/* * Returns WeeChat info "charset_terminal". */ @@ -1764,6 +1785,11 @@ plugin_api_info_init () hook_info (NULL, "weechat_headless", N_("1 if WeeChat is running headless"), NULL, &plugin_api_info_weechat_headless_cb, NULL, NULL); + hook_info (NULL, "auto_connect", + N_("1 if automatic connection to servers is enabled, " + "0 if it has been disabled by the user (option \"-a\" or " + "\"--no-connect\")"), + NULL, &plugin_api_info_auto_connect_cb, NULL, NULL); hook_info (NULL, "charset_terminal", N_("terminal charset"), NULL, &plugin_api_info_charset_terminal_cb, NULL, NULL); diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index 6497c2739..f2065f191 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -271,7 +271,8 @@ plugin_check_autoload (const char *filename) void plugin_get_args (struct t_weechat_plugin *plugin, int argc, char **argv, - int *plugin_argc, char ***plugin_argv) + int *plugin_argc, char ***plugin_argv, + int *no_connect) { int i, temp_argc, length_plugin_name; char **temp_argv; @@ -279,6 +280,8 @@ plugin_get_args (struct t_weechat_plugin *plugin, temp_argc = 0; temp_argv = NULL; + *no_connect = 0; + length_plugin_name = strlen (plugin->name); if (argc > 0) @@ -289,12 +292,15 @@ plugin_get_args (struct t_weechat_plugin *plugin, for (i = 0; i < argc; i++) { if ((strcmp (argv[i], "-a") == 0) - || (strcmp (argv[i], "--no-connect") == 0) - || (strcmp (argv[i], "-s") == 0) - || (strcmp (argv[i], "--no-script") == 0) - || ((strncmp (argv[i], plugin->name, - length_plugin_name) == 0) - && (argv[i][length_plugin_name] == ':'))) + || (strcmp (argv[i], "--no-connect") == 0)) + { + *no_connect = 1; + } + else if ((strcmp (argv[i], "-s") == 0) + || (strcmp (argv[i], "--no-script") == 0) + || ((strncmp (argv[i], plugin->name, + length_plugin_name) == 0) + && (argv[i][length_plugin_name] == ':'))) { temp_argv[temp_argc++] = argv[i]; } @@ -325,7 +331,7 @@ int plugin_call_init (struct t_weechat_plugin *plugin, int argc, char **argv) { t_weechat_init_func *init_func; - int plugin_argc, rc; + int plugin_argc, no_connect, rc, old_auto_connect; char **plugin_argv; if (plugin->initialized) @@ -337,7 +343,11 @@ plugin_call_init (struct t_weechat_plugin *plugin, int argc, char **argv) return 0; /* get arguments for the plugin */ - plugin_get_args (plugin, argc, argv, &plugin_argc, &plugin_argv); + plugin_get_args (plugin, argc, argv, + &plugin_argc, &plugin_argv, &no_connect); + + old_auto_connect = weechat_auto_connect; + weechat_auto_connect = (no_connect) ? 0 : 1; /* init plugin */ if (weechat_debug_core >= 1) @@ -362,6 +372,8 @@ plugin_call_init (struct t_weechat_plugin *plugin, int argc, char **argv) plugin->filename); } + weechat_auto_connect = old_auto_connect; + if (plugin_argv) free (plugin_argv); |