mirror of
https://github.com/weechat/weechat.git
synced 2026-06-28 05:46:38 +02:00
Reintroduce /upgrade command, working only with core and IRC plugin today
Command will be improved in near future and other plugins like xfer will be modified to manage upgrade process.
This commit is contained in:
+77
-504
@@ -34,6 +34,7 @@
|
||||
|
||||
#include "../core/weechat.h"
|
||||
#include "../core/wee-config.h"
|
||||
#include "../core/wee-infolist.h"
|
||||
#include "../core/wee-input.h"
|
||||
#include "../core/wee-string.h"
|
||||
#include "../gui/gui-buffer.h"
|
||||
@@ -45,7 +46,6 @@
|
||||
#include "../gui/gui-window.h"
|
||||
#include "plugin.h"
|
||||
#include "plugin-config.h"
|
||||
#include "plugin-infolist.h"
|
||||
|
||||
|
||||
/*
|
||||
@@ -320,464 +320,16 @@ plugin_api_info_get (struct t_weechat_plugin *plugin, const char *info)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* plugin_api_infolist_get_add_buffer: add a buffer in a list
|
||||
* return 1 if ok, 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
plugin_api_infolist_get_add_buffer (struct t_plugin_infolist *infolist,
|
||||
struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_plugin_infolist_item *ptr_item;
|
||||
|
||||
if (!infolist || !buffer)
|
||||
return 0;
|
||||
|
||||
ptr_item = plugin_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
if (!plugin_infolist_new_var_pointer (ptr_item, "pointer", buffer))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_pointer (ptr_item, "plugin", buffer->plugin))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_string (ptr_item, "plugin_name",
|
||||
(buffer->plugin) ?
|
||||
buffer->plugin->name : NULL))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "number", buffer->number))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_string (ptr_item, "category", buffer->category))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_string (ptr_item, "name", buffer->name))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "type", buffer->type))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "notify", buffer->notify))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "num_displayed", buffer->num_displayed))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "lines_hidden", buffer->lines_hidden))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_string (ptr_item, "title", buffer->title))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "input", buffer->input))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_string (ptr_item, "input_nick", buffer->input_nick))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_string (ptr_item, "input_string", buffer->input_buffer))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* plugin_api_infolist_get_add_buffer_line: add a buffer line in a list
|
||||
* return 1 if ok, 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
plugin_api_infolist_get_add_buffer_line (struct t_plugin_infolist *infolist,
|
||||
struct t_gui_line *line)
|
||||
{
|
||||
struct t_plugin_infolist_item *ptr_item;
|
||||
int i;
|
||||
char option_name[64];
|
||||
|
||||
if (!infolist || !line)
|
||||
return 0;
|
||||
|
||||
ptr_item = plugin_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
if (!plugin_infolist_new_var_time (ptr_item, "date", line->date))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_time (ptr_item, "date_printed", line->date))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_string (ptr_item, "str_time", line->str_time))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "tags_count", line->tags_count))
|
||||
return 0;
|
||||
for (i = 0; i < line->tags_count; i++)
|
||||
{
|
||||
snprintf (option_name, sizeof (option_name), "tag_%05d", i + 1);
|
||||
if (!plugin_infolist_new_var_string (ptr_item, option_name,
|
||||
line->tags_array[i]))
|
||||
return 0;
|
||||
}
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "displayed", line->displayed))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "highlight", line->highlight))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_string (ptr_item, "prefix", line->prefix))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_string (ptr_item, "message", line->message))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* plugin_api_infolist_get_add_nicklist: add a nicklist
|
||||
* return 1 if ok, 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
plugin_api_infolist_get_add_nicklist (struct t_plugin_infolist *infolist,
|
||||
struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_plugin_infolist_item *ptr_item;
|
||||
struct t_gui_nick_group *ptr_group;
|
||||
struct t_gui_nick *ptr_nick;
|
||||
char prefix[2];
|
||||
|
||||
if (!infolist || !buffer)
|
||||
return 0;
|
||||
|
||||
ptr_group = NULL;
|
||||
ptr_nick = NULL;
|
||||
gui_nicklist_get_next_item (buffer, &ptr_group, &ptr_nick);
|
||||
while (ptr_group || ptr_nick)
|
||||
{
|
||||
ptr_item = plugin_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
if (ptr_nick)
|
||||
{
|
||||
if (!plugin_infolist_new_var_string (ptr_item, "type", "nick"))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_string (ptr_item, "name", ptr_nick->name))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_string (ptr_item, "color", ptr_nick->color))
|
||||
return 0;
|
||||
prefix[0] = ptr_nick->prefix;
|
||||
prefix[1] = '\0';
|
||||
if (!plugin_infolist_new_var_string (ptr_item, "prefix", prefix))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_string (ptr_item, "prefix_color", ptr_nick->prefix_color))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "visible", ptr_nick->visible))
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!plugin_infolist_new_var_string (ptr_item, "type", "group"))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_string (ptr_item, "name", ptr_group->name))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_string (ptr_item, "color", ptr_group->color))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "visible", ptr_group->visible))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "level", ptr_group->level))
|
||||
return 0;
|
||||
}
|
||||
gui_nicklist_get_next_item (buffer, &ptr_group, &ptr_nick);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* plugin_api_infolist_get_add_window: add a window in a list
|
||||
* return 1 if ok, 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
plugin_api_infolist_get_add_window (struct t_plugin_infolist *infolist,
|
||||
struct t_gui_window *window)
|
||||
{
|
||||
struct t_plugin_infolist_item *ptr_item;
|
||||
|
||||
if (!infolist || !window)
|
||||
return 0;
|
||||
|
||||
ptr_item = plugin_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
if (!plugin_infolist_new_var_pointer (ptr_item, "pointer", window))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "x", window->win_x))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "y", window->win_y))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "width", window->win_width))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "height", window->win_height))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "width_pct", window->win_width_pct))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "height_pct", window->win_height_pct))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "chat_x", window->win_chat_x))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "chat_y", window->win_chat_y))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "chat_width", window->win_chat_width))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "chat_height", window->win_chat_height))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "nick_x", window->win_nick_x))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "nick_y", window->win_nick_y))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "nick_width", window->win_nick_width))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "nick_height", window->win_nick_height))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "nick_start", window->win_nick_start))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "title_x", window->win_title_x))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "title_y", window->win_title_y))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "title_width", window->win_title_width))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "title_start", window->win_title_start))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "status_x", window->win_status_x))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "status_y", window->win_status_y))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "status_width", window->win_status_width))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "status_height", window->win_status_height))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "input_x", window->win_input_x))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "input_y", window->win_input_y))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "input_width", window->win_input_width))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "input_height", window->win_input_height))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "input_cursor_x", window->win_input_cursor_x))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_pointer (ptr_item, "buffer", window->buffer))
|
||||
return 0;
|
||||
if (!plugin_infolist_new_var_integer (ptr_item, "start_line_y",
|
||||
((window->buffer->type == GUI_BUFFER_TYPE_FREE)
|
||||
&& (window->start_line)) ?
|
||||
window->start_line->y : 0))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* plugin_api_infolist_get_add_options: add config options in a list
|
||||
* return 1 if ok, 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
plugin_api_infolist_get_add_options (struct t_plugin_infolist *infolist,
|
||||
const char *option_name)
|
||||
{
|
||||
struct t_config_file *ptr_config;
|
||||
struct t_config_section *ptr_section;
|
||||
struct t_config_option *ptr_option;
|
||||
struct t_plugin_infolist_item *ptr_item;
|
||||
int length;
|
||||
char *option_full_name, value[128];
|
||||
|
||||
if (!infolist)
|
||||
return 0;
|
||||
|
||||
for (ptr_config = config_files; ptr_config;
|
||||
ptr_config = ptr_config->next_config)
|
||||
{
|
||||
for (ptr_section = ptr_config->sections; ptr_section;
|
||||
ptr_section = ptr_section->next_section)
|
||||
{
|
||||
for (ptr_option = ptr_section->options; ptr_option;
|
||||
ptr_option = ptr_option->next_option)
|
||||
{
|
||||
length = strlen (ptr_config->name) + 1 +
|
||||
strlen (ptr_section->name) + 1 +
|
||||
strlen (ptr_option->name) + 1;
|
||||
option_full_name = malloc (length);
|
||||
if (option_full_name)
|
||||
{
|
||||
snprintf (option_full_name, length, "%s.%s.%s",
|
||||
ptr_config->name,
|
||||
ptr_section->name,
|
||||
ptr_option->name);
|
||||
if (!option_name || !option_name[0]
|
||||
|| string_match (option_full_name, option_name, 0))
|
||||
{
|
||||
ptr_item = plugin_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
{
|
||||
free (option_full_name);
|
||||
return 0;
|
||||
}
|
||||
if (!plugin_infolist_new_var_string (ptr_item,
|
||||
"full_name",
|
||||
option_full_name))
|
||||
{
|
||||
free (option_full_name);
|
||||
return 0;
|
||||
}
|
||||
if (!plugin_infolist_new_var_string (ptr_item,
|
||||
"name",
|
||||
ptr_option->name))
|
||||
{
|
||||
free (option_full_name);
|
||||
return 0;
|
||||
}
|
||||
switch (ptr_option->type)
|
||||
{
|
||||
case CONFIG_OPTION_TYPE_BOOLEAN:
|
||||
if (!plugin_infolist_new_var_string (ptr_item,
|
||||
"type",
|
||||
"boolean"))
|
||||
{
|
||||
free (option_full_name);
|
||||
return 0;
|
||||
}
|
||||
if (CONFIG_BOOLEAN(ptr_option) == CONFIG_BOOLEAN_TRUE)
|
||||
snprintf (value, sizeof (value), "on");
|
||||
else
|
||||
snprintf (value, sizeof (value), "off");
|
||||
if (!plugin_infolist_new_var_string (ptr_item,
|
||||
"value",
|
||||
value))
|
||||
{
|
||||
free (option_full_name);
|
||||
return 0;
|
||||
}
|
||||
if (CONFIG_BOOLEAN_DEFAULT(ptr_option) == CONFIG_BOOLEAN_TRUE)
|
||||
snprintf (value, sizeof (value), "on");
|
||||
else
|
||||
snprintf (value, sizeof (value), "off");
|
||||
if (!plugin_infolist_new_var_string (ptr_item,
|
||||
"default_value",
|
||||
value))
|
||||
{
|
||||
free (option_full_name);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case CONFIG_OPTION_TYPE_INTEGER:
|
||||
if (!plugin_infolist_new_var_string (ptr_item,
|
||||
"type",
|
||||
"integer"))
|
||||
{
|
||||
free (option_full_name);
|
||||
return 0;
|
||||
}
|
||||
if (ptr_option->string_values)
|
||||
{
|
||||
if (!plugin_infolist_new_var_string (ptr_item,
|
||||
"value",
|
||||
ptr_option->string_values[CONFIG_INTEGER(ptr_option)]))
|
||||
{
|
||||
free (option_full_name);
|
||||
return 0;
|
||||
}
|
||||
if (!plugin_infolist_new_var_string (ptr_item,
|
||||
"default_value",
|
||||
ptr_option->string_values[CONFIG_INTEGER_DEFAULT(ptr_option)]))
|
||||
{
|
||||
free (option_full_name);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf (value, sizeof (value), "%d",
|
||||
CONFIG_INTEGER(ptr_option));
|
||||
if (!plugin_infolist_new_var_string (ptr_item,
|
||||
"value",
|
||||
value))
|
||||
{
|
||||
free (option_full_name);
|
||||
return 0;
|
||||
}
|
||||
snprintf (value, sizeof (value), "%d",
|
||||
CONFIG_INTEGER_DEFAULT(ptr_option));
|
||||
if (!plugin_infolist_new_var_string (ptr_item,
|
||||
"default_value",
|
||||
value))
|
||||
{
|
||||
free (option_full_name);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CONFIG_OPTION_TYPE_STRING:
|
||||
if (!plugin_infolist_new_var_string (ptr_item,
|
||||
"type",
|
||||
"string"))
|
||||
{
|
||||
free (option_full_name);
|
||||
return 0;
|
||||
}
|
||||
if (!plugin_infolist_new_var_string (ptr_item,
|
||||
"value",
|
||||
CONFIG_STRING(ptr_option)))
|
||||
{
|
||||
free (option_full_name);
|
||||
return 0;
|
||||
}
|
||||
if (!plugin_infolist_new_var_string (ptr_item,
|
||||
"default_value",
|
||||
CONFIG_STRING_DEFAULT(ptr_option)))
|
||||
{
|
||||
free (option_full_name);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case CONFIG_OPTION_TYPE_COLOR:
|
||||
if (!plugin_infolist_new_var_string (ptr_item,
|
||||
"type",
|
||||
"color"))
|
||||
{
|
||||
free (option_full_name);
|
||||
return 0;
|
||||
}
|
||||
if (!plugin_infolist_new_var_string (ptr_item,
|
||||
"value",
|
||||
gui_color_get_name (CONFIG_COLOR(ptr_option))))
|
||||
{
|
||||
free (option_full_name);
|
||||
return 0;
|
||||
}
|
||||
if (!plugin_infolist_new_var_string (ptr_item,
|
||||
"default_value",
|
||||
gui_color_get_name (CONFIG_COLOR_DEFAULT(ptr_option))))
|
||||
{
|
||||
free (option_full_name);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case CONFIG_NUM_OPTION_TYPES:
|
||||
break;
|
||||
}
|
||||
}
|
||||
free (option_full_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* plugin_api_infolist_get: get list with infos about WeeChat structures
|
||||
* WARNING: caller has to free string returned
|
||||
* by this function after use, with weechat_infolist_free()
|
||||
*/
|
||||
|
||||
struct t_plugin_infolist *
|
||||
struct t_infolist *
|
||||
plugin_api_infolist_get (const char *name, void *pointer, const char *arguments)
|
||||
{
|
||||
struct t_plugin_infolist *ptr_infolist;
|
||||
struct t_infolist *ptr_infolist;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
struct t_gui_line *ptr_line;
|
||||
struct t_gui_window *ptr_window;
|
||||
@@ -791,15 +343,15 @@ plugin_api_infolist_get (const char *name, void *pointer, const char *arguments)
|
||||
if (pointer && (!gui_buffer_valid (pointer)))
|
||||
return NULL;
|
||||
|
||||
ptr_infolist = plugin_infolist_new ();
|
||||
ptr_infolist = infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
if (pointer)
|
||||
{
|
||||
/* build list with only one buffer */
|
||||
if (!plugin_api_infolist_get_add_buffer (ptr_infolist, pointer))
|
||||
if (!gui_buffer_add_to_infolist (ptr_infolist, pointer))
|
||||
{
|
||||
plugin_infolist_free (ptr_infolist);
|
||||
infolist_free (ptr_infolist);
|
||||
return NULL;
|
||||
}
|
||||
return ptr_infolist;
|
||||
@@ -810,10 +362,9 @@ plugin_api_infolist_get (const char *name, void *pointer, const char *arguments)
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
if (!plugin_api_infolist_get_add_buffer (ptr_infolist,
|
||||
ptr_buffer))
|
||||
if (!gui_buffer_add_to_infolist (ptr_infolist, ptr_buffer))
|
||||
{
|
||||
plugin_infolist_free (ptr_infolist);
|
||||
infolist_free (ptr_infolist);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -832,16 +383,15 @@ plugin_api_infolist_get (const char *name, void *pointer, const char *arguments)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ptr_infolist = plugin_infolist_new ();
|
||||
ptr_infolist = infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
for (ptr_line = ((struct t_gui_buffer *)pointer)->lines; ptr_line;
|
||||
ptr_line = ptr_line->next_line)
|
||||
{
|
||||
if (!plugin_api_infolist_get_add_buffer_line (ptr_infolist,
|
||||
ptr_line))
|
||||
if (!gui_buffer_line_add_to_infolist (ptr_infolist, ptr_line))
|
||||
{
|
||||
plugin_infolist_free (ptr_infolist);
|
||||
infolist_free (ptr_infolist);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -854,12 +404,12 @@ plugin_api_infolist_get (const char *name, void *pointer, const char *arguments)
|
||||
if (!pointer || (!gui_buffer_valid (pointer)))
|
||||
return NULL;
|
||||
|
||||
ptr_infolist = plugin_infolist_new ();
|
||||
ptr_infolist = infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
if (!plugin_api_infolist_get_add_nicklist (ptr_infolist, pointer))
|
||||
if (!gui_nicklist_add_to_infolist (ptr_infolist, pointer))
|
||||
{
|
||||
plugin_infolist_free (ptr_infolist);
|
||||
infolist_free (ptr_infolist);
|
||||
return NULL;
|
||||
}
|
||||
return ptr_infolist;
|
||||
@@ -871,15 +421,15 @@ plugin_api_infolist_get (const char *name, void *pointer, const char *arguments)
|
||||
if (pointer && (!gui_window_valid (pointer)))
|
||||
return NULL;
|
||||
|
||||
ptr_infolist = plugin_infolist_new ();
|
||||
ptr_infolist = infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
if (pointer)
|
||||
{
|
||||
/* build list with only one window */
|
||||
if (!plugin_api_infolist_get_add_window (ptr_infolist, pointer))
|
||||
if (!gui_window_add_to_infolist (ptr_infolist, pointer))
|
||||
{
|
||||
plugin_infolist_free (ptr_infolist);
|
||||
infolist_free (ptr_infolist);
|
||||
return NULL;
|
||||
}
|
||||
return ptr_infolist;
|
||||
@@ -891,10 +441,10 @@ plugin_api_infolist_get (const char *name, void *pointer, const char *arguments)
|
||||
if ((string_strcasecmp (arguments, "current") == 0)
|
||||
&& gui_current_window)
|
||||
{
|
||||
if (!plugin_api_infolist_get_add_window (ptr_infolist,
|
||||
gui_current_window))
|
||||
if (!gui_window_add_to_infolist (ptr_infolist,
|
||||
gui_current_window))
|
||||
{
|
||||
plugin_infolist_free (ptr_infolist);
|
||||
infolist_free (ptr_infolist);
|
||||
return NULL;
|
||||
}
|
||||
return ptr_infolist;
|
||||
@@ -907,10 +457,10 @@ plugin_api_infolist_get (const char *name, void *pointer, const char *arguments)
|
||||
for (ptr_window = gui_windows; ptr_window;
|
||||
ptr_window = ptr_window->next_window)
|
||||
{
|
||||
if (!plugin_api_infolist_get_add_window (ptr_infolist,
|
||||
ptr_window))
|
||||
if (!gui_window_add_to_infolist (ptr_infolist,
|
||||
ptr_window))
|
||||
{
|
||||
plugin_infolist_free (ptr_infolist);
|
||||
infolist_free (ptr_infolist);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -921,12 +471,12 @@ plugin_api_infolist_get (const char *name, void *pointer, const char *arguments)
|
||||
}
|
||||
else if (string_strcasecmp (name, "options") == 0)
|
||||
{
|
||||
ptr_infolist = plugin_infolist_new ();
|
||||
ptr_infolist = infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
if (!plugin_api_infolist_get_add_options (ptr_infolist, arguments))
|
||||
if (!config_file_add_to_infolist (ptr_infolist, arguments))
|
||||
{
|
||||
plugin_infolist_free (ptr_infolist);
|
||||
infolist_free (ptr_infolist);
|
||||
return NULL;
|
||||
}
|
||||
return ptr_infolist;
|
||||
@@ -944,12 +494,12 @@ plugin_api_infolist_get (const char *name, void *pointer, const char *arguments)
|
||||
*/
|
||||
|
||||
int
|
||||
plugin_api_infolist_next (struct t_plugin_infolist *infolist)
|
||||
plugin_api_infolist_next (struct t_infolist *infolist)
|
||||
{
|
||||
if (!infolist || !plugin_infolist_valid (infolist))
|
||||
if (!infolist || !infolist_valid (infolist))
|
||||
return 0;
|
||||
|
||||
return (plugin_infolist_next_item (infolist)) ? 1 : 0;
|
||||
return (infolist_next (infolist)) ? 1 : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -959,12 +509,25 @@ plugin_api_infolist_next (struct t_plugin_infolist *infolist)
|
||||
*/
|
||||
|
||||
int
|
||||
plugin_api_infolist_prev (struct t_plugin_infolist *infolist)
|
||||
plugin_api_infolist_prev (struct t_infolist *infolist)
|
||||
{
|
||||
if (!infolist || !plugin_infolist_valid (infolist))
|
||||
if (!infolist || !infolist_valid (infolist))
|
||||
return 0;
|
||||
|
||||
return (plugin_infolist_prev_item (infolist)) ? 1 : 0;
|
||||
return (infolist_prev (infolist)) ? 1 : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* plugin_api_infolist_reset_item_cursor: reset item cursor in infolist
|
||||
*/
|
||||
|
||||
void
|
||||
plugin_api_infolist_reset_item_cursor (struct t_infolist *infolist)
|
||||
{
|
||||
if (infolist && infolist_valid (infolist))
|
||||
{
|
||||
infolist_reset_item_cursor (infolist);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -972,12 +535,12 @@ plugin_api_infolist_prev (struct t_plugin_infolist *infolist)
|
||||
*/
|
||||
|
||||
char *
|
||||
plugin_api_infolist_fields (struct t_plugin_infolist *infolist)
|
||||
plugin_api_infolist_fields (struct t_infolist *infolist)
|
||||
{
|
||||
if (!infolist || !plugin_infolist_valid (infolist))
|
||||
if (!infolist || !infolist_valid (infolist))
|
||||
return NULL;
|
||||
|
||||
return plugin_infolist_get_fields (infolist);
|
||||
return infolist_fields (infolist);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -985,13 +548,12 @@ plugin_api_infolist_fields (struct t_plugin_infolist *infolist)
|
||||
*/
|
||||
|
||||
int
|
||||
plugin_api_infolist_integer (struct t_plugin_infolist *infolist, const char *var)
|
||||
plugin_api_infolist_integer (struct t_infolist *infolist, const char *var)
|
||||
{
|
||||
if (!infolist || !plugin_infolist_valid (infolist)
|
||||
|| !((struct t_plugin_infolist *)infolist)->ptr_item)
|
||||
if (!infolist || !infolist_valid (infolist) || !infolist->ptr_item)
|
||||
return 0;
|
||||
|
||||
return plugin_infolist_get_integer (infolist, var);
|
||||
return infolist_integer (infolist, var);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -999,13 +561,12 @@ plugin_api_infolist_integer (struct t_plugin_infolist *infolist, const char *var
|
||||
*/
|
||||
|
||||
char *
|
||||
plugin_api_infolist_string (struct t_plugin_infolist *infolist, const char *var)
|
||||
plugin_api_infolist_string (struct t_infolist *infolist, const char *var)
|
||||
{
|
||||
if (!infolist || !plugin_infolist_valid (infolist)
|
||||
|| !((struct t_plugin_infolist *)infolist)->ptr_item)
|
||||
if (!infolist || !infolist_valid (infolist) || !infolist->ptr_item)
|
||||
return NULL;
|
||||
|
||||
return plugin_infolist_get_string (infolist, var);
|
||||
return infolist_string (infolist, var);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1013,13 +574,26 @@ plugin_api_infolist_string (struct t_plugin_infolist *infolist, const char *var)
|
||||
*/
|
||||
|
||||
void *
|
||||
plugin_api_infolist_pointer (struct t_plugin_infolist *infolist, const char *var)
|
||||
plugin_api_infolist_pointer (struct t_infolist *infolist, const char *var)
|
||||
{
|
||||
if (!infolist || !plugin_infolist_valid (infolist)
|
||||
|| !((struct t_plugin_infolist *)infolist)->ptr_item)
|
||||
if (!infolist || !infolist_valid (infolist) || !infolist->ptr_item)
|
||||
return NULL;
|
||||
|
||||
return plugin_infolist_get_pointer (infolist, var);
|
||||
return infolist_pointer (infolist, var);
|
||||
}
|
||||
|
||||
/*
|
||||
* plugin_api_infolist_buffer: get a buffer variable value in current list item
|
||||
*/
|
||||
|
||||
void *
|
||||
plugin_api_infolist_buffer (struct t_infolist *infolist, const char *var,
|
||||
int *size)
|
||||
{
|
||||
if (!infolist || !infolist_valid (infolist) || !infolist->ptr_item)
|
||||
return NULL;
|
||||
|
||||
return infolist_buffer (infolist, var, size);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1027,13 +601,12 @@ plugin_api_infolist_pointer (struct t_plugin_infolist *infolist, const char *var
|
||||
*/
|
||||
|
||||
time_t
|
||||
plugin_api_infolist_time (struct t_plugin_infolist *infolist, const char *var)
|
||||
plugin_api_infolist_time (struct t_infolist *infolist, const char *var)
|
||||
{
|
||||
if (!infolist || !plugin_infolist_valid (infolist)
|
||||
|| !((struct t_plugin_infolist *)infolist)->ptr_item)
|
||||
if (!infolist || !infolist_valid (infolist) || !infolist->ptr_item)
|
||||
return 0;
|
||||
|
||||
return plugin_infolist_get_time (infolist, var);
|
||||
return infolist_time (infolist, var);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1041,8 +614,8 @@ plugin_api_infolist_time (struct t_plugin_infolist *infolist, const char *var)
|
||||
*/
|
||||
|
||||
void
|
||||
plugin_api_infolist_free (struct t_plugin_infolist *infolist)
|
||||
plugin_api_infolist_free (struct t_infolist *infolist)
|
||||
{
|
||||
if (infolist && plugin_infolist_valid (infolist))
|
||||
plugin_infolist_free (infolist);
|
||||
if (infolist && infolist_valid (infolist))
|
||||
infolist_free (infolist);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user