From b83230311348968193e5ee53bf109d524b88b1e5 Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Tue, 26 Jun 2012 13:10:17 +0900 Subject: [PATCH] Heap monitor, implementation Replace liblivebox-slave with libprovider Change-Id: I4130acac6a0e2e4f21aa9812348b53ede52da92f --- CMakeLists.txt | 2 +- debian/control | 2 +- include/util.h | 2 ++ packaging/com.samsung.data-provider-slave.spec | 2 +- src/client.c | 28 +++++++++--------- src/fault.c | 6 ++-- src/livebox.c | 12 ++++---- src/main.c | 2 ++ src/so_handler.c | 3 +- src/util.c | 41 ++++++++++++++++++++++++++ 10 files changed, 72 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f771a90..9cf01b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ pkg_check_modules(pkg REQUIRED bundle ecore-x capi-context-engine - livebox-slave + provider ) SET(PACKAGE "${PROJECT_NAME}") diff --git a/debian/control b/debian/control index a94c83c..527f89f 100755 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: data-provider-slave Section: utils Priority: extra Maintainer: Sung-jae Park , Youngjoo Park -Build-Depends: debhelper (>= 5), libappcore-efl-dev, libail-0-dev, dlog-dev, libaul-1-dev, libslp-setting-dev, libslp-utilx-dev, libx11-dev, libslp-sensor-dev, zlib1g-dev, libecore-dev, libcontext-engine-dev, liblivebox-slave-dev +Build-Depends: debhelper (>= 5), libappcore-efl-dev, libail-0-dev, dlog-dev, libaul-1-dev, libslp-setting-dev, libslp-utilx-dev, libx11-dev, libslp-sensor-dev, zlib1g-dev, libecore-dev, libcontext-engine-dev, libprovider-dev Standards-Version: 0.1.0 Package: com.samsung.data-provider-slave diff --git a/include/util.h b/include/util.h index 2d1aa97..8a1c1f5 100644 --- a/include/util.h +++ b/include/util.h @@ -22,5 +22,7 @@ extern int util_check_ext(const char *icon, const char *ext); extern double util_get_timestamp(void); extern const char *util_basename(const char *name); +extern void util_set_main_esp(void *esp); +extern char *util_get_current_module(void); /* End of a file */ diff --git a/packaging/com.samsung.data-provider-slave.spec b/packaging/com.samsung.data-provider-slave.spec index a63dd84..2076677 100644 --- a/packaging/com.samsung.data-provider-slave.spec +++ b/packaging/com.samsung.data-provider-slave.spec @@ -18,7 +18,7 @@ BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(bundle) BuildRequires: pkgconfig(ecore-x) BuildRequires: pkgconfig(capi-context-engine) -BuildRequires: pkgconfig(livebox-slave) +BuildRequires: pkgconfig(provider) %description Loading livebox and managing their life-cycle to generate contents properly. diff --git a/src/client.c b/src/client.c index 0b5c212..6e929e4 100644 --- a/src/client.c +++ b/src/client.c @@ -8,7 +8,7 @@ #include #include -#include +#include #include "conf.h" #include "debug.h" @@ -24,15 +24,15 @@ static struct info { }; /* -extern int livebox_slave_send_updated(const char *pkgname, const char *id, int x, int y, double priority); -extern int livebox_slave_send_desc_updated(const char *pkgname, const char *id, const char *descfile); -extern int livebox_slave_send_deleted(const char *pkgname, const char *id); - -extern struct livebox_buffer *livebox_slave_acquire_buffer(const char *id, int width, int height, int item_size, int (*handler)(struct livebox_buffer *, enum buffer_event, double, double, double)); -extern int livebox_slave_release_buffer(struct livebox_buffer *info); -extern int livebox_sync_buffer(struct livebox_buffer *info); -extern int livebox_slave_send_ret(const char *pkgname, const char *filename, const char *funcname); -extern int livebox_slave_send_call(const char *pkgname, const char *filename, const char *funcname); +extern int provider_send_updated(const char *pkgname, const char *id, int x, int y, double priority); +extern int provider_send_desc_updated(const char *pkgname, const char *id, const char *descfile); +extern int provider_send_deleted(const char *pkgname, const char *id); + +extern struct livebox_buffer *provider_acquire_buffer(const char *id, int width, int height, int item_size, int (*handler)(struct livebox_buffer *, enum buffer_event, double, double, double)); +extern int provider_release_buffer(struct livebox_buffer *info); +extern int provider_sync_buffer(struct livebox_buffer *info); +extern int providersend_ret(const char *pkgname, const char *filename, const char *funcname); +extern int provider_send_call(const char *pkgname, const char *filename, const char *funcname); */ static int method_new(const struct event_arg *arg, int *width, int *height, double *priority) { @@ -203,7 +203,7 @@ static int method_resume(const struct event_arg *arg) static Eina_Bool send_ping_cb(void *data) { - livebox_slave_send_ping(); + provider_send_ping(); return ECORE_CALLBACK_RENEW; } @@ -216,7 +216,7 @@ static int method_disconnected(const struct event_arg *arg) static int method_connected(const struct event_arg *arg) { int ret; - ret = livebox_slave_send_hello(); + ret = provider_send_hello(); if (ret == 0) { s_info.ping_timer = ecore_timer_add(g_conf.ping_time, send_ping_cb, NULL); if (!s_info.ping_timer) @@ -246,13 +246,13 @@ int client_init(const char *name) .connected = method_connected, }; - livebox_slave_init(name, &table); + provider_init(name, &table); return 0; } int client_fini(void) { - livebox_slave_fini(); + provider_fini(); return 0; } diff --git a/src/fault.c b/src/fault.c index dbec1b9..4ea95ae 100644 --- a/src/fault.c +++ b/src/fault.c @@ -13,7 +13,7 @@ #include -#include +#include #include "main.h" #include "debug.h" @@ -157,7 +157,7 @@ int fault_fini(void) int fault_mark_call(const char *pkgname, const char *filename, const char *funcname, int noalarm, int life_time) { - livebox_slave_send_call(pkgname, filename, funcname); + provider_send_call(pkgname, filename, funcname); /*! * \NOTE * To use this "alarm", the livebox have to do not use the 'sleep' series functions. @@ -186,7 +186,7 @@ int fault_unmark_call(const char *pkgname, const char *filename, const char *fun s_info.marked = 0; } - livebox_slave_send_ret(pkgname, filename, funcname); + provider_send_ret(pkgname, filename, funcname); return 0; } diff --git a/src/livebox.c b/src/livebox.c index bb35656..1712a43 100644 --- a/src/livebox.c +++ b/src/livebox.c @@ -6,7 +6,7 @@ #include #include -#include +#include #include "debug.h" #include "conf.h" @@ -104,7 +104,7 @@ static inline int output_handler(struct item *item) s_info.update = NULL; if (item->deleteme) { - livebox_slave_send_deleted(item->inst->item->pkgname, item->inst->filename); + provider_send_deleted(item->inst->item->pkgname, item->inst->filename); (void)so_destroy(item->inst); free(item); return EXIT_FAILURE; @@ -123,7 +123,7 @@ static int desc_updated_cb(const char *filename, void *data, int over) item = data; - livebox_slave_send_desc_updated(item->inst->item->pkgname, item->inst->filename, filename); + provider_send_desc_updated(item->inst->item->pkgname, item->inst->filename, filename); return EXIT_SUCCESS; } @@ -145,7 +145,7 @@ static int file_updated_cb(const char *filename, void *data, int over) item->inst->priority = priority; } - livebox_slave_send_updated(item->inst->item->pkgname, item->inst->filename, + provider_send_updated(item->inst->item->pkgname, item->inst->filename, item->inst->w, item->inst->h, item->inst->priority); return output_handler(item); @@ -242,7 +242,7 @@ static Eina_Bool updator_cb(void *data) if (so_is_updated(item->inst) <= 0) { if (so_need_to_destroy(item->inst) == NEED_TO_DESTROY) { - livebox_slave_send_deleted(item->inst->item->pkgname, item->inst->filename); + provider_send_deleted(item->inst->item->pkgname, item->inst->filename); livebox_destroy(item->inst->item->pkgname, item->inst->filename); return ECORE_CALLBACK_CANCEL; } @@ -364,7 +364,7 @@ int livebox_fini(void) struct item *item; EINA_LIST_FOREACH_SAFE(s_info.item_list, l, n, item) { - livebox_slave_send_deleted(item->inst->item->pkgname, item->inst->filename); + provider_send_deleted(item->inst->item->pkgname, item->inst->filename); livebox_destroy(item->inst->item->pkgname, item->inst->filename); } diff --git a/src/main.c b/src/main.c index 5fe2958..676712f 100644 --- a/src/main.c +++ b/src/main.c @@ -122,6 +122,8 @@ int main(int argc, char *argv[]) .reset = app_reset, }; + util_set_main_esp(&ops); + ops.data = NULL; heap_init(); return appcore_efl_main(util_basename(argv[0]), &argc, &argv, &ops); diff --git a/src/so_handler.c b/src/so_handler.c index a087b39..d05867c 100644 --- a/src/so_handler.c +++ b/src/so_handler.c @@ -6,8 +6,7 @@ #include #include - -#include +#include #include "debug.h" #include "so_handler.h" diff --git a/src/util.c b/src/util.c index a656086..9872cae 100644 --- a/src/util.c +++ b/src/util.c @@ -19,10 +19,12 @@ * */ +#define _GNU_SOURCE #include #include #include #include +#include #include #include @@ -31,6 +33,12 @@ #include "conf.h" #include "debug.h" +static struct { + int *main_esp; +} s_info = { + .main_esp = NULL, +}; + int util_check_ext(const char *icon, const char *ext) { int len; @@ -65,4 +73,37 @@ const char *util_basename(const char *name) return length <= 0 ? name : name + length + (name[length] == '/'); } +/*! + * \note + * Just trying to find the nearest module. + * It could be wrong. + */ +char *util_get_current_module(void) +{ + int *stack; + Dl_info dinfo; + const char *ptr; + char *ret; + + ret = NULL; + for (stack = (int *)&stack; stack < s_info.main_esp ; stack++) { + if (!dladdr((void *)*stack, &dinfo)) + continue; + + ptr = util_basename(dinfo.dli_fname); + if (strncmp(ptr, "liblive-", strlen("liblive-"))) + continue; + + ret = strdup(ptr); + break; + } + + return ret; +} + +void util_set_main_esp(void *esp) +{ + s_info.main_esp = esp; +} + /* End of a file */ -- 2.7.4