Change the type of auto_launch record to TEXT
authorSung-jae Park <nicesj.park@samsung.com>
Thu, 27 Dec 2012 03:46:50 +0000 (12:46 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Thu, 27 Dec 2012 03:46:50 +0000 (12:46 +0900)
To know the exact package name for launching it when a user clicks a box

Change-Id: I0231abf331cd41e8edae807ba5400da09aa0fbb0

include/instance.h
include/package.h
include/parser.h
packaging/org.tizen.data-provider-master.spec
pkgmgr_livebox/livebox.xml
pkgmgr_livebox/src/service_register.c
src/instance.c
src/io.c
src/package.c
src/parser.c

index d9d7af0..016d704 100644 (file)
@@ -169,7 +169,7 @@ extern const char * const instance_content(const struct inst_info *inst);
 extern const char * const instance_category(const struct inst_info *inst);
 extern const char * const instance_cluster(const struct inst_info *inst);
 extern const char * const instance_title(const struct inst_info *inst);
-extern const int const instance_auto_launch(const struct inst_info *inst);
+extern const char * const instance_auto_launch(const struct inst_info *inst);
 extern const int const instance_priority(const struct inst_info *inst);
 extern const struct client_node * const instance_client(const struct inst_info *inst);
 extern const double const instance_period(const struct inst_info *inst);
index 65cafbd..5112d8b 100644 (file)
@@ -71,7 +71,7 @@ extern const char * const package_lb_group(const struct pkg_info *info);
 extern const char * const package_pd_path(const struct pkg_info *info);
 extern const char * const package_pd_group(const struct pkg_info *info);
 extern const int const package_pinup(const struct pkg_info *info);
-extern const int const package_auto_launch(const struct pkg_info *info);
+extern const char * const package_auto_launch(const struct pkg_info *info);
 extern const unsigned int const package_size_list(const struct pkg_info *info);
 extern const int const package_pd_width(const struct pkg_info *info);
 extern const int const package_pd_height(const struct pkg_info *info);
@@ -82,7 +82,7 @@ extern Eina_List *package_ctx_info(struct pkg_info *pkginfo);
 
 extern int package_set_libexec(struct pkg_info *info, const char *libexec);
 extern void package_set_pinup(struct pkg_info *info, int pinup);
-extern void package_set_auto_launch(struct pkg_info *info, int auto_launch);
+extern void package_set_auto_launch(struct pkg_info *info, const char *auto_launch);
 extern void package_set_size_list(struct pkg_info *info, unsigned int size_list);
 extern void package_set_lb_type(struct pkg_info *info, enum lb_type type);
 extern void package_set_pd_type(struct pkg_info *info, enum pd_type type);
index 2be8995..3f7e50e 100644 (file)
@@ -21,7 +21,7 @@ extern int parser_unload(struct parser *handle);
 extern double parser_period(struct parser *handle);
 extern int parser_network(struct parser *handle);
 extern int parser_timeout(struct parser *handle);
-extern int parser_auto_launch(struct parser *handle);
+extern const char *parser_auto_launch(struct parser *handle);
 extern unsigned int parser_size(struct parser *handle);
 extern void parser_get_pdsize(struct parser *handle, unsigned int *width, unsigned int *height);
 extern const char *parser_group_str(struct parser *handle);
index 9f69cdb..f6d2d62 100644 (file)
@@ -1,6 +1,6 @@
 Name: org.tizen.data-provider-master
 Summary: Master data provider
-Version: 0.13.24
+Version: 0.13.25
 Release: 1
 Group: main/app
 License: Flora License
index b4b862c..5df73df 100644 (file)
@@ -1,13 +1,15 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.nicesj" version="1.0" install-location="auto">
 
-<livebox appid="org.tizen.nicesj.livebox" primary="true" secured="false" auto_launch="true" network="false" abi="c" timeout="20" period="10.0" libexec="/usr/apps/org.tizen.myapp/libexec/liblive-org.tizen.nicesj.so" pinup="false" script="edje">
+<livebox appid="org.tizen.nicesj.livebox" primary="true" secured="false" network="false" abi="c" timeout="20" period="10.0" libexec="/usr/apps/org.tizen.myapp/libexec/liblive-org.tizen.nicesj.so" pinup="false" script="edje">
        <label>My livebox</label>
        <icon>/usr/share/icons/small/org.tizen.live-nicesj.png</icon>
        <label xml:lang="en_US">Sample</label>
        <label xml:lang="ko_KR">Hangul</label>
        <content>Content information</content>
 
+       <launch>org.tizen.nicesj</launch>
+
        <setup>org.tizen.nicesj</setup>
 
        <box type="image">
index ae0537c..21ecad5 100644 (file)
@@ -60,7 +60,6 @@
  * = box_type = { text | buffer | script | image }
  * = pd_type = { text | buffer | script }
  * = network = { 1 | 0 }
- * = auto_launch = { 1 | 0 }
  * = secured = { 1 | 0 }
  *
  *
@@ -70,9 +69,9 @@
  * +-------+------+---------+-------------+---------+---------+-----------+-------+
  * |   -   |   -  |    -    |      -      |    -    |    -    |     -     |   -   |
  * +-------+------+---------+-------------+---------+---------+-----------+-------+
- * CREATE TABLE client ( pkgid TEXT PRIMARY KEY NOT NULL, icon TEXT, name TEXT, auto_launch INTEGER, pd_size TEXT, content TEXT DEFAULT "default", nodisplay INTEGER, setup TEXT, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) )
+ * CREATE TABLE client ( pkgid TEXT PRIMARY KEY NOT NULL, icon TEXT, name TEXT, auto_launch TEXT, pd_size TEXT, content TEXT DEFAULT "default", nodisplay INTEGER, setup TEXT, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) )
  *
- * = auto_launch = { 1 | 0 }
+ * = auto_launch = UI-APPID
  * = pd_size = WIDTHxHEIGHT
  *
  *
@@ -163,8 +162,8 @@ enum lb_size {
 struct livebox {
        xmlChar *pkgid;
        int secured;
-       int auto_launch;
        int network;
+       xmlChar *auto_launch;
        xmlChar *abi;
        xmlChar *name; /* Default name */
        xmlChar *icon; /* Default icon */
@@ -608,7 +607,7 @@ static inline int db_create_client(void)
 
        ddl = "CREATE TABLE client (" \
                "pkgid TEXT PRIMARY KEY NOT NULL, icon TEXT, name TEXT, " \
-               "auto_launch INTEGER, pd_size TEXT, content TEXT DEFAULT 'default', nodisplay INTEGER, setup TEXT, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE)";
+               "auto_launch TEXT, pd_size TEXT, content TEXT DEFAULT 'default', nodisplay INTEGER, setup TEXT, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE)";
        if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
                ErrPrint("Failed to execute the DDL (%s)\n", err);
                return -EIO;
@@ -654,7 +653,7 @@ static inline int db_insert_client(struct livebox *livebox)
                goto out;
        }
 
-       ret = sqlite3_bind_int(stmt, 4, livebox->auto_launch);
+       ret = sqlite3_bind_text(stmt, 4, (char *)livebox->auto_launch, -1, NULL);
        if (ret != SQLITE_OK) {
                DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
                ret = -EIO;
@@ -1462,6 +1461,7 @@ static inline int livebox_destroy(struct livebox *livebox)
        struct dlist *il;
        struct dlist *in;
 
+       xmlFree(livebox->auto_launch);
        xmlFree(livebox->pkgid);
        xmlFree(livebox->abi);
        xmlFree(livebox->name);
@@ -1616,6 +1616,22 @@ static inline void update_i18n_icon(struct livebox *livebox, xmlNodePtr node)
        livebox->i18n_list = dlist_append(livebox->i18n_list, i18n);
 }
 
+static inline void update_launch(struct livebox *livebox, xmlNodePtr node)
+{
+       xmlChar *launch;
+       launch = xmlNodeGetContent(node);
+       if (!launch) {
+               DbgPrint("Has no launch\n");
+               return;
+       }
+
+       livebox->auto_launch = xmlStrdup(launch);
+       if (!livebox->auto_launch) {
+               ErrPrint("Failed to duplicate string: %s\n", (char *)launch);
+               return;
+       }
+}
+
 static inline void update_setup(struct livebox *livebox, xmlNodePtr node)
 {
        xmlChar *setup;
@@ -2163,14 +2179,6 @@ static inline int do_install(xmlNodePtr node, const char *appid)
                xmlFree(tmp);
        }
 
-       if (xmlHasProp(node, (const xmlChar *)"auto_launch")) {
-               tmp = xmlGetProp(node, (const xmlChar *)"auto_launch");
-               livebox->auto_launch = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true");
-               xmlFree(tmp);
-       } else {
-               livebox->auto_launch = 1; /* Default value */
-       }
-
        if (xmlHasProp(node, (const xmlChar *)"network")) {
                tmp = xmlGetProp(node, (const xmlChar *)"network");
                livebox->network = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true");
@@ -2262,6 +2270,11 @@ static inline int do_install(xmlNodePtr node, const char *appid)
                        update_setup(livebox, node);
                        continue;
                }
+
+               if (!xmlStrcasecmp(node->name, (const xmlChar *)"launch")) {
+                       update_launch(livebox, node);
+                       continue;
+               }
        }
 
        return db_insert_livebox(livebox, appid);
index 4d9086d..fae978c 100644 (file)
@@ -101,7 +101,7 @@ struct inst_info {
                        struct buffer_info *buffer;
                } canvas;
 
-               int auto_launch;
+               const char *auto_launch;
        } lb;
 
        struct {
@@ -284,7 +284,7 @@ HAPI int instance_unicast_created_event(struct inst_info *inst, struct client_no
        else
                pd_file = "";
 
-       packet = packet_create_noack("created", "dsssiiiissssidiiiiidsi",
+       packet = packet_create_noack("created", "dsssiiiisssssdiiiiidsi",
                        inst->timestamp,
                        package_name(inst->info), inst->id, inst->content,
                        inst->lb.width, inst->lb.height,
@@ -344,7 +344,7 @@ static int instance_broadcast_created_event(struct inst_info *inst)
        if (!inst->client)
                client_browse_list(inst->cluster, inst->category, update_client_list, inst);
 
-       packet = packet_create_noack("created", "dsssiiiissssidiiiiidsi", 
+       packet = packet_create_noack("created", "dsssiiiisssssdiiiiidsi", 
                        inst->timestamp,
                        package_name(inst->info), inst->id, inst->content,
                        inst->lb.width, inst->lb.height,
@@ -471,6 +471,14 @@ static inline void destroy_instance(struct inst_info *inst)
        if (inst->update_timer)
                ecore_timer_del(inst->update_timer);
 
+       /*!
+        * \note
+        *
+        * inst->lb.auto_launch
+        *
+        * will be released by the package object
+        * it is readonly value for instances
+        */
        DbgFree(inst->category);
        DbgFree(inst->cluster);
        DbgFree(inst->content);
@@ -2054,7 +2062,7 @@ HAPI int instance_change_group(struct inst_info *inst, const char *cluster, cons
        return slave_rpc_async_request(package_slave(inst->info), package_name(inst->info), packet, change_group_cb, cbdata, 0);
 }
 
-HAPI const int const instance_auto_launch(const struct inst_info *inst)
+HAPI const char * const instance_auto_launch(const struct inst_info *inst)
 {
        return inst->lb.auto_launch;
 }
index 2ab7ce0..7062420 100644 (file)
--- a/src/io.c
+++ b/src/io.c
@@ -241,7 +241,8 @@ static inline int build_client_info(struct pkg_info *info)
                return -EIO;
        }
 
-       package_set_auto_launch(info, sqlite3_column_int(stmt, 0));
+       package_set_auto_launch(info, (const char *)sqlite3_column_text(stmt, 0));
+
        tmp = (const char *)sqlite3_column_text(stmt, 1);
        if (tmp && strlen(tmp)) {
                if (sscanf(tmp, "%dx%d", &width, &height) != 2) {
index cecc50e..20cc9a0 100644 (file)
@@ -80,7 +80,7 @@ struct pkg_info {
                } info;
 
                unsigned int size_list;
-               int auto_launch;
+               char *auto_launch;
                int pinup;
        } lb;
 
@@ -289,6 +289,7 @@ static inline void destroy_package(struct pkg_info *info)
        DbgFree(info->abi);
        DbgFree(info->pkgname);
        DbgFree(info->libexec);
+       DbgFree(info->lb.auto_launch);
 
        DbgFree(info);
 }
@@ -437,7 +438,27 @@ static inline int load_conf(struct pkg_info *info)
                info->period = MINIMUM_PERIOD;
 
        info->lb.size_list = parser_size(parser);
-       info->lb.auto_launch = parser_auto_launch(parser);
+
+       str = parser_auto_launch(parser);
+       str = str ? str : "";
+       info->lb.auto_launch = strdup(str);
+       if (!info->lb.auto_launch) {
+               ErrPrint("Heap: %s\n", strerror(errno));
+               DbgFree(info->abi);
+               DbgFree(info->script);
+               if (info->pd.type == PD_TYPE_SCRIPT) {
+                       DbgFree(info->pd.info.script.path);
+                       DbgFree(info->pd.info.script.group);
+               }
+
+               if (info->lb.type == LB_TYPE_SCRIPT) {
+                       DbgFree(info->lb.info.script.path);
+                       DbgFree(info->lb.info.script.group);
+               }
+               parser_unload(parser);
+               return -ENOMEM;
+       }
+
        info->secured = parser_secured(parser);
        info->lb.pinup = parser_pinup(parser);
 
@@ -867,14 +888,18 @@ HAPI void package_set_pinup(struct pkg_info *info, int pinup)
        info->lb.pinup = pinup;
 }
 
-HAPI const int const package_auto_launch(const struct pkg_info *info)
+HAPI const char * const package_auto_launch(const struct pkg_info *info)
 {
        return info->lb.auto_launch;
 }
 
-HAPI void package_set_auto_launch(struct pkg_info *info, int auto_launch)
+HAPI void package_set_auto_launch(struct pkg_info *info, const char *auto_launch)
 {
-       info->lb.auto_launch = auto_launch;
+       info->lb.auto_launch = strdup(auto_launch);
+       if (!info->lb.auto_launch) {
+               ErrPrint("Heap: %s\n", strerror(errno));
+               return;
+       }
 }
 
 HAPI const unsigned int const package_size_list(const struct pkg_info *info)
index 4415c67..e7af92e 100644 (file)
@@ -45,7 +45,7 @@ struct parser {
        double period;
        int timeout;
        int network;
-       int auto_launch;
+       char *auto_launch;
        unsigned int size;
        unsigned int pd_width;
        unsigned int pd_height;
@@ -83,7 +83,7 @@ HAPI int parser_timeout(struct parser *handle)
        return handle->timeout;
 }
 
-HAPI int parser_auto_launch(struct parser *handle)
+HAPI const char *parser_auto_launch(struct parser *handle)
 {
        return handle->auto_launch;
 }
@@ -390,7 +390,11 @@ static void auto_launch_handler(struct parser *item, char *buffer)
        if (!rtrim(buffer))
                return;
 
-       item->auto_launch = !!atoi(buffer);
+       item->auto_launch = strdup(buffer);
+       if (!item->auto_launch) {
+               ErrPrint("Heap: %s\n", strerror(errno));
+               return;
+       }
 }
 
 static void size_handler(struct parser *item, char *buffer)
@@ -647,7 +651,7 @@ HAPI struct parser *parser_load(const char *pkgname)
        item->lb_group = NULL;
        item->pd_width = 0;
        item->pd_height = 0;
-       item->auto_launch = 1;
+       item->auto_launch = NULL;
        item->size = 0x00000001;
        item->group = NULL;
        item->secured = 0;
@@ -827,6 +831,7 @@ HAPI int parser_unload(struct parser *item)
 {
        s_list = eina_list_remove(s_list, item);
 
+       DbgFree(item->auto_launch);
        DbgFree(item->abi);
        DbgFree(item->script);
        DbgFree(item->group);