add ability to send messages to the proper channels
Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
parent
f063c61121
commit
5ccfbc70e8
|
@ -22,13 +22,14 @@ _callback_server_motd(Express_Network *net, const char *event, const char *sourc
|
||||||
{
|
{
|
||||||
Channel *chl;
|
Channel *chl;
|
||||||
|
|
||||||
/* DBG("Server Motd"); */
|
DBG("Server Motd");
|
||||||
/* DBG("\tServer: %s", source); */
|
DBG("\tServer: %s", source);
|
||||||
/* DBG("\tUser: %s", params[0]); */
|
DBG("\tCount: %d", count);
|
||||||
/* DBG("\tMessage:"); */
|
DBG("\tUser: %s", params[0]);
|
||||||
/* DBG("\t%s", params[1]); */
|
DBG("\tMessage:");
|
||||||
|
DBG("\t%s", params[1]);
|
||||||
|
|
||||||
if (!(chl = _window_channel_find("Default"))) return;
|
if (!(chl = _window_channel_server_find(source))) return;
|
||||||
_channel_text_append(chl, params[1]);
|
_channel_text_append(chl, params[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,10 +38,11 @@ _callback_channel_message(Express_Network *net, const char *event, const char *s
|
||||||
{
|
{
|
||||||
Channel *chl = NULL;
|
Channel *chl = NULL;
|
||||||
|
|
||||||
/* DBG("Channel Message: %s", params[0]); */
|
DBG("Channel Message: %s", params[0]);
|
||||||
/* DBG("\tUser: %s", source); */
|
DBG("\tCount: %d", count);
|
||||||
/* DBG("\tMessage:"); */
|
DBG("\tUser: %s", source);
|
||||||
/* DBG("\t%s", params[1]); */
|
DBG("\tMessage:");
|
||||||
|
DBG("\t%s", params[1]);
|
||||||
|
|
||||||
if (!(chl = _window_channel_find(params[0]))) return;
|
if (!(chl = _window_channel_find(params[0]))) return;
|
||||||
_channel_text_append(chl, params[1]);
|
_channel_text_append(chl, params[1]);
|
||||||
|
@ -51,21 +53,21 @@ _callback_channel_notice(Express_Network *net, const char *event, const char *so
|
||||||
{
|
{
|
||||||
Channel *chl = NULL;
|
Channel *chl = NULL;
|
||||||
|
|
||||||
/* DBG("Channel Notice: %s", params[0]); */
|
DBG("Channel Notice: %s", params[0]);
|
||||||
/* DBG("\tServer: %s", source); */
|
DBG("\tCount: %d", count);
|
||||||
/* DBG("\tMessage:"); */
|
DBG("\tServer: %s", source);
|
||||||
/* DBG("\t%s", params[1]); */
|
DBG("\tMessage:");
|
||||||
|
DBG("\t%s", params[1]);
|
||||||
|
|
||||||
if (!strcmp(params[0], "*"))
|
if (!strcmp(params[0], "*"))
|
||||||
{
|
{
|
||||||
/* FIXME: Really this should find the first channel that
|
if (!(chl = _window_channel_server_find(source)))
|
||||||
* belongs to each server and print the text there ... OR
|
{
|
||||||
* print this text to ALL channels....
|
ERR("Could not find channel with server name: %s", source);
|
||||||
*
|
|
||||||
* NB: For testing, just using the default channel for now */
|
|
||||||
if (!(chl = _window_channel_find("Default")))
|
if (!(chl = _window_channel_find("Default")))
|
||||||
chl = _window_channel_focused_get();
|
chl = _window_channel_focused_get();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!(chl = _window_channel_find(params[0])))
|
if (!(chl = _window_channel_find(params[0])))
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
struct _Channel
|
struct _Channel
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
|
const char *server;
|
||||||
|
|
||||||
Evas *evas;
|
Evas *evas;
|
||||||
Evas_Object *o_base;
|
Evas_Object *o_base;
|
||||||
|
@ -138,7 +139,7 @@ _cb_options(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
|
||||||
|
|
||||||
/* external functions */
|
/* external functions */
|
||||||
Channel *
|
Channel *
|
||||||
_channel_create(Evas *evas, const char *name)
|
_channel_create(Evas *evas, const char *name, const char *server)
|
||||||
{
|
{
|
||||||
Channel *chl;
|
Channel *chl;
|
||||||
|
|
||||||
|
@ -154,6 +155,9 @@ _channel_create(Evas *evas, const char *name)
|
||||||
/* store channel name */
|
/* store channel name */
|
||||||
if (name) chl->name = eina_stringshare_add(name);
|
if (name) chl->name = eina_stringshare_add(name);
|
||||||
|
|
||||||
|
/* store channel server */
|
||||||
|
if (server) chl->server = eina_stringshare_add(server);
|
||||||
|
|
||||||
/* add base object */
|
/* add base object */
|
||||||
chl->o_base = edje_object_add(evas);
|
chl->o_base = edje_object_add(evas);
|
||||||
_theme_apply(chl->o_base, "express/channel");
|
_theme_apply(chl->o_base, "express/channel");
|
||||||
|
@ -201,6 +205,7 @@ _channel_create(Evas *evas, const char *name)
|
||||||
void
|
void
|
||||||
_channel_destroy(Channel *chl)
|
_channel_destroy(Channel *chl)
|
||||||
{
|
{
|
||||||
|
/* delete channel objects */
|
||||||
if (chl->o_img) evas_object_del(chl->o_img);
|
if (chl->o_img) evas_object_del(chl->o_img);
|
||||||
if (chl->o_spacer) evas_object_del(chl->o_spacer);
|
if (chl->o_spacer) evas_object_del(chl->o_spacer);
|
||||||
if (chl->o_grid) evas_object_del(chl->o_grid);
|
if (chl->o_grid) evas_object_del(chl->o_grid);
|
||||||
|
@ -210,6 +215,9 @@ _channel_destroy(Channel *chl)
|
||||||
/* delete channel name */
|
/* delete channel name */
|
||||||
if (chl->name) eina_stringshare_del(chl->name);
|
if (chl->name) eina_stringshare_del(chl->name);
|
||||||
|
|
||||||
|
/* delete channel server name */
|
||||||
|
if (chl->server) eina_stringshare_del(chl->server);
|
||||||
|
|
||||||
/* free allocated channel structure */
|
/* free allocated channel structure */
|
||||||
free(chl);
|
free(chl);
|
||||||
}
|
}
|
||||||
|
@ -261,6 +269,12 @@ _channel_name_get(Channel *chl)
|
||||||
return chl->name;
|
return chl->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
_channel_server_name_get(Channel *chl)
|
||||||
|
{
|
||||||
|
return chl->server;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_channel_size_update(Channel *chl)
|
_channel_size_update(Channel *chl)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef _CHANNEL_H_
|
#ifndef _CHANNEL_H_
|
||||||
# define _CHANNEL_H_ 1
|
# define _CHANNEL_H_ 1
|
||||||
|
|
||||||
Channel *_channel_create(Evas *evas, const char *name);
|
Channel *_channel_create(Evas *evas, const char *name, const char *server);
|
||||||
void _channel_destroy(Channel *chl);
|
void _channel_destroy(Channel *chl);
|
||||||
void _channel_update(Channel *chl);
|
void _channel_update(Channel *chl);
|
||||||
void _channel_focused_set(Channel *chl, Eina_Bool focus);
|
void _channel_focused_set(Channel *chl, Eina_Bool focus);
|
||||||
|
@ -10,6 +10,7 @@ void _channel_focus(Channel *chl);
|
||||||
void _channel_unfocus(Channel *chl);
|
void _channel_unfocus(Channel *chl);
|
||||||
|
|
||||||
const char *_channel_name_get(Channel *chl);
|
const char *_channel_name_get(Channel *chl);
|
||||||
|
const char *_channel_server_name_get(Channel *chl);
|
||||||
|
|
||||||
void _channel_size_update(Channel *chl);
|
void _channel_size_update(Channel *chl);
|
||||||
void _channel_size_min_get(Channel *chl, int *w, int *h);
|
void _channel_size_min_get(Channel *chl, int *w, int *h);
|
||||||
|
|
|
@ -238,7 +238,6 @@ _cb_idle(void *data EINA_UNUSED)
|
||||||
if (!express_network_connected_get(net))
|
if (!express_network_connected_get(net))
|
||||||
{
|
{
|
||||||
/* start connection process */
|
/* start connection process */
|
||||||
DBG("Connect Network %s", cfg_net->name);
|
|
||||||
express_network_connect(net);
|
express_network_connect(net);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -335,7 +334,7 @@ _window_create(void)
|
||||||
evas_object_show(_win->o_base);
|
evas_object_show(_win->o_base);
|
||||||
|
|
||||||
/* try to create a default channel */
|
/* try to create a default channel */
|
||||||
if ((chl = _window_channel_create("Default")))
|
if ((chl = _window_channel_create("Default", NULL)))
|
||||||
{
|
{
|
||||||
/* swallow channel background */
|
/* swallow channel background */
|
||||||
_window_channel_swallow(chl);
|
_window_channel_swallow(chl);
|
||||||
|
@ -417,7 +416,7 @@ _window_channel_find(const char *name)
|
||||||
|
|
||||||
/* get channel name and compare */
|
/* get channel name and compare */
|
||||||
chl_name = _channel_name_get(chl);
|
chl_name = _channel_name_get(chl);
|
||||||
if (strcmp(chl_name, name)) continue;
|
if ((chl_name) && (strcmp(chl_name, name))) continue;
|
||||||
|
|
||||||
return chl;
|
return chl;
|
||||||
}
|
}
|
||||||
|
@ -425,6 +424,25 @@ _window_channel_find(const char *name)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Channel *
|
||||||
|
_window_channel_server_find(const char *server)
|
||||||
|
{
|
||||||
|
Eina_List *l = NULL;
|
||||||
|
Channel *chl;
|
||||||
|
|
||||||
|
/* loop existing channels */
|
||||||
|
EINA_LIST_FOREACH(_win->channels, l, chl)
|
||||||
|
{
|
||||||
|
const char *srv_name;
|
||||||
|
|
||||||
|
srv_name = _channel_server_name_get(chl);
|
||||||
|
if ((srv_name) && (!strcmp(srv_name, server)))
|
||||||
|
return chl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_window_update(void)
|
_window_update(void)
|
||||||
{
|
{
|
||||||
|
@ -468,11 +486,11 @@ _window_size_update(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
Channel *
|
Channel *
|
||||||
_window_channel_create(const char *name)
|
_window_channel_create(const char *name, const char *server)
|
||||||
{
|
{
|
||||||
Channel *chl;
|
Channel *chl;
|
||||||
|
|
||||||
if (!(chl = _channel_create(_win->evas, name))) return NULL;
|
if (!(chl = _channel_create(_win->evas, name, server))) return NULL;
|
||||||
|
|
||||||
/* append this channel to the list */
|
/* append this channel to the list */
|
||||||
_win->channels = eina_list_append(_win->channels, chl);
|
_win->channels = eina_list_append(_win->channels, chl);
|
||||||
|
@ -713,7 +731,8 @@ _window_network_channels_create(Express_Network *net)
|
||||||
Eina_List *l;
|
Eina_List *l;
|
||||||
Config_Network *cfg_net;
|
Config_Network *cfg_net;
|
||||||
Channel *chl;
|
Channel *chl;
|
||||||
const char *name;
|
Express_Server *srv;
|
||||||
|
const char *name, *srv_name = NULL;
|
||||||
/* int i = -1; */
|
/* int i = -1; */
|
||||||
|
|
||||||
/* remove the default channel window
|
/* remove the default channel window
|
||||||
|
@ -729,6 +748,13 @@ _window_network_channels_create(Express_Network *net)
|
||||||
/* get the name of this network */
|
/* get the name of this network */
|
||||||
name = express_network_name_get(net);
|
name = express_network_name_get(net);
|
||||||
|
|
||||||
|
/* get which server is connected on this network */
|
||||||
|
if ((srv = express_network_server_connected_get(net)))
|
||||||
|
{
|
||||||
|
/* get the name of this server */
|
||||||
|
srv_name = express_network_server_realname_get(srv);
|
||||||
|
}
|
||||||
|
|
||||||
/* go through network configs and find this network */
|
/* go through network configs and find this network */
|
||||||
EINA_LIST_FOREACH(_ex_cfg->networks, l, cfg_net)
|
EINA_LIST_FOREACH(_ex_cfg->networks, l, cfg_net)
|
||||||
{
|
{
|
||||||
|
@ -741,7 +767,8 @@ _window_network_channels_create(Express_Network *net)
|
||||||
EINA_LIST_FOREACH(cfg_net->channels, c, cfg_chl)
|
EINA_LIST_FOREACH(cfg_net->channels, c, cfg_chl)
|
||||||
{
|
{
|
||||||
/* try to create a channel */
|
/* try to create a channel */
|
||||||
if (!(chl = _window_channel_create(cfg_chl->name))) continue;
|
if (!(chl = _window_channel_create(cfg_chl->name, srv_name)))
|
||||||
|
continue;
|
||||||
|
|
||||||
/* if (i < 0) */
|
/* if (i < 0) */
|
||||||
/* { */
|
/* { */
|
||||||
|
@ -793,7 +820,7 @@ _window_network_channels_destroy(Express_Network *net)
|
||||||
Channel *chl;
|
Channel *chl;
|
||||||
|
|
||||||
/* try to create a default channel */
|
/* try to create a default channel */
|
||||||
if ((chl = _window_channel_create("Default")))
|
if ((chl = _window_channel_create("Default", NULL)))
|
||||||
{
|
{
|
||||||
/* swallow channel background */
|
/* swallow channel background */
|
||||||
_window_channel_swallow(chl);
|
_window_channel_swallow(chl);
|
||||||
|
|
|
@ -6,9 +6,10 @@ Eina_Bool _window_destroy(void);
|
||||||
void _window_update(void);
|
void _window_update(void);
|
||||||
void _window_size_update(void);
|
void _window_size_update(void);
|
||||||
|
|
||||||
Channel *_window_channel_create(const char *name);
|
Channel *_window_channel_create(const char *name, const char *server);
|
||||||
void _window_channel_destroy(const char *name);
|
void _window_channel_destroy(const char *name);
|
||||||
Channel *_window_channel_find(const char *name);
|
Channel *_window_channel_find(const char *name);
|
||||||
|
Channel *_window_channel_server_find(const char *server);
|
||||||
|
|
||||||
void _window_channel_swallow(Channel *chl);
|
void _window_channel_swallow(Channel *chl);
|
||||||
void _window_channel_unswallow(Channel *chl);
|
void _window_channel_unswallow(Channel *chl);
|
||||||
|
|
Loading…
Reference in New Issue