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;
|
||||
|
||||
/* DBG("Server Motd"); */
|
||||
/* DBG("\tServer: %s", source); */
|
||||
/* DBG("\tUser: %s", params[0]); */
|
||||
/* DBG("\tMessage:"); */
|
||||
/* DBG("\t%s", params[1]); */
|
||||
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_find("Default"))) return;
|
||||
if (!(chl = _window_channel_server_find(source))) return;
|
||||
_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;
|
||||
|
||||
/* DBG("Channel Message: %s", params[0]); */
|
||||
/* DBG("\tUser: %s", source); */
|
||||
/* DBG("\tMessage:"); */
|
||||
/* DBG("\t%s", params[1]); */
|
||||
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, params[1]);
|
||||
|
@ -51,20 +53,20 @@ _callback_channel_notice(Express_Network *net, const char *event, const char *so
|
|||
{
|
||||
Channel *chl = NULL;
|
||||
|
||||
/* DBG("Channel Notice: %s", params[0]); */
|
||||
/* DBG("\tServer: %s", source); */
|
||||
/* DBG("\tMessage:"); */
|
||||
/* DBG("\t%s", params[1]); */
|
||||
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], "*"))
|
||||
{
|
||||
/* FIXME: Really this should find the first channel that
|
||||
* belongs to each server and print the text there ... OR
|
||||
* print this text to ALL channels....
|
||||
*
|
||||
* NB: For testing, just using the default channel for now */
|
||||
if (!(chl = _window_channel_find("Default")))
|
||||
chl = _window_channel_focused_get();
|
||||
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
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
struct _Channel
|
||||
{
|
||||
const char *name;
|
||||
const char *server;
|
||||
|
||||
Evas *evas;
|
||||
Evas_Object *o_base;
|
||||
|
@ -138,7 +139,7 @@ _cb_options(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
|
|||
|
||||
/* external functions */
|
||||
Channel *
|
||||
_channel_create(Evas *evas, const char *name)
|
||||
_channel_create(Evas *evas, const char *name, const char *server)
|
||||
{
|
||||
Channel *chl;
|
||||
|
||||
|
@ -154,6 +155,9 @@ _channel_create(Evas *evas, const char *name)
|
|||
/* store channel name */
|
||||
if (name) chl->name = eina_stringshare_add(name);
|
||||
|
||||
/* store channel server */
|
||||
if (server) chl->server = eina_stringshare_add(server);
|
||||
|
||||
/* add base object */
|
||||
chl->o_base = edje_object_add(evas);
|
||||
_theme_apply(chl->o_base, "express/channel");
|
||||
|
@ -201,6 +205,7 @@ _channel_create(Evas *evas, const char *name)
|
|||
void
|
||||
_channel_destroy(Channel *chl)
|
||||
{
|
||||
/* delete channel objects */
|
||||
if (chl->o_img) evas_object_del(chl->o_img);
|
||||
if (chl->o_spacer) evas_object_del(chl->o_spacer);
|
||||
if (chl->o_grid) evas_object_del(chl->o_grid);
|
||||
|
@ -210,6 +215,9 @@ _channel_destroy(Channel *chl)
|
|||
/* delete channel 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(chl);
|
||||
}
|
||||
|
@ -261,6 +269,12 @@ _channel_name_get(Channel *chl)
|
|||
return chl->name;
|
||||
}
|
||||
|
||||
const char *
|
||||
_channel_server_name_get(Channel *chl)
|
||||
{
|
||||
return chl->server;
|
||||
}
|
||||
|
||||
void
|
||||
_channel_size_update(Channel *chl)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef _CHANNEL_H_
|
||||
# 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_update(Channel *chl);
|
||||
void _channel_focused_set(Channel *chl, Eina_Bool focus);
|
||||
|
@ -10,6 +10,7 @@ void _channel_focus(Channel *chl);
|
|||
void _channel_unfocus(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_min_get(Channel *chl, int *w, int *h);
|
||||
|
|
|
@ -238,7 +238,6 @@ _cb_idle(void *data EINA_UNUSED)
|
|||
if (!express_network_connected_get(net))
|
||||
{
|
||||
/* start connection process */
|
||||
DBG("Connect Network %s", cfg_net->name);
|
||||
express_network_connect(net);
|
||||
}
|
||||
}
|
||||
|
@ -335,7 +334,7 @@ _window_create(void)
|
|||
evas_object_show(_win->o_base);
|
||||
|
||||
/* try to create a default channel */
|
||||
if ((chl = _window_channel_create("Default")))
|
||||
if ((chl = _window_channel_create("Default", NULL)))
|
||||
{
|
||||
/* swallow channel background */
|
||||
_window_channel_swallow(chl);
|
||||
|
@ -417,7 +416,7 @@ _window_channel_find(const char *name)
|
|||
|
||||
/* get channel name and compare */
|
||||
chl_name = _channel_name_get(chl);
|
||||
if (strcmp(chl_name, name)) continue;
|
||||
if ((chl_name) && (strcmp(chl_name, name))) continue;
|
||||
|
||||
return chl;
|
||||
}
|
||||
|
@ -425,6 +424,25 @@ _window_channel_find(const char *name)
|
|||
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
|
||||
_window_update(void)
|
||||
{
|
||||
|
@ -468,11 +486,11 @@ _window_size_update(void)
|
|||
}
|
||||
|
||||
Channel *
|
||||
_window_channel_create(const char *name)
|
||||
_window_channel_create(const char *name, const char *server)
|
||||
{
|
||||
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 */
|
||||
_win->channels = eina_list_append(_win->channels, chl);
|
||||
|
@ -713,7 +731,8 @@ _window_network_channels_create(Express_Network *net)
|
|||
Eina_List *l;
|
||||
Config_Network *cfg_net;
|
||||
Channel *chl;
|
||||
const char *name;
|
||||
Express_Server *srv;
|
||||
const char *name, *srv_name = NULL;
|
||||
/* int i = -1; */
|
||||
|
||||
/* remove the default channel window
|
||||
|
@ -729,6 +748,13 @@ _window_network_channels_create(Express_Network *net)
|
|||
/* get the name of this network */
|
||||
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 */
|
||||
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)
|
||||
{
|
||||
/* 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) */
|
||||
/* { */
|
||||
|
@ -793,7 +820,7 @@ _window_network_channels_destroy(Express_Network *net)
|
|||
Channel *chl;
|
||||
|
||||
/* try to create a default channel */
|
||||
if ((chl = _window_channel_create("Default")))
|
||||
if ((chl = _window_channel_create("Default", NULL)))
|
||||
{
|
||||
/* swallow channel background */
|
||||
_window_channel_swallow(chl);
|
||||
|
|
|
@ -6,9 +6,10 @@ Eina_Bool _window_destroy(void);
|
|||
void _window_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);
|
||||
Channel *_window_channel_find(const char *name);
|
||||
Channel *_window_channel_server_find(const char *server);
|
||||
|
||||
void _window_channel_swallow(Channel *chl);
|
||||
void _window_channel_unswallow(Channel *chl);
|
||||
|
|
Loading…
Reference in New Issue