Unload SO only if it is uninstalled or upgraded
authorSung-jae Park <nicesj.park@samsung.com>
Thu, 14 Aug 2014 01:44:20 +0000 (10:44 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Thu, 14 Aug 2014 01:44:20 +0000 (10:44 +0900)
Change-Id: I4cd3d6b41b23e688c014ff1c47d42af782cd7994

include/lb.h
include/so_handler.h
packaging/com.samsung.data-provider-slave.spec
src/client.c
src/lb.c
src/so_handler.c

index a72ea74..55b9c2f 100644 (file)
@@ -18,7 +18,7 @@ extern void lb_init(void);
 extern void lb_fini(void);
 
 extern int lb_create(const char *pkgname, const char *id, const char *content_info, int timeout, int has_livebox_script, double period, const char *cluster, const char *category, int *w, int *h, double *priority, int skip_need_to_create, const char *abi, char **out_content, char **out_title);
-extern int lb_destroy(const char *pkgname, const char *id);
+extern int lb_destroy(const char *pkgname, const char *id, int type);
 
 extern int lb_resize(const char *pkgname, const char *id, int w, int h);
 extern int lb_clicked(const char *pkgname, const char *id, const char *event, double timestamp, double x, double y);
index 2281712..1817c7a 100644 (file)
@@ -143,7 +143,7 @@ extern int so_create(const char *pkgname, const char *filename, const char *cont
 extern int so_is_updated(struct instance *inst);
 extern int so_need_to_destroy(struct instance *inst);
 extern int so_update(struct instance *inst);
-extern int so_destroy(struct instance *inst);
+extern int so_destroy(struct instance *inst, int unload);
 extern int so_clicked(struct instance *inst, const char *event, double timestamp, double x, double y);
 extern int so_script_event(struct instance *inst, const char *emission, const char *source, struct event_info *event_info);
 extern int so_resize(struct instance *inst, int w, int h);
index d9c946c..7c950c8 100644 (file)
@@ -3,7 +3,7 @@
 
 Name: com.samsung.data-provider-slave
 Summary: Plugin type livebox service provider
-Version: 0.17.4
+Version: 0.17.5
 Release: 1
 Group: HomeTF/Livebox
 License: Flora
index a6859b8..76ae1a6 100644 (file)
@@ -182,7 +182,7 @@ static int method_delete(struct event_arg *arg, void *data)
                (void)lb_system_event(arg->pkgname, arg->id, LB_SYS_EVENT_DELETED);
        }
 
-       ret = lb_destroy(arg->pkgname, arg->id);
+       ret = lb_destroy(arg->pkgname, arg->id, 0);
        return ret;
 }
 
index fbe2694..5564165 100644 (file)
--- a/src/lb.c
+++ b/src/lb.c
@@ -74,6 +74,7 @@ struct item {
        int is_lb_show;
        int is_pd_show;
        int is_lb_updated;
+       int unload_so;
 };
 
 static struct info {
@@ -316,7 +317,7 @@ static inline void do_force_update(struct item *item)
        if (ret <= 0) {
                if (so_need_to_destroy(item->inst) == NEED_TO_DESTROY) {
                        provider_send_deleted(item->inst->item->pkgname, item->inst->id);
-                       lb_destroy(item->inst->item->pkgname, item->inst->id);
+                       lb_destroy(item->inst->item->pkgname, item->inst->id, INSTANCE_DESTROY_DEFAULT);
                        /*!
                         * \CRITICAL
                         * Every caller of this, must not access the item from now.
@@ -918,7 +919,7 @@ static inline int output_handler(struct item *item)
                if (item->deleteme) {
                        update_monitor_del(item->inst->id, item);
                        provider_send_deleted(item->inst->item->pkgname, item->inst->id);
-                       (void)so_destroy(item->inst);
+                       (void)so_destroy(item->inst, item->unload_so);
                        free(item);
                        return EXIT_FAILURE;
                }
@@ -1059,7 +1060,7 @@ static Eina_Bool updator_cb(void *data)
        if (ret <= 0) {
                if (so_need_to_destroy(item->inst) == NEED_TO_DESTROY) {
                        provider_send_deleted(item->inst->item->pkgname, item->inst->id);
-                       lb_destroy(item->inst->item->pkgname, item->inst->id);
+                       lb_destroy(item->inst->item->pkgname, item->inst->id, INSTANCE_DESTROY_DEFAULT);
                        /*!
                         * \CRITICAL
                         * Every caller of this, must not access the item from now.
@@ -1519,7 +1520,7 @@ HAPI int lb_create(const char *pkgname, const char *id, const char *content_info
                if (!item->timer) {
                        ErrPrint("Failed to add timer (%s - %s, content[%s], cluster[%s], category[%s], abi[%s]\n", pkgname, id, content_info, cluster, category, abi);
                        update_monitor_del(id, item);
-                       (void)so_destroy(inst);
+                       (void)so_destroy(inst, item->unload_so);
                        free(item);
                        return LB_STATUS_ERROR_FAULT;
                }
@@ -1586,7 +1587,7 @@ HAPI int lb_create(const char *pkgname, const char *id, const char *content_info
        return need_to_create;
 }
 
-HAPI int lb_destroy(const char *pkgname, const char *id)
+HAPI int lb_destroy(const char *pkgname, const char *id, int type)
 {
        Eina_List *l;
        Eina_List *n;
@@ -1639,12 +1640,17 @@ HAPI int lb_destroy(const char *pkgname, const char *id)
                item->timer = NULL;
        }
 
+       /*
+        * To keep the previous status, we should or'ing the value.
+        */
+       item->unload_so = (item->unload_so || (type == INSTANCE_DESTROY_UNINSTALL));
+
        if (item->monitor) {
                item->deleteme = 1;
        } else {
                update_monitor_del(id, item);
                free(item);
-               (void)so_destroy(inst);
+               (void)so_destroy(inst, item->unload_so);
        }
 
        return LB_STATUS_SUCCESS;
@@ -2146,7 +2152,7 @@ HAPI int lb_delete_all_deleteme(void)
                }
 
                update_monitor_del(item->inst->id, item);
-               (void)so_destroy(item->inst);
+               (void)so_destroy(item->inst, item->unload_so);
                free(item);
                cnt++;
        }
@@ -2164,7 +2170,7 @@ HAPI int lb_delete_all(void)
 
        EINA_LIST_FOREACH_SAFE(s_info.item_list, l, n, item) {
                update_monitor_del(item->inst->id, item);
-               (void)so_destroy(item->inst);
+               (void)so_destroy(item->inst, item->unload_so);
                free(item);
                cnt++;
        }
index 5317abb..aadb3a8 100644 (file)
@@ -611,7 +611,7 @@ HAPI int so_create(const char *pkgname, const char *id, const char *content_info
        return ret;
 }
 
-HAPI int so_destroy(struct instance *inst)
+HAPI int so_destroy(struct instance *inst, int unload)
 {
        struct so_item *item;
        int ret;
@@ -638,11 +638,9 @@ HAPI int so_destroy(struct instance *inst)
        item->inst_list = eina_list_remove(item->inst_list, inst);
        delete_instance(inst);
 
-#if 0
-       if (!item->inst_list) {
+       if (unload && !item->inst_list) {
                delete_livebox(item);
        }
-#endif
 
        return ret;
 }