diff options
author | tomsmeding <tom.smeding@gmail.com> | 2017-04-09 20:33:29 +0200 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2017-04-09 20:33:29 +0200 |
commit | 299368b5d5facd4996ad2b763979f2b3edf8cb09 (patch) | |
tree | 4a264ef433b232b60597d90cf44c26fb58ceda40 /weechat | |
parent | 915529d323dbb903cd702436ba4e083e80187972 (diff) |
weechat: Set notify to 'messages' for 2-people chats
Diffstat (limited to 'weechat')
-rw-r--r-- | weechat/TODO.txt | 1 | ||||
-rw-r--r-- | weechat/tomsg.c | 21 |
2 files changed, 18 insertions, 4 deletions
diff --git a/weechat/TODO.txt b/weechat/TODO.txt deleted file mode 100644 index 7f8db51..0000000 --- a/weechat/TODO.txt +++ /dev/null @@ -1 +0,0 @@ -- buffer_set(buffer, "notify", "2") on chats with 2 people 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); |