add support for channel topic displaying

Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
Chris Michael 2014-12-16 15:35:44 -05:00
parent 2a85cde33d
commit f61a78eb61
4 changed files with 30 additions and 4 deletions

View File

@ -18,7 +18,7 @@ _callback_server_disconnected(Express_Network *net, const char *event EINA_UNUSE
}
void
_callback_server_motd(Express_Network *net, const char *event, const char *source, const char **params, unsigned int count, void *data)
_callback_server_motd(Express_Network *net EINA_UNUSED, const char *event EINA_UNUSED, const char *source, const char **params, unsigned int count EINA_UNUSED, void *data EINA_UNUSED)
{
Channel *chl;
@ -34,7 +34,7 @@ _callback_server_motd(Express_Network *net, const char *event, const char *sourc
}
void
_callback_channel_message(Express_Network *net, const char *event, const char *source, const char **params, unsigned int count, void *data)
_callback_channel_message(Express_Network *net EINA_UNUSED, const char *event EINA_UNUSED, const char *source, const char **params, unsigned int count, void *data EINA_UNUSED)
{
Channel *chl = NULL;
@ -50,7 +50,7 @@ _callback_channel_message(Express_Network *net, const char *event, const char *s
}
void
_callback_channel_notice(Express_Network *net, const char *event, const char *source, const char **params, unsigned int count, void *data)
_callback_channel_notice(Express_Network *net EINA_UNUSED, const char *event EINA_UNUSED, const char *source, const char **params, unsigned int count EINA_UNUSED, void *data EINA_UNUSED)
{
Channel *chl = NULL;
@ -78,3 +78,22 @@ _callback_channel_notice(Express_Network *net, const char *event, const char *so
if (!chl) return;
_channel_text_append(chl, NULL, params[1]);
}
void
_callback_channel_topic(Express_Network *net EINA_UNUSED, const char *event EINA_UNUSED, const char *source, const char **params, unsigned int count, void *data EINA_UNUSED)
{
Channel *chl = NULL;
char buff[PATH_MAX];
DBG("Channel Topic: %s", params[0]);
DBG("\tCount: %d", count);
DBG("\tUser: %s", source);
DBG("\tMessage:");
DBG("\t%s", params[1]);
DBG("\t%s", params[2]);
if (!(chl = _window_channel_find(params[1]))) return;
snprintf(buff, sizeof(buff), "Topic for %s is: ", params[1]);
_channel_text_append(chl, NULL, buff);
_channel_text_append(chl, NULL, params[2]);
}

View File

@ -7,5 +7,6 @@ void _callback_server_motd(Express_Network *net, const char *event, const char *
void _callback_channel_message(Express_Network *net, const char *event, const char *source, const char **params, unsigned int count, void *data);
void _callback_channel_notice(Express_Network *net, const char *event, const char *source, const char **params, unsigned int count, void *data);
void _callback_channel_topic(Express_Network *net, const char *event, const char *source, const char **params, unsigned int count, void *data);
#endif

View File

@ -215,6 +215,7 @@ _cb_idle(void *data EINA_UNUSED)
cbs.motd = _callback_server_motd;
cbs.channel_msg = _callback_channel_message;
cbs.channel_notice = _callback_channel_notice;
cbs.topic = _callback_channel_topic;
/* try to create a new network */
if (!(net = express_network_create(&cbs, cfg_net->name)))

View File

@ -136,7 +136,12 @@ _process_buffer(Express_Network *net, char *data, int length)
(*net->callbacks.motd)(net, "MOTD", prefix, params, index,
net->callbacks.data);
}
/* call the motd callback */
else if (code == 332)
{
if (net->callbacks.topic)
(*net->callbacks.topic)(net, "TOPIC", prefix, params, index,
net->callbacks.data);
}
else if (net->callbacks.numeric)
(*net->callbacks.numeric)(net, code, prefix, params, index,
net->callbacks.data);