implement TEP install, update 80/50980/8 accepted/tizen/mobile/20151117.005608 accepted/tizen/tv/20151117.005625 accepted/tizen/wearable/20151117.005635 submit/tizen/20151116.110857
authorVBS <jungh.yeon@samsung.com>
Tue, 3 Nov 2015 11:32:33 +0000 (20:32 +0900)
committerVBS <jungh.yeon@samsung.com>
Wed, 11 Nov 2015 06:17:30 +0000 (15:17 +0900)
[app-installer][pkgmgr-info][pkgmgr-server][pkgmgr-tool][slp-pkgmgr]

Signed-off-by: VBS <jungh.yeon@samsung.com>
Change-Id: Ie376dd71bb487229d165e36592f20987a6ed5128

src/pkgmgr-server.c
src/request.c

index 350cb0e..bc1b2c8 100644 (file)
@@ -691,6 +691,7 @@ static char **__generate_argv(const char *args)
 static void __exec_with_arg_vector(const char *cmd, char **argv, uid_t uid)
 {
        user_ctx* user_context = get_user_context(uid);
+
        if(!user_context) {
                DBG("Failed to getenv for the user : %d", uid);
                exit(1);
@@ -702,6 +703,7 @@ static void __exec_with_arg_vector(const char *cmd, char **argv, uid_t uid)
        free_user_context(user_context);
 
        /* Execute backend !!! */
+
        int ret = execv(cmd, argv);
 
        /* Code below: exec failure. Should not be happened! */
@@ -719,14 +721,15 @@ static void __process_install(pm_dbus_msg *item)
 {
        char *backend_cmd;
        char **args_vector;
-       char args[MAX_PKG_ARGS_LEN];
+       char args[MAX_PKG_ARGS_LEN] = {'\0', };
 
        backend_cmd = _get_backend_cmd(item->pkg_type);
        if (backend_cmd == NULL)
                return;
 
-       snprintf(args, sizeof(args), "%s -k %s -i %s", backend_cmd,
-                       item->req_id, item->pkgid);
+       snprintf(args, sizeof(args), "%s -k %s -i %s %s", backend_cmd,
+                       item->req_id, item->pkgid, item->args);
+
        args_vector = __generate_argv(args);
        args_vector[0] = backend_cmd;
 
@@ -908,6 +911,7 @@ gboolean queue_job(void *data)
        strncpy(ptr->pkgtype, item->pkg_type, MAX_PKG_TYPE_LEN-1);
        strncpy(ptr->pkgid, item->pkgid, MAX_PKG_NAME_LEN-1);
        strncpy(ptr->args, item->args, MAX_PKG_ARGS_LEN-1);
+
        ptr->uid = item->uid;
        ptr->pid = fork();
        DBG("child forked [%d] for request type [%d]", ptr->pid, item->req_type);
index 7b1d8d4..9e59939 100644 (file)
@@ -17,6 +17,7 @@ static const char instropection_xml[] =
        "      <arg type='u' name='uid' direction='in'/>"
        "      <arg type='s' name='pkgtype' direction='in'/>"
        "      <arg type='s' name='pkgpath' direction='in'/>"
+       "      <arg type='as' name='args' direction='in'/>"
        "      <arg type='i' name='ret' direction='out'/>"
        "      <arg type='s' name='reqkey' direction='out'/>"
        "    </method>"
@@ -124,31 +125,75 @@ static int __handle_request_install(uid_t uid,
        uid_t target_uid = (uid_t)-1;
        char *pkgtype = NULL;
        char *pkgpath = NULL;
-       char *reqkey;
+       char *args = NULL;
+       char *reqkey = NULL;
+       gchar **tmp_args = NULL;
+       gsize args_count;
+       int ret = -1;
+       GVariant *value;
+       gchar *str;
+       int i = 0;
+       int len = 0;
+
+       g_variant_get(parameters, "(u&s&s@as)", &target_uid, &pkgtype, &pkgpath, &value);
+       tmp_args = (gchar **)g_variant_get_strv(value, &args_count);
+
+       for (i = 0; i < args_count; i++)
+               len = len + strlen(tmp_args[i]) + 1;
+
+       args = (char *)calloc(len, sizeof(char));
+       if (args == NULL) {
+               ERR("calloc failed");
+               ret =  -1;
+               goto catch;
+       }
+
+       for (i = 0; i < args_count; i++) {
+               strncat(args, tmp_args[i], strlen(tmp_args[i]));
+               strncat(args, " ", strlen(" "));
+       }
 
-       g_variant_get(parameters, "(u&s&s)", &target_uid, &pkgtype, &pkgpath);
-       if (target_uid == (uid_t)-1 || pkgtype == NULL || pkgpath == NULL) {
+       if (target_uid == (uid_t)-1 || pkgtype == NULL) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ECOMM, ""));
-               return -1;
+               ret = -1;
+               goto catch;
+       }
+
+       if (pkgpath == NULL) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(is)", PKGMGR_R_ECOMM, ""));
+               ret = -1;
+               goto catch;
        }
 
        reqkey = __generate_reqkey(pkgpath);
-       if (reqkey == NULL)
-               return -1;
+       if (reqkey == NULL) {
+               ret = -1;
+               goto catch;
+       }
+
        if (_pm_queue_push(target_uid, reqkey, PKGMGR_REQUEST_TYPE_INSTALL, pkgtype,
-                               pkgpath, "")) {
+                               pkgpath, args)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ESYSTEM, ""));
-               free(reqkey);
-               return -1;
+               ret = -1;
+               goto catch;
        }
 
        g_dbus_method_invocation_return_value(invocation,
                        g_variant_new("(is)", PKGMGR_R_OK, reqkey));
-       free(reqkey);
 
-       return 0;
+       ret = 0;
+
+catch:
+       if (reqkey)
+               free(reqkey);
+
+       if (args)
+               free(args);
+
+       return ret;
 }
 
 static int __handle_request_reinstall(uid_t uid,