summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--src/core/wee-upgrade.c2
-rw-r--r--src/gui/gui-nicklist.c141
-rw-r--r--src/gui/gui-nicklist.h3
-rw-r--r--src/plugins/plugin-api.c2
5 files changed, 105 insertions, 46 deletions
diff --git a/ChangeLog b/ChangeLog
index d8c00d539..970616e67 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,7 @@
WeeChat ChangeLog
=================
FlashCode <flashcode@flashtux.org>
-v0.3.2-dev, 2010-02-11
+v0.3.2-dev, 2010-02-12
Version 0.3.2 (under dev!)
@@ -15,6 +15,7 @@ Version 0.3.2 (under dev!)
* core: add new option weechat.look.time_format to customize default format
for date/time displayed (localized date by default), add function
weechat_util_get_time_string in plugin API (patch #6914)
+* core: use arguments for infolist "nicklist" to return only one nick or group
* gui: fix bug with global history, reset pointer to last entry after each user
input (bug #28754)
* api: add "version_number" for function info_get to get WeeChat version as
diff --git a/src/core/wee-upgrade.c b/src/core/wee-upgrade.c
index dcb48084e..c468763cd 100644
--- a/src/core/wee-upgrade.c
+++ b/src/core/wee-upgrade.c
@@ -135,7 +135,7 @@ upgrade_weechat_save_buffers (struct t_upgrade_file *upgrade_file)
ptr_infolist = infolist_new ();
if (!ptr_infolist)
return 0;
- if (!gui_nicklist_add_to_infolist (ptr_infolist, ptr_buffer))
+ if (!gui_nicklist_add_to_infolist (ptr_infolist, ptr_buffer, NULL))
{
infolist_free (ptr_infolist);
return 0;
diff --git a/src/gui/gui-nicklist.c b/src/gui/gui-nicklist.c
index bf671c2f8..f6174274c 100644
--- a/src/gui/gui-nicklist.c
+++ b/src/gui/gui-nicklist.c
@@ -632,68 +632,125 @@ gui_nicklist_compute_visible_count (struct t_gui_buffer *buffer,
}
/*
+ * gui_nicklist_add_group_to_infolist: add a group in an infolist
+ * return 1 if ok, 0 if error
+ */
+
+int
+gui_nicklist_add_group_to_infolist (struct t_infolist *infolist,
+ struct t_gui_nick_group *group)
+{
+ struct t_infolist_item *ptr_item;
+
+ if (!infolist || !group)
+ return 0;
+
+ ptr_item = infolist_new_item (infolist);
+ if (!ptr_item)
+ return 0;
+
+ if (!infolist_new_var_string (ptr_item, "type", "group"))
+ return 0;
+ if (group->parent)
+ {
+ if (!infolist_new_var_string (ptr_item, "parent_name", group->parent->name))
+ return 0;
+ }
+ if (!infolist_new_var_string (ptr_item, "name", group->name))
+ return 0;
+ if (!infolist_new_var_string (ptr_item, "color", group->color))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "visible", group->visible))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "level", group->level))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * gui_nicklist_add_nick_to_infolist: add a nick in an infolist
+ * return 1 if ok, 0 if error
+ */
+
+int
+gui_nicklist_add_nick_to_infolist (struct t_infolist *infolist,
+ struct t_gui_nick *nick)
+{
+ struct t_infolist_item *ptr_item;
+
+ if (!infolist || !nick)
+ return 0;
+
+ ptr_item = infolist_new_item (infolist);
+ if (!ptr_item)
+ return 0;
+
+ if (!infolist_new_var_string (ptr_item, "type", "nick"))
+ return 0;
+ if (nick->group)
+ {
+ if (!infolist_new_var_string (ptr_item, "group_name", nick->group->name))
+ return 0;
+ }
+ if (!infolist_new_var_string (ptr_item, "name", nick->name))
+ return 0;
+ if (!infolist_new_var_string (ptr_item, "color", nick->color))
+ return 0;
+ if (!infolist_new_var_string (ptr_item, "prefix", nick->prefix))
+ return 0;
+ if (!infolist_new_var_string (ptr_item, "prefix_color", nick->prefix_color))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "visible", nick->visible))
+ return 0;
+
+ return 1;
+}
+
+/*
* 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_gui_buffer *buffer,
+ const char *name)
{
- struct t_infolist_item *ptr_item;
struct t_gui_nick_group *ptr_group;
struct t_gui_nick *ptr_nick;
if (!infolist || !buffer)
return 0;
+ /* add only one nick if asked */
+ if (name && (strncmp (name, "nick_", 5) == 0))
+ {
+ ptr_nick = gui_nicklist_search_nick (buffer, NULL, name + 5);
+ if (!ptr_nick)
+ return 0;
+ return gui_nicklist_add_nick_to_infolist (infolist, ptr_nick);
+ }
+
+ /* add only one group if asked */
+ if (name && (strncmp (name, "group_", 6) == 0))
+ {
+ ptr_group = gui_nicklist_search_group (buffer, NULL, name + 6);
+ if (!ptr_group)
+ return 0;
+ return gui_nicklist_add_group_to_infolist (infolist, ptr_group);
+ }
+
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;
- if (!infolist_new_var_string (ptr_item, "prefix", ptr_nick->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;
- }
+ gui_nicklist_add_nick_to_infolist (infolist, ptr_nick);
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_add_group_to_infolist (infolist, ptr_group);
+
gui_nicklist_get_next_item (buffer, &ptr_group, &ptr_nick);
}
diff --git a/src/gui/gui-nicklist.h b/src/gui/gui-nicklist.h
index 037e8d027..e6fbb4071 100644
--- a/src/gui/gui-nicklist.h
+++ b/src/gui/gui-nicklist.h
@@ -82,7 +82,8 @@ extern char *gui_nicklist_get_group_start (const char *name);
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);
+ struct t_gui_buffer *buffer,
+ const char *name);
extern void gui_nicklist_print_log (struct t_gui_nick_group *group, int indent);
#endif /* gui-nicklist.h */
diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c
index 77aa2844c..d3286845f 100644
--- a/src/plugins/plugin-api.c
+++ b/src/plugins/plugin-api.c
@@ -668,7 +668,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
ptr_infolist = infolist_new ();
if (ptr_infolist)
{
- if (!gui_nicklist_add_to_infolist (ptr_infolist, pointer))
+ if (!gui_nicklist_add_to_infolist (ptr_infolist, pointer, arguments))
{
infolist_free (ptr_infolist);
return NULL;