summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2024-02-19 18:29:21 +0100
committerSébastien Helleu <flashcode@flashtux.org>2024-02-19 18:29:21 +0100
commita167322d8b572948a0c2cf74139c8e6c1e1dc45c (patch)
tree86343bed330b78e89b16e91c20ed969f2cc8b6da /src/plugins
parentf19808cedd5749066f6da0e1c289533f14f83c82 (diff)
downloadweechat-a167322d8b572948a0c2cf74139c8e6c1e1dc45c.zip
api: add info "plugin_loaded"
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/plugin-api-info.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/plugins/plugin-api-info.c b/src/plugins/plugin-api-info.c
index f59aa004c..f22515847 100644
--- a/src/plugins/plugin-api-info.c
+++ b/src/plugins/plugin-api-info.c
@@ -1180,6 +1180,39 @@ error:
}
/*
+ * Returns WeeChat info "plugin_loaded".
+ */
+
+char *
+plugin_api_info_plugin_loaded_cb (const void *pointer, void *data,
+ const char *info_name,
+ const char *arguments)
+{
+ struct t_weechat_plugin *ptr_plugin;
+
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+ (void) info_name;
+
+ if (!arguments || !arguments[0])
+ return NULL;
+
+ for (ptr_plugin = weechat_plugins; ptr_plugin;
+ ptr_plugin = ptr_plugin->next_plugin)
+ {
+ if (strcmp (ptr_plugin->name, arguments) == 0)
+ {
+ /* plugin loaded */
+ return strdup ("1");
+ }
+ }
+
+ /* plugin not loaded */
+ return NULL;
+}
+
+/*
* Returns secured data hashtable.
*/
@@ -2234,6 +2267,10 @@ plugin_api_info_init ()
"timestamp (optional, current time by default), number of "
"passwords before/after to test (optional, 0 by default)"),
&plugin_api_info_totp_validate_cb, NULL, NULL);
+ hook_info (NULL, "plugin_loaded",
+ N_("1 if plugin is loaded"),
+ N_("plugin name"),
+ &plugin_api_info_plugin_loaded_cb, NULL, NULL);
/* WeeChat core info_hashtable hooks */
hook_info_hashtable (NULL,