summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSemun Lee <sm79.lee@samsung.com>2014-02-25 20:06:26 +0900
committerSemun Lee <sm79.lee@samsung.com>2014-02-25 20:06:26 +0900
commit92210284ef62357b7a08fbd973d291ee1afe04ec (patch)
treee219cc5a2c18ba8914b427df1f0660cfc264f36e /src
parentf0e0a08562a88cac22640384e1f8cadbec9f4ce1 (diff)
parentc7bb89ae628988e1555a950c8b478c9de85ef2c6 (diff)
downloadui-gadget-1-92210284ef62357b7a08fbd973d291ee1afe04ec.tar.gz
ui-gadget-1-92210284ef62357b7a08fbd973d291ee1afe04ec.tar.bz2
ui-gadget-1-92210284ef62357b7a08fbd973d291ee1afe04ec.zip
Merge branches 'HEAD' and 'tizen_2.2' into tizen
Conflicts: CMakeLists.txt client/CMakeLists.txt client/ug-client.c include/ui-gadget.h packaging/ui-gadget-1.spec src/manager.c ui-gadget-1.manifest
Diffstat (limited to 'src')
-rw-r--r--src/manager.c262
-rw-r--r--src/module.c73
2 files changed, 254 insertions, 81 deletions
diff --git a/src/manager.c b/src/manager.c
index c96d5b2..015e1eb 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -38,6 +38,11 @@
#include "ug-engine.h"
#include "ug-dbg.h"
+#define Idle_Cb Ecore_Cb
+
+#define ugman_idler_add(func, data) \
+ ecore_job_add((Ecore_Cb) func, (void *)data);
+
struct ug_manager {
ui_gadget_h root;
ui_gadget_h fv_top;
@@ -85,12 +90,19 @@ static int ug_relation_del(ui_gadget_h ug)
p = ug->parent;
if (!p) {
- _ERR("ug_relation_del failed: no parent");
+ _WRN("ug_relation_del failed: no parent");
return -1;
}
- p->children = g_slist_remove(p->children, ug);
- if (ug->children)
+
+ if(p->children) {
+ p->children = g_slist_remove(p->children, ug);
+ }
+
+ if (ug->children) {
g_slist_free(ug->children);
+ ug->children = NULL;
+ }
+
ug->parent = NULL;
return 0;
@@ -242,10 +254,11 @@ static void ugman_tree_dump(ui_gadget_h ug)
while (child) {
c = child->data;
- _DBG("[%d] %s [%c] (%p) (PARENT: %s)",
+ _DBG("[%d] %s [%c] (mem : %s) (ug : %p) (PARENT: %s)",
lv,
c && c->name ? c->name : "NO CHILD INFO FIXIT!!!",
- c && c->mode == UG_MODE_FULLVIEW ? 'F' : 'f', c, name);
+ c && c->mode == UG_MODE_FULLVIEW ? 'F' : 'f',
+ c->module->addr, c, name);
ugman_tree_dump(c);
child = g_slist_next(child);
}
@@ -279,7 +292,7 @@ static void ugman_ug_start(void *data)
_ERR("ug is null");
return;
} else if (ug->state != UG_STATE_CREATED) {
- _ERR("ug(%p) state(%d) is error", ug, ug->state);
+ _DBG("start cb will be not invoked because ug(%p) state(%d) is not created", ug, ug->state);
return;
}
@@ -339,6 +352,8 @@ static int ugman_ug_resume(void *data)
if (!ug)
goto end;
+ _DBG("ug(%p)->state : %d", ug, ug->state);
+
switch (ug->state) {
case UG_STATE_CREATED:
ugman_ug_start(ug);
@@ -401,36 +416,40 @@ static int ugman_indicator_update(enum ug_option opt, enum ug_event event)
_DBG("indicator update opt(%d) cur_state(%d)", opt, cur_state);
+#ifndef ENABLE_UG_HANDLE_INDICATOR_HIDE
+ enable = 1;
+#else
switch (GET_OPT_INDICATOR_VAL(opt)) {
- case UG_OPT_INDICATOR_ENABLE:
- if (event == UG_EVENT_NONE)
- enable = 1;
- else
- enable = cur_state ? 1 : 0;
- break;
- case UG_OPT_INDICATOR_PORTRAIT_ONLY:
- enable = ug_man.is_landscape ? 0 : 1;
- break;
- case UG_OPT_INDICATOR_LANDSCAPE_ONLY:
- enable = ug_man.is_landscape ? 1 : 0;
- break;
- case UG_OPT_INDICATOR_DISABLE:
- enable = 0;
- break;
- case UG_OPT_INDICATOR_MANUAL:
- return 0;
- default:
- _ERR("update failed: Invalid opt(%d)", opt);
- return -1;
+ case UG_OPT_INDICATOR_ENABLE:
+ if (event == UG_EVENT_NONE)
+ enable = 1;
+ else
+ enable = cur_state ? 1 : 0;
+ break;
+ case UG_OPT_INDICATOR_PORTRAIT_ONLY:
+ enable = ug_man.is_landscape ? 0 : 1;
+ break;
+ case UG_OPT_INDICATOR_LANDSCAPE_ONLY:
+ enable = ug_man.is_landscape ? 1 : 0;
+ break;
+ case UG_OPT_INDICATOR_DISABLE:
+ enable = 0;
+ break;
+ case UG_OPT_INDICATOR_MANUAL:
+ return 0;
+ default:
+ _ERR("update failed: Invalid opt(%d)", opt);
+ return -1;
}
+#endif
if(cur_state != enable) {
_DBG("set indicator as %d", enable);
-
#ifndef WAYLAND
utilx_enable_indicator(ug_man.disp, ug_man.win_id, enable);
#endif
}
+
return 0;
}
@@ -479,38 +498,31 @@ static int ugman_ug_destroy(void *data)
{
ui_gadget_h ug = data;
struct ug_module_ops *ops = NULL;
- GSList *child, *trail;
+ struct ug_cbs *cbs;
job_start();
if (!ug)
goto end;
- _DBG("ugman_ug_destroy ug(%p) state(%d)", ug, ug->state);
+ _DBG("ug(%p) state(%d)", ug, ug->state);
switch (ug->state) {
- case UG_STATE_CREATED:
- case UG_STATE_RUNNING:
- case UG_STATE_STOPPED:
- case UG_STATE_DESTROYING:
- break;
- default:
- goto end;
+ case UG_STATE_CREATED:
+ case UG_STATE_RUNNING:
+ case UG_STATE_STOPPED:
+ case UG_STATE_DESTROYING:
+ case UG_STATE_PENDING_DESTROY:
+ break;
+ default:
+ _WRN("ug(%p) state is already destroyed", ug);
+ goto end;
}
ug->state = UG_STATE_DESTROYED;
- if (ug->children) {
- child = ug->children;
- _DBG("ug_destroy ug(%p) has child(%p)", ug, child->data);
- while (child) {
- trail = g_slist_next(child);
- ugman_ug_destroy(child->data);
- child = trail;
- }
- }
-
if((ug != ug_man.root) && (ug->layout) &&
+ (ug->mode == UG_MODE_FULLVIEW) &&
(ug->layout_state != UG_LAYOUT_DESTROY)) {
/* ug_destroy_all case */
struct ug_engine_ops *eng_ops = NULL;
@@ -530,13 +542,29 @@ static int ugman_ug_destroy(void *data)
ops->destroy(ug, ug->service, ops->priv);
}
+ cbs = &ug->cbs;
+ if (cbs && cbs->end_cb) {
+ _DBG("ug(%p) end cb will be invoked", ug);
+ cbs->end_cb(ug, cbs->priv);
+ }
+
+ if((ug->parent) && (ug->parent->state == UG_STATE_PENDING_DESTROY)) {
+ if((ug->parent->children) && (g_slist_length(ug->parent->children) == 1)) {
+ _WRN("pended parent ug(%p) destroy job is added to loop", ug->parent);
+ ugman_idler_add((Idle_Cb)ugman_ug_destroy, ug->parent);
+ } else {
+ _WRN("pended parent ug(%p) will be destroyed after another children is destroyed", ug->parent);
+ }
+ }
+
if (ug != ug_man.root)
ug_relation_del(ug);
if (ug->mode == UG_MODE_FULLVIEW) {
if (ug_man.fv_top == ug) {
ug_fvlist_del(ug);
- ugman_ug_getopt(ug_man.fv_top);
+ if(!ug_man.destroy_all)
+ ugman_ug_getopt(ug_man.fv_top);
} else {
ug_fvlist_del(ug);
}
@@ -558,7 +586,12 @@ static int ugman_ug_destroy(void *data)
static void ug_hide_end_cb(void *data)
{
ui_gadget_h ug = data;
- ecore_idler_add((Ecore_Task_Cb)ugman_ug_destroy, ug);
+ if (ug->children) {
+ _WRN("child ug is still destroying. parent ug(%p) will be destroyed later", ug);
+ ug->state = UG_STATE_PENDING_DESTROY;
+ } else {
+ ugman_idler_add((Idle_Cb)ugman_ug_destroy, (void *)ug);
+ }
}
static int ugman_ug_create(void *data)
@@ -590,8 +623,9 @@ static int ugman_ug_create(void *data)
}
if (ug->mode == UG_MODE_FULLVIEW) {
if (eng_ops && eng_ops->create) {
- //change start cb function call after transition,finished for fullview
ug_man.conform = eng_ops->create(ug_man.win, ug, ugman_ug_start);
+ if(!ug_man.conform)
+ return -1;
}
}
cbs = &ug->cbs;
@@ -642,8 +676,18 @@ int ugman_ug_add(ui_gadget_h parent, ui_gadget_h ug)
ug_fvlist_add(ug_man.root);
}
- if (!parent)
+ if (!parent) {
parent = ug_man.root;
+ } else {
+ switch (parent->state) {
+ case UG_STATE_DESTROYING:
+ case UG_STATE_PENDING_DESTROY:
+ case UG_STATE_DESTROYED:
+ _WRN("parent(%p) state(%d) error", parent, parent->state);
+ return -1;
+ default:;
+ }
+ }
if (ug_relation_add(parent, ug)) {
_ERR("failed : ug_relation_add fail");
@@ -707,7 +751,8 @@ ui_gadget_h ugman_ug_load(ui_gadget_h parent,
int ugman_ug_destroying(ui_gadget_h ug)
{
struct ug_module_ops *ops = NULL;
- GSList *child, *trail;
+
+ _DBG("ugman_ug_destroying");
ug->destroy_me = 1;
ug->state = UG_STATE_DESTROYING;
@@ -715,15 +760,6 @@ int ugman_ug_destroying(ui_gadget_h ug)
if (ug->module)
ops = &ug->module->ops;
- if (ug->children) {
- child = ug->children;
- while (child) {
- trail = g_slist_next(child);
- ugman_ug_destroying(child->data);
- child = trail;
- }
- }
-
if (ops && ops->destroying)
ops->destroying(ug, ug->service, ops->priv);
@@ -743,12 +779,12 @@ int ugman_ug_del(ui_gadget_h ug)
_DBG("ugman_ug_del start ug(%p)", ug);
if (ug->destroy_me) {
- _ERR("ugman_ug_del failed: ug is alreay on destroying");
+ _WRN("ugman_ug_del failed: ug is alreay on destroying");
return -1;
}
if (!ug_man.is_initted) {
- _ERR("ugman_ug_del failed: manager is not initted");
+ _WRN("ugman_ug_del failed: manager is not initted");
return -1;
}
@@ -757,6 +793,18 @@ int ugman_ug_del(ui_gadget_h ug)
return -1;
}
+ if (ug->children) {
+ GSList *child, *trail;
+
+ child = ug->children;
+ _DBG("ugman_ug_del ug(%p) has child(%p)", ug, child->data);
+ while (child) {
+ trail = g_slist_next(child);
+ ugman_ug_del(child->data);
+ child = trail;
+ }
+ }
+
ugman_ug_destroying(ug);
/* pre call for indicator update time issue */
@@ -776,6 +824,7 @@ int ugman_ug_del(ui_gadget_h ug)
}
}
}
+
if((is_update)&&(t)) {
ugman_ug_getopt(t);
}
@@ -783,14 +832,37 @@ int ugman_ug_del(ui_gadget_h ug)
if (ug_man.engine)
eng_ops = &ug_man.engine->ops;
- if (eng_ops && eng_ops->destroy)
- if (ug->mode == UG_MODE_FULLVIEW)
+ if (ug->mode == UG_MODE_FULLVIEW) {
+ if (eng_ops && eng_ops->destroy)
eng_ops->destroy(ug, ug_man.fv_top, ug_hide_end_cb);
- else {
- eng_ops->destroy(ug, NULL, ug_hide_end_cb);
+ else
+ ugman_idler_add((Idle_Cb)ugman_ug_destroy, ug);
+ } else {
+ _DBG("ug(%p) mode is frameview", ug);
+ ug_hide_end_cb(ug);
+ }
+
+ _DBG("ugman_ug_del(%p) end", ug);
+
+ return 0;
+}
+
+
+int ugman_ug_del_child(ui_gadget_h ug)
+{
+ GSList *child, *trail;
+
+ if (ug->children) {
+ child = ug->children;
+ _DBG("ug destroy all. ug(%p) has child(%p)", ug, child->data);
+ while (child) {
+ trail = g_slist_next(child);
+ ugman_ug_del_child(child->data);
+ child = trail;
}
- else
- ecore_idler_add((Ecore_Task_Cb)ugman_ug_destroy, ug);
+ }
+
+ ugman_ug_destroy(ug);
return 0;
}
@@ -810,10 +882,11 @@ int ugman_ug_del_all(void)
_DBG("ug_del_all. root(%p) walking(%d) ", ug_man.root, ug_man.walking);
- if (ug_man.walking > 0)
+ if (ug_man.walking > 0) {
ug_man.destroy_all = 1;
- else
- ugman_ug_destroy(ug_man.root);
+ } else {
+ ugman_ug_del_child(ug_man.root);
+ }
return 0;
}
@@ -821,13 +894,17 @@ int ugman_ug_del_all(void)
#ifndef WAYLAND
int ugman_init(Display *disp, Window xid, void *win, enum ug_option opt)
{
- ug_man.is_initted = 1;
ug_man.win = win;
ug_man.disp = disp;
ug_man.win_id = xid;
ug_man.base_opt = opt;
ug_man.last_rotate_evt = UG_EVENT_NONE;
- ug_man.engine = ug_engine_load();
+
+ if (!ug_man.is_initted) {
+ ug_man.engine = ug_engine_load();
+ }
+
+ ug_man.is_initted = 1;
return 0;
}
@@ -848,7 +925,7 @@ int ugman_resume(void)
_DBG("ugman_resume called");
- ecore_idler_add((Ecore_Task_Cb)ugman_ug_resume, ug_man.root);
+ ugman_idler_add((Idle_Cb)ugman_ug_resume, ug_man.root);
return 0;
}
@@ -862,13 +939,13 @@ int ugman_pause(void)
}
if (!ug_man.root) {
- _ERR("ugman_pause failed: no root");
+ _WRN("ugman_pause failed: no root");
return -1;
}
_DBG("ugman_pause called");
- ecore_idler_add((Ecore_Task_Cb)ugman_ug_pause, ug_man.root);
+ ugman_idler_add((Idle_Cb)ugman_ug_pause, ug_man.root);
return 0;
}
@@ -915,7 +992,7 @@ int ugman_send_event(enum ug_event event)
is_rotation = 0;
}
- ecore_idler_add((Ecore_Task_Cb)ugman_send_event_pre, (void *)event);
+ ugman_idler_add((Idle_Cb)ugman_send_event_pre, (void *)event);
if (is_rotation && ug_man.fv_top)
ugman_indicator_update(ug_man.fv_top->opt, event);
@@ -993,9 +1070,30 @@ void *ugman_get_window(void)
void *ugman_get_conformant(void)
{
- return ug_man.conform;
-}
+ struct ug_engine_ops *eng_ops = NULL;
+ void* ret = NULL;
+
+ if(ug_man.conform) {
+ _DBG("return cached conform(%p) info", ug_man.conform);
+ return ug_man.conform;
+ }
+
+ if (ug_man.engine) {
+ eng_ops = &ug_man.engine->ops;
+ } else {
+ _WRN("ui engine is not loaded");
+ return NULL;
+ }
+ if (eng_ops && eng_ops->create) {
+ ret = eng_ops->request(ug_man.win, NULL, UG_UI_REQ_GET_CONFORMANT);
+ ug_man.conform = ret;
+ } else {
+ _WRN("ui engine is not loaded");
+ }
+
+ return ret;
+}
static inline void job_start(void)
{
@@ -1008,8 +1106,10 @@ static inline void job_end(void)
if (!ug_man.walking && ug_man.destroy_all) {
ug_man.destroy_all = 0;
- if (ug_man.root)
- ugman_ug_destroy(ug_man.root);
+ if (ug_man.root) {
+ _DBG("ug_destroy_all pneding job exist. ug_destroy_all begin");
+ ugman_ug_del_all();
+ }
}
if (ug_man.walking < 0)
diff --git a/src/module.c b/src/module.c
index 8307325..e07291e 100644
--- a/src/module.c
+++ b/src/module.c
@@ -38,6 +38,9 @@
#define UG_MODULE_INIT_SYM "UG_MODULE_INIT"
#define UG_MODULE_EXIT_SYM "UG_MODULE_EXIT"
+#define MEM_ADDR_LEN 8
+#define MEM_ADDR_TOT_LEN 17
+
static int file_exist(const char *filename)
{
FILE *file;
@@ -49,6 +52,66 @@ static int file_exist(const char *filename)
return 0;
}
+static char *__ug_module_get_addr(const char *ug_so)
+{
+ FILE *file;
+ int ret;
+ char buf[PATH_MAX] = {0,};
+ char mem[PATH_MAX] = {0,};
+
+ char *token_param = NULL;
+ char *saveptr = NULL;
+ int cnt = 0;
+
+ if(ug_so == NULL)
+ goto func_out;
+
+ snprintf(buf, sizeof(buf), "/proc/%d/maps", getpid());
+
+ file = fopen(buf, "r");
+ if (file == NULL) {
+ _WRN("proc open fail(%d)", errno);
+ goto func_out;
+ }
+
+ memset(buf, 0x00, PATH_MAX);
+
+ while(fgets(buf, PATH_MAX, file) != NULL)
+ {
+ if(strstr(buf, ug_so)) {
+ token_param = strtok_r(buf," ", &saveptr);
+ if((token_param == NULL) || (strlen(token_param) > MEM_ADDR_TOT_LEN)) {
+ _ERR("proc token param(%s) error", token_param);
+ goto close_out;
+ }
+
+ if(cnt > 0) {
+ memcpy((void *)(mem+MEM_ADDR_LEN+1),
+ (const void *)(token_param+MEM_ADDR_LEN+1), MEM_ADDR_LEN);
+ } else {
+ memcpy((void *)mem, (const void *)token_param, strlen(token_param));
+ cnt++;
+ }
+ } else {
+ if(cnt > 0)
+ goto close_out;
+ }
+
+ memset(buf, 0x00, PATH_MAX);
+ saveptr = NULL;
+ }
+
+close_out:
+ fclose(file);
+ file = NULL;
+
+func_out:
+ if(strlen(mem) > 0)
+ return strdup(mem);
+ else
+ return NULL;
+}
+
struct ug_module *ug_module_load(const char *name)
{
void *handle;
@@ -78,6 +141,9 @@ struct ug_module *ug_module_load(const char *name)
snprintf(ug_file, PATH_MAX, "/usr/ug/lib/libug-%s.so", name);
if (file_exist(ug_file))
break;
+ snprintf(ug_file, PATH_MAX, "/opt/ug/lib/libug-%s.so", name);
+ if (file_exist(ug_file))
+ break;
snprintf(ug_file, PATH_MAX, "/opt/usr/ug/lib/libug-%s.so", name);
if (file_exist(ug_file))
break;
@@ -105,6 +171,9 @@ struct ug_module *ug_module_load(const char *name)
module->handle = handle;
module->module_name = strdup(name);
+
+ module->addr = __ug_module_get_addr(ug_file);
+
return module;
module_dlclose:
@@ -131,6 +200,7 @@ int ug_module_unload(struct ug_module *module)
else
_ERR("dlsym failed: %s", dlerror());
+ _DBG("dlclose(%s)", module->module_name);
dlclose(module->handle);
module->handle = NULL;
}
@@ -138,6 +208,9 @@ int ug_module_unload(struct ug_module *module)
if(module->module_name)
free(module->module_name);
+ if(module->addr)
+ free(module->addr);
+
free(module);
return 0;
}