Update the data provider master
authorSung-jae Park <nicesj.park@samsung.com>
Tue, 5 Feb 2013 06:55:34 +0000 (06:55 +0000)
committerSung-jae Park <nicesj.park@samsung.com>
Tue, 5 Feb 2013 06:55:34 +0000 (06:55 +0000)
Fix the liveinfo bug (Command line parser is updated)
Manifest file is updated for rule of daemon type package.

Change-Id: I61ce630765c936d6a11dc6094ec3598b5da47d83

org.tizen.data-provider-master.manifest
packaging/org.tizen.data-provider-master.spec
pkgmgr_livebox/src/service_register.c
util_liveinfo/src/liveinfo.c

index 57bc637..4bdb04c 100644 (file)
@@ -8,6 +8,9 @@
                        <label name="data-provider-master::data" />
                        <label name="data-provider-master::share" />
                </provide>
+               <request>
+                       <smack request="sys-assert::core" type="rwxat" />
+               </request>
        </define>
        <request>
                <domain name="_" />
index 8ab615b..07b6aff 100644 (file)
@@ -1,6 +1,6 @@
 Name: org.tizen.data-provider-master
 Summary: Master service provider for liveboxes.
-Version: 0.15.7
+Version: 0.15.12
 Release: 1
 Group: framework/livebox
 License: Flora License
index 786e9ba..1b15470 100644 (file)
@@ -2125,7 +2125,7 @@ static inline int db_insert_livebox(struct livebox *livebox, const char *appid)
 
        if (livebox->size_list & LB_SIZE_TYPE_EASY_3x3) {
                ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_EASY_3x3, (char *)livebox->preview[9]);
-               if (ret < 9)
+               if (ret < 0)
                        goto errout;
        }
 
index 3a72f91..7506620 100644 (file)
@@ -492,139 +492,206 @@ static inline void fini_directory(void)
 {
 }
 
-static inline void do_command(const char *cmd)
+static inline struct node *update_target_dir(const char *cmd)
 {
-       char command[256];
-       char argument[4096] = { '\0', };
+       struct node *node;
 
-       if (!strlen(cmd) || *cmd == '#') {
-               prompt(NULL);
-               return;
+       node = (*cmd == '/') ? s_info.rootdir : s_info.curdir;
+       node = node_find(s_info.targetdir, cmd);
+
+       return node;
+}
+
+static int get_token(const char *src, char *out)
+{
+       int len = 0;
+       while (*src && *src == ' ') src++;
+
+       if (!*src)
+               return 0;
+
+       while (*src && *src != ' ') {
+               *out++ = *src++;
+               len++;
        }
 
-       if (sscanf(cmd, "%255[^ ] %s", command, argument) == 2)
-               cmd = command;
+       *out = '\0';
+       return len;
+}
 
-       if (!strcasecmp(cmd, "exit") || !strcasecmp(cmd, "quit")) {
-               ecore_main_loop_quit();
-       } else if (!strcasecmp(cmd, "set")) {
-               char variable[4096] = { '0', };
-               char value[4096] = { '0', };
+static inline int do_set(const char *cmd)
+{
+       int i;
+       char variable[4096] = { '0', };
 
-               if (sscanf(argument, "%4095[^ ] %s", variable, value) != 2) {
-                       printf("Invalid argument(%s): set [VAR] [VAL]\n", argument);
-                       goto out;
-               }
+       cmd += 4;
+       i = get_token(cmd, variable);
 
-               send_command(cmd, variable, value);
-       } else if (!strcasecmp(cmd, "get")) {
-               send_command(cmd, argument, "");
-       } else if (!strcasecmp(cmd, "ls")) {
-               const char *name;
-               struct node *parent;
+       cmd += i;
+       while (*cmd && *cmd == ' ') cmd++;
 
-               if (*argument) {
-                       s_info.targetdir = (*argument == '/') ? s_info.rootdir : s_info.curdir;
-                       s_info.targetdir = node_find(s_info.targetdir, argument);
-               } else {
-                       s_info.targetdir = s_info.curdir;
-               }
+       if (!i || !*cmd) {
+               printf("Invalid argument(%s): set [VAR] [VAL]\n", cmd);
+               return -EINVAL;
+       }
 
-               if (!s_info.targetdir) {
-                       printf("%s is not exists\n", argument);
-                       goto out;
-               }
+       send_command("set", variable, cmd);
+       return 0;
+}
 
-               name = node_name(s_info.targetdir);
-               if (name) {
-                       if (!strcmp(name, "package")) {
-                               if (s_info.cmd == NOP) {
-                                       send_pkg_list();
-                                       return;
-                               }
+static inline int do_get(const char *cmd)
+{
+       cmd += 4;
 
-                               printf("Waiting the server response\n");
-                               goto out;
-                       } else if (!strcmp(name, "provider")) {
-                               if (s_info.cmd == NOP) {
-                                       send_slave_list();
-                                       return;
-                               }
+       while (*cmd && *cmd == ' ') cmd++;
+       if (!*cmd) {
+               printf("Invalid argument(%s): get [VAR]\n", cmd);
+               return -EINVAL;
+       }
 
-                               printf("Waiting the server response\n");
-                               goto out;
-                       }
-               }
+       send_command("get", cmd, "");
+       return 0;
+}
 
-               parent = node_parent(s_info.targetdir);
-               if (parent && node_name(parent)) {
-                       if (!strcmp(node_name(parent), "package")) {
-                               if (s_info.cmd != NOP) {
-                                       printf("Waiting the server response\n");
-                                       goto out;
-                               }
-                               send_inst_list(name);
-                               return;
+static inline int do_ls(const char *cmd)
+{
+       const char *name;
+       struct node *parent;
+
+       cmd += 2;
+
+       while (*cmd && *cmd == ' ')
+               cmd++;
+
+       s_info.targetdir = *cmd ? update_target_dir(cmd) : s_info.curdir;
+       if (!s_info.targetdir) {
+               printf("%s is not exists\n", cmd);
+               return -ENOENT;
+       }
+
+       name = node_name(s_info.targetdir);
+       if (name) {
+               if (!strcmp(name, "package")) {
+                       if (s_info.cmd == NOP) {
+                               send_pkg_list();
+                               return 0;
                        }
-               }
 
-               ls();
-       } else if (!strcasecmp(cmd, "cd")) {
-               if (!*argument)
-                       goto out;
+                       printf("Waiting the server response\n");
+                       return -EBUSY;
+               } else if (!strcmp(name, "provider")) {
+                       if (s_info.cmd == NOP) {
+                               send_slave_list();
+                               return 0;
+                       }
 
-               if (s_info.cmd != NOP) {
                        printf("Waiting the server response\n");
-                       goto out;
+                       return -EBUSY;
                }
+       }
 
-               s_info.targetdir = (*argument == '/') ? s_info.rootdir : s_info.curdir;
-               s_info.targetdir = node_find(s_info.targetdir, argument);
-               if (!s_info.targetdir) {
-                       printf("%s is not exists\n", argument);
-                       goto out;
-               }
+       parent = node_parent(s_info.targetdir);
+       if (parent && node_name(parent)) {
+               if (!strcmp(node_name(parent), "package")) {
+                       if (s_info.cmd != NOP) {
+                               printf("Waiting the server response\n");
+                               return -EBUSY;
+                       }
 
-               if (node_type(s_info.targetdir) != NODE_DIR) {
-                       printf("Unable change directory to %s\n", argument);
-                       goto out;
+                       send_inst_list(name);
+                       return 0;
                }
+       }
 
-               if (!(node_mode(s_info.targetdir) & NODE_EXEC)) {
-                       printf("Access denied %s\n", argument);
-                       goto out;
-               }
+       ls();
+       return -1;
+}
 
-               s_info.curdir = s_info.targetdir;
-       } else if (!strcasecmp(cmd, "rm")) {
-               if (!*argument)
-                       goto out;
+static inline int do_cd(const char *cmd)
+{
+       cmd += 2;
 
-               if (s_info.cmd != NOP) {
-                       printf("Waiting the server response\n");
-                       goto out;
-               }
+       while (*cmd && *cmd == ' ')
+                cmd++;
 
-               s_info.targetdir = (*argument == '/') ? s_info.rootdir : s_info.curdir;
-               s_info.targetdir = node_find(s_info.targetdir, argument);
-               if (!s_info.targetdir) {
-                       printf("%s is not exists\n", argument);
-                       goto out;
-               }
+       if (!*cmd)
+               return -1;
 
-               if (!(node_mode(s_info.targetdir) & NODE_WRITE)) {
-                       printf("Access denied %s\n", argument);
-                       goto out;
-               }
+       if (s_info.cmd != NOP) {
+               printf("Waiting the server response\n");
+               return -EBUSY;
+       }
 
-               send_inst_delete();
-       } else if (!strcasecmp(cmd, "help")) {
-               help();
-       } else {
-               printf("Unknown command - \"help\"\n");
+       s_info.targetdir = update_target_dir(cmd);
+       if (!s_info.targetdir) {
+               printf("%s is not exists\n", cmd);
+               return -ENOENT;
+       }
+
+       if (node_type(s_info.targetdir) != NODE_DIR) {
+               printf("Unable change directory to %s\n", cmd);
+               return -EINVAL;
+       }
+
+       if (!(node_mode(s_info.targetdir) & NODE_EXEC)) {
+               printf("Access denied %s\n", cmd);
+               return -EACCES;
+       }
+
+       s_info.curdir = s_info.targetdir;
+       return -1;
+}
+
+static inline int do_rm(const char *cmd)
+{
+       cmd += 2;
+       while (*cmd && *cmd == ' ') cmd++;
+       if (!*cmd)
+               return -1;
+
+       if (s_info.cmd != NOP) {
+               printf("Waiting the server response\n");
+               return -EBUSY;
+       }
+
+       s_info.targetdir = update_target_dir(cmd);
+       if (!s_info.targetdir) {
+               printf("%s is not exists\n", cmd);
+               return -ENOENT;
+       }
+
+       if (!(node_mode(s_info.targetdir) & NODE_WRITE)) {
+               printf("Access denied %s\n", cmd);
+               return -EACCES;
+       }
+
+       send_inst_delete();
+       return 0;
+}
+
+static inline void do_command(const char *cmd)
+{
+       /* Skip the first spaces */
+       while (*cmd && *cmd == ' ') cmd++;
+
+       if (strlen(cmd) && *cmd != '#') {
+               if (!strncasecmp(cmd, "exit", 4) || !strncasecmp(cmd, "quit", 4)) {
+                       ecore_main_loop_quit();
+               } else if (!strncasecmp(cmd, "set ", 4) && do_set(cmd) == 0) {
+                       return;
+               } else if (!strncasecmp(cmd, "get ", 4) && do_get(cmd) == 0) {
+                       return;
+               } else if (!strncasecmp(cmd, "ls", 2) && do_ls(cmd) == 0) {
+                       return;
+               } else if (!strncasecmp(cmd, "cd", 2) && do_cd(cmd) == 0) {
+                       return;
+               } else if (!strncasecmp(cmd, "rm", 2) && do_rm(cmd) == 0) {
+                       return;
+               } else {
+                       help();
+               }
        }
 
-out:
        prompt(NULL);
        return;
 }