Update package management code.
authorSung-jae Park <nicesj.park@samsung.com>
Tue, 3 Sep 2013 02:26:39 +0000 (11:26 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Tue, 3 Sep 2013 02:26:39 +0000 (11:26 +0900)
1. Deliever the reason why the instance is deleted when send a delete event to service provider.
2. Fix the bug of package manager event handler
3. Input event thread is updated. Check the slot number.
4. Remove some field of instance ADT which is duplicated with package ADT.

Change-Id: Ica570847d82e7d3eb4c8514938967b554e9ec99b

include/instance.h
include/io.h
include/package.h
packaging/data-provider-master.spec
src/event.c
src/instance.c
src/io.c
src/notification_service.c
src/package.c
src/server.c
src/utility_service.c

index 32856d6..6bbf554 100644 (file)
@@ -136,6 +136,7 @@ struct client_node;
 
 extern struct inst_info *instance_create(struct client_node *client, double timestamp, const char *pkgname, const char *content, const char *cluster, const char *category, double period, int width, int height);
 extern int instance_destroy(struct inst_info *inst, enum instance_destroy_type type);
+extern int instance_reload(struct inst_info *inst, enum instance_destroy_type type);
 
 extern struct inst_info * instance_ref(struct inst_info *inst);
 extern struct inst_info * instance_unref(struct inst_info *inst);
index 7639aae..c3d83b4 100644 (file)
@@ -18,8 +18,8 @@ extern int io_init(void);
 extern int io_fini(void);
 extern int io_load_package_db(struct pkg_info *info);
 extern char *io_livebox_pkgname(const char *pkgname);
-extern int io_update_livebox_package(const char *pkgname, int (*cb)(const char *lb_pkgname, int prime, void *data), void *data);
-extern int io_crawling_liveboxes(int (*cb)(const char *pkgname, int prime, void *data), void *data);
-extern int io_is_exists(const char *pkgname); /* Manifest Package Name */
+extern int io_update_livebox_package(const char *pkgname, int (*cb)(const char *pkgid, const char *lbid, int prime, void *data), void *data);
+extern int io_crawling_liveboxes(int (*cb)(const char *pkgid, const char *lbid, int prime, void *data), void *data);
+extern int io_is_exists(const char *lbid);
 
 /* End of a file */
index 71d911d..df57123 100644 (file)
@@ -43,7 +43,7 @@ struct slave_node;
  * \brief
  * Construction & Destruction
  */
-extern struct pkg_info *package_create(const char *pkgname);
+extern struct pkg_info *package_create(const char *pkgid, const char *lbid);
 extern int package_destroy(struct pkg_info *info);
 extern char *package_lb_pkgname(const char *pkgname);
 extern int package_is_lb_pkgname(const char *pkgname);
index 0d623a5..e363d0b 100644 (file)
@@ -1,6 +1,6 @@
 Name: data-provider-master
 Summary: Master service provider for liveboxes.
-Version: 0.25.8
+Version: 0.25.10
 Release: 1
 Group: HomeTF/Livebox
 License: Flora License
index 592ee7a..37ea6a6 100644 (file)
@@ -156,6 +156,7 @@ static inline int processing_input_event(struct input_event *event)
                        if (s_info.event_data.device < 0) {
                                s_info.event_data.x = -1;
                                s_info.event_data.y = -1;
+                               s_info.event_data.slot = -1;
                        }
                        break;
                /*
@@ -633,6 +634,7 @@ HAPI int event_deactivate(int (*event_cb)(enum event_state state, struct event_d
 
        s_info.event_data.x = -1;
        s_info.event_data.y = -1;
+       s_info.event_data.slot = -1;
        return LB_STATUS_SUCCESS;
 }
 
index 02107be..5ae31aa 100644 (file)
@@ -120,8 +120,6 @@ struct inst_info {
                        struct buffer_info *buffer;
                } canvas;
 
-               const char *auto_launch;
-               int timeout;
                double period;
        } lb;
 
@@ -396,7 +394,7 @@ HAPI int instance_unicast_created_event(struct inst_info *inst, struct client_no
                        inst->pd.width, inst->pd.height,
                        inst->cluster, inst->category,
                        lb_file, pd_file,
-                       inst->lb.auto_launch,
+                       package_auto_launch(inst->info),
                        inst->lb.priority,
                        package_size_list(inst->info),
                        !!inst->client,
@@ -461,7 +459,7 @@ static int instance_broadcast_created_event(struct inst_info *inst)
                        inst->pd.width, inst->pd.height,
                        inst->cluster, inst->category,
                        lb_file, pd_file,
-                       inst->lb.auto_launch,
+                       package_auto_launch(inst->info),
                        inst->lb.priority,
                        package_size_list(inst->info),
                        !!inst->client,
@@ -661,14 +659,6 @@ static inline void destroy_instance(struct inst_info *inst)
                DbgFree(tag_item);
        }
 
-       /*!
-        * \note
-        *
-        * inst->lb.auto_launch
-        *
-        * will be released by the package object
-        * it is readonly value for instances
-        */
        EINA_LIST_FREE(inst->delete_event_list, item) {
                DbgFree(item);
        }
@@ -711,11 +701,9 @@ static inline int fork_package(struct inst_info *inst, const char *pkgname)
        }
 
        snprintf(inst->id, len, SCHEMA_FILE "%s%s_%d_%lf.png", IMAGE_PATH, package_name(info), client_pid(inst->client), inst->timestamp);
-       inst->lb.auto_launch = package_auto_launch(info);
 
        instance_set_pd_size(inst, package_pd_width(info), package_pd_height(info));
 
-       inst->lb.timeout = package_timeout(info);
        inst->lb.period = package_period(info);
 
        inst->info = info;
@@ -869,16 +857,12 @@ static void deactivate_cb(struct slave_node *slave, const struct packet *packet,
                 * The instance_reload will care this.
                 * And it will be called from the slave activate callback.
                 */
-               inst->changing_state = 0;
-               instance_unref(inst);
-               return;
+               goto out;
        }
 
        if (packet_get(packet, "i", &ret) != 1) {
                ErrPrint("Invalid argument\n");
-               inst->changing_state = 0;
-               instance_unref(inst);
-               return;
+               goto out;
        }
 
        if (inst->state == INST_DESTROYED) {
@@ -887,9 +871,7 @@ static void deactivate_cb(struct slave_node *slave, const struct packet *packet,
                 * Already destroyed.
                 * Do nothing at here anymore.
                 */
-               inst->changing_state = 0;
-               instance_unref(inst);
-               return;
+               goto out;
        }
 
        switch (ret) {
@@ -946,6 +928,7 @@ static void deactivate_cb(struct slave_node *slave, const struct packet *packet,
                break;
        }
 
+out:
        inst->changing_state = 0;
        instance_unref(inst);
 }
@@ -1316,6 +1299,49 @@ HAPI int instance_destroy(struct inst_info *inst, enum instance_destroy_type typ
        return slave_rpc_async_request(package_slave(inst->info), package_name(inst->info), packet, deactivate_cb, instance_ref(inst), 0);
 }
 
+HAPI int instance_reload(struct inst_info *inst, enum instance_destroy_type type)
+{
+       struct packet *packet;
+       int ret;
+
+       DbgPrint("Reload instance (%s)\n", instance_id(inst));
+
+       if (!inst) {
+               ErrPrint("Invalid instance handle\n");
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       switch (inst->state) {
+       case INST_REQUEST_TO_ACTIVATE:
+       case INST_REQUEST_TO_REACTIVATE:
+               return LB_STATUS_SUCCESS;
+       case INST_INIT:
+               ret = instance_activate(inst);
+               if (ret < 0) {
+                       ErrPrint("Failed to activate instance: %d (%s)\n", ret, instance_id(inst));
+               }
+               return LB_STATUS_SUCCESS;
+       case INST_DESTROYED:
+       case INST_REQUEST_TO_DESTROY:
+               DbgPrint("Instance is destroying now\n");
+               return LB_STATUS_SUCCESS;
+       default:
+               break;
+       }
+
+       packet = packet_create("delete", "ssi", package_name(inst->info), inst->id, type);
+       if (!packet) {
+               ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
+               return LB_STATUS_ERROR_FAULT;
+       }
+
+       inst->destroy_type = type;
+       inst->requested_state = INST_ACTIVATED;
+       inst->state = INST_REQUEST_TO_DESTROY;
+       inst->changing_state = 1;
+       return slave_rpc_async_request(package_slave(inst->info), package_name(inst->info), packet, deactivate_cb, instance_ref(inst), 0);
+}
+
 /* Client Deactivated Callback */
 static int pd_buffer_close_cb(struct client_node *client, void *inst)
 {
@@ -1454,7 +1480,7 @@ HAPI int instance_reactivate(struct inst_info *inst)
                        package_name(inst->info),
                        inst->id,
                        inst->content,
-                       inst->lb.timeout,
+                       package_timeout(inst->info),
                        !!package_lb_path(inst->info),
                        inst->lb.period,
                        inst->cluster,
@@ -1520,7 +1546,7 @@ HAPI int instance_activate(struct inst_info *inst)
                        package_name(inst->info),
                        inst->id,
                        inst->content,
-                       inst->lb.timeout,
+                       package_timeout(inst->info),
                        !!package_lb_path(inst->info),
                        inst->lb.period,
                        inst->cluster,
@@ -2538,7 +2564,7 @@ HAPI int instance_change_group(struct inst_info *inst, const char *cluster, cons
 
 HAPI const char * const instance_auto_launch(const struct inst_info *inst)
 {
-       return inst->lb.auto_launch;
+       return package_auto_launch(inst->info);
 }
 
 HAPI const int const instance_priority(const struct inst_info *inst)
@@ -2553,7 +2579,7 @@ HAPI const struct client_node *const instance_client(const struct inst_info *ins
 
 HAPI const int const instance_timeout(const struct inst_info *inst)
 {
-       return inst->lb.timeout;
+       return package_timeout(inst->info);
 }
 
 HAPI const double const instance_period(const struct inst_info *inst)
index 456316d..4eea26c 100644 (file)
--- a/src/io.c
+++ b/src/io.c
@@ -578,7 +578,7 @@ static inline int build_group_info(struct pkg_info *info)
        return LB_STATUS_SUCCESS;
 }
 
-HAPI int io_is_exists(const char *pkgname) /* Manifest Package Name */
+HAPI int io_is_exists(const char *lbid)
 {
        sqlite3_stmt *stmt;
        int ret;
@@ -588,13 +588,13 @@ HAPI int io_is_exists(const char *pkgname) /* Manifest Package Name */
                return LB_STATUS_ERROR_IO;
        }
 
-       ret = sqlite3_prepare_v2(s_info.handle, "SELECT COUNT(pkgid) FROM pkgmap WHERE appid = ?", -1, &stmt, NULL);
+       ret = sqlite3_prepare_v2(s_info.handle, "SELECT COUNT(pkgid) FROM pkgmap WHERE pkgid = ?", -1, &stmt, NULL);
        if (ret != SQLITE_OK) {
                ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
                return LB_STATUS_ERROR_IO;
        }
 
-       ret = sqlite3_bind_text(stmt, 1, pkgname, -1, SQLITE_TRANSIENT);
+       ret = sqlite3_bind_text(stmt, 1, lbid, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
                ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = LB_STATUS_ERROR_IO;
@@ -602,7 +602,7 @@ HAPI int io_is_exists(const char *pkgname) /* Manifest Package Name */
        }
 
        if (sqlite3_step(stmt) != SQLITE_ROW) {
-               ErrPrint("%s has no record (%s)\n", pkgname, sqlite3_errmsg(s_info.handle));
+               ErrPrint("%s has no record (%s)\n", lbid, sqlite3_errmsg(s_info.handle));
                ret = LB_STATUS_ERROR_IO;
                goto out;
        }
@@ -665,7 +665,7 @@ out:
        return pkgid;
 }
 
-HAPI int io_crawling_liveboxes(int (*cb)(const char *pkgname, int prime, void *data), void *data)
+HAPI int io_crawling_liveboxes(int (*cb)(const char *pkgid, const char *lbid, int prime, void *data), void *data)
 {
        DIR *dir;
 
@@ -675,10 +675,11 @@ HAPI int io_crawling_liveboxes(int (*cb)(const char *pkgname, int prime, void *d
                int ret;
                sqlite3_stmt *stmt;
 
-               ret = sqlite3_prepare_v2(s_info.handle, "SELECT pkgid, prime FROM pkgmap", -1, &stmt, NULL);
+               ret = sqlite3_prepare_v2(s_info.handle, "SELECT appid, pkgid, prime FROM pkgmap", -1, &stmt, NULL);
                if (ret != SQLITE_OK) {
                        ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
                } else {
+                       const char *lbid;
                        const char *pkgid;
                        int prime;
 
@@ -688,8 +689,14 @@ HAPI int io_crawling_liveboxes(int (*cb)(const char *pkgname, int prime, void *d
                                        continue;
                                }
 
+                               lbid = (const char *)sqlite3_column_text(stmt, 1);
+                               if (!lbid || !strlen(lbid)) {
+                                       continue;
+                               }
+
                                prime = (int)sqlite3_column_int(stmt, 1);
-                               if (cb(pkgid, prime, data) < 0) {
+
+                               if (cb(pkgid, lbid, prime, data) < 0) {
                                        sqlite3_reset(stmt);
                                        sqlite3_finalize(stmt);
                                        return LB_STATUS_ERROR_CANCEL;
@@ -712,7 +719,7 @@ HAPI int io_crawling_liveboxes(int (*cb)(const char *pkgname, int prime, void *d
                                continue;
                        }
 
-                       if (cb(ent->d_name, -1, data) < 0) {
+                       if (cb(ent->d_name, ent->d_name, -2, data) < 0) {
                                if (closedir(dir) < 0) {
                                        ErrPrint("closedir: %s\n", strerror(errno));
                                }
@@ -728,14 +735,14 @@ HAPI int io_crawling_liveboxes(int (*cb)(const char *pkgname, int prime, void *d
        return LB_STATUS_SUCCESS;
 }
 
-HAPI int io_update_livebox_package(const char *pkgname, int (*cb)(const char *lb_pkgname, int prime, void *data), void *data)
+HAPI int io_update_livebox_package(const char *pkgid, int (*cb)(const char *pkgid, const char *lbid, int prime, void *data), void *data)
 {
        sqlite3_stmt *stmt;
-       char *pkgid;
+       char *lbid;
        int prime;
        int ret;
 
-       if (!cb || !pkgname) {
+       if (!cb || !pkgid) {
                return LB_STATUS_ERROR_INVALID;
        }
 
@@ -750,7 +757,7 @@ HAPI int io_update_livebox_package(const char *pkgname, int (*cb)(const char *lb
                return LB_STATUS_ERROR_FAULT;
        }
 
-       ret = sqlite3_bind_text(stmt, 1, pkgname, -1, SQLITE_TRANSIENT);
+       ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
        if (ret != SQLITE_OK) {
                ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = LB_STATUS_ERROR_FAULT;
@@ -759,14 +766,14 @@ HAPI int io_update_livebox_package(const char *pkgname, int (*cb)(const char *lb
 
        ret = 0;
        while (sqlite3_step(stmt) == SQLITE_ROW) {
-               pkgid = (char *)sqlite3_column_text(stmt, 0);
-               if (!pkgid || !strlen(pkgid)) {
+               lbid = (char *)sqlite3_column_text(stmt, 0);
+               if (!lbid || !strlen(lbid)) {
                        continue;
                }
 
                prime = sqlite3_column_int(stmt, 1);
 
-               if (cb(pkgid, prime, data) < 0) {
+               if (cb(pkgid, lbid, prime, data) < 0) {
                        DbgPrint("Callback canceled\n");
                        break;
                }
index 5396475..0149b7f 100755 (executable)
@@ -286,7 +286,7 @@ static void _handler_delete_multiple(struct tcb *tcb, struct packet *packet, voi
                if (ret != NOTIFICATION_ERROR_NONE) {
                        ErrPrint("failed to delete notifications:%d\n", ret);
                        if (list_deleted != NULL) {
-                               free(list_deleted);
+                               DbgFree(list_deleted);
                        }
                        return ;
                }
@@ -324,7 +324,7 @@ static void _handler_delete_multiple(struct tcb *tcb, struct packet *packet, voi
                }
 
                if (list_deleted != NULL) {
-                       free(list_deleted);
+                       DbgFree(list_deleted);
                        list_deleted = NULL;
                }
        } else {
index fccd666..cd21aa8 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <packet.h>
 #include <livebox-errno.h>
+#include <livebox-service.h>
 #include <ail.h>
 
 #include "critical_log.h"
@@ -58,7 +59,8 @@ struct fault_info {
  */
 
 struct pkg_info {
-       char *pkgname;
+       char *pkgid;
+       char *lbid;
 
        struct {
                enum lb_type type;
@@ -285,7 +287,7 @@ static inline void destroy_package(struct pkg_info *info)
                /* This items will be deleted from group_del_livebox */
        }
 
-       group_del_livebox(info->pkgname);
+       group_del_livebox(info->lbid);
        package_clear_fault(info);
 
        s_info.pkg_list = eina_list_remove(s_info.pkg_list, info);
@@ -302,9 +304,10 @@ static inline void destroy_package(struct pkg_info *info)
 
        DbgFree(info->script);
        DbgFree(info->abi);
-       DbgFree(info->pkgname);
+       DbgFree(info->lbid);
        DbgFree(info->lb.libexec);
        DbgFree(info->lb.auto_launch);
+       DbgFree(info->pkgid);
 
        DbgFree(info);
 }
@@ -315,7 +318,7 @@ static inline int load_conf(struct pkg_info *info)
        const char *str;
        const char *group;
 
-       parser = parser_load(info->pkgname);
+       parser = parser_load(info->lbid);
        if (!parser) {
                info->lb.size_list = 0x01; /* Default */
 
@@ -481,15 +484,15 @@ static inline int load_conf(struct pkg_info *info)
        parser_get_pdsize(parser, &info->pd.width, &info->pd.height);
 
        group = parser_group_str(parser);
-       if (group && group_add_livebox(group, info->pkgname) < 0) {
-               ErrPrint("Failed to build cluster tree for %s{%s}\n", info->pkgname, group);
+       if (group && group_add_livebox(group, info->lbid) < 0) {
+               ErrPrint("Failed to build cluster tree for %s{%s}\n", info->lbid, group);
        }
 
        parser_unload(parser);
        return LB_STATUS_SUCCESS;
 }
 
-HAPI struct pkg_info *package_create(const char *pkgname)
+HAPI struct pkg_info *package_create(const char *pkgid, const char *lbid)
 {
        struct pkg_info *pkginfo;
 
@@ -499,18 +502,27 @@ HAPI struct pkg_info *package_create(const char *pkgname)
                return NULL;
        }
 
-       pkginfo->pkgname = io_livebox_pkgname(pkgname);
-       if (!pkginfo->pkgname) {
+       pkginfo->pkgid = strdup(pkgid);
+       if (!pkginfo->pkgid) {
+               ErrPrint("Heap: %s\n", strerror(errno));
+               DbgFree(pkginfo);
+               return NULL;
+       }
+
+       pkginfo->lbid = io_livebox_pkgname(lbid);
+       if (!pkginfo->lbid) {
                ErrPrint("Failed to get pkgname, fallback to fs checker\n");
-               if (util_validate_livebox_package(pkgname) < 0) {
-                       ErrPrint("Invalid package name: %s\n", pkgname);
+               if (util_validate_livebox_package(lbid) < 0) {
+                       ErrPrint("Invalid package name: %s\n", lbid);
+                       DbgFree(pkginfo->pkgid);
                        DbgFree(pkginfo);
                        return NULL;
                }
 
-               pkginfo->pkgname = strdup(pkgname);
-               if (!pkginfo->pkgname) {
+               pkginfo->lbid = strdup(lbid);
+               if (!pkginfo->lbid) {
                        ErrPrint("Heap: %s\n", strerror(errno));
+                       DbgFree(pkginfo->pkgid);
                        DbgFree(pkginfo);
                        return NULL;
                }
@@ -520,7 +532,8 @@ HAPI struct pkg_info *package_create(const char *pkgname)
                ErrPrint("Failed to load DB, fall back to conf file loader\n");
                if (load_conf(pkginfo) < 0) {
                        ErrPrint("Failed to initiate the conf file loader\n");
-                       DbgFree(pkginfo->pkgname);
+                       DbgFree(pkginfo->lbid);
+                       DbgFree(pkginfo->pkgid);
                        DbgFree(pkginfo);
                        return NULL;
                }
@@ -556,47 +569,47 @@ HAPI void package_del_ctx_info(struct pkg_info *pkginfo, struct context_info *in
 
 HAPI char *package_lb_pkgname(const char *pkgname)
 {
-       char *lb_pkgname;
+       char *lbid;
 
-       lb_pkgname = io_livebox_pkgname(pkgname);
-       if (!lb_pkgname) {
+       lbid = io_livebox_pkgname(pkgname);
+       if (!lbid) {
                if (util_validate_livebox_package(pkgname) < 0) {
                        return NULL;
                }
 
-               lb_pkgname = strdup(pkgname);
-               if (!lb_pkgname) {
+               lbid = strdup(pkgname);
+               if (!lbid) {
                        ErrPrint("Heap: %s\n", strerror(errno));
                        return NULL;
                }
        }
 
-       return lb_pkgname;
+       return lbid;
 }
 
 HAPI int package_is_lb_pkgname(const char *pkgname)
 {
-       char *lb_pkgname;
+       char *lbid;
        int ret;
 
-       lb_pkgname = package_lb_pkgname(pkgname);
-       ret = !!lb_pkgname;
-       DbgFree(lb_pkgname);
+       lbid = package_lb_pkgname(pkgname);
+       ret = !!lbid;
+       DbgFree(lbid);
 
        return ret;
 }
 
-HAPI struct pkg_info *package_find(const char *pkgname)
+HAPI struct pkg_info *package_find(const char *lbid)
 {
        Eina_List *l;
        struct pkg_info *info;
 
-       if (!pkgname) {
+       if (!lbid) {
                return NULL;
        }
 
        EINA_LIST_FOREACH(s_info.pkg_list, l, info) {
-               if (!strcmp(info->pkgname, pkgname)) {
+               if (!strcmp(info->lbid, lbid)) {
                        return info;
                }
        }
@@ -604,15 +617,15 @@ HAPI struct pkg_info *package_find(const char *pkgname)
        return NULL;
 }
 
-HAPI struct inst_info *package_find_instance_by_id(const char *pkgname, const char *id)
+HAPI struct inst_info *package_find_instance_by_id(const char *lbid, const char *id)
 {
        Eina_List *l;
        struct inst_info *inst;
        struct pkg_info *info;
 
-       info = package_find(pkgname);
+       info = package_find(lbid);
        if (!info) {
-               ErrPrint("Package %s is not exists\n", pkgname);
+               ErrPrint("Package %s is not exists\n", lbid);
                return NULL;
        }
 
@@ -625,15 +638,15 @@ HAPI struct inst_info *package_find_instance_by_id(const char *pkgname, const ch
        return NULL;
 }
 
-HAPI struct inst_info *package_find_instance_by_timestamp(const char *pkgname, double timestamp)
+HAPI struct inst_info *package_find_instance_by_timestamp(const char *lbid, double timestamp)
 {
        Eina_List *l;
        struct inst_info *inst;
        struct pkg_info *info;
 
-       info = package_find(pkgname);
+       info = package_find(lbid);
        if (!info) {
-               ErrPrint("Package %s is not exists\n", pkgname);
+               ErrPrint("Package %s is not exists\n", lbid);
                return NULL;
        }
 
@@ -654,7 +667,7 @@ HAPI int package_dump_fault_info(struct pkg_info *info)
 
        CRITICAL_LOG("=============\n");
        CRITICAL_LOG("faulted at %lf\n", info->fault_info->timestamp);
-       CRITICAL_LOG("Package: %s\n", info->pkgname);
+       CRITICAL_LOG("Package: %s\n", info->lbid);
        CRITICAL_LOG("Function: %s\n", info->fault_info->function);
        CRITICAL_LOG("InstanceID: %s\n", info->fault_info->filename);
        return LB_STATUS_SUCCESS;
@@ -1077,7 +1090,7 @@ static inline int assign_new_slave(struct pkg_info *info)
                return LB_STATUS_ERROR_INVALID;
        }
 
-       s_pkgname = util_replace_string(tmp, REPLACE_TAG_APPID, info->pkgname);
+       s_pkgname = util_replace_string(tmp, REPLACE_TAG_APPID, info->lbid);
        if (!s_pkgname) {
                DbgPrint("Failed to get replaced string\n");
                s_pkgname = strdup(tmp);
@@ -1088,7 +1101,7 @@ static inline int assign_new_slave(struct pkg_info *info)
                }
        }
 
-       DbgPrint("New slave[%s] is assigned for %s (using %s / abi[%s])\n", s_name, info->pkgname, s_pkgname, info->abi);
+       DbgPrint("New slave[%s] is assigned for %s (using %s / abi[%s])\n", s_name, info->lbid, s_pkgname, info->abi);
        info->slave = slave_create(s_name, info->secured, info->abi, s_pkgname, info->network);
 
        DbgFree(s_name);
@@ -1124,7 +1137,7 @@ HAPI int package_add_instance(struct pkg_info *info, struct inst_info *inst)
                                return ret;
                        }
                } else {
-                       DbgPrint("Slave %s is used for %s\n", slave_name(info->slave), info->pkgname);
+                       DbgPrint("Slave %s is used for %s\n", slave_name(info->slave), info->lbid);
                }
 
                slave_ref(info->slave);
@@ -1203,7 +1216,7 @@ static int client_created_cb(struct client_node *client, void *data)
 
        EINA_LIST_FOREACH(s_info.pkg_list, l, info) {
                if (info->fault_info) {
-                       fault_unicast_info(client, info->pkgname, info->fault_info->filename, info->fault_info->function);
+                       fault_unicast_info(client, info->lbid, info->fault_info->filename, info->fault_info->function);
                        continue;
                }
 
@@ -1224,7 +1237,7 @@ static int client_created_cb(struct client_node *client, void *data)
                                         */
                                        if (client_is_subscribed(client, instance_cluster(inst), instance_category(inst))) {
                                                instance_unicast_created_event(inst, client);
-                                               DbgPrint("(Subscribed) Created package: %s\n", info->pkgname);
+                                               DbgPrint("(Subscribed) Created package: %s\n", info->lbid);
                                        }
                                }
 
@@ -1240,17 +1253,17 @@ static int client_created_cb(struct client_node *client, void *data)
        return 0;
 }
 
-static int io_uninstall_cb(const char *pkgname, int prime, void *data)
+static int io_uninstall_cb(const char *pkgid, const char *lbid, int prime, void *data)
 {
        struct pkg_info *info;
        Eina_List *l;
        Eina_List *n;
        struct inst_info *inst;
 
-       DbgPrint("Package %s is uninstalled\n", pkgname);
-       info = package_find(pkgname);
+       DbgPrint("Package %s is uninstalled\n", lbid);
+       info = package_find(lbid);
        if (!info) {
-               DbgPrint("%s is not yet loaded\n", pkgname);
+               DbgPrint("%s is not yet loaded\n", lbid);
                return 0;
        }
 
@@ -1278,17 +1291,13 @@ static inline void reload_package_info(struct pkg_info *info)
        Eina_List *l;
        Eina_List *n;
        struct inst_info *inst;
+       unsigned int size_type;
+       int width;
+       int height;
 
        DbgPrint("Already exists, try to update it\n");
-       /*!
-        * \note
-        * Without "is_uninstalled", the package will be kept
-        */
-       EINA_LIST_FOREACH_SAFE(info->inst_list, l, n, inst) {
-               instance_destroy(inst, INSTANCE_DESTROY_PKGMGR);
-       }
 
-       group_del_livebox(info->pkgname);
+       group_del_livebox(info->lbid);
        package_clear_fault(info);
 
        /*!
@@ -1296,89 +1305,98 @@ static inline void reload_package_info(struct pkg_info *info)
         * Nested DB I/O
         */
        io_load_package_db(info);
+
+       /*!
+        * \note
+        * Without "is_uninstalled", the package will be kept
+        */
+       EINA_LIST_FOREACH_SAFE(info->inst_list, l, n, inst) {
+               width = instance_lb_width(inst);
+               height = instance_lb_height(inst);
+               size_type = livebox_service_size_type(width, height);
+               if (info->lb.size_list & size_type) {
+                       instance_reload(inst, INSTANCE_DESTROY_PKGMGR);
+               } else {
+                       instance_destroy(inst, INSTANCE_DESTROY_PKGMGR);
+               }
+       }
 }
 
-static int io_install_cb(const char *pkgname, int prime, void *data)
+static int io_install_cb(const char *pkgid, const char *lbid, int prime, void *data)
 {
        struct pkg_info *info;
 
-       DbgPrint("Livebox package %s is installed\n", pkgname);
-       info = package_find(pkgname);
+       info = package_find(lbid);
        if (info) {
-               reload_package_info(info);
+               /*!
+                * Already exists. skip to create this.
+                */
+               return 0;
+       }
+
+       info = package_create(pkgid, lbid);
+       if (!info) {
+               ErrPrint("Failed to build an info %s\n", lbid);
        } else {
-               info = package_create(pkgname);
-               if (!info) {
-                       ErrPrint("Failed to build an info: %s\n", pkgname);
-               } else {
-                       DbgPrint("Package %s is built\n", pkgname);
-               }
+               DbgPrint("Livebox %s is built\n", lbid);
        }
 
        return 0;
 }
 
-static int install_cb(const char *pkgname, enum pkgmgr_status status, double value, void *data)
+static int uninstall_cb(const char *pkgname, enum pkgmgr_status status, double value, void *data)
 {
-       int ret;
+       Eina_List *l;
+       Eina_List *n;
+       struct pkg_info *info;
 
        if (status != PKGMGR_STATUS_END) {
                return 0;
        }
 
-       ret = io_update_livebox_package(pkgname, io_install_cb, NULL);
-       return 0;
-}
-
-static int uninstall_cb(const char *pkgname, enum pkgmgr_status status, double value, void *data)
-{
-       int ret;
-
-       if (status == PKGMGR_STATUS_START) {
-               ret = io_update_livebox_package(pkgname, io_uninstall_cb, NULL);
-               if (ret == 0) {
-                       /*! for keeping the old style */
-                       (void)io_uninstall_cb(pkgname, -1, NULL);
+       EINA_LIST_FOREACH_SAFE(s_info.pkg_list, l, n, info) {
+               if (!strcmp(info->pkgid, pkgname)) {
+                       io_uninstall_cb(pkgname, info->lbid, -1, NULL);
                }
        }
 
        return 0;
 }
 
-static int io_update_cb(const char *pkgname, int prime, void *data)
+static int update_cb(const char *pkgname, enum pkgmgr_status status, double value, void *data)
 {
+       Eina_List *l;
+       Eina_List *n;
        struct pkg_info *info;
 
-       DbgPrint("Livebox package %s is updated\n", pkgname);
-       info = package_find(pkgname);
-       if (!info) {
+       if (status != PKGMGR_STATUS_END) {
                return 0;
        }
 
-       reload_package_info(info);
-       return 0;
-}
-
-static int update_cb(const char *pkgname, enum pkgmgr_status status, double value, void *data)
-{
-       int ret;
-       if (status != PKGMGR_STATUS_END) {
-               return 0;
+       EINA_LIST_FOREACH_SAFE(s_info.pkg_list, l, n, info) {
+               if (!strcmp(info->pkgid, pkgname)) {
+                       DbgPrint("Update lbid: %s\n", info->lbid);
+                       if (io_is_exists(info->lbid) == 1) {
+                               reload_package_info(info);
+                       } else {
+                               io_uninstall_cb(pkgname, info->lbid, -1, NULL);
+                       }
+               }
        }
 
-       ret = io_update_livebox_package(pkgname, io_update_cb, NULL);
+       (void)io_update_livebox_package(pkgname, io_install_cb, NULL);
        return 0;
 }
 
-static int crawling_liveboxes(const char *pkgname, int prime, void *data)
+static int crawling_liveboxes(const char *pkgid, const char *lbid, int prime, void *data)
 {
-       if (package_find(pkgname)) {
-               ErrPrint("Information of %s is already built\n", pkgname);
+       if (package_find(lbid)) {
+               ErrPrint("Information of %s is already built\n", lbid);
        } else {
                struct pkg_info *info;
-               info = package_create(pkgname);
+               info = package_create(pkgid, lbid);
                if (info) {
-                       DbgPrint("[%s] information is built prime(%d)\n", pkgname, prime);
+                       DbgPrint("[%s] information is built prime(%d)\n", lbid, prime);
                }
        }
 
@@ -1390,7 +1408,7 @@ HAPI int package_init(void)
        client_global_event_handler_add(CLIENT_GLOBAL_EVENT_CREATE, client_created_cb, NULL);
        pkgmgr_init();
 
-       pkgmgr_add_event_callback(PKGMGR_EVENT_INSTALL, install_cb, NULL);
+       pkgmgr_add_event_callback(PKGMGR_EVENT_INSTALL, update_cb, NULL);
        pkgmgr_add_event_callback(PKGMGR_EVENT_UNINSTALL, uninstall_cb, NULL);
        pkgmgr_add_event_callback(PKGMGR_EVENT_UPDATE, update_cb, NULL);
 
@@ -1407,7 +1425,7 @@ HAPI int package_fini(void)
        struct pkg_info *info;
        struct inst_info *inst;
 
-       pkgmgr_del_event_callback(PKGMGR_EVENT_INSTALL, install_cb, NULL);
+       pkgmgr_del_event_callback(PKGMGR_EVENT_INSTALL, update_cb, NULL);
        pkgmgr_del_event_callback(PKGMGR_EVENT_UNINSTALL, uninstall_cb, NULL);
        pkgmgr_del_event_callback(PKGMGR_EVENT_UPDATE, update_cb, NULL);
        pkgmgr_fini();
@@ -1436,7 +1454,7 @@ HAPI const char *package_find_by_secured_slave(struct slave_node *slave)
 
        EINA_LIST_FOREACH(s_info.pkg_list, l, info) {
                if (info->slave == slave) {
-                       return info->pkgname;
+                       return info->lbid;
                }
        }
 
@@ -1445,7 +1463,7 @@ HAPI const char *package_find_by_secured_slave(struct slave_node *slave)
 
 HAPI const char * const package_name(const struct pkg_info *info)
 {
-       return info->pkgname;
+       return info->lbid;
 }
 
 /*!
@@ -1500,7 +1518,7 @@ HAPI int package_alter_instances_to_client(struct client_node *client, enum alte
                                        if (!instance_has_client(inst, client)) {
                                                instance_unicast_created_event(inst, client);
                                                instance_add_client(inst, client);
-                                               DbgPrint("(Subscribed) Created package: %s\n", info->pkgname);
+                                               DbgPrint("(Subscribed) Created package: %s\n", info->lbid);
                                        }
                                        break;
                                case ALTER_DESTROY:
index b048f8f..1d09231 100644 (file)
@@ -862,7 +862,7 @@ static struct packet *client_new(pid_t pid, int handle, const struct packet *pac
        struct pkg_info *info;
        int width;
        int height;
-       char *lb_pkgname;
+       char *lbid;
        char *mainappid;
 
        client = client_find_by_rpc_handle(handle);
@@ -882,25 +882,35 @@ static struct packet *client_new(pid_t pid, int handle, const struct packet *pac
        DbgPrint("pid[%d] period[%lf] pkgname[%s] content[%s] cluster[%s] category[%s] period[%lf]\n",
                                                pid, timestamp, pkgname, content, cluster, category, period);
 
-       lb_pkgname = package_lb_pkgname(pkgname);
-       if (!lb_pkgname) {
+       lbid = package_lb_pkgname(pkgname);
+       if (!lbid) {
                ErrPrint("This %s has no livebox package\n", pkgname);
                ret = LB_STATUS_ERROR_INVALID;
                goto out;
        }
 
-       mainappid = livebox_service_mainappid(lb_pkgname);
+       mainappid = livebox_service_mainappid(lbid);
        if (!package_is_enabled(mainappid)) {
                DbgFree(mainappid);
-               DbgFree(lb_pkgname);
+               DbgFree(lbid);
                ret = LB_STATUS_ERROR_DISABLED;
                goto out;
        }
        DbgFree(mainappid);
 
-       info = package_find(lb_pkgname);
+       info = package_find(lbid);
        if (!info) {
-               info = package_create(lb_pkgname);
+               char *pkgid;
+               pkgid = livebox_service_appid(lbid);
+               if (!pkgid) {
+                       DbgFree(mainappid);
+                       DbgFree(lbid);
+                       ret = LB_STATUS_ERROR_FAULT;
+                       goto out;
+               }
+
+               info = package_create(pkgid, lbid);
+               DbgFree(pkgid);
        }
 
        if (!info) {
@@ -917,7 +927,7 @@ static struct packet *client_new(pid_t pid, int handle, const struct packet *pac
                        period = MINIMUM_PERIOD;
                }
 
-               inst = instance_create(client, timestamp, lb_pkgname, content, cluster, category, period, width, height);
+               inst = instance_create(client, timestamp, lbid, content, cluster, category, period, width, height);
                /*!
                 * \note
                 * Using the "inst" without validate its value is at my disposal. ;)
@@ -925,7 +935,7 @@ static struct packet *client_new(pid_t pid, int handle, const struct packet *pac
                ret = inst ? 0 : LB_STATUS_ERROR_FAULT;
        }
 
-       DbgFree(lb_pkgname);
+       DbgFree(lbid);
 
 out:
        result = packet_create_reply(packet, "i", ret);
@@ -6235,7 +6245,7 @@ static struct packet *service_update(pid_t pid, int handle, const struct packet
        const char *id;
        const char *cluster;
        const char *category;
-       char *lb_pkgname;
+       char *lbid;
        int ret;
 
        ret = packet_get(packet, "ssss", &pkgname, &id, &cluster, &category);
@@ -6245,30 +6255,30 @@ static struct packet *service_update(pid_t pid, int handle, const struct packet
                goto out;
        }
 
-       lb_pkgname = package_lb_pkgname(pkgname);
-       if (!lb_pkgname) {
+       lbid = package_lb_pkgname(pkgname);
+       if (!lbid) {
                ErrPrint("Invalid package %s\n", pkgname);
                ret = LB_STATUS_ERROR_INVALID;
                goto out;
        }
 
-       pkg = package_find(lb_pkgname);
+       pkg = package_find(lbid);
        if (!pkg) {
                ret = LB_STATUS_ERROR_NOT_EXIST;
-               DbgFree(lb_pkgname);
+               DbgFree(lbid);
                goto out;
        }
 
        if (package_is_fault(pkg)) {
                ret = LB_STATUS_ERROR_FAULT;
-               DbgFree(lb_pkgname);
+               DbgFree(lbid);
                goto out;
        }
 
        inst_list = package_instance_list(pkg);
        if (!eina_list_count(inst_list)) {
                ret = LB_STATUS_ERROR_NOT_EXIST;
-               DbgFree(lb_pkgname);
+               DbgFree(lbid);
                goto out;
        }
 
@@ -6285,7 +6295,7 @@ static struct packet *service_update(pid_t pid, int handle, const struct packet
                }
 
                if (ret == LB_STATUS_ERROR_NOT_EXIST) {
-                       DbgFree(lb_pkgname);
+                       DbgFree(lbid);
                        goto out;
                }
        }
@@ -6294,8 +6304,8 @@ static struct packet *service_update(pid_t pid, int handle, const struct packet
         * \TODO
         * Validate the update requstor.
         */
-       slave_rpc_request_update(lb_pkgname, id, cluster, category);
-       DbgFree(lb_pkgname);
+       slave_rpc_request_update(lbid, id, cluster, category);
+       DbgFree(lbid);
        ret = LB_STATUS_SUCCESS;
 
 out:
index c554d9b..5b98b5b 100644 (file)
@@ -33,7 +33,7 @@
 #include "conf.h"
 
 #ifndef SVC_PKG
-#define SVC_PKG                "com.samsung.data-provider-slave.icon"
+#define SVC_PKG                "org.tizen.data-provider-slave.icon"
 #endif
 
 #ifndef LAUNCH_TIMEOUT