Fix to disable/enable multiple packages 40/95640/1
authorSangyoon Jang <s89.jang@samsung.com>
Fri, 4 Nov 2016 06:00:44 +0000 (15:00 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Fri, 4 Nov 2016 06:00:44 +0000 (15:00 +0900)
Submit together:
 - https://review.tizen.org/gerrit/95565

Change-Id: Ib44668d5025b74414aa58ec9a9650a43540c03a2
Signed-off-by: Sangyoon Jang <s89.jang@samsung.com>
org.tizen.pkgmgr.conf
src/request.c

index 9d799ca..e94bf6c 100644 (file)
@@ -36,8 +36,8 @@
                <check send_destination="org.tizen.pkgmgr" send_interface="org.tizen.pkgmgr" send_member="check_blacklist" privilege="http://tizen.org/privilege/packagemanager.admin"/>
                <check send_destination="org.tizen.pkgmgr" send_interface="org.tizen.pkgmgr" send_member="enable_app_splash_screen" privilege="http://tizen.org/privilege/packagemanager.admin"/>
                <check send_destination="org.tizen.pkgmgr" send_interface="org.tizen.pkgmgr" send_member="disable_app_splash_screen" privilege="http://tizen.org/privilege/packagemanager.admin"/>
-               <check send_destination="org.tizen.pkgmgr" send_interface="org.tizen.pkgmgr" send_member="enable_pkg" privilege="http://tizen.org/privilege/packagemanager.admin"/>
-               <check send_destination="org.tizen.pkgmgr" send_interface="org.tizen.pkgmgr" send_member="disable_pkg" privilege="http://tizen.org/privilege/packagemanager.admin"/>
+               <check send_destination="org.tizen.pkgmgr" send_interface="org.tizen.pkgmgr" send_member="enable_pkgs" privilege="http://tizen.org/privilege/packagemanager.admin"/>
+               <check send_destination="org.tizen.pkgmgr" send_interface="org.tizen.pkgmgr" send_member="disable_pkgs" privilege="http://tizen.org/privilege/packagemanager.admin"/>
                <check send_destination="org.tizen.pkgmgr" send_interface="org.tizen.pkgmgr" send_member="enable_app" privilege="http://tizen.org/privilege/packagemanager.admin"/>
                <check send_destination="org.tizen.pkgmgr" send_interface="org.tizen.pkgmgr" send_member="disable_app" privilege="http://tizen.org/privilege/packagemanager.admin"/>
                <check send_destination="org.tizen.pkgmgr" send_interface="org.tizen.pkgmgr" send_member="enable_global_app_for_uid" privilege="http://tizen.org/privilege/packagemanager.admin"/>
index a9385b8..3ae16c7 100644 (file)
@@ -55,16 +55,16 @@ static const char instropection_xml[] =
        "      <arg type='i' name='ret' direction='out'/>"
        "      <arg type='s' name='reqkey' direction='out'/>"
        "    </method>"
-       "    <method name='enable_pkg'>"
+       "    <method name='enable_pkgs'>"
        "      <arg type='u' name='uid' direction='in'/>"
        "      <arg type='s' name='pkgtype' direction='in'/>"
-       "      <arg type='s' name='pkgid' direction='in'/>"
+       "      <arg type='as' name='pkgids' direction='in'/>"
        "      <arg type='i' name='ret' direction='out'/>"
        "    </method>"
-       "    <method name='disable_pkg'>"
+       "    <method name='disable_pkgs'>"
        "      <arg type='u' name='uid' direction='in'/>"
        "      <arg type='s' name='pkgtype' direction='in'/>"
-       "      <arg type='s' name='pkgid' direction='in'/>"
+       "      <arg type='as' name='pkgids' direction='in'/>"
        "      <arg type='i' name='ret' direction='out'/>"
        "    </method>"
        "    <method name='enable_app'>"
@@ -534,76 +534,86 @@ static int __handle_request_move(uid_t uid,
        return 0;
 }
 
-static int __handle_request_enable_pkg(uid_t uid,
+static int __handle_request_enable_pkgs(uid_t uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
        char *pkgtype = NULL;
        char *pkgid = NULL;
        char *reqkey = NULL;
+       GVariantIter *iter;
 
-       g_variant_get(parameters, "(u&s&s)", &target_uid, &pkgtype, &pkgid);
-       if (target_uid == (uid_t)-1 || pkgid == NULL) {
+       g_variant_get(parameters, "(u&sas)", &target_uid, &pkgtype, &iter);
+       if (target_uid == (uid_t)-1 || pkgtype == NULL || iter == NULL) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(i)", PKGMGR_R_ECOMM));
                return -1;
        }
 
-       reqkey = __generate_reqkey(pkgid);
-       if (reqkey == NULL) {
-               g_dbus_method_invocation_return_value(invocation,
-                               g_variant_new("(i)", PKGMGR_R_ENOMEM));
-               return -1;
-       }
+       while (g_variant_iter_loop(iter, "&s", &pkgid)) {
+               reqkey = __generate_reqkey(pkgid);
+               if (reqkey == NULL) {
+                       g_dbus_method_invocation_return_value(invocation,
+                                       g_variant_new("(i)", PKGMGR_R_ENOMEM));
+                       return -1;
+               }
+
+               if (_pm_queue_push(target_uid, reqkey,
+                                       PKGMGR_REQUEST_TYPE_ENABLE_PKG,
+                                       pkgtype, pkgid, "")) {
+                       g_dbus_method_invocation_return_value(invocation,
+                                       g_variant_new("(i)", PKGMGR_R_ESYSTEM));
+                       free(reqkey);
+                       return -1;
+               }
 
-       if (_pm_queue_push(target_uid, reqkey, PKGMGR_REQUEST_TYPE_ENABLE_PKG, pkgtype,
-                               pkgid, "")) {
-               g_dbus_method_invocation_return_value(invocation,
-                               g_variant_new("(i)", PKGMGR_R_ESYSTEM));
                free(reqkey);
-               return -1;
        }
 
        g_dbus_method_invocation_return_value(invocation,
                        g_variant_new("(i)", PKGMGR_R_OK));
-       free(reqkey);
 
        return 0;
 }
 
-static int __handle_request_disable_pkg(uid_t uid,
+static int __handle_request_disable_pkgs(uid_t uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
        char *pkgtype = NULL;
        char *pkgid = NULL;
        char *reqkey = NULL;
+       GVariantIter *iter;
 
-       g_variant_get(parameters, "(u&s&s)", &target_uid, &pkgtype, &pkgid);
-       if (target_uid == (uid_t)-1 || pkgid == NULL) {
+       g_variant_get(parameters, "(u&sas)", &target_uid, &pkgtype, &iter);
+       if (target_uid == (uid_t)-1 || pkgtype == NULL || iter == NULL) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(i)", PKGMGR_R_ECOMM));
                return -1;
        }
 
-       reqkey = __generate_reqkey(pkgid);
-       if (reqkey == NULL) {
-               g_dbus_method_invocation_return_value(invocation,
-                               g_variant_new("(i)", PKGMGR_R_ENOMEM));
-               return -1;
-       }
+       while (g_variant_iter_loop(iter, "&s", &pkgid)) {
+               reqkey = __generate_reqkey(pkgid);
+               if (reqkey == NULL) {
+                       g_dbus_method_invocation_return_value(invocation,
+                                       g_variant_new("(i)", PKGMGR_R_ENOMEM));
+                       return -1;
+               }
+
+               if (_pm_queue_push(target_uid, reqkey,
+                                       PKGMGR_REQUEST_TYPE_DISABLE_PKG,
+                                       pkgtype, pkgid, "")) {
+                       g_dbus_method_invocation_return_value(invocation,
+                                       g_variant_new("(i)", PKGMGR_R_ESYSTEM));
+                       free(reqkey);
+                       return -1;
+               }
 
-       if (_pm_queue_push(target_uid, reqkey, PKGMGR_REQUEST_TYPE_DISABLE_PKG, pkgtype,
-                               pkgid, "")) {
-               g_dbus_method_invocation_return_value(invocation,
-                               g_variant_new("(i)", PKGMGR_R_ESYSTEM));
                free(reqkey);
-               return -1;
        }
 
        g_dbus_method_invocation_return_value(invocation,
                        g_variant_new("(i)", PKGMGR_R_OK));
-       free(reqkey);
 
        return 0;
 }
@@ -1289,10 +1299,10 @@ static void __handle_method_call(GDBusConnection *connection,
                ret = __handle_request_cleardata(uid, invocation, parameters);
        else if (g_strcmp0(method_name, "move") == 0)
                ret = __handle_request_move(uid, invocation, parameters);
-       else if (g_strcmp0(method_name, "enable_pkg") == 0)
-               ret = __handle_request_enable_pkg(uid, invocation, parameters);
-       else if (g_strcmp0(method_name, "disable_pkg") == 0)
-               ret = __handle_request_disable_pkg(uid, invocation, parameters);
+       else if (g_strcmp0(method_name, "enable_pkgs") == 0)
+               ret = __handle_request_enable_pkgs(uid, invocation, parameters);
+       else if (g_strcmp0(method_name, "disable_pkgs") == 0)
+               ret = __handle_request_disable_pkgs(uid, invocation, parameters);
        else if (g_strcmp0(method_name, "getsize") == 0)
                ret = __handle_request_getsize(uid, invocation, parameters);
        else if (g_strcmp0(method_name, "clearcache") == 0)