From 91bcfbb4e89f2964820915c258ef79e944c47ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Tue, 16 May 2023 20:00:48 +0200 Subject: [PATCH] core: move creation of info_hashtable "secured_data" in plugin-api-info.c --- src/core/wee-secure.c | 28 ---------------------------- src/plugins/plugin-api-info.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/core/wee-secure.c b/src/core/wee-secure.c index 892dfaf57..39ff5d199 100644 --- a/src/core/wee-secure.c +++ b/src/core/wee-secure.c @@ -494,24 +494,6 @@ secure_decrypt_data_not_decrypted (const char *passphrase) return num_ok; } -/* - * Returns secured data hashtable. - */ - -struct t_hashtable * -secure_info_hashtable_secured_data_cb (const void *pointer, void *data, - const char *info_name, - struct t_hashtable *hashtable) -{ - /* make C compiler happy */ - (void) pointer; - (void) data; - (void) info_name; - (void) hashtable; - - return hashtable_dup (secure_hashtable_data); -} - /* * Initializes secured data. * @@ -554,16 +536,6 @@ secure_init () return 0; } - /* info (hashtable) with the secured data */ - hook_info_hashtable ( - NULL, - "secured_data", - N_("secured data"), - NULL, - N_("secured data: names and values (be careful: the values are " - "sensitive data: do NOT print/log them anywhere)"), - &secure_info_hashtable_secured_data_cb, NULL, NULL); - return 1; } diff --git a/src/plugins/plugin-api-info.c b/src/plugins/plugin-api-info.c index a476a015e..3546491f8 100644 --- a/src/plugins/plugin-api-info.c +++ b/src/plugins/plugin-api-info.c @@ -32,9 +32,11 @@ #include "../core/weechat.h" #include "../core/wee-config.h" #include "../core/wee-crypto.h" +#include "../core/wee-hashtable.h" #include "../core/wee-hook.h" #include "../core/wee-infolist.h" #include "../core/wee-proxy.h" +#include "../core/wee-secure.h" #include "../core/wee-string.h" #include "../core/wee-url.h" #include "../core/wee-util.h" @@ -1024,6 +1026,24 @@ error: return NULL; } +/* + * Returns secured data hashtable. + */ + +struct t_hashtable * +plugin_api_info_hashtable_secured_data_cb (const void *pointer, void *data, + const char *info_name, + struct t_hashtable *hashtable) +{ + /* make C compiler happy */ + (void) pointer; + (void) data; + (void) info_name; + (void) hashtable; + + return hashtable_dup (secure_hashtable_data); +} + /* * Returns WeeChat infolist "bar". * @@ -2039,6 +2059,15 @@ plugin_api_info_init () "\"y\": y coordinate (string with integer >= 0)"), N_("see function \"hook_focus\" in Plugin API reference"), &gui_focus_info_hashtable_gui_focus_info_cb, NULL, NULL); + /* info (hashtable) with the secured data */ + hook_info_hashtable ( + NULL, + "secured_data", + N_("secured data"), + NULL, + N_("secured data: names and values (be careful: the values are " + "sensitive data: do NOT print/log them anywhere)"), + &plugin_api_info_hashtable_secured_data_cb, NULL, NULL); /* WeeChat core infolist hooks */ hook_infolist (NULL, "bar",