summaryrefslogtreecommitdiff
path: root/src/gui/gui-buffer.c
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2024-04-07 10:09:04 +0200
committerSébastien Helleu <flashcode@flashtux.org>2024-04-07 13:18:14 +0200
commit89fe540b531705d8455685173c692522e81cd134 (patch)
tree717a3b15ef5e7d254a2515371efac6d79329f527 /src/gui/gui-buffer.c
parent40a68549b5d4d99c0083f15242aab7516a87871f (diff)
downloadweechat-89fe540b531705d8455685173c692522e81cd134.zip
core: add unique "id" in nicklist group and nick (issue #2081)
The id is a "long long" variable with the current time (microseconds precision). It is guaranteed to be unique for all groups and nicks inside the buffer, and the same number is never used again in the same buffer, during the lifetime of the process. It persists and is unchanged after `/upgrade`.
Diffstat (limited to 'src/gui/gui-buffer.c')
-rw-r--r--src/gui/gui-buffer.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c
index 8941affea..d7edf0c90 100644
--- a/src/gui/gui-buffer.c
+++ b/src/gui/gui-buffer.c
@@ -110,9 +110,9 @@ char *gui_buffer_properties_get_integer[] =
};
char *gui_buffer_properties_get_string[] =
{ "id", "plugin", "name", "full_name", "old_full_name", "short_name", "title",
- "input", "text_search_input", "highlight_words", "highlight_disable_regex",
- "highlight_regex", "highlight_tags_restrict", "highlight_tags",
- "hotlist_max_level_nicks",
+ "nicklist_last_id_assigned", "input", "text_search_input", "highlight_words",
+ "highlight_disable_regex", "highlight_regex", "highlight_tags_restrict",
+ "highlight_tags", "hotlist_max_level_nicks",
NULL
};
char *gui_buffer_properties_get_pointer[] =
@@ -888,10 +888,11 @@ gui_buffer_new_props_with_id (long long id,
new_buffer->nicklist_groups_visible_count = 0;
new_buffer->nicklist_nicks_count = 0;
new_buffer->nicklist_nicks_visible_count = 0;
+ new_buffer->nicklist_last_id_assigned = -1;
new_buffer->nickcmp_callback = NULL;
new_buffer->nickcmp_callback_pointer = NULL;
new_buffer->nickcmp_callback_data = NULL;
- gui_nicklist_add_group (new_buffer, NULL, "root", NULL, 0);
+ gui_nicklist_add_group_with_id (new_buffer, 0, NULL, "root", NULL, 0);
/* input */
new_buffer->input = 1;
@@ -1539,6 +1540,12 @@ gui_buffer_get_string (struct t_gui_buffer *buffer, const char *property)
return gui_buffer_type_string[buffer->type];
else if (strcmp (property, "title") == 0)
return buffer->title;
+ else if (strcmp (property, "nicklist_last_id_assigned") == 0)
+ {
+ snprintf (str_value, sizeof (str_value),
+ "%lld", buffer->nicklist_last_id_assigned);
+ return str_value;
+ }
else if (strcmp (property, "input") == 0)
return buffer->input_buffer;
else if (strcmp (property, "text_search_input") == 0)
@@ -5188,6 +5195,7 @@ gui_buffer_hdata_buffer_cb (const void *pointer, void *data,
HDATA_VAR(struct t_gui_buffer, nicklist_groups_visible_count, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, nicklist_nicks_count, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, nicklist_nicks_visible_count, INTEGER, 0, NULL, NULL);
+ HDATA_VAR(struct t_gui_buffer, nicklist_last_id_assigned, LONGLONG, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, nickcmp_callback, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, nickcmp_callback_pointer, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, nickcmp_callback_data, POINTER, 0, NULL, NULL);
@@ -5407,6 +5415,9 @@ gui_buffer_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!infolist_new_var_integer (ptr_item, "nicklist_nicks_visible_count", buffer->nicklist_nicks_visible_count))
return 0;
+ snprintf (str_value, sizeof (str_value), "%lld", buffer->nicklist_last_id_assigned);
+ if (!infolist_new_var_string (ptr_item, "nicklist_last_id_assigned", str_value))
+ return 0;
if (!infolist_new_var_string (ptr_item, "title", buffer->title))
return 0;
if (!infolist_new_var_integer (ptr_item, "input", buffer->input))
@@ -5643,6 +5654,7 @@ gui_buffer_print_log ()
log_printf (" nicklist_groups_vis_cnt : %d", ptr_buffer->nicklist_groups_visible_count);
log_printf (" nicklist_nicks_count. . : %d", ptr_buffer->nicklist_nicks_count);
log_printf (" nicklist_nicks_vis_cnt. : %d", ptr_buffer->nicklist_nicks_visible_count);
+ log_printf (" nicklist_last_id_assigned: %lld", ptr_buffer->nicklist_last_id_assigned);
log_printf (" nickcmp_callback. . . . : %p", ptr_buffer->nickcmp_callback);
log_printf (" nickcmp_callback_pointer: %p", ptr_buffer->nickcmp_callback_pointer);
log_printf (" nickcmp_callback_data . : %p", ptr_buffer->nickcmp_callback_data);