express/src/bin/callbacks.c

100 lines
3.0 KiB
C
Raw Normal View History

#include "private.h"
#include "callbacks.h"
#include "window.h"
#include "channel.h"
void
_callback_server_connected(Express_Network *net, const char *event EINA_UNUSED, const char *source, const char **params EINA_UNUSED, unsigned int count EINA_UNUSED, void *data EINA_UNUSED)
{
DBG("Server %s Connected", source);
_window_network_channels_create(net);
}
void
_callback_server_disconnected(Express_Network *net, const char *event EINA_UNUSED, const char *source, const char **params EINA_UNUSED, unsigned int count EINA_UNUSED, void *data EINA_UNUSED)
{
DBG("Server %s Disconnected", source);
_window_network_channels_destroy(net);
}
void
_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;
DBG("Server Motd");
DBG("\tServer: %s", source);
DBG("\tCount: %d", count);
DBG("\tUser: %s", params[0]);
DBG("\tMessage:");
DBG("\t%s", params[1]);
if (!(chl = _window_channel_server_find(source))) return;
_channel_text_append(chl, NULL, params[1]);
}
void
_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;
DBG("Channel Message: %s", params[0]);
DBG("\tCount: %d", count);
DBG("\tUser: %s", source);
DBG("\tMessage:");
DBG("\t%s", params[1]);
if (!(chl = _window_channel_find(params[0]))) return;
_channel_text_append(chl, source, params[1]);
}
void
_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;
DBG("Channel Notice: %s", params[0]);
DBG("\tCount: %d", count);
DBG("\tServer: %s", source);
DBG("\tMessage:");
DBG("\t%s", params[1]);
if (!strcmp(params[0], "*"))
{
if (!(chl = _window_channel_server_find(source)))
{
ERR("Could not find channel with server name: %s", source);
if (!(chl = _window_channel_find("Default")))
chl = _window_channel_focused_get();
}
}
else
{
if (!(chl = _window_channel_find(params[0])))
chl = _window_channel_focused_get();
}
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]);
}