Clouseau: libclouseau_preload is now correctly split.

SVN revision: 83681
This commit is contained in:
Tom Hacohen 2013-02-06 13:19:28 +00:00
parent eb977554a7
commit 20df08e176
8 changed files with 286 additions and 192 deletions

View File

@ -1,7 +1,11 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <Elementary_Cursor.h>
#include <Ecore_Con_Eet.h>
#include "clouseau_private.h"
#include "Clouseau.h"
#define CLIENT_NAME "Clouseau Client"

View File

@ -6,7 +6,7 @@
#include <unistd.h>
#include <Ecore_Con_Eet.h>
#include "clouseau_private.h"
#include "Clouseau.h"
#define LOCK_FILE "/tmp/clouseaud.pid"

View File

@ -7,6 +7,62 @@
* These functions will probably need to be renamed/change as well.
* We'll also remove the private include once things are done. */
#include <Elementary.h>
typedef struct _Clouseau_Bitmap Clouseau_Bitmap;
typedef struct _Clouseau_Tree_Item Clouseau_Tree_Item;
/* Legacy type. */
typedef struct _Clouseau_Object Clouseau_Object;
typedef enum
{
CLOUSEAU_OBJ_TYPE_UNKNOWN,
CLOUSEAU_OBJ_TYPE_OTHER,
CLOUSEAU_OBJ_TYPE_ELM,
CLOUSEAU_OBJ_TYPE_TEXT,
CLOUSEAU_OBJ_TYPE_IMAGE,
CLOUSEAU_OBJ_TYPE_EDJE,
CLOUSEAU_OBJ_TYPE_TEXTBLOCK
} Clouseau_Object_Type;
struct _Clouseau_Bitmap
{
unsigned char *bmp;
int bmp_count; /* is (w * h), for EET_DATA_DESCRIPTOR_ADD_BASIC_VAR_ARRAY */
Evas_Coord w;
Evas_Coord h;
};
/* FIXME: Should name be a stringshare?
* FIXME: Should strip this structure to be half the size. Most of the stuff are
* not really needed. */
struct _Clouseau_Tree_Item
{
Eina_List *children;
Eina_List *eo_info; /* The intermediate type we use for eet. */
Eo_Dbg_Info *new_eo_info;
const char *name;
unsigned long long ptr; /* Just a ptr, we keep the value but not accessing mem */
Clouseau_Object *info; /* Legacy */
Eina_Bool is_obj;
Eina_Bool is_clipper;
Eina_Bool is_visible;
};
EAPI Eina_Bool clouseau_app_connect(void);
EAPI void clouseau_app_data_req_cb_set(Eina_List *(*cb)(void));
EAPI void clouseau_app_canvas_bmp_cb_set(void *(*cb)(Ecore_Evas *ee, Evas_Coord *w_out, Evas_Coord *h_out));
EAPI Clouseau_Object *clouseau_object_information_get(Clouseau_Tree_Item *treeit);
EAPI Eina_Bool clouseau_daemon_connect(void);
EAPI Eina_Bool clouseau_client_connect(void);
EAPI Eina_Bool clouseau_disconnect(void);
EAPI int clouseau_init(const char *appname);
EAPI int clouseau_shutdown(void);
/* FIXME: Remove. */
#include "clouseau_private.h"
#endif

View File

@ -28,10 +28,7 @@ libclouseau_la_CFLAGS = @EFL_CFLAGS@
libclouseau_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@
libclouseau_preload_la_SOURCES = \
clouseau_preload.c \
clouseau_object_information.c \
clouseau_data_legacy.c \
clouseau_data.c
clouseau_preload.c
libclouseau_preload_la_LDFLAGS = -module -avoid-version -rdynamic
libclouseau_preload_la_DEPENDENCIES = $(top_builddir)/config.h libclouseau.la

View File

@ -1,5 +1,10 @@
#include "clouseau_private.h"
static int _clouseau_init_count = 0;
static Eina_Stringshare *_my_appname = NULL;
static Eina_List *(*_load_list)(void) = NULL;
static void *(*_canvas_bmp_get)(Ecore_Evas *ee, Evas_Coord *w_out, Evas_Coord *h_out) = NULL;
/* Highlight functions. */
static Eina_Bool
_clouseau_highlight_fade(void *_rect)
@ -144,3 +149,212 @@ clouseau_data_object_highlight(Evas_Object *obj, Clouseau_Evas_Props *props, bmp
tmp = evas_object_data_get(obj, ".clouseau.bt");
fprintf(stderr, "Creation backtrace :\n%s*******\n", tmp); */
}
EAPI Clouseau_Object *
clouseau_object_information_get(Clouseau_Tree_Item *treeit)
{
Evas_Object *obj = (void*) (uintptr_t) treeit->ptr;
Eo_Dbg_Info *eo_dbg_info = EO_DBG_INFO_LIST_APPEND(NULL, "");
if (!treeit->is_obj)
return NULL;
eo_do(obj, eo_dbg_info_get(eo_dbg_info));
treeit->eo_info = clouseau_eo_to_legacy_convert(eo_dbg_info);
eo_dbg_info_free(eo_dbg_info); /* Free original list */
return NULL;
}
Eina_Bool
_add(EINA_UNUSED void *data, Ecore_Con_Reply *reply,
EINA_UNUSED Ecore_Con_Server *conn)
{
/* ecore_con_server_data_size_max_set(conn, -1); */
connect_st t = { getpid(), _my_appname };
ecore_con_eet_send(reply, CLOUSEAU_APP_CLIENT_CONNECT_STR, &t);
return ECORE_CALLBACK_RENEW;
}
Eina_Bool
_del(EINA_UNUSED void *data, EINA_UNUSED Ecore_Con_Reply *reply,
Ecore_Con_Server *conn)
{
if (!conn)
{
printf("Failed to establish connection to the server.\n");
}
printf("Lost server with ip <%s>\n", ecore_con_server_ip_get(conn));
ecore_con_server_del(conn);
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);
}
/* FIXME: This one is ugly and should be done elsewhere.. */
EAPI void
clouseau_app_data_req_cb_set(Eina_List *(*cb)(void))
{
_load_list = cb;
}
/* FIXME: This one is ugly and should be done elsewhere.. */
EAPI void
clouseau_app_canvas_bmp_cb_set(void *(*cb)(Ecore_Evas *ee, Evas_Coord *w_out, Evas_Coord *h_out))
{
_canvas_bmp_get = cb;
}
EAPI Eina_Bool
clouseau_app_connect(void)
{
Ecore_Con_Server *server;
const char *address = LOCALHOST;
Ecore_Con_Eet *eet_svr = NULL;
server = ecore_con_server_connect(ECORE_CON_REMOTE_TCP,
LOCALHOST, PORT, NULL);
if (!server)
{
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;
}
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);
return EINA_TRUE;
}
EAPI Eina_Bool
clouseau_daemon_connect(void)
{
return EINA_TRUE;
}
EAPI Eina_Bool
clouseau_client_connect(void)
{
return EINA_TRUE;
}
EAPI Eina_Bool
clouseau_disconnect(void)
{
return EINA_TRUE;
}
EAPI int
clouseau_init(const char *appname)
{
if (++_clouseau_init_count == 1)
{
_my_appname = eina_stringshare_add(appname);
eina_init();
ecore_init();
ecore_con_init();
clouseau_data_init();
}
return _clouseau_init_count;
}
EAPI int
clouseau_shutdown(void)
{
if (--_clouseau_init_count == 0)
{
eina_stringshare_del(_my_appname);
_my_appname = NULL;
clouseau_data_shutdown();
ecore_con_shutdown();
ecore_shutdown();
eina_shutdown();
}
else if (_clouseau_init_count < 0)
{
_clouseau_init_count = 0;
printf("Tried to shutdown although not initiated.\n");
}
return _clouseau_init_count;
}

View File

@ -191,23 +191,6 @@ clouseau_eo_to_legacy_convert(Eo_Dbg_Info *root)
return new_list;
}
EAPI Clouseau_Object *
clouseau_object_information_get(Clouseau_Tree_Item *treeit)
{
Evas_Object *obj = (void*) (uintptr_t) treeit->ptr;
Eo_Dbg_Info *eo_dbg_info = EO_DBG_INFO_LIST_APPEND(NULL, "");
if (!treeit->is_obj)
return NULL;
eo_do(obj, eo_dbg_info_get(eo_dbg_info));
treeit->eo_info = clouseau_eo_to_legacy_convert(eo_dbg_info);
eo_dbg_info_free(eo_dbg_info); /* Free original list */
return NULL;
}
static const struct {
const char *text;
Evas_Object_Pointer_Mode mode;

View File

@ -141,134 +141,6 @@ _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)
{
/* ecore_con_server_data_size_max_set(conn, -1); */
connect_st t = { getpid(), _my_app_name };
ecore_con_eet_send(reply, CLOUSEAU_APP_CLIENT_CONNECT_STR, &t);
return ECORE_CALLBACK_RENEW;
}
Eina_Bool
_del(EINA_UNUSED void *data, EINA_UNUSED Ecore_Con_Reply *reply,
Ecore_Con_Server *conn)
{
if (!conn)
{
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));
ecore_con_server_del(conn);
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
_connect_to_daemon(void)
{
Ecore_Con_Server *server;
const char *address = LOCALHOST;
Ecore_Con_Eet *eet_svr = NULL;
eina_init();
ecore_init();
ecore_con_init();
server = ecore_con_server_connect(ECORE_CON_REMOTE_TCP,
LOCALHOST, PORT, NULL);
if (!server)
{
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;
}
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);
return EINA_TRUE;
}
/** PRELOAD functions. */
/* Hook on the elm_init
@ -301,9 +173,11 @@ ecore_main_loop_begin(void)
_my_app_name = "clouseau";
}
clouseau_data_init();
clouseau_init(_my_app_name);
clouseau_app_data_req_cb_set(_load_list);
clouseau_app_canvas_bmp_cb_set(_canvas_bmp_get);
if(!_connect_to_daemon())
if(!clouseau_app_connect())
{
printf("Failed to connect to server.\n");
return;
@ -311,7 +185,7 @@ ecore_main_loop_begin(void)
_ecore_main_loop_begin();
clouseau_data_shutdown();
clouseau_shutdown();
return;
}

View File

@ -1,13 +1,15 @@
#ifndef _CLOUSEAU_PRIVATE2_H
#define _CLOUSEAU_PRIVATE2_H
/* This header replaces Clouseau.h
#include <Elementary.h>
/* This header replaces the old Clouseau.h
* The contents here are not public by any means, and the name indicated as if
* they were.
* We will "whitelist" parts from here to the public header when we'll need
* it. */
#include <Elementary.h>
#include "Clouseau.h"
typedef struct _Clouseau_Evas_Props Clouseau_Evas_Props;
typedef struct _Clouseau_Evas_Text_Props Clouseau_Evas_Text_Props;
@ -17,10 +19,6 @@ typedef struct _Clouseau_Edje_Props Clouseau_Edje_Props;
typedef struct _Clouseau_Evas_Map_Point_Props Clouseau_Evas_Map_Point_Props;
typedef struct _Clouseau_Extra_Props Clouseau_Extra_Props;
typedef struct _Clouseau_Object Clouseau_Object;
typedef struct _Clouseau_Bitmap Clouseau_Bitmap;
typedef struct _Clouseau_Tree_Item Clouseau_Tree_Item;
/* The color of the highlight */
enum {
@ -34,17 +32,6 @@ enum {
PADDING = 0,
};
typedef enum
{
CLOUSEAU_OBJ_TYPE_UNKNOWN,
CLOUSEAU_OBJ_TYPE_OTHER,
CLOUSEAU_OBJ_TYPE_ELM,
CLOUSEAU_OBJ_TYPE_TEXT,
CLOUSEAU_OBJ_TYPE_IMAGE,
CLOUSEAU_OBJ_TYPE_EDJE,
CLOUSEAU_OBJ_TYPE_TEXTBLOCK
} Clouseau_Object_Type;
struct _Clouseau_Evas_Map_Point_Props
{
Evas_Coord x, y, z;
@ -130,27 +117,6 @@ struct _Clouseau_Object
Clouseau_Extra_Props extra_props;
};
struct _Clouseau_Bitmap
{
unsigned char *bmp;
int bmp_count; /* is (w * h), for EET_DATA_DESCRIPTOR_ADD_BASIC_VAR_ARRAY */
Evas_Coord w;
Evas_Coord h;
};
struct _Clouseau_Tree_Item
{
Eina_List *children;
Eina_List *eo_info; /* A list of Eo_Dbg_Info, to be shown */
Eo_Dbg_Info *new_eo_info;
const char *name;
unsigned long long ptr; /* Just a ptr, we keep the value but not accessing mem */
Clouseau_Object *info;
Eina_Bool is_obj;
Eina_Bool is_clipper;
Eina_Bool is_visible;
};
void clouseau_object_desc_shutdown(void);
/* Public */