summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2008-08-19 23:22:52 +0200
committerSebastien Helleu <flashcode@flashtux.org>2008-08-19 23:22:52 +0200
commitb76d7e4a5cac659b08ae992b74af5f26b67dc205 (patch)
tree0edd58880852c7f70cc4ff4f8faf79473c09c164 /src/gui
parentff1983533b9288f4d310e7eac6fb976bd119a48d (diff)
downloadweechat-b76d7e4a5cac659b08ae992b74af5f26b67dc205.zip
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.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui-buffer.c217
-rw-r--r--src/gui/gui-buffer.h15
-rw-r--r--src/gui/gui-chat.c21
-rw-r--r--src/gui/gui-chat.h5
-rw-r--r--src/gui/gui-history.c20
-rw-r--r--src/gui/gui-history.h2
-rw-r--r--src/gui/gui-hotlist.c29
-rw-r--r--src/gui/gui-hotlist.h2
-rw-r--r--src/gui/gui-nicklist.c73
-rw-r--r--src/gui/gui-nicklist.h3
-rw-r--r--src/gui/gui-window.c88
-rw-r--r--src/gui/gui-window.h4
12 files changed, 433 insertions, 46 deletions
diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c
index 1c3ca520d..42a403044 100644
--- a/src/gui/gui-buffer.c
+++ b/src/gui/gui-buffer.c
@@ -35,6 +35,7 @@
#include "../core/weechat.h"
#include "../core/wee-config.h"
#include "../core/wee-hook.h"
+#include "../core/wee-infolist.h"
#include "../core/wee-log.h"
#include "../core/wee-string.h"
#include "../core/wee-utf8.h"
@@ -98,6 +99,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
{
/* init buffer */
new_buffer->plugin = plugin;
+ new_buffer->plugin_name_for_upgrade = NULL;
new_buffer->number = (last_gui_buffer) ? last_gui_buffer->number + 1 : 1;
new_buffer->category = (category) ? strdup (category) : NULL;
new_buffer->name = strdup (name);
@@ -208,9 +210,9 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
}
/*
- * buffer_valid: check if a buffer pointer exists
- * return 1 if buffer exists
- * 0 if buffer is not found
+ * gui_buffer_valid: check if a buffer pointer exists
+ * return 1 if buffer exists
+ * 0 if buffer is not found
*/
int
@@ -234,6 +236,30 @@ gui_buffer_valid (struct t_gui_buffer *buffer)
}
/*
+ * gui_buffer_set_plugin_for_upgrade: set plugin pointer for buffers with a
+ * given name (used after /upgrade)
+ */
+
+void
+gui_buffer_set_plugin_for_upgrade (char *name, struct t_weechat_plugin *plugin)
+{
+ struct t_gui_buffer *ptr_buffer;
+
+ for (ptr_buffer = gui_buffers; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ if (ptr_buffer->plugin_name_for_upgrade
+ && (strcmp (ptr_buffer->plugin_name_for_upgrade, name) == 0))
+ {
+ free (ptr_buffer->plugin_name_for_upgrade);
+ ptr_buffer->plugin_name_for_upgrade = NULL;
+
+ ptr_buffer->plugin = plugin;
+ }
+ }
+}
+
+/*
* gui_buffer_get_integer: get a buffer property as integer
*/
@@ -488,25 +514,28 @@ gui_buffer_set_highlight_tags (struct t_gui_buffer *buffer,
void
gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
- const char *value)
+ void *value)
{
+ const char *value_str;
long number;
char *error;
-
+
if (!property || !value)
return;
+ value_str = (const char *)value;
+
/* properties that does NOT need a buffer */
if (string_strcasecmp (property, "hotlist") == 0)
{
- if (strcmp (value, "-") == 0)
+ if (strcmp (value_str, "-") == 0)
gui_add_hotlist = 0;
- else if (strcmp (value, "+") == 0)
+ else if (strcmp (value_str, "+") == 0)
gui_add_hotlist = 1;
else
{
error = NULL;
- number = strtol (value, &error, 10);
+ number = strtol (value_str, &error, 10);
if (error && !error[0])
gui_hotlist_add (buffer, number, NULL, 1);
}
@@ -516,30 +545,46 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
return;
/* properties that need a buffer */
- if (string_strcasecmp (property, "display") == 0)
+ if (string_strcasecmp (property, "close_callback") == 0)
+ {
+ buffer->close_callback = value;
+ }
+ else if (string_strcasecmp (property, "close_callback_data") == 0)
+ {
+ buffer->close_callback_data = value;
+ }
+ else if (string_strcasecmp (property, "input_callback") == 0)
+ {
+ buffer->input_callback = value;
+ }
+ else if (string_strcasecmp (property, "input_callback_data") == 0)
+ {
+ buffer->input_callback_data = value;
+ }
+ else if (string_strcasecmp (property, "display") == 0)
{
gui_window_switch_to_buffer (gui_current_window, buffer);
gui_window_redraw_buffer (buffer);
}
else if (string_strcasecmp (property, "category") == 0)
{
- gui_buffer_set_category (buffer, value);
+ gui_buffer_set_category (buffer, value_str);
}
else if (string_strcasecmp (property, "name") == 0)
{
- gui_buffer_set_name (buffer, value);
+ gui_buffer_set_name (buffer, value_str);
}
else if (string_strcasecmp (property, "type") == 0)
{
- if (string_strcasecmp (value, "formated") == 0)
+ if (string_strcasecmp (value_str, "formated") == 0)
gui_buffer_set_type (buffer, GUI_BUFFER_TYPE_FORMATED);
- else if (string_strcasecmp (value, "free") == 0)
+ else if (string_strcasecmp (value_str, "free") == 0)
gui_buffer_set_type (buffer, GUI_BUFFER_TYPE_FREE);
}
else if (string_strcasecmp (property, "notify") == 0)
{
error = NULL;
- number = strtol (value, &error, 10);
+ number = strtol (value_str, &error, 10);
if (error && !error[0]
&& (number < GUI_BUFFER_NUM_NOTIFY))
{
@@ -551,44 +596,44 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
}
else if (string_strcasecmp (property, "title") == 0)
{
- gui_buffer_set_title (buffer, value);
+ gui_buffer_set_title (buffer, value_str);
}
else if (string_strcasecmp (property, "nicklist") == 0)
{
error = NULL;
- number = strtol (value, &error, 10);
+ number = strtol (value_str, &error, 10);
if (error && !error[0])
gui_buffer_set_nicklist (buffer, number);
}
else if (string_strcasecmp (property, "nicklist_case_sensitive") == 0)
{
error = NULL;
- number = strtol (value, &error, 10);
+ number = strtol (value_str, &error, 10);
if (error && !error[0])
gui_buffer_set_nicklist_case_sensitive (buffer, number);
}
else if (string_strcasecmp (property, "nicklist_display_groups") == 0)
{
error = NULL;
- number = strtol (value, &error, 10);
+ number = strtol (value_str, &error, 10);
if (error && !error[0])
gui_buffer_set_nicklist_display_groups (buffer, number);
}
else if (string_strcasecmp (property, "nick") == 0)
{
- gui_buffer_set_nick (buffer, value);
+ gui_buffer_set_nick (buffer, value_str);
}
else if (string_strcasecmp (property, "highlight_words") == 0)
{
- gui_buffer_set_highlight_words (buffer, value);
+ gui_buffer_set_highlight_words (buffer, value_str);
}
else if (string_strcasecmp (property, "highlight_tags") == 0)
{
- gui_buffer_set_highlight_tags (buffer, value);
+ gui_buffer_set_highlight_tags (buffer, value_str);
}
else if (string_strncasecmp (property, "key_bind_", 9) == 0)
{
- gui_keyboard_bind (buffer, property + 9, value);
+ gui_keyboard_bind (buffer, property + 9, value_str);
}
else if (string_strncasecmp (property, "key_unbind_", 11) == 0)
{
@@ -600,7 +645,7 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
else if (string_strcasecmp (property, "input") == 0)
{
gui_input_delete_line (buffer);
- gui_input_insert_string (buffer, value, 0);
+ gui_input_insert_string (buffer, value_str, 0);
gui_input_text_changed_signal ();
gui_buffer_ask_input_refresh (buffer, 1);
}
@@ -1097,6 +1142,132 @@ gui_buffer_move_to_number (struct t_gui_buffer *buffer, int number)
}
/*
+ * gui_buffer_add_to_infolist: add a buffer in an infolist
+ * return 1 if ok, 0 if error
+ */
+
+int
+gui_buffer_add_to_infolist (struct t_infolist *infolist,
+ struct t_gui_buffer *buffer)
+{
+ struct t_infolist_item *ptr_item;
+
+ if (!infolist || !buffer)
+ return 0;
+
+ ptr_item = infolist_new_item (infolist);
+ if (!ptr_item)
+ return 0;
+
+ if (!infolist_new_var_pointer (ptr_item, "pointer", buffer))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "current_buffer",
+ (gui_current_window->buffer == buffer) ? 1 : 0))
+ return 0;
+ if (!infolist_new_var_pointer (ptr_item, "plugin", buffer->plugin))
+ return 0;
+ if (!infolist_new_var_string (ptr_item, "plugin_name",
+ (buffer->plugin) ?
+ buffer->plugin->name : NULL))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "number", buffer->number))
+ return 0;
+ if (!infolist_new_var_string (ptr_item, "category", buffer->category))
+ return 0;
+ if (!infolist_new_var_string (ptr_item, "name", buffer->name))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "type", buffer->type))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "notify", buffer->notify))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "num_displayed", buffer->num_displayed))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "lines_hidden", buffer->lines_hidden))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "nicklist_case_sensitive", buffer->nicklist_case_sensitive))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "nicklist_display_groups", buffer->nicklist_display_groups))
+ return 0;
+ if (!infolist_new_var_string (ptr_item, "title", buffer->title))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "input", buffer->input))
+ return 0;
+ if (!infolist_new_var_string (ptr_item, "input_nick", buffer->input_nick))
+ return 0;
+ if (!infolist_new_var_string (ptr_item, "input_string", buffer->input_buffer))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * gui_buffer_line_add_to_infolist: add a buffer line in an infolist
+ * return 1 if ok, 0 if error
+ */
+
+int
+gui_buffer_line_add_to_infolist (struct t_infolist *infolist,
+ struct t_gui_line *line)
+{
+ struct t_infolist_item *ptr_item;
+ int i, length;
+ char option_name[64], *tags;
+
+ if (!infolist || !line)
+ return 0;
+
+ ptr_item = infolist_new_item (infolist);
+ if (!ptr_item)
+ return 0;
+
+ if (!infolist_new_var_time (ptr_item, "date", line->date))
+ return 0;
+ if (!infolist_new_var_time (ptr_item, "date_printed", line->date))
+ return 0;
+ if (!infolist_new_var_string (ptr_item, "str_time", line->str_time))
+ return 0;
+
+ /* write tags */
+ if (!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 (!infolist_new_var_string (ptr_item, option_name,
+ line->tags_array[i]))
+ return 0;
+ length += strlen (line->tags_array[i]) + 1;
+ }
+ tags = malloc (length + 1);
+ if (!tags)
+ return 0;
+ tags[0] = '\0';
+ for (i = 0; i < line->tags_count; i++)
+ {
+ strcat (tags, line->tags_array[i]);
+ if (i < line->tags_count - 1)
+ strcat (tags, ",");
+ }
+ if (!infolist_new_var_string (ptr_item, "tags", tags))
+ {
+ free (tags);
+ return 0;
+ }
+ free (tags);
+
+ if (!infolist_new_var_integer (ptr_item, "displayed", line->displayed))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "highlight", line->highlight))
+ return 0;
+ if (!infolist_new_var_string (ptr_item, "prefix", line->prefix))
+ return 0;
+ if (!infolist_new_var_string (ptr_item, "message", line->message))
+ return 0;
+
+ return 1;
+}
+
+/*
* gui_buffer_dump_hexa: dump content of buffer as hexa data in log file
*/
diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h
index 5156acda4..cea43e42c 100644
--- a/src/gui/gui-buffer.h
+++ b/src/gui/gui-buffer.h
@@ -20,6 +20,8 @@
#ifndef __WEECHAT_GUI_BUFFER_H
#define __WEECHAT_GUI_BUFFER_H 1
+struct t_infolist;
+
enum t_gui_buffer_type
{
GUI_BUFFER_TYPE_FORMATED = 0,
@@ -68,6 +70,11 @@ struct t_gui_buffer
{
struct t_weechat_plugin *plugin; /* plugin which created this buffer */
/* (NULL for a WeeChat buffer) */
+ /* when upgrading, plugins are not loaded, so we use next variable
+ to store plugin name, then restore plugin pointer when plugin is
+ loaded */
+ char *plugin_name_for_upgrade; /* plugin name when upgrading */
+
int number; /* buffer number (for jump/switch) */
char *category; /* category name */
char *name; /* buffer name */
@@ -172,6 +179,8 @@ extern struct t_gui_buffer *gui_buffer_new (struct t_weechat_plugin *plugin,
struct t_gui_buffer *buffer),
void *close_callback_data);
extern int gui_buffer_valid (struct t_gui_buffer *buffer);
+extern void gui_buffer_set_plugin_for_upgrade (char *name,
+ struct t_weechat_plugin *plugin);
extern int gui_buffer_get_integer (struct t_gui_buffer *buffer,
const char *property);
extern char *gui_buffer_get_string (struct t_gui_buffer *buffer,
@@ -197,7 +206,7 @@ extern void gui_buffer_set_nicklist_case_sensitive (struct t_gui_buffer * buffer
int case_sensitive);
extern void gui_buffer_set_nick (struct t_gui_buffer *buffer, const char *new_nick);
extern void gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
- const char *value);
+ void *value);
extern struct t_gui_buffer *gui_buffer_search_main ();
extern struct t_gui_buffer *gui_buffer_search_by_category_name (const char *category,
const char *name);
@@ -216,6 +225,10 @@ extern void gui_buffer_switch_next (struct t_gui_window *window);
extern void gui_buffer_switch_by_number (struct t_gui_window *window,
int number);
extern void gui_buffer_move_to_number (struct t_gui_buffer *buffer, int number);
+extern int gui_buffer_add_to_infolist (struct t_infolist *infolist,
+ struct t_gui_buffer *buffer);
+extern int gui_buffer_line_add_to_infolist (struct t_infolist *infolist,
+ struct t_gui_line *line);
extern void gui_buffer_dump_hexa (struct t_gui_buffer *buffer);
extern void gui_buffer_print_log ();
diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c
index 6e72682ba..87fde2fe1 100644
--- a/src/gui/gui-chat.c
+++ b/src/gui/gui-chat.c
@@ -47,6 +47,7 @@
#include "gui-window.h"
+char *gui_chat_buffer = NULL; /* buffer for printf */
char *gui_chat_prefix[GUI_CHAT_NUM_PREFIXES]; /* prefixes */
char gui_chat_prefix_empty[] = ""; /* empty prefix */
int gui_chat_time_length = 0; /* length of time for each line (in chars) */
@@ -899,7 +900,6 @@ void
gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
const char *tags, const char *message, ...)
{
- char *buf;
va_list argptr;
time_t date_printed;
int display_time;
@@ -924,15 +924,16 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
return;
}
- buf = malloc (GUI_CHAT_BUFFER_PRINTF_SIZE);
- if (!buf)
+ if (!gui_chat_buffer)
+ gui_chat_buffer = malloc (GUI_CHAT_BUFFER_PRINTF_SIZE);
+ if (!gui_chat_buffer)
return;
va_start (argptr, message);
- vsnprintf (buf, GUI_CHAT_BUFFER_PRINTF_SIZE, message, argptr);
+ vsnprintf (gui_chat_buffer, GUI_CHAT_BUFFER_PRINTF_SIZE, message, argptr);
va_end (argptr);
- utf8_normalize (buf, '?');
+ utf8_normalize (gui_chat_buffer, '?');
date_printed = time (NULL);
if (date <= 0)
@@ -941,14 +942,14 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
if (gui_init_ok)
ptr_line = buffer->last_line;
- pos = buf;
+ pos = gui_chat_buffer;
while (pos)
{
pos_prefix = NULL;
display_time = 1;
/* if two first chars are tab, then do not display time */
- if ((buf[0] == '\t') && (buf[1] == '\t'))
+ if ((pos[0] == '\t') && (pos[1] == '\t'))
{
display_time = 0;
pos += 2;
@@ -956,11 +957,11 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
else
{
/* if tab found, use prefix (before tab) */
- pos_tab = strchr (buf, '\t');
+ pos_tab = strchr (pos, '\t');
if (pos_tab)
{
pos_tab[0] = '\0';
- pos_prefix = buf;
+ pos_prefix = pos;
pos = pos_tab + 1;
}
}
@@ -996,8 +997,6 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
if (gui_init_ok)
gui_buffer_ask_chat_refresh (buffer, 1);
-
- free (buf);
}
/*
diff --git a/src/gui/gui-chat.h b/src/gui/gui-chat.h
index 30c7c6894..35c20530e 100644
--- a/src/gui/gui-chat.h
+++ b/src/gui/gui-chat.h
@@ -77,6 +77,11 @@ extern int gui_chat_line_match_tags (struct t_gui_line *line, int tags_count,
extern void gui_chat_line_free (struct t_gui_buffer *buffer,
struct t_gui_line *line);
extern void gui_chat_line_free_all (struct t_gui_buffer *buffer);
+extern void gui_chat_line_add (struct t_gui_buffer *buffer, time_t date,
+ time_t date_printed, const char *tags,
+ const char *prefix, const char *message);
+extern void gui_chat_line_add_y (struct t_gui_buffer *buffer, int y,
+ const char *message);
extern void gui_chat_printf_date_tags (struct t_gui_buffer *buffer,
time_t date, const char *tags,
const char *message, ...);
diff --git a/src/gui/gui-history.c b/src/gui/gui-history.c
index 84d7eea93..51ac680a1 100644
--- a/src/gui/gui-history.c
+++ b/src/gui/gui-history.c
@@ -34,7 +34,7 @@
struct t_gui_history *history_global = NULL;
-struct t_gui_history *history_global_last = NULL;
+struct t_gui_history *last_history_global = NULL;
struct t_gui_history *history_global_ptr = NULL;
int num_history_global = 0;
@@ -115,7 +115,7 @@ gui_history_global_add (const char *string)
if (history_global)
history_global->prev_history = new_history;
else
- history_global_last = new_history;
+ last_history_global = new_history;
new_history->next_history = history_global;
new_history->prev_history = NULL;
history_global = new_history;
@@ -125,14 +125,14 @@ gui_history_global_add (const char *string)
if ((CONFIG_INTEGER(config_history_max_commands) > 0)
&& (num_history_global > CONFIG_INTEGER(config_history_max_commands)))
{
- ptr_history = history_global_last->prev_history;
- if (history_global_ptr == history_global_last)
+ ptr_history = last_history_global->prev_history;
+ if (history_global_ptr == last_history_global)
history_global_ptr = ptr_history;
- history_global_last->prev_history->next_history = NULL;
- if (history_global_last->text)
- free (history_global_last->text);
- free (history_global_last);
- history_global_last = ptr_history;
+ last_history_global->prev_history->next_history = NULL;
+ if (last_history_global->text)
+ free (last_history_global->text);
+ free (last_history_global);
+ last_history_global = ptr_history;
num_history_global--;
}
}
@@ -157,7 +157,7 @@ gui_history_global_free ()
history_global = ptr_history;
}
history_global = NULL;
- history_global_last = NULL;
+ last_history_global = NULL;
history_global_ptr = NULL;
num_history_global = 0;
}
diff --git a/src/gui/gui-history.h b/src/gui/gui-history.h
index 323817d33..e85b8f73d 100644
--- a/src/gui/gui-history.h
+++ b/src/gui/gui-history.h
@@ -30,7 +30,7 @@ struct t_gui_history
};
extern struct t_gui_history *history_global;
-extern struct t_gui_history *history_global_last;
+extern struct t_gui_history *last_history_global;
extern struct t_gui_history *history_global_ptr;
/* history functions (gui-history.c) */
diff --git a/src/gui/gui-hotlist.c b/src/gui/gui-hotlist.c
index 8f5c559a0..9bde8ae87 100644
--- a/src/gui/gui-hotlist.c
+++ b/src/gui/gui-hotlist.c
@@ -29,6 +29,7 @@
#include "../core/weechat.h"
#include "../core/wee-config.h"
#include "../core/wee-hook.h"
+#include "../core/wee-infolist.h"
#include "../core/wee-log.h"
#include "../core/wee-util.h"
#include "../plugins/plugin.h"
@@ -378,6 +379,34 @@ gui_hotlist_remove_buffer (struct t_gui_buffer *buffer)
}
/*
+ * gui_hotlist_add_to_infolist: add a hotlist in an infolist
+ * return 1 if ok, 0 if error
+ */
+
+int
+gui_hotlist_add_to_infolist (struct t_infolist *infolist,
+ struct t_gui_hotlist *hotlist)
+{
+ struct t_infolist_item *ptr_item;
+
+ if (!infolist || !hotlist)
+ return 0;
+
+ ptr_item = infolist_new_item (infolist);
+ if (!ptr_item)
+ return 0;
+
+ if (!infolist_new_var_integer (ptr_item, "priority", hotlist->priority))
+ return 0;
+ if (!infolist_new_var_buffer (ptr_item, "creation_time", &(hotlist->creation_time), sizeof (struct timeval)))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "buffer_number", hotlist->buffer->number))
+ return 0;
+
+ return 1;
+}
+
+/*
* gui_hotlist_print_log: print hotlist in log (usually for crash dump)
*/
diff --git a/src/gui/gui-hotlist.h b/src/gui/gui-hotlist.h
index 3099cc0b1..486e8bab6 100644
--- a/src/gui/gui-hotlist.h
+++ b/src/gui/gui-hotlist.h
@@ -57,6 +57,8 @@ extern void gui_hotlist_free (struct t_gui_hotlist **hotlist,
extern void gui_hotlist_free_all (struct t_gui_hotlist **hotlist,
struct t_gui_hotlist **last_hotlist);
extern void gui_hotlist_remove_buffer (struct t_gui_buffer *buffer);
+extern int gui_hotlist_add_to_infolist (struct t_infolist *infolist,
+ struct t_gui_hotlist *hotlist);
extern void gui_hotlist_print_log ();
#endif /* gui-hotlist.h */
diff --git a/src/gui/gui-nicklist.c b/src/gui/gui-nicklist.c
index 179b906f1..e851e008b 100644
--- a/src/gui/gui-nicklist.c
+++ b/src/gui/gui-nicklist.c
@@ -34,6 +34,7 @@
#include "../core/weechat.h"
#include "../core/wee-hook.h"
+#include "../core/wee-infolist.h"
#include "../core/wee-log.h"
#include "../core/wee-string.h"
#include "../core/wee-utf8.h"
@@ -610,6 +611,78 @@ gui_nicklist_compute_visible_count (struct t_gui_buffer *buffer,
}
/*
+ * gui_nicklist_add_to_infolist: add a nicklist in an infolist
+ * return 1 if ok, 0 if error
+ */
+
+int
+gui_nicklist_add_to_infolist (struct t_infolist *infolist,
+ struct t_gui_buffer *buffer)
+{
+ struct t_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 = infolist_new_item (infolist);
+ if (!ptr_item)
+ return 0;
+
+ if (ptr_nick)
+ {
+ if (!infolist_new_var_string (ptr_item, "type", "nick"))
+ return 0;
+ if (ptr_nick->group)
+ {
+ if (!infolist_new_var_string (ptr_item, "group_name", ptr_nick->group->name))
+ return 0;
+ }
+ if (!infolist_new_var_string (ptr_item, "name", ptr_nick->name))
+ return 0;
+ if (!infolist_new_var_string (ptr_item, "color", ptr_nick->color))
+ return 0;
+ prefix[0] = ptr_nick->prefix;
+ prefix[1] = '\0';
+ if (!infolist_new_var_string (ptr_item, "prefix", prefix))
+ return 0;
+ if (!infolist_new_var_string (ptr_item, "prefix_color", ptr_nick->prefix_color))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "visible", ptr_nick->visible))
+ return 0;
+ }
+ else
+ {
+ if (!infolist_new_var_string (ptr_item, "type", "group"))
+ return 0;
+ if (ptr_group->parent)
+ {
+ if (!infolist_new_var_string (ptr_item, "parent_name", ptr_group->parent->name))
+ return 0;
+ }
+ if (!infolist_new_var_string (ptr_item, "name", ptr_group->name))
+ return 0;
+ if (!infolist_new_var_string (ptr_item, "color", ptr_group->color))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "visible", ptr_group->visible))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "level", ptr_group->level))
+ return 0;
+ }
+ gui_nicklist_get_next_item (buffer, &ptr_group, &ptr_nick);
+ }
+
+ return 1;
+}
+
+/*
* gui_nicklist_print_log: print nicklist infos in log (usually for crash dump)
*/
diff --git a/src/gui/gui-nicklist.h b/src/gui/gui-nicklist.h
index 4ca8f7a70..687109731 100644
--- a/src/gui/gui-nicklist.h
+++ b/src/gui/gui-nicklist.h
@@ -21,6 +21,7 @@
#define __WEECHAT_GUI_NICKLIST_H 1
struct t_gui_buffer;
+struct t_infolist;
struct t_gui_nick_group
{
@@ -79,6 +80,8 @@ extern int gui_nicklist_get_max_length (struct t_gui_buffer *buffer,
struct t_gui_nick_group *group);
extern void gui_nicklist_compute_visible_count (struct t_gui_buffer *buffer,
struct t_gui_nick_group *group);
+extern int gui_nicklist_add_to_infolist (struct t_infolist *infolist,
+ struct t_gui_buffer *buffer);
extern void gui_nicklist_print_log (struct t_gui_nick_group *group, int indent);
/* nicklist functions (GUI dependent) */
diff --git a/src/gui/gui-window.c b/src/gui/gui-window.c
index 0b5c498e2..d9da78738 100644
--- a/src/gui/gui-window.c
+++ b/src/gui/gui-window.c
@@ -35,6 +35,7 @@
#include "../core/weechat.h"
#include "../core/wee-config.h"
#include "../core/wee-hook.h"
+#include "../core/wee-infolist.h"
#include "../core/wee-log.h"
#include "../core/wee-utf8.h"
#include "../plugins/plugin.h"
@@ -881,6 +882,93 @@ gui_window_search_stop (struct t_gui_window *window)
}
/*
+ * gui_window_add_to_infolist: add a window in an infolist
+ * return 1 if ok, 0 if error
+ */
+
+int
+gui_window_add_to_infolist (struct t_infolist *infolist,
+ struct t_gui_window *window)
+{
+ struct t_infolist_item *ptr_item;
+
+ if (!infolist || !window)
+ return 0;
+
+ ptr_item = infolist_new_item (infolist);
+ if (!ptr_item)
+ return 0;
+
+ if (!infolist_new_var_pointer (ptr_item, "pointer", window))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "x", window->win_x))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "y", window->win_y))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "width", window->win_width))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "height", window->win_height))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "width_pct", window->win_width_pct))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "height_pct", window->win_height_pct))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "chat_x", window->win_chat_x))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "chat_y", window->win_chat_y))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "chat_width", window->win_chat_width))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "chat_height", window->win_chat_height))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "nick_x", window->win_nick_x))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "nick_y", window->win_nick_y))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "nick_width", window->win_nick_width))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "nick_height", window->win_nick_height))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "nick_start", window->win_nick_start))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "title_x", window->win_title_x))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "title_y", window->win_title_y))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "title_width", window->win_title_width))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "title_start", window->win_title_start))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "status_x", window->win_status_x))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "status_y", window->win_status_y))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "status_width", window->win_status_width))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "status_height", window->win_status_height))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "input_x", window->win_input_x))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "input_y", window->win_input_y))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "input_width", window->win_input_width))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "input_height", window->win_input_height))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "input_cursor_x", window->win_input_cursor_x))
+ return 0;
+ if (!infolist_new_var_pointer (ptr_item, "buffer", window->buffer))
+ return 0;
+ if (!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;
+}
+
+/*
* gui_window_print_log: print window infos in log (usually for crash dump)
*/
diff --git a/src/gui/gui-window.h b/src/gui/gui-window.h
index b753b6364..b47da4082 100644
--- a/src/gui/gui-window.h
+++ b/src/gui/gui-window.h
@@ -20,6 +20,8 @@
#ifndef __WEECHAT_GUI_WINDOW_H
#define __WEECHAT_GUI_WINDOW_H 1
+struct t_infolist;
+
extern int gui_init_ok;
extern int gui_ok;
extern int gui_window_refresh_needed;
@@ -135,6 +137,8 @@ extern void gui_window_search_start (struct t_gui_window *window);
extern void gui_window_search_restart (struct t_gui_window *window);
extern void gui_window_search_stop (struct t_gui_window *window);
extern int gui_window_search_text (struct t_gui_window *window);
+extern int gui_window_add_to_infolist (struct t_infolist *infolist,
+ struct t_gui_window *window);
extern void gui_window_print_log ();
/* window functions (GUI dependent) */