From f103069e3d58dfbbd45afb38983cf80c9a692327 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Wed, 22 Feb 2017 14:35:30 +0900 Subject: [PATCH] Add enable/disable apps - Add handling enable/disable apps Related changes : [slp-pkgmgr] : https://review.tizen.org/gerrit/115926 Change-Id: Ib1ffaaeca75dc2a3d49939c43259b67e33d45d19 Signed-off-by: Junghyun Yeon --- src/request.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/src/request.c b/src/request.c index b3f9164..cfa9ac4 100644 --- a/src/request.c +++ b/src/request.c @@ -78,6 +78,18 @@ static const char instropection_xml[] = " " " " " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " " " " " " " @@ -713,6 +725,91 @@ static int __handle_request_disable_pkgs(uid_t caller_uid, return 0; } +static int __handle_request_enable_apps(uid_t caller_uid, + GDBusMethodInvocation *invocation, GVariant *parameters) +{ + uid_t target_uid = (uid_t)-1; + char *appid; + char *reqkey; + char buf[MAX_PKG_ARGS_LEN]; + GVariantIter *iter; + + g_variant_get(parameters, "(uas)", &target_uid, &iter); + if (target_uid == (uid_t)-1 || iter == NULL) { + g_dbus_method_invocation_return_value(invocation, + g_variant_new("(is)", PKGMGR_R_ECOMM, "")); + return -1; + } + + reqkey = __generate_reqkey("enable_apps"); + if (reqkey == NULL) { + g_dbus_method_invocation_return_value(invocation, + g_variant_new("(is)", PKGMGR_R_ENOMEM, "")); + return -1; + } + + while (g_variant_iter_next(iter, "&s", &appid)) { + if (_push_queue(target_uid, caller_uid, reqkey, + REQUEST_TYPE_ENABLE_APP, + "default", appid, buf)) { + g_dbus_method_invocation_return_value(invocation, + g_variant_new("(is)", + PKGMGR_R_ESYSTEM, "")); + free(reqkey); + return -1; + } + } + + g_dbus_method_invocation_return_value(invocation, + g_variant_new("(is)", PKGMGR_R_OK, reqkey)); + + free(reqkey); + return 0; +} + +static int __handle_request_disable_apps(uid_t caller_uid, + GDBusMethodInvocation *invocation, GVariant *parameters) +{ + uid_t target_uid = (uid_t)-1; + char *appid; + char *reqkey; + char buf[MAX_PKG_ARGS_LEN]; + GVariantIter *iter; + + g_variant_get(parameters, "(uas)", &target_uid, &iter); + if (target_uid == (uid_t)-1 || iter == NULL) { + g_dbus_method_invocation_return_value(invocation, + g_variant_new("(is)", PKGMGR_R_ECOMM, "")); + return -1; + } + + reqkey = __generate_reqkey("disable_apps"); + if (reqkey == NULL) { + g_dbus_method_invocation_return_value(invocation, + g_variant_new("(is)", PKGMGR_R_ENOMEM, "")); + return -1; + } + + while (g_variant_iter_next(iter, "&s", &appid)) { + if (_push_queue(target_uid, caller_uid, reqkey, + REQUEST_TYPE_DISABLE_APP, + "default", appid, buf)) { + g_dbus_method_invocation_return_value(invocation, + g_variant_new("(is)", + PKGMGR_R_ESYSTEM, "")); + free(reqkey); + return -1; + } + } + + g_dbus_method_invocation_return_value(invocation, + g_variant_new("(is)", PKGMGR_R_OK, reqkey)); + + free(reqkey); + return 0; + +} + static int __handle_request_enable_app(uid_t caller_uid, GDBusMethodInvocation *invocation, GVariant *parameters) { @@ -1531,6 +1628,10 @@ static void __handle_method_call(GDBusConnection *connection, ret = __handle_request_enable_app(uid, invocation, parameters); else if (g_strcmp0(method_name, "disable_app") == 0) ret = __handle_request_disable_app(uid, invocation, parameters); + else if (g_strcmp0(method_name, "enable_apps") == 0) + ret = __handle_request_enable_apps(uid, invocation, parameters); + else if (g_strcmp0(method_name, "disable_apps") == 0) + ret = __handle_request_disable_apps(uid, invocation, parameters); else if (g_strcmp0(method_name, "enable_global_app_for_uid") == 0) ret = __handle_request_enable_global_app_for_uid(uid, invocation, parameters); -- 2.7.4