diff options
author | tomsmeding <tom.smeding@gmail.com> | 2017-04-15 17:19:55 +0200 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2017-04-15 17:19:55 +0200 |
commit | 40bb947cd10f50d13423c5f16cfd6a36927dd209 (patch) | |
tree | fe6d2fb176a240dc9182117c1274cb39fadb5812 | |
parent | cbe3d8302cb1e50f7a5f00c10b5262ccddd51331 (diff) |
weechat: Request is_online status on member list receive
-rw-r--r-- | weechat/global.h | 1 | ||||
-rw-r--r-- | weechat/tomsg.c | 31 |
2 files changed, 32 insertions, 0 deletions
diff --git a/weechat/global.h b/weechat/global.h index 10274a9..7972975 100644 --- a/weechat/global.h +++ b/weechat/global.h @@ -1,6 +1,7 @@ #pragma once #include <stdint.h> +#include <inttypes.h> typedef uint8_t u8; diff --git a/weechat/tomsg.c b/weechat/tomsg.c index 8fcc3de..01aa995 100644 --- a/weechat/tomsg.c +++ b/weechat/tomsg.c @@ -135,6 +135,32 @@ static void history_net_callback(int fd,struct net_response res,void *payload){ fprintf(debugf,"history_net_callback(fd=%d,res={.type=%d})\n",fd,res.type); } +struct room_and_name{ + struct roomdata *room; + char *name; +}; + +static void isonline_net_callback(int fd,struct net_response res,void *payload){ + (void)fd; + fprintf(debugf,"isonline_net_callback(fd=%d,res={.type=%d,.number=%" PRIi64 "})\n", + fd,res.type,res.number); + const char *color= + res.type!=NET_NUMBER ? "red" : + res.number >= 1 ? "weechat.color.chat_nick" : + "weechat.color.nicklist_away"; + + struct room_and_name *rn=(struct room_and_name*)payload; + struct roomdata *room=rn->room; + char *name=rn->name; + free(rn); + + struct t_gui_nick *nickp=weechat_nicklist_search_nick(room->buffer,room->buffer_nickgroup,name); + fprintf(debugf," nickp=%p: setting '%s' to '%s'\n",nickp,name,color); + free(name); + if(nickp==NULL)return; + weechat_nicklist_nick_set(room->buffer,nickp,"color",color); +} + static void members_net_callback(int fd,struct net_response res,void *payload){ struct roomdata *room=(struct roomdata*)payload; assert(room); @@ -154,6 +180,11 @@ static void members_net_callback(int fd,struct net_response res,void *payload){ res.items[i],"weechat.color.chat_nick", "","weechat.color.chat_nick", 1); + struct room_and_name *payload=malloc(sizeof(struct room_and_name)); + assert(payload); + payload->room=room; + payload->name=strdup(res.items[i]); + net_sendf(fd,isonline_net_callback,payload,"is_online %s",res.items[i]); } room->nmembers=res.nitems; room_update_attributes(room); |