if it's failed to get the pkgtype from the file, use the pkgtype argument. 58/101958/1 accepted/tizen/3.0/common/20161206.125837 accepted/tizen/3.0/ivi/20161206.000425 accepted/tizen/3.0/mobile/20161206.000312 accepted/tizen/3.0/tv/20161206.000343 accepted/tizen/3.0/wearable/20161206.000403 submit/tizen_3.0/20161205.120256
authorjongmyeongko <jongmyeong.ko@samsung.com>
Fri, 2 Dec 2016 13:02:40 +0000 (22:02 +0900)
committerjongmyeongko <jongmyeong.ko@samsung.com>
Fri, 2 Dec 2016 13:02:40 +0000 (22:02 +0900)
Change-Id: I8deaf21a552e94007e5a1c7b9341dcb69ccfe0d5
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
src/request.c

index d8e034a..f7c10fb 100644 (file)
@@ -21,6 +21,7 @@ static const char instropection_xml[] =
        "  <interface name='org.tizen.pkgmgr'>"
        "    <method name='install'>"
        "      <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'/>"
@@ -34,6 +35,7 @@ static const char instropection_xml[] =
        "    </method>"
        "    <method name='mount_install'>"
        "      <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'/>"
@@ -278,6 +280,7 @@ static int __handle_request_install(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
+       char *arg_pkgtype = NULL;
        const char *pkgtype;
        char *pkgpath = NULL;
        char *args = NULL;
@@ -289,7 +292,8 @@ static int __handle_request_install(uid_t caller_uid,
        int i = 0;
        int len = 0;
 
-       g_variant_get(parameters, "(u&s@as)", &target_uid, &pkgpath, &value);
+       g_variant_get(parameters, "(u&s&s@as)", &target_uid, &arg_pkgtype,
+                       &pkgpath, &value);
        tmp_args = (gchar **)g_variant_get_strv(value, &args_count);
 
        for (i = 0; i < args_count; i++)
@@ -318,6 +322,8 @@ static int __handle_request_install(uid_t caller_uid,
        }
 
        pkgtype = _get_pkgtype_from_file(pkgpath);
+       if (!pkgtype && arg_pkgtype)
+               pkgtype = (const char *)arg_pkgtype;
        if (pkgtype == NULL) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ECOMM, ""));
@@ -363,6 +369,7 @@ static int __handle_request_mount_install(uid_t caller_uid,
        GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
+       char *arg_pkgtype = NULL;
        const char *pkgtype;
        char *pkgpath = NULL;
        char *args = NULL;
@@ -374,7 +381,8 @@ static int __handle_request_mount_install(uid_t caller_uid,
        int i = 0;
        int len = 0;
 
-       g_variant_get(parameters, "(u&s@as)", &target_uid, &pkgpath, &value);
+       g_variant_get(parameters, "(u&s&s@as)", &target_uid, &arg_pkgtype,
+                       &pkgpath, &value);
        tmp_args = (gchar **)g_variant_get_strv(value, &args_count);
 
        for (i = 0; i < args_count; i++)
@@ -403,6 +411,8 @@ static int __handle_request_mount_install(uid_t caller_uid,
        }
 
        pkgtype = _get_pkgtype_from_file(pkgpath);
+       if (!pkgtype && arg_pkgtype)
+               pkgtype = (const char *)arg_pkgtype;
        if (pkgtype == NULL) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ECOMM, ""));