elm test_gengrid.c: Use elm_gengrid_item_class_new/free() APIs.

SVN revision: 80081
This commit is contained in:
Daniel Juyung Seo 2012-12-03 16:27:03 +00:00
parent 65e9f49ccd
commit 5e39cbd7f9
5 changed files with 988 additions and 750 deletions

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
#endif
#include <fcntl.h>
#include <Ecore_Con_Eet.h>
#include <Ecore_Ipc.h>
#include "clouseau_private.h"
@ -13,7 +13,7 @@
static Eina_List *gui = NULL; /* List of app_info_st for gui clients */
static Eina_List *app = NULL; /* List of app_info_st for app clients */
static Ecore_Con_Eet *eet_svr = NULL;
Ecore_Ipc_Server *ipc_svr = NULL;
/* For Debug */
char msg_buf[MAX_LINE+1];
@ -39,11 +39,9 @@ static void
_daemon_cleanup(void)
{ /* Free strings */
app_info_st *p;
time_t currentTime;
time (&currentTime);
sprintf(msg_buf,"\n\n%sClients connected to this server when exiting: %d\n"
, ctime(&currentTime), eina_list_count(app) + eina_list_count(gui));
sprintf(msg_buf,"Clients connected to this server when exiting: %d\n",
eina_list_count(ecore_ipc_server_clients_get(ipc_svr)));
log_message(LOG_FILE, "a", msg_buf);
EINA_LIST_FREE(gui, p)
@ -51,9 +49,6 @@ _daemon_cleanup(void)
if(p->file)
free(p->file);
if (p->ptr)
free((void *) (uint32_t) p->ptr);
free(p->name);
free(p);
}
@ -63,18 +58,15 @@ _daemon_cleanup(void)
if(p->file)
free(p->file);
if (p->ptr)
free((void *) (uint32_t) p->ptr);
free(p->name);
free(p);
}
gui = app = NULL;
eet_svr = NULL;
ipc_svr = NULL;
clouseau_data_shutdown();
ecore_con_shutdown();
ecore_ipc_shutdown();
ecore_shutdown();
eina_shutdown();
}
@ -123,19 +115,15 @@ _client_ptr_cmp(const void *d1, const void *d2)
}
static Eina_List *
_add_client(Eina_List *clients, connect_st *t, void *client, const char *type)
_add_client(Eina_List *clients, connect_st *t, void *client)
{
sprintf(msg_buf, "\n<%s> msg from <%p>", __func__, client);
log_message(LOG_FILE, "a", msg_buf);
if(!eina_list_search_unsorted(clients, _client_ptr_cmp, client))
{
app_info_st *st = calloc(1, sizeof(app_info_st));
st->name = strdup(t->name);
st->pid = t->pid;
st->ptr = (unsigned long long) (uintptr_t) client;
sprintf(msg_buf, "\tAdded %s client <%p>", type, client);
log_message(LOG_FILE, "a", msg_buf);
return eina_list_append(clients, st);
}
@ -143,18 +131,13 @@ _add_client(Eina_List *clients, connect_st *t, void *client, const char *type)
}
static Eina_List *
_remove_client(Eina_List *clients, void *client, const char *type)
_remove_client(Eina_List *clients, void *client)
{
app_info_st *p = eina_list_search_unsorted(clients, _client_ptr_cmp, client);
sprintf(msg_buf, "\n<%s> msg from <%p>", __func__, client);
log_message(LOG_FILE, "a", msg_buf);
if (p)
{
free(p->name);
free(p);
sprintf(msg_buf, "\tRemoved %s client <%p>", type, client);
log_message(LOG_FILE, "a", msg_buf);
return eina_list_remove(clients, p);
}
@ -162,269 +145,308 @@ _remove_client(Eina_List *clients, void *client, const char *type)
}
Eina_Bool
_add(EINA_UNUSED void *data, Ecore_Con_Reply *reply,
EINA_UNUSED Ecore_Con_Client *conn)
_add(void *data EINA_UNUSED, int type EINA_UNUSED, Ecore_Ipc_Event_Client_Add *ev)
{
/* TODO: ecore_ipc_client_data_size_max_set(ev->client, -1); */
sprintf(msg_buf, "\n<%s> msg from <%p>", __func__, reply);
ecore_ipc_client_data_size_max_set(ev->client, -1);
sprintf(msg_buf, "<%s> msg from <%p>", __func__, ev->client);
log_message(LOG_FILE, "a", msg_buf);
return ECORE_CALLBACK_RENEW;
}
Eina_Bool
_del(EINA_UNUSED void *data, Ecore_Con_Reply *reply,
EINA_UNUSED Ecore_Con_Client *conn)
_del(void *data EINA_UNUSED, int type EINA_UNUSED, Ecore_Ipc_Event_Client_Del *ev)
{
sprintf(msg_buf, "\n<%s> msg from <%p>", __func__, reply);
if (!ev->client)
return ECORE_CALLBACK_RENEW;
sprintf(msg_buf, "<%s> msg from <%p>", __func__, ev->client);
log_message(LOG_FILE, "a", msg_buf);
/* Now we need to find if its an APP or GUI client */
app_info_st *i = eina_list_search_unsorted(gui, _client_ptr_cmp, reply);
app_info_st *i = eina_list_search_unsorted(gui, _client_ptr_cmp, ev->client);
if (i) /* Only need to remove GUI client from list */
gui = _remove_client(gui, reply, "GUI");
gui = _remove_client(gui, ev->client);
i = eina_list_search_unsorted(app, _client_ptr_cmp, reply);
i = eina_list_search_unsorted(app, _client_ptr_cmp, ev->client);
if (i)
{ /* Notify all GUI clients to remove this APP */
app_closed_st t = { (unsigned long long) (uintptr_t) reply };
app_closed_st t = { (unsigned long long) (uintptr_t) ev->client };
Eina_List *l;
EINA_LIST_FOREACH(gui, l, i)
int size;
void *p = clouseau_data_packet_compose(CLOUSEAU_APP_CLOSED,
&t, sizeof(t), &size, NULL, 0);
if (p)
{
sprintf(msg_buf, "\t<%p> Sending APP_CLOSED to <%p>",
reply, (void *) (uint32_t) i->ptr);
log_message(LOG_FILE, "a", msg_buf);
ecore_con_eet_send((void *) (uintptr_t) i->ptr,
CLOUSEAU_APP_CLOSED_STR, &t);
EINA_LIST_FOREACH(gui, l, i)
{
ecore_ipc_client_send((void *) (uintptr_t) i->ptr,
0,0,0,0,EINA_FALSE, p, size);
ecore_ipc_client_flush((void *) (uintptr_t) i->ptr);
}
free(p);
}
app = _remove_client(app, reply, "APP");
app = _remove_client(app, ev->client);
}
if (!(gui || app))
ecore_ipc_client_del(ev->client);
if (!eina_list_count(ecore_ipc_server_clients_get(ipc_svr)))
{ /* Trigger cleanup and exit when all clients disconneced */
/* ecore_con_eet_server_free(eet_svr); why this causes Segfault? */
ecore_con_server_del(data);
ecore_main_loop_quit();
}
return ECORE_CALLBACK_RENEW;
}
void
_gui_client_connect_cb(EINA_UNUSED void *data, Ecore_Con_Reply *reply,
EINA_UNUSED const char *protocol_name, void *value)
{ /* Register GUI, then notify about all APP */
app_info_st *st;
Eina_List *l;
connect_st *t = value;
sprintf(msg_buf, "\n<%s> msg from <%p>", __func__, reply);
Eina_Bool
_data(void *data EINA_UNUSED, int type EINA_UNUSED, Ecore_Ipc_Event_Client_Data *ev)
{
void *p;
int size = 0;
sprintf(msg_buf, "<%s> msg from <%p>", __func__, ev->client);
log_message(LOG_FILE, "a", msg_buf);
gui = _add_client(gui, t, reply, "GUI");
/* Add all registered apps to newly open GUI */
EINA_LIST_FOREACH(app, l, st)
Variant_st *v = clouseau_data_packet_info_get(ev->data, ev->size);
/* This is where daemon impl communication protocol.
* In order to simplify, all messages also contains recipient ptr
* as saved by daemon.
* Thus we only need to peek this info then FWD, reply to this recipient */
if (!v)
{
sprintf(msg_buf, "\t<%p> Sending APP_ADD to <%p>",
(void *) (uint32_t) st->ptr, reply);
log_message(LOG_FILE, "a", msg_buf);
ecore_con_eet_send(reply, CLOUSEAU_APP_ADD_STR, st);
log_message(LOG_FILE, "a", "Failed to decode data.");
return ECORE_CALLBACK_RENEW;
}
}
void
_app_client_connect_cb(EINA_UNUSED void *data, Ecore_Con_Reply *reply,
EINA_UNUSED const char *protocol_name, void *value)
{ /* Register APP then notify GUI about it */
app_info_st *st;
Eina_List *l;
connect_st *t = value;
app_info_st m = { t->pid, (char *) t->name, NULL,
(unsigned long long) (uintptr_t) reply, NULL, 0 };
sprintf(msg_buf, "\n<%s> msg from <%p>", __func__, reply);
log_message(LOG_FILE, "a", msg_buf);
app = _add_client(app, t, reply, "APP");
/* Notify all GUI clients to add APP */
EINA_LIST_FOREACH(gui, l, st)
switch(clouseau_data_packet_mapping_type_get(v->type))
{
sprintf(msg_buf, "\t<%p> Sending APP_ADD to <%p>",
reply, (void *) (uint32_t) st->ptr);
log_message(LOG_FILE, "a", msg_buf);
ecore_con_eet_send((void *) (uint32_t) st->ptr,
CLOUSEAU_APP_ADD_STR, &m);
}
}
case CLOUSEAU_APP_CLIENT_CONNECT:
{ /* Register APP then notify GUI about it */
app_info_st *st;
Eina_List *l;
connect_st *t = v->data;
app_info_st m = { t->pid, (char *) t->name, NULL,
(unsigned long long) (uintptr_t) ev->client, NULL, 0 };
void
_data_req_cb(EINA_UNUSED void *data, Ecore_Con_Reply *reply,
EINA_UNUSED const char *protocol_name, void *value)
{ /* msg coming from GUI, FWD this to APP specified in REQ */
data_req_st *req = value;
sprintf(msg_buf, "\n<%s> msg from <%p>", __func__, reply);
log_message(LOG_FILE, "a", msg_buf);
app = _add_client(app, t, ev->client);
p = clouseau_data_packet_compose(CLOUSEAU_APP_ADD,
&m, sizeof(m), &size, NULL, 0);
if (req->app)
{ /* Requesting specific app data */
if(eina_list_search_unsorted(app,
_client_ptr_cmp,
(void *) (uintptr_t) req->app))
{ /* Do the req only of APP connected to daemon */
data_req_st t = {
(unsigned long long) (uintptr_t) reply,
(unsigned long long) (uintptr_t) req->app };
if (p)
{
EINA_LIST_FOREACH(gui, l, st)
{ /* Notify all GUI clients to add APP */
ecore_ipc_client_send(
(void *) (uintptr_t) st->ptr,
0,0,0,0,EINA_FALSE, p, size);
ecore_ipc_client_flush(
(void *) (uintptr_t) st->ptr);
}
sprintf(msg_buf, "\t<%p> Sending DATA_REQ to <%p>",
reply, (void *) (uint32_t) req->app);
log_message(LOG_FILE, "a", msg_buf);
ecore_con_eet_send((void *) (uint32_t) req->app,
CLOUSEAU_DATA_REQ_STR, &t);
}
}
else
{ /* requesting ALL apps data */
Eina_List *l;
app_info_st *st;
data_req_st t = {
(unsigned long long) (uintptr_t) reply,
(unsigned long long) (uintptr_t) NULL };
free(p);
}
}
break;
EINA_LIST_FOREACH(app, l, st)
{
t.app = (unsigned long long) (uintptr_t) st->ptr;
sprintf(msg_buf, "\t<%p> Sending DATA_REQ to <%p>",
reply, (void *) (uint32_t) st->ptr);
log_message(LOG_FILE, "a", msg_buf);
ecore_con_eet_send((void *) (uint32_t) st->ptr, CLOUSEAU_DATA_REQ_STR, &t);
}
}
}
case CLOUSEAU_GUI_CLIENT_CONNECT:
{ /* Register GUI, then notify about all APP */
app_info_st *st;
Eina_List *l;
connect_st *t = v->data;
gui = _add_client(gui, t, ev->client);
EINA_LIST_FOREACH(app, l, st)
{ /* Add all registered apps to newly open GUI */
p = clouseau_data_packet_compose(CLOUSEAU_APP_ADD,
st, sizeof(*st), &size, NULL, 0);
void
_tree_data_cb(EINA_UNUSED void *data, EINA_UNUSED Ecore_Con_Reply *reply,
EINA_UNUSED const char *protocol_name, void *value)
{ /* Tree Data comes from APP, GUI client specified in msg */
tree_data_st *td = value;
sprintf(msg_buf, "\n<%s> msg from <%p>", __func__, reply);
log_message(LOG_FILE, "a", msg_buf);
if (p)
{
ecore_ipc_client_send(ev->client,
0,0,0,0,EINA_FALSE, p, size);
ecore_ipc_client_flush(ev->client);
free(p);
}
}
if (td->gui)
{ /* Sending tree data to specific GUI client */
if(eina_list_search_unsorted(gui,
_client_ptr_cmp,
(void *) (uintptr_t) td->gui))
{ /* Do the req only of GUI connected to daemon */
sprintf(msg_buf, "\t<%p> Sending TREE_DATA to <%p>",
reply, (void *) (uint32_t) td->gui);
log_message(LOG_FILE, "a", msg_buf);
ecore_con_eet_send((void *) (uint32_t) td->gui,
CLOUSEAU_TREE_DATA_STR, value);
}
}
else
{ /* Sending tree data to all GUI clients */
Eina_List *l;
app_info_st *info;
EINA_LIST_FOREACH(gui, l, info)
{
sprintf(msg_buf, "\t<%p> Sending TREE_DATA to <%p>",
reply, (void *) (uint32_t) info->ptr);
log_message(LOG_FILE, "a", msg_buf);
ecore_con_eet_send((void *) (uint32_t) info->ptr,
CLOUSEAU_TREE_DATA_STR, value);
}
}
break;
case CLOUSEAU_DATA_REQ:
{ /* msg coming from GUI, FWD this to app specified in req */
data_req_st *req = v->data;
if (req->app)
{ /* Requesting specific app data */
if(eina_list_search_unsorted(app,
_client_ptr_cmp,
(void *) (uintptr_t) req->app))
{ /* Do the req only of APP connected to daemon */
data_req_st t = {
(unsigned long long) (uintptr_t) ev->client,
(unsigned long long) (uintptr_t) req->app };
p = clouseau_data_packet_compose(CLOUSEAU_DATA_REQ,
&t, sizeof(t), &size, NULL, 0);
if (p)
{
ecore_ipc_client_send(
(void *) (uintptr_t) req->app,
0,0,0,0, EINA_FALSE, p, size);
ecore_ipc_client_flush(
(void *) (uintptr_t) req->app);
free(p);
}
}
}
else
{ /* requesting ALL apps data */
Eina_List *l;
app_info_st *st;
data_req_st t = {
(unsigned long long) (uintptr_t) ev->client,
(unsigned long long) (uintptr_t) NULL };
EINA_LIST_FOREACH(app, l, st)
{
t.app = (unsigned long long) (uintptr_t) st->ptr;
p = clouseau_data_packet_compose(CLOUSEAU_DATA_REQ,
&t, sizeof(t), &size, NULL, 0);
if (p)
{
ecore_ipc_client_send(
(void *) (uintptr_t) st->ptr,
0,0,0,0, EINA_FALSE, p, size);
ecore_ipc_client_flush(
(void *) (uintptr_t) st->ptr);
free(p);
}
}
}
}
break;
case CLOUSEAU_TREE_DATA:
{ /* Tree Data comes from APP, GUI client specified in msg */
tree_data_st *td = v->data;
if (td->gui)
{ /* Sending tree data to specific GUI client */
if(eina_list_search_unsorted(gui,
_client_ptr_cmp,
(void *) (uintptr_t) td->gui))
{ /* Do the req only of GUI connected to daemon */
ecore_ipc_client_send(
(void *) (uintptr_t) td->gui, 0,0,0,0,
EINA_FALSE, ev->data, ev->size);
ecore_ipc_client_flush(
(void *) (uintptr_t) td->gui);
}
}
else
{ /* Sending tree data to all GUI clients */
Eina_List *l;
app_info_st *info;
EINA_LIST_FOREACH(gui, l, info)
{
ecore_ipc_client_send(
(void *) (uintptr_t) info->ptr, 0,0,0,0,
EINA_FALSE, ev->data, ev->size);
ecore_ipc_client_flush(
(void *) (uintptr_t) info->ptr);
}
}
clouseau_data_tree_free(td->tree);
}
break;
case CLOUSEAU_HIGHLIGHT:
{ /* FWD this message to app */
highlight_st *ht = v->data;
if(eina_list_search_unsorted(app,
_client_ptr_cmp, (void *) (uintptr_t) ht->app))
{ /* Do the req only of APP connected to daemon */
ecore_ipc_client_send((void *)
(uintptr_t) ht->app, 0,0,0,0,
EINA_FALSE, ev->data, ev->size);
ecore_ipc_client_flush((void *) (uintptr_t) ht->app);
}
}
break;
case CLOUSEAU_BMP_REQ:
{
bmp_req_st *req = v->data;
if(eina_list_search_unsorted(app,
_client_ptr_cmp, (void *) (uintptr_t) req->app))
{ /* Do the req only of APP connected to daemon */
bmp_req_st t = {
(unsigned long long) (uintptr_t) ev->client,
req->app, req->object, req->ctr };
p = clouseau_data_packet_compose(CLOUSEAU_BMP_REQ,
&t, sizeof(t), &size, NULL, 0);
if (p)
{ /* FWD req to app with client data */
ecore_ipc_client_send(
(void *) (uintptr_t) req->app,
0,0,0,0, EINA_FALSE, p, size);
ecore_ipc_client_flush(
(void *) (uintptr_t) req->app);
free(p);
}
}
}
break;
case CLOUSEAU_BMP_DATA:
{ /* Bmp Data comes from APP, GUI client specified in msg */
bmp_info_st *st = v->data;
if (st->gui)
{ /* Sending BMP data to specific GUI client */
if(eina_list_search_unsorted(gui,
_client_ptr_cmp,
(void *) (uintptr_t) st->gui))
{ /* Do the req only of GUI connected to daemon */
ecore_ipc_client_send(
(void *) (uintptr_t) st->gui, 0,0,0,0,
EINA_FALSE, ev->data, ev->size);
ecore_ipc_client_flush(
(void *) (uintptr_t) st->gui);
}
}
else
{ /* Sending BMP data to all GUI clients */
Eina_List *l;
app_info_st *info;
EINA_LIST_FOREACH(gui, l, info)
{
ecore_ipc_client_send(
(void *) (uintptr_t) info->ptr, 0,0,0,0,
EINA_FALSE, ev->data, ev->size);
ecore_ipc_client_flush(
(void *) (uintptr_t) info->ptr);
}
}
if (st->bmp)
free(st->bmp);
}
break;
default:
break;
}
clouseau_data_tree_free(td->tree);
}
clouseau_data_variant_free(v);
void
_highlight_cb(EINA_UNUSED void *data, EINA_UNUSED Ecore_Con_Reply *reply,
EINA_UNUSED const char *protocol_name, void *value)
{ /* FWD this message to APP */
highlight_st *ht = value;
sprintf(msg_buf, "\n<%s> msg from <%p>", __func__, reply);
log_message(LOG_FILE, "a", msg_buf);
if(eina_list_search_unsorted(app,
_client_ptr_cmp, (void *) (uintptr_t) ht->app))
{ /* Do the REQ only of APP connected to daemon */
sprintf(msg_buf, "\t<%p> Sending HIGHLIGHT to <%p>",
reply, (void *) (uint32_t) ht->app);
log_message(LOG_FILE, "a", msg_buf);
ecore_con_eet_send((void *) (uint32_t) ht->app,
CLOUSEAU_HIGHLIGHT_STR, value);
}
}
void
_bmp_req_cb(EINA_UNUSED void *data, Ecore_Con_Reply *reply,
EINA_UNUSED const char *protocol_name, void *value)
{ /* BMP data request coming from GUI to APP client */
bmp_req_st *req = value;
sprintf(msg_buf, "\n<%s> msg from <%p>", __func__, reply);
log_message(LOG_FILE, "a", msg_buf);
if(eina_list_search_unsorted(app,
_client_ptr_cmp, (void *) (uintptr_t) req->app))
{ /* Do the req only if APP connected to daemon */
bmp_req_st t = {
(unsigned long long) (uintptr_t) reply,
req->app, req->object, req->ctr };
sprintf(msg_buf, "\t<%p> Sending BMP_REQ to <%p>",
reply, (void *) (uint32_t) req->app);
log_message(LOG_FILE, "a", msg_buf);
ecore_con_eet_send((void *) (uint32_t) req->app,
CLOUSEAU_BMP_REQ_STR, &t);
}
}
void
_bmp_data_cb(EINA_UNUSED void *data, EINA_UNUSED Ecore_Con_Reply *reply,
EINA_UNUSED const char *protocol_name, EINA_UNUSED const char *section,
void *value, EINA_UNUSED size_t length)
{ /* BMP Data comes from APP, GUI client specified in msg */
bmp_info_st *st = clouseau_data_packet_info_get(protocol_name,
value, length);
sprintf(msg_buf, "\n<%s> msg from <%p>", __func__, reply);
log_message(LOG_FILE, "a", msg_buf);
if (st->gui)
{ /* Sending BMP data to specific GUI client */
if(eina_list_search_unsorted(gui,
_client_ptr_cmp,
(void *) (uintptr_t) st->gui))
{ /* Do the req only of GUI connected to daemon */
sprintf(msg_buf, "\t<%p> Sending BMP_DATA to <%p>",
reply, (void *) (uint32_t) st->gui);
log_message(LOG_FILE, "a", msg_buf);
ecore_con_eet_raw_send((void *) (uint32_t) st->gui,
CLOUSEAU_BMP_DATA_STR, "BMP", value, length);
}
}
else
{ /* Sending BMP data to all GUI clients */
Eina_List *l;
app_info_st *info;
EINA_LIST_FOREACH(gui, l, info)
{
sprintf(msg_buf, "\t<%p> Sending BMP_DATA to <%p>",
reply, (void *) (uint32_t) info->ptr);
log_message(LOG_FILE, "a", msg_buf);
ecore_con_eet_raw_send((void *) (uint32_t) info->ptr,
CLOUSEAU_BMP_DATA_STR, "BMP", value, length);
}
}
if (st->bmp)
free(st->bmp);
free(st);
log_message(LOG_FILE, "a", "_data() finished");
return ECORE_CALLBACK_RENEW;
}
/* END - Ecore communication callbacks */
@ -433,37 +455,18 @@ int main(void)
daemonize();
eina_init();
ecore_init();
ecore_con_init();
ecore_ipc_init();
clouseau_data_init();
Ecore_Con_Server *server = NULL;
if (!(server = ecore_con_server_add(ECORE_CON_REMOTE_TCP,
if (!(ipc_svr = ecore_ipc_server_add(ECORE_IPC_REMOTE_SYSTEM,
LISTEN_IP, PORT, NULL)))
exit(1);
eet_svr = ecore_con_eet_server_new(server);
if (!eet_svr)
exit(2);
ecore_ipc_server_data_size_max_set(ipc_svr, -1);
clouseau_register_descs(eet_svr);
/* Register callbacks for ecore_con_eet */
ecore_con_eet_client_connect_callback_add(eet_svr, _add, NULL);
ecore_con_eet_client_disconnect_callback_add(eet_svr, _del, server);
ecore_con_eet_data_callback_add(eet_svr, CLOUSEAU_GUI_CLIENT_CONNECT_STR,
_gui_client_connect_cb, NULL);
ecore_con_eet_data_callback_add(eet_svr, CLOUSEAU_APP_CLIENT_CONNECT_STR,
_app_client_connect_cb, NULL);
ecore_con_eet_data_callback_add(eet_svr, CLOUSEAU_DATA_REQ_STR,
_data_req_cb, NULL);
ecore_con_eet_data_callback_add(eet_svr, CLOUSEAU_TREE_DATA_STR,
_tree_data_cb, NULL);
ecore_con_eet_data_callback_add(eet_svr, CLOUSEAU_HIGHLIGHT_STR,
_highlight_cb, NULL);
ecore_con_eet_data_callback_add(eet_svr, CLOUSEAU_BMP_REQ_STR,
_bmp_req_cb, NULL);
ecore_con_eet_raw_data_callback_add(eet_svr, CLOUSEAU_BMP_DATA_STR,
_bmp_data_cb, NULL);
ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD, (Ecore_Event_Handler_Cb)_add, NULL);
ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DEL, (Ecore_Event_Handler_Cb)_del, NULL);
ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DATA, (Ecore_Event_Handler_Cb)_data, NULL);
ecore_main_loop_begin();
_daemon_cleanup();

View File

@ -2,7 +2,7 @@
#include <dlfcn.h>
#include <execinfo.h>
#include <Ecore_Con_Eet.h>
#include <Ecore_Ipc.h>
#include <Edje.h>
#include <Evas.h>
#include <Elementary.h>
@ -139,130 +139,157 @@ _load_list(void)
return tree; /* User has to call clouseau_tree_free() */
}
Eina_Bool
_add(EINA_UNUSED void *data, Ecore_Con_Reply *reply,
EINA_UNUSED Ecore_Con_Server *conn)
static Eina_Bool
_add(void *data EINA_UNUSED, int type EINA_UNUSED, Ecore_Ipc_Event_Server_Add *ev)
{
/* ecore_con_server_data_size_max_set(conn, -1); */
void *p;
int size = 0;
ecore_ipc_server_data_size_max_set(ev->server, -1);
connect_st t = { getpid(), _my_app_name };
ecore_con_eet_send(reply, CLOUSEAU_APP_CLIENT_CONNECT_STR, &t);
p = clouseau_data_packet_compose(CLOUSEAU_APP_CLIENT_CONNECT,
&t, sizeof(t), &size, NULL, 0);
if (p)
{
ecore_ipc_server_send(ev->server, 0,0,0,0,EINA_FALSE, p, size);
ecore_ipc_server_flush(ev->server);
free(p);
}
return ECORE_CALLBACK_RENEW;
}
Eina_Bool
_del(EINA_UNUSED void *data, EINA_UNUSED Ecore_Con_Reply *reply,
Ecore_Con_Server *conn)
static Eina_Bool
_del(void *data EINA_UNUSED, int type EINA_UNUSED, Ecore_Ipc_Event_Server_Del *ev)
{
if (!conn)
if (!ev->server)
{
printf("Failed to establish connection to the server.\nExiting.\n");
ecore_main_loop_quit();
return ECORE_CALLBACK_RENEW;
}
printf("Lost server with ip <%s>\n", ecore_con_server_ip_get(conn));
printf("Lost server with ip %s!\n", ecore_ipc_server_ip_get(ev->server));
ecore_con_server_del(conn);
ecore_ipc_server_del(ev->server);
ecore_main_loop_quit();
return ECORE_CALLBACK_RENEW;
}
void
_data_req_cb(EINA_UNUSED void *data, Ecore_Con_Reply *reply,
EINA_UNUSED const char *protocol_name, void *value)
{ /* data req includes ptr to GUI, to tell which client asking */
data_req_st *req = value;
tree_data_st t;
t.gui = req->gui; /* GUI client requesting data from daemon */
t.app = req->app; /* APP client sending data to daemon */
t.tree = _load_list();
if (t.tree)
{ /* Reply with tree data to data request */
ecore_con_eet_send(reply, CLOUSEAU_TREE_DATA_STR, &t);
clouseau_data_tree_free(t.tree);
}
}
void
_highlight_cb(EINA_UNUSED void *data, EINA_UNUSED Ecore_Con_Reply *reply,
EINA_UNUSED const char *protocol_name, void *value)
{ /* Highlight msg contains PTR of object to highlight */
highlight_st *ht = value;
Evas_Object *obj = (Evas_Object *) (uintptr_t) ht->object;
clouseau_data_object_highlight(obj, NULL, NULL);
}
void
_bmp_req_cb(EINA_UNUSED void *data, EINA_UNUSED Ecore_Con_Reply *reply,
EINA_UNUSED const char *protocol_name, void *value)
{ /* Bitmap req msg contains PTR of Ecore Evas */
bmp_req_st *req = value;
Evas_Coord w, h;
unsigned int size = 0;
void *bmp = _canvas_bmp_get((Ecore_Evas *) (uintptr_t)
req->object, &w, &h);
bmp_info_st t = { req->gui,
req->app, req->object , req->ctr, w, h,
NULL,NULL, NULL, 1.0,
NULL, NULL, NULL, NULL, NULL, NULL };
void *p = clouseau_data_packet_compose(CLOUSEAU_BMP_DATA_STR,
&t, &size, bmp, (w * h * sizeof(int)));
if (p)
{
ecore_con_eet_raw_send(reply, CLOUSEAU_BMP_DATA_STR, "BMP", p, size);
free(p);
}
if (bmp)
free(bmp);
}
static Eina_Bool
_data(void *data EINA_UNUSED, int type EINA_UNUSED, Ecore_Ipc_Event_Server_Data *ev)
{
Variant_st *v;
v = clouseau_data_packet_info_get(ev->data, ev->size);
switch (clouseau_data_packet_mapping_type_get(v->type))
{
case CLOUSEAU_DATA_REQ:
{ /* data req includes ptr to GUI, to tell which client asking */
int size = 0;
data_req_st *req = v->data;
tree_data_st t;
t.gui = req->gui; /* GUI client requesting data from daemon */
t.app = req->app; /* APP client sending data to daemon */
t.tree = _load_list();
if (t.tree)
{ /* Reply with tree data to data request */
void *p = clouseau_data_packet_compose(CLOUSEAU_TREE_DATA,
&t, sizeof(t), &size, NULL, 0);
if (p)
{
ecore_ipc_server_send(ev->server, 0,0,0,0,
EINA_FALSE, p, size);
ecore_ipc_server_flush(ev->server);
free(p);
}
clouseau_data_tree_free(t.tree);
}
}
break;
case CLOUSEAU_HIGHLIGHT:
{ /* Highlight msg contains PTR of object to highlight */
highlight_st *ht = v->data;
Evas_Object *obj = (Evas_Object *) (uintptr_t) ht->object;
clouseau_data_object_highlight(obj, NULL, NULL);
}
break;
case CLOUSEAU_BMP_REQ:
{ /* Bitmap req msg contains PTR of Ecore Evas */
bmp_req_st *req = v->data;
Evas_Coord w, h;
int size = 0;
void *bmp = _canvas_bmp_get((Ecore_Evas *) (uintptr_t)
req->object, &w, &h);
bmp_info_st t = { req->gui,
req->app, req->object , req->ctr, w, h,
NULL,NULL, NULL, 1.0,
NULL, NULL, NULL, NULL, NULL, NULL };
void *p = clouseau_data_packet_compose(CLOUSEAU_BMP_DATA,
&t, sizeof(t), &size, bmp, (w * h * sizeof(int)));
if (p)
{
ecore_ipc_server_send(ev->server, 0,0,0,0,
EINA_FALSE, p, size);
ecore_ipc_server_flush(ev->server);
free(p);
}
if (bmp)
free(bmp);
}
break;
default:
break;
}
clouseau_data_variant_free(v);
return ECORE_CALLBACK_RENEW;
}
static int
_connect_to_daemon(void)
{
Ecore_Con_Server *server;
Ecore_Ipc_Server *svr;
const char *address = LOCALHOST;
Ecore_Con_Eet *eet_svr = NULL;
eina_init();
ecore_init();
ecore_con_init();
ecore_ipc_init();
server = ecore_con_server_connect(ECORE_CON_REMOTE_TCP,
svr = ecore_ipc_server_connect(ECORE_IPC_REMOTE_SYSTEM,
LOCALHOST, PORT, NULL);
if (!server)
if (!svr)
{
printf("could not connect to the server: %s, port %d.\n",
address, PORT);
return EINA_FALSE;
}
eet_svr = ecore_con_eet_client_new(server);
if (!eet_svr)
{
printf("could not create con_eet client.\n");
return EINA_FALSE;
}
ecore_ipc_server_data_size_max_set(svr, -1);
clouseau_register_descs(eet_svr);
/* Register callbacks for ecore_con_eet */
ecore_con_eet_server_connect_callback_add(eet_svr, _add, NULL);
ecore_con_eet_server_disconnect_callback_add(eet_svr, _del, NULL);
ecore_con_eet_data_callback_add(eet_svr, CLOUSEAU_DATA_REQ_STR,
_data_req_cb, NULL);
ecore_con_eet_data_callback_add(eet_svr, CLOUSEAU_HIGHLIGHT_STR,
_highlight_cb, NULL);
ecore_con_eet_data_callback_add(eet_svr, CLOUSEAU_BMP_REQ_STR,
_bmp_req_cb, NULL);
/* set event handler for server connect */
ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_ADD,
(Ecore_Event_Handler_Cb)_add, NULL);
/* set event handler for server disconnect */
ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DEL,
(Ecore_Event_Handler_Cb)_del, NULL);
/* set event handler for receiving server data */
ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DATA,
(Ecore_Event_Handler_Cb)_data, NULL);
return EINA_TRUE;
}
@ -297,14 +324,14 @@ ecore_main_loop_begin(void)
_my_app_name = "clouseau";
}
clouseau_data_init();
if(!_connect_to_daemon())
{
printf("Failed to connect to server.\n");
return;
}
clouseau_data_init();
_ecore_main_loop_begin();
clouseau_data_shutdown();

View File

@ -19,6 +19,7 @@ static Eet_Data_Descriptor *clouseau_tree_edd = NULL;
static Eet_Data_Descriptor *clouseau_app_closed_edd = NULL;
static Eet_Data_Descriptor *clouseau_highlight_edd = NULL;
static Eet_Data_Descriptor *clouseau_bmp_req_edd = NULL;
static Eet_Data_Descriptor *clouseau_variant_edd = NULL;
static Eet_Data_Descriptor *clouseau_protocol_edd = NULL;
static Eet_Data_Descriptor *clouseau_map_point_props_edd = NULL;
@ -44,6 +45,97 @@ clouseau_data_tree_free(Eina_List *tree)
_clouseau_tree_item_free(treeit);
}
static const struct {
Clouseau_Message_Type t;
const char *name;
} eet_mapping[] = {
{ CLOUSEAU_GUI_CLIENT_CONNECT, "GUI_CONNECT" },
{ CLOUSEAU_APP_CLIENT_CONNECT, "APP_CONNECT" },
{ CLOUSEAU_APP_ADD, "APP_ADD" },
{ CLOUSEAU_DATA_REQ, "DATA_REQ" },
{ CLOUSEAU_TREE_DATA, "TREE_DATA" },
{ CLOUSEAU_APP_CLOSED, "APP_CLOSED" },
{ CLOUSEAU_HIGHLIGHT, "HIGHLIGHT" },
{ CLOUSEAU_BMP_REQ, "BMP_REQ" },
{ CLOUSEAU_BMP_DATA, "BMP_DATA" },
{ CLOUSEAU_UNKNOWN, NULL }
};
EAPI Clouseau_Message_Type
clouseau_data_packet_mapping_type_get(const char *name)
{
int i;
if (!name)
return CLOUSEAU_UNKNOWN;
for (i = 0; eet_mapping[i].name != NULL; ++i)
if (strcmp(name, eet_mapping[i].name) == 0)
return eet_mapping[i].t;
return CLOUSEAU_UNKNOWN;
}
static const char *
_clouseau_packet_mapping_type_str_get(Clouseau_Message_Type t)
{
int i;
for (i = 0; eet_mapping[i].name != NULL; ++i)
if (t == eet_mapping[i].t)
return eet_mapping[i].name;
return NULL;
}
static const char *
_clouseau_variant_type_get(const void *data, Eina_Bool *unknow EINA_UNUSED)
{
const char * const *type = data;
int i;
for (i = 0; eet_mapping[i].name != NULL; ++i)
if (strcmp(*type, eet_mapping[i].name) == 0)
return eet_mapping[i].name;
return NULL;
}
static Eina_Bool
_clouseau_variant_type_set(const char *type,
void *data,
Eina_Bool unknow EINA_UNUSED)
{
const char **t = data;
*t = type;
return EINA_TRUE;
}
EAPI void
clouseau_data_variant_free(Variant_st *v)
{
if (v->data)
free(v->data);
free(v);
}
EAPI Variant_st *
clouseau_data_variant_alloc(Clouseau_Message_Type t, size_t size, void *info)
{
Variant_st *v;
if (t == CLOUSEAU_UNKNOWN) return NULL;
/* This will allocate variant and message struct */
v = malloc(sizeof(Variant_st));
v->data = malloc(size);
_clouseau_variant_type_set(_clouseau_packet_mapping_type_str_get(t),
&v->type, EINA_FALSE);
memcpy(v->data, info, size);
return v;
}
static void
_clouseau_connect_desc_make(void)
{
@ -479,6 +571,8 @@ _clouseau_object_desc_make(void)
static void
clouseau_data_descriptors_init(void)
{
Eet_Data_Descriptor_Class eddc;
_clouseau_bmp_req_desc_make();
_clouseau_bmp_info_desc_make();
_clouseau_shot_list_desc_make();
@ -490,6 +584,36 @@ clouseau_data_descriptors_init(void)
_clouseau_tree_data_desc_make();
_clouseau_app_closed_desc_make();
_clouseau_highlight_desc_make();
/* for variant */
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Variant_st);
clouseau_protocol_edd = eet_data_descriptor_file_new(&eddc);
eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
eddc.func.type_get = _clouseau_variant_type_get;
eddc.func.type_set = _clouseau_variant_type_set;
clouseau_variant_edd = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_MAPPING(clouseau_variant_edd,
"GUI_CONNECT", clouseau_connect_edd);
EET_DATA_DESCRIPTOR_ADD_MAPPING(clouseau_variant_edd,
"APP_CONNECT", clouseau_connect_edd);
EET_DATA_DESCRIPTOR_ADD_MAPPING(clouseau_variant_edd,
"APP_ADD" , clouseau_app_add_edd);
EET_DATA_DESCRIPTOR_ADD_MAPPING(clouseau_variant_edd,
"DATA_REQ", clouseau_data_req_edd);
EET_DATA_DESCRIPTOR_ADD_MAPPING(clouseau_variant_edd,
"TREE_DATA", clouseau_tree_data_edd);
EET_DATA_DESCRIPTOR_ADD_MAPPING(clouseau_variant_edd,
"APP_CLOSED", clouseau_app_closed_edd);
EET_DATA_DESCRIPTOR_ADD_MAPPING(clouseau_variant_edd,
"HIGHLIGHT", clouseau_highlight_edd);
EET_DATA_DESCRIPTOR_ADD_MAPPING(clouseau_variant_edd,
"BMP_REQ", clouseau_bmp_req_edd);
EET_DATA_DESCRIPTOR_ADD_MAPPING(clouseau_variant_edd,
"BMP_DATA", clouseau_bmp_info_edd);
EET_DATA_DESCRIPTOR_ADD_VARIANT(clouseau_protocol_edd, Variant_st,
"data", data, type, clouseau_variant_edd);
}
static void
@ -502,6 +626,7 @@ clouseau_data_descriptors_shutdown(void)
eet_data_descriptor_free(clouseau_app_closed_edd);
eet_data_descriptor_free(clouseau_highlight_edd);
eet_data_descriptor_free(clouseau_object_edd);
eet_data_descriptor_free(clouseau_variant_edd);
eet_data_descriptor_free(clouseau_bmp_req_edd);
eet_data_descriptor_free(clouseau_bmp_info_edd);
eet_data_descriptor_free(clouseau_shot_list_edd);
@ -564,110 +689,124 @@ _net_to_host_blob_get(void *blob, int blob_size)
}
EAPI void *
clouseau_data_packet_compose(const char *p_type, void *data,
unsigned int *size, void *blob, int blob_size)
{ /* Returns packet BLOB and size in size param, NULL on failure */
/* User has to free returned buffer */
/* Packet is composed of Message Type + packet data. */
void *net_blob = NULL;
clouseau_data_packet_compose(Clouseau_Message_Type t, void *data,
int data_size, int *size,
void *blob, int blob_size)
{
/* Returns packet BLOB and size in size param, NULL on failure */
/* Packet is composed of packet type BYTE + packet data. */
void *p = NULL;
void *pb = NULL;
unsigned char p_type = VARIANT_PACKET;
Variant_st *v;
if (!strcmp(p_type, CLOUSEAU_BMP_DATA_STR))
{ /* Builed Bitmap data as follows:
First uint32_t is encoding size of bmp_info_st
The next to come will be the encoded bmp_info_st itself
Then we have blob_size param (specifiying bmp-blob-size)
folloed by the Bitmap raw data. */
switch (t)
{
case CLOUSEAU_BMP_DATA:
{ /* Builed Bitmap data as follows:
First we have encoding size of bmp_info_st
(Done Network Byte Order)
The next to come will be the encoded bmp_info_st itself
folloed by the Bitmap raw data. */
int t_size; /* total size */
int e_size;
uint32_t e_size32;
uint32_t tmp;
void *p;
char *b;
char *ptr;
/* First, we like to encode bmp_info_st from data */
int e_size;
uint32_t enc_size;
void *net_blob;
char *b;
/* First, we like to encode bmp_info_st from data */
p = eet_data_descriptor_encode(clouseau_bmp_info_edd, data, &e_size);
e_size32 = (uint32_t) e_size;
v = clouseau_data_variant_alloc(t, data_size, data);
p = eet_data_descriptor_encode(clouseau_protocol_edd, v, &e_size);
clouseau_data_variant_free(v);
/* Allocate buffer to hold whole packet data */
t_size = sizeof(e_size32) + /* encoding size of bmp_info_st */
+ e_size /* Encoded bmp_info_st */
+ sizeof(e_size32) /* bmp-blob-size */
+ blob_size; /* The BMP blob data */
/* Save encoded size in network format */
enc_size = htonl((uint32_t) e_size);
net_blob = _host_to_net_blob_get(blob, &blob_size);
ptr = b = malloc(t_size);
/* Update size to the buffer size we about to return */
*size = (e_size + blob_size + sizeof(enc_size));
b = malloc(*size);
/* START - Build BMP_RAW_DATA packet data */
/* Size of encoded bmp_info_st comes next in uint32 format */
memcpy(ptr, &e_size32, sizeof(e_size32));
ptr += sizeof(e_size32);
/* Copy encoded-size first, followd by encoded data */
memcpy(b, &enc_size, sizeof(enc_size));
memcpy(b + sizeof(enc_size), p, e_size);
free(p);
/* Encoded bmp_info_st comes next */
memcpy(ptr, p, e_size);
ptr += e_size;
if (net_blob) /* Copy BMP info */
{
memcpy(b + sizeof(enc_size) + e_size, net_blob, blob_size);
free(net_blob);
}
/* Size of BMP blob comes next */
tmp = (uint32_t) blob_size;
memcpy(ptr, &tmp, sizeof(uint32_t));
ptr += sizeof(uint32_t);
p_type = BMP_RAW_DATA;
p = b;
}
break;
if (blob && blob_size)
{ /* BMP blob info comes right after BMP blob_size */
memcpy(ptr, blob, blob_size);
}
/* Save encoded size in network format */
net_blob = _host_to_net_blob_get(b, &t_size);
*size = t_size; /* Update packet size */
/* All info now in net_blob, free allocated mem */
free(b);
free(p);
/* END - Build BMP_RAW_DATA packet data */
default:
{
/* All others are variant packets with EET encoding */
/* Variant is composed of message type + ptr to data */
v = clouseau_data_variant_alloc(t, data_size, data);
p = eet_data_descriptor_encode(clouseau_protocol_edd, v, size);
clouseau_data_variant_free(v);
}
}
return net_blob;
pb = malloc((*size) + 1);
*((unsigned char *) pb) = p_type;
memcpy(((char *) pb) + 1, p, *size);
*size = (*size) + 1; /* Add space for packet type */
free(p);
return pb; /* User has to free(pb) */
}
EAPI void *
clouseau_data_packet_info_get(const char *p_type, void *data, size_t size)
EAPI Variant_st *
clouseau_data_packet_info_get(void *data, int size)
{
bmp_info_st *st = NULL;
void *host_blob = _net_to_host_blob_get(data, size);
char *ptr = host_blob;
/* user has to use variant_free() to free return struct */
char *ch = data;
Variant_st *v;
if (size <= 0)
return NULL;
if (!strcmp(p_type, CLOUSEAU_BMP_DATA_STR))
switch (*ch)
{
uint32_t *e_size32 = (uint32_t *) ptr;
int e_size = (int) (*e_size32); /* First Encoded bmp_info_st size */
ptr += sizeof(uint32_t);
case BMP_RAW_DATA:
{
void *bmp = NULL;
bmp_info_st *st;
char *b;
uint32_t enc_size;
int blob_size;
/* Get the encoded bmp_info_st */
st = eet_data_descriptor_decode(clouseau_bmp_info_edd
,ptr, e_size);
ptr += e_size;
b = (char *) (ch + 1);
enc_size = ntohl(*(uint32_t *) b);
/* blob_size is total size minus 1st byte and enc_size size */
blob_size = size - (enc_size + 1 + sizeof(enc_size));
if (blob_size)
{
/* Allocate BMP only if was included in packet */
bmp = _net_to_host_blob_get(b + sizeof(enc_size) + enc_size,
blob_size);
}
st->bmp = NULL;
/* User have to free both: variant_free(rt), free(t->bmp) */
v = eet_data_descriptor_decode(clouseau_protocol_edd,
b + sizeof(enc_size), enc_size);
/* Next Get bmp-blob-size */
e_size32 = (uint32_t *) ptr;
e_size = (int) (*e_size32); /* Get bmp-blob size */
ptr += sizeof(uint32_t);
st = v->data;
st->bmp = bmp;
return v;
}
break;
/* Now we need to get the bmp data */
if (e_size)
{ /* BMP data available, allocate and copy */
st->bmp = malloc(e_size); /* Freed by user */
memcpy(st->bmp, ptr, e_size);
}
} /* User has to free st, st->bmp */
free(host_blob);
return st;
default:
return eet_data_descriptor_decode(clouseau_protocol_edd,
ch + 1, size - 1);
}
}
/* HIGHLIGHT code. */
@ -883,6 +1022,7 @@ clouseau_data_eet_info_read(const char *filename,
EINA_LIST_FREE(t->view, st)
{
Variant_st *v;
char buf[1024];
int alpha;
int compress;
@ -896,7 +1036,8 @@ clouseau_data_eet_info_read(const char *filename,
&alpha, &compress, &quality, &lossy);
/* Add the bitmaps to the actuall app data struct */
(*a)->view = eina_list_append((*a)->view, st);
v = clouseau_data_variant_alloc(CLOUSEAU_BMP_DATA, sizeof(*st), st);
(*a)->view = eina_list_append((*a)->view, v);
}
free(t);
@ -920,34 +1061,6 @@ clouseau_data_init(void)
return clouseau_init_count;
}
EAPI int
clouseau_register_descs(Ecore_Con_Eet *eet_svr)
{ /* Register descriptors for ecore_con_eet */
if (clouseau_init_count)
{ /* MUST be called after clouseau_data_init */
ecore_con_eet_register(eet_svr, CLOUSEAU_GUI_CLIENT_CONNECT_STR,
clouseau_connect_edd);
ecore_con_eet_register(eet_svr, CLOUSEAU_APP_CLIENT_CONNECT_STR,
clouseau_connect_edd);
ecore_con_eet_register(eet_svr, CLOUSEAU_APP_ADD_STR,
clouseau_app_add_edd);
ecore_con_eet_register(eet_svr, CLOUSEAU_DATA_REQ_STR,
clouseau_data_req_edd);
ecore_con_eet_register(eet_svr, CLOUSEAU_TREE_DATA_STR,
clouseau_tree_data_edd);
ecore_con_eet_register(eet_svr, CLOUSEAU_APP_CLOSED_STR,
clouseau_app_closed_edd);
ecore_con_eet_register(eet_svr, CLOUSEAU_HIGHLIGHT_STR,
clouseau_highlight_edd);
ecore_con_eet_register(eet_svr, CLOUSEAU_BMP_REQ_STR,
clouseau_bmp_req_edd);
ecore_con_eet_register(eet_svr, CLOUSEAU_BMP_DATA_STR,
clouseau_bmp_info_edd);
}
return clouseau_init_count;
}
EAPI int
clouseau_data_shutdown(void)
{

View File

@ -1,7 +1,6 @@
#ifndef EET_DATA_H
#define EET_DATA_H
#include "Clouseau.h"
#include <Ecore_Con_Eet.h>
/* Global constants */
#define BMP_FIELD "bmp"
@ -10,21 +9,33 @@
#define LOCALHOST "127.0.0.1"
#define LISTEN_IP "0.0.0.0" /* Avail all, no mask */
#define CLOUSEAU_GUI_CLIENT_CONNECT_STR "CLOUSEAU_GUI_CLIENT_CONNECT"
#define CLOUSEAU_APP_CLIENT_CONNECT_STR "CLOUSEAU_APP_CLIENT_CONNECT"
#define CLOUSEAU_APP_ADD_STR "CLOUSEAU_APP_ADD"
#define CLOUSEAU_DATA_REQ_STR "CLOUSEAU_DATA_REQ"
#define CLOUSEAU_TREE_DATA_STR "CLOUSEAU_TREE_DATA"
#define CLOUSEAU_APP_CLOSED_STR "CLOUSEAU_APP_CLOSED"
#define CLOUSEAU_HIGHLIGHT_STR "CLOUSEAU_HIGHLIGHT"
#define CLOUSEAU_BMP_REQ_STR "CLOUSEAU_BMP_REQ"
#define CLOUSEAU_BMP_DATA_STR "CLOUSEAU_BMP_DATA"
/* Define packet types, used by packet encode / decode */
#define VARIANT_PACKET 0
#define BMP_RAW_DATA 1
/* Private function */
#define CLOUSEAU_APP_ADD_ENTRY "clouseau/app"
#define CLOUSEAU_TREE_DATA_ENTRY "clouseau/app/tree"
#define CLOUSEAU_BMP_LIST_ENTRY "clouseau/app/shot_list"
#define CLOUSEAU_BMP_DATA_ENTRY "clouseau/app/screenshot"
enum _Clouseau_Message_Type
{ /* Add any supported types of packets here */
CLOUSEAU_UNKNOWN = 0,
CLOUSEAU_GUI_CLIENT_CONNECT = 1, /* client PID, name */
CLOUSEAU_APP_CLIENT_CONNECT = 2, /* client PID, name */
CLOUSEAU_APP_ADD = 3, /* client PTR, name, PID fwd to GUI client */
CLOUSEAU_DATA_REQ = 4, /* GUI client PTR (NULL for all),APP client PTR (NULL for all) */
CLOUSEAU_TREE_DATA = 5, /* GUI client PTR (NULL for all),APP client PTR, Tree Data */
CLOUSEAU_APP_CLOSED = 6,/* APP client PTR from DAEMON to GUI */
CLOUSEAU_HIGHLIGHT = 7, /* APP client PTR, object PTR */
CLOUSEAU_BMP_REQ = 8, /* APP client PTR, object PTR */
CLOUSEAU_BMP_DATA = 9 /* bmp_info_st header + BMP raw data */
};
typedef enum _Clouseau_Message_Type Clouseau_Message_Type;
/* This is used for composing message and encoding/decoding with EET */
struct _Variant_st
{
const char *type;
void *data;
};
typedef struct _Variant_st Variant_st;
struct _connect_st
{ /* This will be used for APP, GUI client connect */
@ -39,7 +50,7 @@ struct _app_info_st
char *name;
char *file; /* Valid only if was read from file in offline mode */
unsigned long long ptr; /* (void *) client ptr of app as saved by daemon */
Eina_List *view; /* Screen views pointers of (bmp_info_st *) */
Eina_List *view; /* Screen views view->data is (bmp_info_st *) ptr */
unsigned int refresh_ctr; /* Counter of how many times down refresh */
};
typedef struct _app_info_st app_info_st;
@ -126,21 +137,33 @@ struct _data_desc
Eet_Data_Descriptor *highlight;
Eet_Data_Descriptor *tree;
Eet_Data_Descriptor *obj_info;
Eet_Data_Descriptor *_variant_descriptor;
Eet_Data_Descriptor *_variant_unified_descriptor;
};
typedef struct _data_desc data_desc;
/* Private function */
#define CLOUSEAU_APP_ADD_ENTRY "clouseau/app"
#define CLOUSEAU_TREE_DATA_ENTRY "clouseau/app/tree"
#define CLOUSEAU_BMP_LIST_ENTRY "clouseau/app/shot_list"
#define CLOUSEAU_BMP_DATA_ENTRY "clouseau/app/screenshot"
/* Exported From Object information */
EAPI void clouseau_object_information_free(Clouseau_Object *oinfo);
EAPI Clouseau_Object * clouseau_object_information_get(Clouseau_Tree_Item *treeit);
/* Exported function */
EAPI void clouseau_data_tree_free(Eina_List *tree);
EAPI void *clouseau_data_packet_compose(const char *p_type, void *data, unsigned int *size, void *blob, int blob_size);
EAPI void *clouseau_data_packet_info_get(const char *p_type, void *data, size_t size);
EAPI Clouseau_Message_Type clouseau_data_packet_mapping_type_get(const char *name);
EAPI void clouseau_data_variant_free(Variant_st *v);
EAPI Variant_st *clouseau_data_variant_alloc(Clouseau_Message_Type t, size_t size, void *info);
EAPI void * clouseau_data_packet_compose(Clouseau_Message_Type t, void *data, int data_size, int *size, void *blob, int blob_size);
EAPI Variant_st *
clouseau_data_packet_info_get(void *data, int size);
EAPI void clouseau_data_object_highlight(Evas_Object *obj, Clouseau_Evas_Props *props, bmp_info_st *view);
EAPI Eina_Bool clouseau_data_eet_info_save(const char *filename, app_info_st *a, tree_data_st *ftd, Eina_List *ck_list);
EAPI Eina_Bool clouseau_data_eet_info_read(const char *filename, app_info_st **a, tree_data_st **ftd);
EAPI int clouseau_data_init(void);
EAPI int clouseau_register_descs(Ecore_Con_Eet *eet_svr);
EAPI int clouseau_data_shutdown(void);
#endif /* EET_DATA_H */