From 40bb947cd10f50d13423c5f16cfd6a36927dd209 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sat, 15 Apr 2017 17:19:55 +0200 Subject: weechat: Request is_online status on member list receive --- weechat/global.h | 1 + weechat/tomsg.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) 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 +#include 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); -- cgit v1.2.3-70-g09d2