From 09f70f3b89ec8f42249f5fc66f813fec52c3011f Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Mon, 28 Nov 2016 21:02:27 +0900 Subject: [PATCH] Add request type and codes for set app label Related changes: [slp-pkgmgr] : https://review.tizen.org/gerrit/100579 Change-Id: Ib2b395db143d6230817884c922e09c37f7289b38 Signed-off-by: Junghyun Yeon --- include/pkgmgr-server.h | 1 + src/pkgmgr-server.c | 15 +++++++++++++++ src/request.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) diff --git a/include/pkgmgr-server.h b/include/pkgmgr-server.h index 895c9bd..210a8a4 100644 --- a/include/pkgmgr-server.h +++ b/include/pkgmgr-server.h @@ -77,6 +77,7 @@ enum request_type { REQUEST_TYPE_SET_RESTRICTION_MODE, REQUEST_TYPE_UNSET_RESTRICTION_MODE, REQUEST_TYPE_GET_RESTRICTION_MODE, + REQUEST_TYPE_SET_APP_LABEL, }; gboolean queue_job(void *data); diff --git a/src/pkgmgr-server.c b/src/pkgmgr-server.c index e4c312f..04a80ca 100644 --- a/src/pkgmgr-server.c +++ b/src/pkgmgr-server.c @@ -1260,6 +1260,18 @@ static int __process_get_restriction_mode(struct backend_job *job) return ret; } +static int __process_set_app_label(struct backend_job *job) +{ + int ret; + int mode = -1; + + ret = pkgmgr_parser_update_app_label_info_in_usr_db(job->pkgid, job->appid, + job->args); + _return_value_to_caller(job->req_id, g_variant_new("(i)", ret)); + + return ret; +} + gboolean queue_job(void *data) { struct backend_job *job = NULL; @@ -1416,6 +1428,9 @@ gboolean queue_job(void *data) ret = __process_get_restriction_mode(job); _free_backend_job(job); break; + case REQUEST_TYPE_SET_APP_LABEL: + ret = __process_set_app_label(job); + _free_backend_job(job); default: ret = -1; break; diff --git a/src/request.c b/src/request.c index 3269b24..1213bc9 100644 --- a/src/request.c +++ b/src/request.c @@ -160,6 +160,12 @@ static const char instropection_xml[] = " " " " " " + " " + " " + " " + " " + " " + " " " " ""; static GDBusNodeInfo *instropection_data; @@ -1331,6 +1337,44 @@ static int __handle_request_get_restriction_mode(uid_t caller_uid, return 0; } +static int __handle_request_set_app_label(uid_t uid, + GDBusMethodInvocation *invocation, GVariant *parameters) +{ + uid_t target_uid = (uid_t)-1; + char *appid = NULL; + char *label = NULL; + char *reqkey; + + g_variant_get(parameters, "(uss)", &target_uid, &appid, &label); + if (target_uid == (uid_t)-1 || appid == NULL || label == NULL) { + g_dbus_method_invocation_return_value(invocation, + g_variant_new("(i)", PKGMGR_R_ECOMM)); + return -1; + } + + reqkey = __generate_reqkey("appid"); + if (reqkey == NULL) { + g_dbus_method_invocation_return_value(invocation, + g_variant_new("(i)", PKGMGR_R_ENOMEM)); + return -1; + } + + if (_push_queue(target_uid, reqkey, + REQUEST_TYPE_SET_APP_LABEL, + "default", appid, label)) { + g_dbus_method_invocation_return_value(invocation, + g_variant_new("(i)", PKGMGR_R_ESYSTEM)); + free(reqkey); + return -1; + } + + if (!g_hash_table_insert(req_table, (gpointer)reqkey, + (gpointer)invocation)) + ERR("reqkey already exists"); + + return 0; +} + static uid_t __get_caller_uid(GDBusConnection *connection, const char *name) { GError *err = NULL; @@ -1429,6 +1473,8 @@ static void __handle_method_call(GDBusConnection *connection, else if (g_strcmp0(method_name, "get_restriction_mode") == 0) ret = __handle_request_get_restriction_mode(uid, invocation, parameters); + else if (g_strcmp0(method_name, "set_app_label") == 0) + ret = __handle_request_set_app_label(uid, invocation, parameters); else ret = -1; -- 2.7.4