From 299368b5d5facd4996ad2b763979f2b3edf8cb09 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sun, 9 Apr 2017 20:33:29 +0200 Subject: weechat: Set notify to 'messages' for 2-people chats --- weechat/tomsg.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'weechat/tomsg.c') diff --git a/weechat/tomsg.c b/weechat/tomsg.c index c860aea..9c92543 100644 --- a/weechat/tomsg.c +++ b/weechat/tomsg.c @@ -24,6 +24,7 @@ struct roomdata{ char *name; struct t_gui_buffer *buffer; struct t_gui_nick_group *buffer_nickgroup; + int nmembers; struct conndata *conn; // do not free }; @@ -50,6 +51,18 @@ static struct t_weechat_plugin *weechat_plugin; static struct t_hashtable *conntable; +static void room_update_attributes(struct roomdata *room){ + bool private=room->nmembers<=2; + weechat_buffer_set(room->buffer,"localvar_set_type",private?"private":"channel"); + weechat_buffer_set(room->buffer,"notify",private?"2":"1"); + fprintf(debugf,"room_update_attributes: set private for room %s to %d\n",room->name,private); + if(room->conn->username){ + weechat_buffer_set(room->buffer,"localvar_set_nick",room->conn->username); + } else { + weechat_buffer_set(room->buffer,"localvar_del_nick",""); + } +} + static void close_room(struct roomdata *room){ fprintf(debugf,"close_room(room=%p)\n",room); free(room->name); @@ -108,11 +121,9 @@ static void create_room_buffer(struct roomdata *room){ weechat_buffer_set(room->buffer,"nicklist","1"); weechat_buffer_set(room->buffer,"nicklist_case_sensitive","1"); weechat_buffer_set(room->buffer,"nicklist_display_groups","0"); - if(room->conn->username){ - weechat_buffer_set(room->buffer,"localvar_set_nick",room->conn->username); - } room->buffer_nickgroup=NULL; + room_update_attributes(room); } static void history_net_callback(int fd,struct net_response res,void *payload){ @@ -141,6 +152,8 @@ static void members_net_callback(int fd,struct net_response res,void *payload){ "","chat_nick", 1); } + room->nmembers=res.nitems; + room_update_attributes(room); } static void push_net_callback(int fd,struct net_response res,void *payload){ @@ -177,6 +190,8 @@ static void push_net_callback(int fd,struct net_response res,void *payload){ "","chat_nick", 1); } + room->nmembers++; + room_update_attributes(room); } else if(res.type==NET_INVITE){ weechat_printf(room->buffer,"%sYou were invited into this room",netpfx); net_sendf(fd,history_net_callback,room,"history %s 10",room->name); -- cgit v1.2.3-54-g00ecf