diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2017-04-25 21:07:15 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2017-04-25 21:07:15 +0200 |
commit | 8edca0dd75bdbe500b2a8c59e338f871cf696b19 (patch) | |
tree | 01217b4dd847aeb19c72f073a4e57f35d72335fb /src/plugins/buflist/buflist-bar-item.c | |
parent | 4049c6c8a272b7cb5eef93015dff94698bd6c62d (diff) | |
download | weechat-8edca0dd75bdbe500b2a8c59e338f871cf696b19.zip |
buflist: add pointers to IRC server and channel
New pointers in evaluated formats:
- irc_server: IRC server
- irc_channel: IRC channel
Diffstat (limited to 'src/plugins/buflist/buflist-bar-item.c')
-rw-r--r-- | src/plugins/buflist/buflist-bar-item.c | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/src/plugins/buflist/buflist-bar-item.c b/src/plugins/buflist/buflist-bar-item.c index 5220a23d5..036b42f0b 100644 --- a/src/plugins/buflist/buflist-bar-item.c +++ b/src/plugins/buflist/buflist-bar-item.c @@ -52,13 +52,18 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data, struct t_gui_buffer *ptr_buffer, *ptr_current_buffer; struct t_gui_nick *ptr_gui_nick; struct t_gui_hotlist *ptr_hotlist; + struct t_hdata *hdata_irc_server, *hdata_irc_channel; + struct t_irc_server *ptr_server; + struct t_irc_channel *ptr_channel; char **buflist, *str_buflist, *condition; + char str_condition[512]; char str_format_number[32], str_format_number_empty[32]; char str_nick_prefix[32], str_color_nick_prefix[32]; char str_number[32], *line, **hotlist, *str_hotlist; char str_hotlist_count[32]; const char *ptr_format, *ptr_format_current, *ptr_format_indent; - const char *ptr_name, *ptr_type, *ptr_nick, *ptr_nick_prefix; + const char *ptr_name, *ptr_type, *ptr_server_name, *ptr_channel_name; + const char *ptr_nick, *ptr_nick_prefix; const char *ptr_hotlist_format, *ptr_hotlist_priority; const char *hotlist_priority_none = "none"; const char *hotlist_priority[4] = { "low", "message", "private", @@ -79,6 +84,9 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data, prev_number = -1; + hdata_irc_server = NULL; + hdata_irc_channel = NULL; + buflist = weechat_string_dyn_alloc (256); ptr_format = weechat_config_string (buflist_config_format_buffer); @@ -113,6 +121,58 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data, weechat_hashtable_set (buflist_hashtable_pointers, "buffer", ptr_buffer); + /* set IRC server/channel pointers */ + ptr_server = NULL; + ptr_channel = NULL; + if (strcmp (weechat_buffer_get_string (ptr_buffer, "plugin"), "irc") == 0) + { + ptr_server_name = weechat_buffer_get_string (ptr_buffer, "localvar_server"); + if (ptr_server_name && ptr_server_name[0]) + { + if (!hdata_irc_server) + hdata_irc_server = weechat_hdata_get ("irc_server"); + if (hdata_irc_server) + { + snprintf (str_condition, sizeof (str_condition), + "${irc_server.name} == %s", + ptr_server_name); + ptr_server = weechat_hdata_get_list (hdata_irc_server, + "irc_servers"); + ptr_server = weechat_hdata_search (hdata_irc_server, + ptr_server, + str_condition, + 1); + if (ptr_server) + { + ptr_channel_name = weechat_buffer_get_string (ptr_buffer, + "localvar_channel"); + if (ptr_channel_name && ptr_channel_name[0]) + { + if (!hdata_irc_channel) + hdata_irc_channel = weechat_hdata_get ("irc_channel"); + if (hdata_irc_channel) + { + snprintf (str_condition, sizeof (str_condition), + "${irc_channel.name} == %s", + ptr_channel_name); + ptr_channel = weechat_hdata_pointer (hdata_irc_server, + ptr_server, + "channels"); + ptr_channel = weechat_hdata_search (hdata_irc_channel, + ptr_channel, + str_condition, + 1); + } + } + } + } + } + } + weechat_hashtable_set (buflist_hashtable_pointers, + "irc_server", ptr_server); + weechat_hashtable_set (buflist_hashtable_pointers, + "irc_channel", ptr_channel); + /* check condition: if false, the buffer is not displayed */ condition = weechat_string_eval_expression ( weechat_config_string (buflist_config_look_display_conditions), |