aboutsummaryrefslogtreecommitdiff
path: root/weechat/tomsg.c
diff options
context:
space:
mode:
Diffstat (limited to 'weechat/tomsg.c')
-rw-r--r--weechat/tomsg.c31
1 files changed, 31 insertions, 0 deletions
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);