enable private ug load
authorHyungdeuk Kim <hd3.kim@samsung.com>
Wed, 26 Dec 2012 07:55:56 +0000 (16:55 +0900)
committerHyungdeuk Kim <hd3.kim@samsung.com>
Wed, 26 Dec 2012 07:55:56 +0000 (16:55 +0900)
CMakeLists.txt
client/ug-client.c
packaging/ui-gadget-1.spec
src/engine.c
src/manager.c
src/module.c
src/ug.c

index 2992d7063971198ced5221bba37847842044c4cb..a47b5059d136f0d8eeb1e472c69dd9034fd81a55 100755 (executable)
@@ -28,7 +28,7 @@ SET(SRCS src/ug.c
 
 ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
 
-PKG_CHECK_MODULES(PKGS REQUIRED glib-2.0 utilX bundle dlog x11 capi-appfw-application appsvc)
+PKG_CHECK_MODULES(PKGS REQUIRED glib-2.0 utilX bundle dlog x11 capi-appfw-application appsvc capi-appfw-app-manager)
 FOREACH(flag ${PKGS_CFLAGS})
        SET(CFLAGS "${CFLAGS} ${flag}")
 ENDFOREACH(flag)
index b8e025b87e2865041388650b8d5f4976916634b1..1b555f591d194f4c63a3c5f111512624c0adab1a 100755 (executable)
@@ -105,7 +105,7 @@ static int rotate(enum appcore_rm m, void *data)
        return 0;
 }
 
-void layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv)
+void _ug_client_layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv)
 {
        struct appdata *ad;
        Evas_Object *base;
@@ -135,7 +135,7 @@ void layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv)
        }
 }
 
-void result_cb(ui_gadget_h ug, service_h result, void *priv)
+void _ug_client_result_cb(ui_gadget_h ug, service_h result, void *priv)
 {
        struct appdata *ad;
        int ret;
@@ -149,7 +149,7 @@ void result_cb(ui_gadget_h ug, service_h result, void *priv)
                LOGE("service_reply_to_launch_request failed, %d", ret);
 }
 
-void destroy_cb(ui_gadget_h ug, void *priv)
+void _ug_client_destroy_cb(ui_gadget_h ug, void *priv)
 {
        if (!ug)
                return;
@@ -187,7 +187,7 @@ static Evas_Object *create_win(const char *name)
        return eo;
 }
 
-static Evas_Object *load_edj(Evas_Object *parent, const char *file,
+static Evas_Object *_ug_client_load_edj(Evas_Object *parent, const char *file,
                             const char *group)
 {
        Evas_Object *eo;
@@ -247,7 +247,7 @@ static int app_create(void *data)
        ad->conform = conform;
 
        /* load edje */
-       ly = load_edj(conform, EDJ_FILE, GRP_MAIN);
+       ly = _ug_client_load_edj(conform, EDJ_FILE, GRP_MAIN);
        if (ly == NULL)
                return -1;
        elm_win_resize_object_add(win, conform);
@@ -276,11 +276,16 @@ static int app_terminate(void *data)
        struct appdata *ad = data;
 
        ug_destroy_all();
-       if (ad->ly_main)
+
+       if (ad->ly_main) {
                evas_object_del(ad->ly_main);
+               ad->ly_main = NULL;
+       }
 
-       if (ad->win)
+       if (ad->win) {
                evas_object_del(ad->win);
+               ad->win = NULL;
+       }
 
        return 0;
 }
@@ -291,7 +296,7 @@ static int app_pause(void *data)
 
        ug_pause();
        if (!ad->is_transient) {
-               LOGD("app_pause received. close ug service\n");
+               LOGD("app_pause received. close ug service");
                elm_exit();
        }
        return 0;
@@ -305,7 +310,7 @@ static int app_resume(void *data)
 
 static int svc_cb(void *data)
 {
-       LOGD("svc_cb called\n");
+       LOGD("svc_cb called");
        return 0;
 }
 
@@ -320,7 +325,7 @@ static int app_reset(bundle *b, void *data)
 
        ret = appsvc_request_transient_app(b, id2, svc_cb, "svc test");
        if (ret)
-               LOGD("fail to request transient app: return value(%d)\n", ret);
+               LOGD("fail to request transient app: return value(%d)", ret);
        else
                ad->is_transient = 1;
 
@@ -334,16 +339,19 @@ static int app_reset(bundle *b, void *data)
        else
                service_create_event(b, &service);
 
-       service_clone(&ad->request, service);
+       if(service) {
+               service_clone(&ad->request, service);
+               service_destroy(service);
+       }
 
-       cbs.layout_cb = layout_cb;
-       cbs.destroy_cb = destroy_cb;
-       cbs.result_cb = result_cb;
+       cbs.layout_cb = _ug_client_layout_cb;
+       cbs.destroy_cb = _ug_client_destroy_cb;
+       cbs.result_cb = _ug_client_result_cb;
        cbs.priv = ad;
 
        mode = ad->is_frameview ? UG_MODE_FRAMEVIEW : UG_MODE_FULLVIEW;
 
-       ad->ug = ug_create(NULL, ad->name, mode, service, &cbs);
+       ad->ug = ug_create(NULL, ad->name, mode, ad->request, &cbs);
        if (ad->ug == NULL) {
                LOGE("ug_create fail: %s", ad->name);
                elm_exit();
index 584059a04e137a4d266f3284ebf877dc0b367709..811ef74007394da92204b97fa093fe9534488d03 100755 (executable)
@@ -1,7 +1,7 @@
 
 Name:       ui-gadget-1
 Summary:    UI Gadget Library
-Version:    0.1.6
+Version:    0.1.8
 Release:    1
 Group:      System/Libraries
 License:    Apache License, Version 2.0
@@ -17,6 +17,7 @@ BuildRequires:  pkgconfig(x11)
 BuildRequires:  pkgconfig(appsvc)
 BuildRequires:  pkgconfig(capi-appfw-application)
 BuildRequires:  pkgconfig(capi-system-runtime-info)
+BuildRequires:  pkgconfig(capi-appfw-app-manager)
 BuildRequires:  cmake
 BuildRequires:  edje-bin
 
index ff1f3fb13a58807272af8b4c7e42b13a1dc3952d..3dcdb11fb9f32075cb61bf6ea47e19fc40d72331 100755 (executable)
@@ -123,5 +123,6 @@ int ug_engine_unload(struct ug_engine *engine)
        }
 
        free(engine);
+       engine = NULL;
        return 0;
 }
index 76f7d3f34dd4dc08a3bffdf2a3f4cb4c7a669fe0..1242463163e120c5b241646e98dd98f1e9ca895c 100755 (executable)
@@ -366,8 +366,10 @@ static int ugman_ug_destroy(void *data)
                }
        }
 
-       if (ops && ops->destroy)
+       if (ops && ops->destroy) {
+               _DBG("ug module destory cb call");
                ops->destroy(ug, ug->service, ops->priv);
+       }
 
        ug_relation_del(ug);
 
@@ -574,6 +576,13 @@ int ugman_ug_del(ui_gadget_h ug)
 
        ugman_ug_destroying(ug);
 
+       /* pre call for indicator update time issue */
+       if (ug_man.fv_top == ug) {
+               ui_gadget_h t;
+               t = g_slist_nth_data(ug_man.fv_list, 1);
+               ugman_ug_getopt(t);
+       }
+
        if (ug_man.engine)
                eng_ops = &ug_man.engine->ops;
 
@@ -697,7 +706,7 @@ int ugman_send_event(enum ug_event event)
        }
 
        if (!ug_man.root) {
-               _ERR("ugman_send_event failed: no root\n");
+               _ERR("ugman_send_event failed: no root");
                return -1;
        }
 
@@ -735,13 +744,13 @@ static int ugman_send_key_event_to_ug(ui_gadget_h ug,
 int ugman_send_key_event(enum ug_key_event event)
 {
        if (!ug_man.is_initted) {
-               _ERR("ugman_send_key_event failed: manager is not initted\n");
+               _ERR("ugman_send_key_event failed: manager is not initted");
                return -1;
        }
 
        if (!ug_man.fv_top || !ugman_ug_exist(ug_man.fv_top)
            || ug_man.fv_top->state == UG_STATE_DESTROYED) {
-               _ERR("ugman_send_key_event failed: full view top UG is invalid\n");
+               _ERR("ugman_send_key_event failed: full view top UG is invalid");
                return -1;
        }
 
@@ -752,13 +761,13 @@ int ugman_send_message(ui_gadget_h ug, service_h msg)
 {
        struct ug_module_ops *ops = NULL;
        if (!ug || !ugman_ug_exist(ug) || ug->state == UG_STATE_DESTROYED) {
-               _ERR("ugman_send_message failed: Invalid ug\n");
+               _ERR("ugman_send_message failed: Invalid ug");
                errno = EINVAL;
                return -1;
        }
 
        if (!msg) {
-               _ERR("ugman_send_message failed: Invalid msg\n");
+               _ERR("ugman_send_message failed: Invalid msg");
                errno = EINVAL;
                return -1;
        }
index 3b75a41f7be0858eb854fe23f574f40f8af2c135..da518d377e76368a78dbd1d5f08c33bf3ffee865 100644 (file)
@@ -28,6 +28,8 @@
 #include <unistd.h>
 #include <sys/types.h>
 
+#include <app_manager.h>
+
 #include "ug-module.h"
 #include "ug-dbg.h"
 
@@ -50,8 +52,7 @@ struct ug_module *ug_module_load(const char *name)
        void *handle;
        struct ug_module *module;
        char ug_file[PATH_MAX];
-
-       uid_t uid;
+       char *pkg_name = NULL;
 
        int (*module_init) (struct ug_module_ops *ops);
 
@@ -62,14 +63,9 @@ struct ug_module *ug_module_load(const char *name)
                return NULL;
        }
 
-#if 0
-       char *pkg_name = NULL;
-       pkg_name = getenv("PKG_NAME");
-       uid = geteuid();
-#endif
+       app_manager_get_package(getpid(), &pkg_name);
 
        do {
-#if 0
                if (pkg_name) {
                        snprintf(ug_file, PATH_MAX, "/usr/apps/%s/lib/libug-%s.so", pkg_name, name);
                        if (file_exist(ug_file))
@@ -78,7 +74,6 @@ struct ug_module *ug_module_load(const char *name)
                        if (file_exist(ug_file))
                                break;
                }
-#endif
                snprintf(ug_file, PATH_MAX, "/usr/ug/lib/libug-%s.so", name);
                if (file_exist(ug_file))
                        break;
@@ -87,15 +82,20 @@ struct ug_module *ug_module_load(const char *name)
                        break;
        } while (0);
 
+       if(pkg_name) {
+               free(pkg_name);
+               pkg_name = NULL;
+       }
+
        handle = dlopen(ug_file, RTLD_LAZY);
        if (!handle) {
-               _ERR("dlopen failed: %s\n", dlerror());
+               _ERR("dlopen failed: %s", dlerror());
                goto module_free;
        }
 
        module_init = dlsym(handle, UG_MODULE_INIT_SYM);
        if (!module_init) {
-               _ERR("dlsym failed: %s\n", dlerror());
+               _ERR("dlsym failed: %s", dlerror());
                goto module_dlclose;
        }
 
@@ -127,9 +127,10 @@ int ug_module_unload(struct ug_module *module)
                if (module_exit)
                        module_exit(&module->ops);
                else
-                       _ERR("dlsym failed: %s\n", dlerror());
+                       _ERR("dlsym failed: %s", dlerror());
 
                dlclose(module->handle);
+               module->handle = NULL;
        }
 
        free(module);
index 68c53744dff9d2d11fbaccbeb3ce82e3871fa894..1796a1523f88daeb0fd0d882e5f6c0c3d44c1420 100755 (executable)
--- a/src/ug.c
+++ b/src/ug.c
@@ -39,7 +39,7 @@ ui_gadget_h ug_root_create(void)
 
        ug = calloc(1, sizeof(struct ui_gadget_s));
        if (!ug) {
-               _ERR("ug root create failed: Memory allocation failed\n");
+               _ERR("ug root create failed: Memory allocation failed");
                return NULL;
        }
 
@@ -53,17 +53,22 @@ ui_gadget_h ug_root_create(void)
 int ug_free(ui_gadget_h ug)
 {
        if (!ug) {
-               _ERR("ug free failed: Invalid ug\n");
+               _ERR("ug free failed: Invalid ug");
                errno = EINVAL;
                return -1;
        }
 
-       if (ug->module)
+       if (ug->module) {
                ug_module_unload(ug->module);
-       if (ug->name)
+       }
+       if (ug->name) {
                free((void *)ug->name);
-       if (ug->service)
+               ug->name = NULL;
+       }
+       if (ug->service) {
                service_destroy(ug->service);
+               ug->service = NULL;
+       }
        free(ug);
        ug = NULL;
        return 0;
@@ -75,13 +80,13 @@ UG_API ui_gadget_h ug_create(ui_gadget_h parent,
                                   service_h service, struct ug_cbs *cbs)
 {
        if (!name) {
-               _ERR("ug_create() failed: Invalid name\n");
+               _ERR("ug_create() failed: Invalid name");
                errno = EINVAL;
                return NULL;
        }
 
        if (mode < UG_MODE_FULLVIEW || mode >= UG_MODE_INVALID) {
-               _ERR("ug_create() failed: Invalid mode\n");
+               _ERR("ug_create() failed: Invalid mode");
                errno = EINVAL;
                return NULL;
        }
@@ -92,12 +97,12 @@ UG_API ui_gadget_h ug_create(ui_gadget_h parent,
 UG_API int ug_init(Display *disp, Window xid, void *win, enum ug_option opt)
 {
        if (!win || !xid || !disp) {
-               _ERR("ug_init() failed: Invalid arguments\n");
+               _ERR("ug_init() failed: Invalid arguments");
                return -1;
        }
 
        if (opt < UG_OPT_INDICATOR_ENABLE || opt >= UG_OPT_MAX) {
-               _ERR("ug_init() failed: Invalid option\n");
+               _ERR("ug_init() failed: Invalid option");
                return -1;
        }
 
@@ -127,7 +132,7 @@ UG_API int ug_destroy_all(void)
 UG_API int ug_destroy_me(ui_gadget_h ug)
 {
        if (!ug || !ugman_ug_exist(ug)) {
-               _ERR("ug_destroy_me() failed: Invalid ug\n");
+               _ERR("ug_destroy_me() failed: Invalid ug");
                errno = EINVAL;
                return -1;
        }
@@ -139,7 +144,7 @@ UG_API int ug_destroy_me(ui_gadget_h ug)
 
        if (!ug->cbs.destroy_cb) {
                _ERR("ug_destroy_me() failed: destroy callback does not "
-                       "exist\n");
+                       "exist");
                return -1;
        }
 
@@ -150,7 +155,7 @@ UG_API int ug_destroy_me(ui_gadget_h ug)
 UG_API void *ug_get_layout(ui_gadget_h ug)
 {
        if (!ug || !ugman_ug_exist(ug)) {
-               _ERR("ug_get_layout() failed: Invalid ug\n");
+               _ERR("ug_get_layout() failed: Invalid ug");
                errno = EINVAL;
                return NULL;
        }
@@ -161,7 +166,7 @@ UG_API void *ug_get_parent_layout(ui_gadget_h ug)
 {
        ui_gadget_h parent;
        if (!ug || !ugman_ug_exist(ug)) {
-               _ERR("ug_get_parent_layout() failed: Invalid ug\n");
+               _ERR("ug_get_parent_layout() failed: Invalid ug");
                errno = EINVAL;
                return NULL;
        }
@@ -176,7 +181,7 @@ UG_API void *ug_get_parent_layout(ui_gadget_h ug)
 UG_API enum ug_mode ug_get_mode(ui_gadget_h ug)
 {
        if (!ug || !ugman_ug_exist(ug)) {
-               _ERR("ug_get_mode() failed: Invalid ug\n");
+               _ERR("ug_get_mode() failed: Invalid ug");
                errno = EINVAL;
                return UG_MODE_INVALID;
        }
@@ -192,7 +197,7 @@ UG_API void *ug_get_window(void)
 UG_API int ug_send_event(enum ug_event event)
 {
        if (event <= UG_EVENT_NONE || event >= UG_EVENT_MAX) {
-               _ERR("ug_send_event() failed: Invalid event\n");
+               _ERR("ug_send_event() failed: Invalid event");
                return -1;
        }
 
@@ -202,7 +207,7 @@ UG_API int ug_send_event(enum ug_event event)
 UG_API int ug_send_key_event(enum ug_key_event event)
 {
        if (event <= UG_KEY_EVENT_NONE || event >= UG_KEY_EVENT_MAX) {
-               _ERR("ug_send_key_event() failed: Invalid event\n");
+               _ERR("ug_send_key_event() failed: Invalid event");
                return -1;
        }
 
@@ -214,20 +219,20 @@ UG_API int ug_send_result(ui_gadget_h ug, service_h result)
        service_h result_dup = NULL;
 
        if (!ug || !ugman_ug_exist(ug)) {
-               _ERR("ug_send_result() failed: Invalid ug\n");
+               _ERR("ug_send_result() failed: Invalid ug");
                errno = EINVAL;
                return -1;
        }
 
        if (!ug->cbs.result_cb) {
-               _ERR("ug_send_result() failed: result callback does not exist\n");
+               _ERR("ug_send_result() failed: result callback does not exist");
                return -1;
        }
 
        if (result) {
                service_clone(&result_dup, result);
                if (!result_dup) {
-                       _ERR("ug_send_result() failed: service_destroy failed\n");
+                       _ERR("ug_send_result() failed: service_destroy failed");
                        return -1;
                }
        }
@@ -248,7 +253,7 @@ UG_API int ug_send_message(ui_gadget_h ug, service_h msg)
        if (msg) {
                service_clone(&msg_dup, msg);
                if (!msg_dup) {
-                       _ERR("ug_send_message() failed: service_destroy failed\n");
+                       _ERR("ug_send_message() failed: service_destroy failed");
                        return -1;
                }
        }
@@ -264,7 +269,7 @@ UG_API int ug_send_message(ui_gadget_h ug, service_h msg)
 UG_API int ug_disable_effect(ui_gadget_h ug)
 {
        if (ug->layout_state != UG_LAYOUT_INIT) {
-               _ERR("ug_disable_effect() failed: ug has already been shown\n");
+               _ERR("ug_disable_effect() failed: ug has already been shown");
                return -1;
        }
        ug->layout_state = UG_LAYOUT_NOEFFECT;