1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-01 15:26:37 +02:00

core: add "proxy" infolist and hdata

This commit is contained in:
Sebastien Helleu
2013-06-08 11:40:27 +02:00
parent fb7edb3518
commit 21356d9909
26 changed files with 385 additions and 14 deletions
+47
View File
@@ -40,6 +40,7 @@
#include "../core/wee-hook.h"
#include "../core/wee-infolist.h"
#include "../core/wee-input.h"
#include "../core/wee-proxy.h"
#include "../core/wee-string.h"
#include "../core/wee-url.h"
#include "../core/wee-util.h"
@@ -413,6 +414,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
struct t_gui_hotlist *ptr_hotlist;
struct t_gui_key *ptr_key;
struct t_weechat_plugin *ptr_plugin;
struct t_proxy *ptr_proxy;
struct t_gui_layout *ptr_layout;
int context, number, i;
char *error;
@@ -801,6 +803,45 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
}
}
}
else if (string_strcasecmp (infolist_name, "proxy") == 0)
{
/* invalid proxy pointer ? */
if (pointer && (!proxy_valid (pointer)))
return NULL;
ptr_infolist = infolist_new ();
if (ptr_infolist)
{
if (pointer)
{
/* build list with only one proxy */
if (!proxy_add_to_infolist (ptr_infolist, pointer))
{
infolist_free (ptr_infolist);
return NULL;
}
return ptr_infolist;
}
else
{
/* build list with all proxies matching arguments */
for (ptr_proxy = weechat_proxies; ptr_proxy;
ptr_proxy = ptr_proxy->next_proxy)
{
if (!arguments || !arguments[0]
|| string_match (ptr_proxy->name, arguments, 0))
{
if (!proxy_add_to_infolist (ptr_infolist, ptr_proxy))
{
infolist_free (ptr_infolist);
return NULL;
}
}
}
return ptr_infolist;
}
}
}
else if (string_strcasecmp (infolist_name, "url_options") == 0)
{
ptr_infolist = infolist_new ();
@@ -1144,6 +1185,10 @@ plugin_api_init ()
N_("plugin pointer (optional)"),
N_("plugin name (can start or end with \"*\" as wildcard) (optional)"),
&plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "proxy", N_("list of proxies"),
N_("proxy pointer (optional)"),
N_("proxy name (can start or end with \"*\" as wildcard) (optional)"),
&plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "url_options", N_("options for URL"),
NULL,
NULL,
@@ -1200,6 +1245,8 @@ plugin_api_init ()
&gui_nicklist_hdata_nick_cb, NULL);
hook_hdata (NULL, "plugin", N_("plugin"),
&plugin_hdata_plugin_cb, NULL);
hook_hdata (NULL, "proxy", N_("proxy"),
&proxy_hdata_proxy_cb, NULL);
hook_hdata (NULL, "window", N_("window"),
&gui_window_hdata_window_cb, NULL);
hook_hdata (NULL, "window_scroll", N_("scroll info in window"),