From 0995eb334f919f2038b8409aab17f2d67470c381 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Wed, 5 Mar 2014 11:43:32 +0100 Subject: [PATCH] relay: add signals "relay_client_xxx" for client status changes (closes #2) New signals: - relay_client_connecting - relay_client_waiting_auth - relay_client_connected - relay_client_auth_failed - relay_client_disconnected --- ChangeLog.asciidoc | 1 + doc/en/weechat_plugin_api.en.txt | 25 +++++++++++++++++++++++++ doc/fr/weechat_plugin_api.fr.txt | 25 +++++++++++++++++++++++++ doc/it/weechat_plugin_api.it.txt | 30 ++++++++++++++++++++++++++++++ doc/ja/weechat_plugin_api.ja.txt | 30 ++++++++++++++++++++++++++++++ src/plugins/relay/relay-client.c | 25 ++++++++++++++++++++++++- 6 files changed, 135 insertions(+), 1 deletion(-) diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc index 0aa4b3c81..db0909de6 100644 --- a/ChangeLog.asciidoc +++ b/ChangeLog.asciidoc @@ -59,6 +59,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] * lua: fix interpreter used after unload of a script * perl: fix context used after unload of a script * python: fix interpreter used after unload of a script +* relay: add signals "relay_client_xxx" for client status changes (closes #2) * relay: add option relay.network.clients_purge_delay * relay: fix freeze after /upgrade when many disconnected clients still exist * relay: fix NULL pointer when reading buffer lines for irc backlog diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt index c8a06524c..4fdaf749d 100644 --- a/doc/en/weechat_plugin_api.en.txt +++ b/doc/en/weechat_plugin_api.en.txt @@ -7854,6 +7854,31 @@ List of signals sent by WeeChat and plugins: String: comma-separated list of scripts removed | Python script(s) removed +| relay | relay_client_connecting + + _(WeeChat ≥ 0.4.4)_ | + Pointer: relay client | + A relay client is connecting + +| relay | relay_client_waiting_auth + + _(WeeChat ≥ 0.4.4)_ | + Pointer: relay client | + Waiting for authentication from a relay client + +| relay | relay_client_connected + + _(WeeChat ≥ 0.4.4)_ | + Pointer: relay client | + A relay client is connected + +| relay | relay_client_auth_failed + + _(WeeChat ≥ 0.4.4)_ | + Pointer: relay client | + Authentication of a relay client has failed + +| relay | relay_client_disconnected + + _(WeeChat ≥ 0.4.4)_ | + Pointer: relay client | + A relay client is disconnected + | ruby | ruby_script_loaded + _(WeeChat ≥ 0.3.9)_ | String: path to script | diff --git a/doc/fr/weechat_plugin_api.fr.txt b/doc/fr/weechat_plugin_api.fr.txt index 79cef0b85..0c505952c 100644 --- a/doc/fr/weechat_plugin_api.fr.txt +++ b/doc/fr/weechat_plugin_api.fr.txt @@ -7994,6 +7994,31 @@ Liste des signaux envoyés par WeeChat et les extensions : Chaîne : liste de scripts supprimés (séparés par des virgules) | Script(s) python supprimé(s) +| relay | relay_client_connecting + + _(WeeChat ≥ 0.4.4)_ | + Pointeur : client relay | + Un client relay est en train de se connecter + +| relay | relay_client_waiting_auth + + _(WeeChat ≥ 0.4.4)_ | + Pointeur : client relay | + Attente de l'authentification d'un client relay + +| relay | relay_client_connected + + _(WeeChat ≥ 0.4.4)_ | + Pointeur : client relay | + Un client relay est connecté + +| relay | relay_client_auth_failed + + _(WeeChat ≥ 0.4.4)_ | + Pointeur : client relay | + L'authentification d'un client relay a échoué + +| relay | relay_client_disconnected + + _(WeeChat ≥ 0.4.4)_ | + Pointeur : client relay | + Un client relay est déconnecté + | ruby | ruby_script_loaded + _(WeeChat ≥ 0.3.9)_ | Chaîne : chemin vers le script | diff --git a/doc/it/weechat_plugin_api.it.txt b/doc/it/weechat_plugin_api.it.txt index bc560e3e2..71e7f1324 100644 --- a/doc/it/weechat_plugin_api.it.txt +++ b/doc/it/weechat_plugin_api.it.txt @@ -8005,6 +8005,36 @@ List of signals sent by WeeChat and plugins: String: comma-separated list of scripts removed | Python script(s) removed +// TRANSLATION MISSING +| relay | relay_client_connecting + + _(WeeChat ≥ 0.4.4)_ | + Pointer: relay client | + A relay client is connecting + +// TRANSLATION MISSING +| relay | relay_client_waiting_auth + + _(WeeChat ≥ 0.4.4)_ | + Pointer: relay client | + Waiting for authentication from a relay client + +// TRANSLATION MISSING +| relay | relay_client_connected + + _(WeeChat ≥ 0.4.4)_ | + Pointer: relay client | + A relay client is connected + +// TRANSLATION MISSING +| relay | relay_client_auth_failed + + _(WeeChat ≥ 0.4.4)_ | + Pointer: relay client | + Authentication of a relay client has failed + +// TRANSLATION MISSING +| relay | relay_client_disconnected + + _(WeeChat ≥ 0.4.4)_ | + Pointer: relay client | + A relay client is disconnected + // TRANSLATION MISSING | ruby | ruby_script_loaded + _(WeeChat ≥ 0.3.9)_ | diff --git a/doc/ja/weechat_plugin_api.ja.txt b/doc/ja/weechat_plugin_api.ja.txt index 773c94a84..56e682fcc 100644 --- a/doc/ja/weechat_plugin_api.ja.txt +++ b/doc/ja/weechat_plugin_api.ja.txt @@ -7858,6 +7858,36 @@ WeeChat とプラグインが送信するシグナルのリスト: String: 削除されたスクリプトへのパスのコンマ区切りリスト | Python スクリプトを削除 +// TRANSLATION MISSING +| relay | relay_client_connecting + + _(WeeChat ≥ 0.4.4)_ | + Pointer: relay client | + A relay client is connecting + +// TRANSLATION MISSING +| relay | relay_client_waiting_auth + + _(WeeChat ≥ 0.4.4)_ | + Pointer: relay client | + Waiting for authentication from a relay client + +// TRANSLATION MISSING +| relay | relay_client_connected + + _(WeeChat ≥ 0.4.4)_ | + Pointer: relay client | + A relay client is connected + +// TRANSLATION MISSING +| relay | relay_client_auth_failed + + _(WeeChat ≥ 0.4.4)_ | + Pointer: relay client | + Authentication of a relay client has failed + +// TRANSLATION MISSING +| relay | relay_client_disconnected + + _(WeeChat ≥ 0.4.4)_ | + Pointer: relay client | + A relay client is disconnected + | ruby | ruby_script_loaded + _(WeeChat バージョン 0.3.9 以上で利用可)_ | String: スクリプトへのパス | diff --git a/src/plugins/relay/relay-client.c b/src/plugins/relay/relay-client.c index 2584fd4d2..c60870c94 100644 --- a/src/plugins/relay/relay-client.c +++ b/src/plugins/relay/relay-client.c @@ -46,10 +46,14 @@ #include "relay-websocket.h" -char *relay_client_status_string[] = /* strings for status */ +char *relay_client_status_string[] = /* status strings for display */ { N_("connecting"), N_("waiting auth"), N_("connected"), N_("auth failed"), N_("disconnected") }; +char *relay_client_status_name[] = /* name of status (for signal/info) */ +{ "connecting", "waiting_auth", + "connected", "auth_failed", "disconnected" +}; char *relay_client_data_type_string[] = /* strings for data types */ { "text", "binary" }; @@ -133,6 +137,21 @@ relay_client_search_by_id (int id) return NULL; } +/* + * Sends a signal with the status of client ("relay_client_xxx"). + */ + +void +relay_client_send_signal (struct t_relay_client *client) +{ + char signal[128]; + + snprintf (signal, sizeof (signal), + "relay_client_%s", + relay_client_status_name[client->status]); + weechat_hook_signal_send (signal, WEECHAT_HOOK_SIGNAL_POINTER, client); +} + /* * Sets description for a client. */ @@ -1139,6 +1158,8 @@ relay_client_new (int sock, const char *address, struct t_relay_server *server) relay_buffer_open (); } + relay_client_send_signal (new_client); + relay_buffer_refresh (WEECHAT_HOTLIST_PRIVATE); } else @@ -1317,6 +1338,8 @@ relay_client_set_status (struct t_relay_client *client, gnutls_deinit (client->gnutls_sess); #endif } + + relay_client_send_signal (client); } relay_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);