2014-01-19 04:04:02 -08:00
|
|
|
#include "private.h"
|
|
|
|
#include "callbacks.h"
|
2014-01-19 06:40:03 -08:00
|
|
|
#include "window.h"
|
2014-01-20 09:32:08 -08:00
|
|
|
#include "channel.h"
|
2014-01-19 04:04:02 -08:00
|
|
|
|
|
|
|
void
|
2014-01-19 06:40:03 -08:00
|
|
|
_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)
|
2014-01-19 04:04:02 -08:00
|
|
|
{
|
|
|
|
DBG("Server %s Connected", source);
|
2014-01-19 06:40:03 -08:00
|
|
|
_window_network_channels_create(net);
|
2014-01-19 04:04:02 -08:00
|
|
|
}
|
|
|
|
|
2014-01-20 09:32:08 -08:00
|
|
|
void
|
2014-12-16 12:35:44 -08:00
|
|
|
_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)
|
2014-01-20 09:32:08 -08:00
|
|
|
{
|
|
|
|
Channel *chl;
|
|
|
|
|
2014-12-17 10:09:47 -08:00
|
|
|
DBG("Server Motd");
|
|
|
|
DBG("\tServer: %s", source);
|
|
|
|
DBG("\tCount: %d", count);
|
|
|
|
DBG("\tUser: %s", params[0]);
|
|
|
|
DBG("\tMessage:");
|
|
|
|
DBG("\t%s", params[1]);
|
2014-01-20 09:32:08 -08:00
|
|
|
|
2014-12-11 11:14:34 -08:00
|
|
|
if (!(chl = _window_channel_server_find(source))) return;
|
2014-12-16 11:26:58 -08:00
|
|
|
_channel_text_append(chl, NULL, params[1]);
|
2014-01-20 09:32:08 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-12-16 12:35:44 -08:00
|
|
|
_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)
|
2014-01-20 09:32:08 -08:00
|
|
|
{
|
|
|
|
Channel *chl = NULL;
|
|
|
|
|
2014-12-16 11:26:58 -08:00
|
|
|
DBG("Channel Message: %s", params[0]);
|
|
|
|
DBG("\tCount: %d", count);
|
|
|
|
DBG("\tUser: %s", source);
|
|
|
|
DBG("\tMessage:");
|
|
|
|
DBG("\t%s", params[1]);
|
2014-01-20 09:32:08 -08:00
|
|
|
|
|
|
|
if (!(chl = _window_channel_find(params[0]))) return;
|
2014-12-16 11:26:58 -08:00
|
|
|
|
|
|
|
_channel_text_append(chl, source, params[1]);
|
2014-01-20 09:32:08 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-12-16 12:35:44 -08:00
|
|
|
_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)
|
2014-01-20 09:32:08 -08:00
|
|
|
{
|
|
|
|
Channel *chl = NULL;
|
|
|
|
|
2014-12-17 10:09:47 -08:00
|
|
|
DBG("Channel Notice: %s", params[0]);
|
|
|
|
DBG("\tCount: %d", count);
|
|
|
|
DBG("\tServer: %s", source);
|
|
|
|
DBG("\tMessage:");
|
|
|
|
DBG("\t%s", params[1]);
|
2014-01-20 09:32:08 -08:00
|
|
|
|
|
|
|
if (!strcmp(params[0], "*"))
|
|
|
|
{
|
2014-12-11 11:14:34 -08:00
|
|
|
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();
|
|
|
|
}
|
2014-01-20 09:32:08 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!(chl = _window_channel_find(params[0])))
|
|
|
|
chl = _window_channel_focused_get();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!chl) return;
|
2014-12-16 11:26:58 -08:00
|
|
|
_channel_text_append(chl, NULL, params[1]);
|
2014-01-20 09:32:08 -08:00
|
|
|
}
|
2014-12-16 12:35:44 -08:00
|
|
|
|
|
|
|
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]);
|
|
|
|
}
|
2014-12-17 12:26:47 -08:00
|
|
|
|
|
|
|
void
|
|
|
|
_callback_user_quit(Express_Network *net EINA_UNUSED, const char *event EINA_UNUSED, const char *source, const char **params EINA_UNUSED, unsigned int count EINA_UNUSED, void *data EINA_UNUSED)
|
|
|
|
{
|
|
|
|
DBG("User Quit");
|
|
|
|
DBG("\tCount: %d", count);
|
|
|
|
DBG("\tUser: %s", source);
|
|
|
|
DBG("\tMessage:");
|
|
|
|
DBG("\t%s", params[0]);
|
|
|
|
|
|
|
|
// param[0] == reason
|
|
|
|
// source == user
|
|
|
|
|
|
|
|
/* FIXME: We have a problem here. No channel gets passed in, so we will
|
|
|
|
* need to find the channel this user is in, and send the message to that
|
|
|
|
* channel */
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_callback_user_part(Express_Network *net EINA_UNUSED, const char *event EINA_UNUSED, const char *source, const char **params EINA_UNUSED, unsigned int count EINA_UNUSED, void *data EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Channel *chl = NULL;
|
|
|
|
char buff[PATH_MAX];
|
|
|
|
|
|
|
|
DBG("User Part %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;
|
|
|
|
|
|
|
|
snprintf(buff, sizeof(buff), "User %s has left %s: %s",
|
|
|
|
source, params[0], params[1]);
|
|
|
|
_channel_text_append(chl, NULL, buff);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-12-18 07:44:07 -08:00
|
|
|
_callback_user_join(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)
|
2014-12-17 12:26:47 -08:00
|
|
|
{
|
2014-12-18 07:44:07 -08:00
|
|
|
Channel *chl = NULL;
|
|
|
|
char buff[PATH_MAX];
|
2014-12-17 12:26:47 -08:00
|
|
|
|
|
|
|
DBG("User Join %s", params[0]);
|
|
|
|
DBG("\tCount: %d", count);
|
|
|
|
DBG("\tUser: %s", source);
|
|
|
|
DBG("\tMessage:");
|
|
|
|
DBG("\t%s", params[1]);
|
|
|
|
|
2014-12-18 07:44:07 -08:00
|
|
|
/* skip user join messages for our own nick */
|
|
|
|
if (!strcmp(source, express_network_nickname_get(net))) return;
|
2014-12-17 12:26:47 -08:00
|
|
|
|
2014-12-18 07:44:07 -08:00
|
|
|
/* find the channel */
|
|
|
|
if (!(chl = _window_channel_find(params[0]))) return;
|
2014-12-17 12:26:47 -08:00
|
|
|
|
2014-12-18 07:44:07 -08:00
|
|
|
snprintf(buff, sizeof(buff), "User %s has joined %s", source, params[0]);
|
|
|
|
_channel_text_append(chl, NULL, buff);
|
2014-12-17 12:26:47 -08:00
|
|
|
}
|