From d0765d918977a0348050521d7b8f79faf99e07d3 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Fri, 30 Jan 2015 14:54:35 -0500 Subject: [PATCH] handle parsing irc NAMES command Signed-off-by: Chris Michael --- src/bin/callbacks.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/bin/callbacks.c b/src/bin/callbacks.c index 5e2a611..b6dc053 100644 --- a/src/bin/callbacks.c +++ b/src/bin/callbacks.c @@ -136,15 +136,16 @@ void _callback_channel_names(Express_Network *net EINA_UNUSED, const char *event EINA_UNUSED, const char *source EINA_UNUSED, const char **params, unsigned int count EINA_UNUSED, void *data EINA_UNUSED) { Channel *chl = NULL; - /* char buff[PATH_MAX]; */ + char **users; + unsigned int n = 0, i = 0; - DBG("Channel Names: %s", params[0]); - DBG("\tCount: %d", count); - DBG("\tUser: %s", source); - DBG("\tMessage:"); - DBG("\t%s", params[1]); // trash (@ or =) - DBG("\t%s", params[2]); // channel name - DBG("\t%s", params[3]); // names + /* DBG("Channel Names: %s", params[0]); */ + /* DBG("\tCount: %d", count); */ + /* DBG("\tUser: %s", source); */ + /* DBG("\tMessage:"); */ + /* DBG("\t%s", params[1]); */ + /* DBG("\t%s", params[2]); */ + /* DBG("\t%s", params[3]); */ if (!(chl = _window_channel_find(params[2]))) return; @@ -153,9 +154,21 @@ _callback_channel_names(Express_Network *net EINA_UNUSED, const char *event EINA else _channel_userlist_hide(chl); - /* snprintf(buff, sizeof(buff), "Topic for %s set by %s at %s\r\n", */ - /* params[1], params[2], strtime); */ - /* _channel_text_append(chl, NULL, buff); */ + users = eina_str_split_full(params[3], " ", -1, &n); + for (; i < n; i++) + { + if (users[i][0] == '@') + { + users[i]++; + _channel_userlist_user_append(chl, users[i], EINA_TRUE); + } + else + _channel_userlist_user_append(chl, users[i], EINA_FALSE); + } + _channel_userlist_go(chl); + + free(users[0]); + free(users); } void