express: Support servers which auto-join channels when connecting

Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
Chris Michael 2015-03-03 13:05:51 -05:00
parent c402734869
commit fae267cd01
1 changed files with 28 additions and 9 deletions

View File

@ -205,7 +205,7 @@ _callback_channel_names(Express_Network *net EINA_UNUSED, const char *event EINA
}
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)
_callback_user_quit(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;
char buff[PATH_MAX];
@ -229,7 +229,7 @@ _callback_user_quit(Express_Network *net EINA_UNUSED, const char *event EINA_UNU
}
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)
_callback_user_part(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;
char buff[PATH_MAX];
@ -248,24 +248,43 @@ _callback_user_part(Express_Network *net EINA_UNUSED, const char *event EINA_UNU
}
void
_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)
_callback_user_join(Express_Network *net, const char *event EINA_UNUSED, const char *source, const char **params, unsigned int count EINA_UNUSED, void *data EINA_UNUSED)
{
Channel *chl = NULL;
char buff[PATH_MAX];
char buff[PATH_MAX], channel[PATH_MAX];
int crlf = 0, lf = 0;
/* DBG("User Join %s", params[0]); */
crlf = _find_crlf(params[0], strlen(params[0]), &lf);
if (crlf > 0)
eina_strlcpy(channel, params[0], crlf + lf - 1);
else
eina_strlcpy(channel, params[0], strlen(params[0]) + 1);
/* DBG("User Join %s", channel); */
/* DBG("\tCount: %d", count); */
/* DBG("\tUser: %s", source); */
/* DBG("\tMessage:"); */
/* DBG("\t%s", params[1]); */
/* find the channel */
if (!(chl = _window_channel_find(channel)))
{
Express_Server *srv;
if ((srv = express_network_server_connected_get(net)))
{
const char *srv_name = NULL;
srv_name = express_network_server_realname_get(srv);
if ((chl = _window_channel_create(channel, srv_name)))
_channel_network_set(chl, net);
}
}
/* skip user join messages for our own nick */
if (!strcmp(source, express_network_nickname_get(net))) return;
/* find the channel */
if (!(chl = _window_channel_find(params[0]))) return;
snprintf(buff, sizeof(buff), "%s has joined %s\r\n", source, params[0]);
snprintf(buff, sizeof(buff), "%s has joined %s\r\n", source, channel);
_channel_text_append(chl, NULL, buff);
}