Add new feature to change app's icon 32/140332/4
authorjongmyeongko <jongmyeong.ko@samsung.com>
Mon, 24 Jul 2017 13:15:22 +0000 (22:15 +0900)
committerjongmyeong ko <jongmyeong.ko@samsung.com>
Tue, 8 Aug 2017 11:25:48 +0000 (11:25 +0000)
Change-Id: Ibd95433998584de550a42fffc294fc9978cd92ff
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
include/pkgmgr-server.h
org.tizen.pkgmgr.conf
src/pkgmgr-server.c
src/request.c

index 488fb3a..b67d817 100644 (file)
@@ -84,6 +84,7 @@ enum request_type {
        REQUEST_TYPE_UNSET_RESTRICTION_MODE,
        REQUEST_TYPE_GET_RESTRICTION_MODE,
        REQUEST_TYPE_SET_APP_LABEL,
+       REQUEST_TYPE_SET_APP_ICON,
        REQUEST_TYPE_MIGRATE_EXTERNAL_IMAGE,
 };
 
index 2966566..51df132 100644 (file)
@@ -48,5 +48,6 @@
                <check send_destination="org.tizen.pkgmgr" send_interface="org.tizen.pkgmgr" send_member="unregister_pkg_updateinfo" privilege="http://tizen.org/privilege/packagemanager.admin"/>
                <check send_destination="org.tizen.pkgmgr" send_interface="org.tizen.pkgmgr" send_member="unregister_all_pkg_updateinfo" privilege="http://tizen.org/privilege/packagemanager.admin"/>
                <check send_destination="org.tizen.pkgmgr" send_interface="org.tizen.pkgmgr" send_member="set_app_label" privilege="http://tizen.org/privilege/packagemanager.admin"/>
+               <check send_destination="org.tizen.pkgmgr" send_interface="org.tizen.pkgmgr" send_member="set_app_icon" privilege="http://tizen.org/privilege/packagemanager.admin"/>
        </policy>
 </busconfig>
index 480b341..d99a76e 100644 (file)
@@ -1772,6 +1772,17 @@ static int __process_set_app_label(struct backend_job *job)
        return ret;
 }
 
+static int __process_set_app_icon(struct backend_job *job)
+{
+       int ret;
+
+       ret = pkgmgr_parser_update_app_icon_info_in_usr_db(job->pkgid,
+                       job->target_uid, job->args);
+       _return_value_to_caller(job->req_id, g_variant_new("(i)", ret));
+
+       return ret;
+}
+
 static int __process_migrate_external_image(struct backend_job *job)
 {
        char *backend_cmd;
@@ -1988,6 +1999,10 @@ gboolean queue_job(void *data)
                ret = __process_set_app_label(job);
                _free_backend_job(job);
                break;
+       case REQUEST_TYPE_SET_APP_ICON:
+               ret = __process_set_app_icon(job);
+               _free_backend_job(job);
+               break;
        case REQUEST_TYPE_MIGRATE_EXTERNAL_IMAGE:
                __set_backend_busy(x);
                __set_power_lock();
index f68a4e2..7bb0346 100644 (file)
@@ -200,6 +200,12 @@ static const char instropection_xml[] =
        "      <arg type='s' name='label' direction='in'/>"
        "      <arg type='i' name='ret' direction='out'/>"
        "    </method>"
+       "    <method name='set_app_icon'>"
+       "      <arg type='u' name='uid' direction='in'/>"
+       "      <arg type='s' name='appid' direction='in'/>"
+       "      <arg type='s' name='icon_path' direction='in'/>"
+       "      <arg type='i' name='ret' direction='out'/>"
+       "    </method>"
        "    <method name='migrate_external_image'>"
        "      <arg type='u' name='uid' direction='in'/>"
        "      <arg type='s' name='pkgid' direction='in'/>"
@@ -1709,6 +1715,44 @@ static int __handle_request_set_app_label(uid_t uid,
        return 0;
 }
 
+static int __handle_request_set_app_icon(uid_t uid,
+               GDBusMethodInvocation *invocation, GVariant *parameters)
+{
+       uid_t target_uid = (uid_t)-1;
+       char *appid = NULL;
+       char *icon_path = NULL;
+       char *reqkey;
+
+       g_variant_get(parameters, "(uss)", &target_uid, &appid, &icon_path);
+       if (target_uid == (uid_t)-1 || appid == NULL || icon_path == NULL) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_ECOMM));
+               return -1;
+       }
+
+       reqkey = __generate_reqkey("app_icon");
+       if (reqkey == NULL) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_ENOMEM));
+               return -1;
+       }
+
+       if (_push_queue(target_uid, uid, reqkey,
+                               REQUEST_TYPE_SET_APP_ICON,
+                               "default", appid, icon_path, NULL)) {
+               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 int __handle_request_migrate_external_image(uid_t uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
@@ -1871,6 +1915,8 @@ static void __handle_method_call(GDBusConnection *connection,
                                parameters);
        else if (g_strcmp0(method_name, "set_app_label") == 0)
                ret = __handle_request_set_app_label(uid, invocation, parameters);
+       else if (g_strcmp0(method_name, "set_app_icon") == 0)
+               ret = __handle_request_set_app_icon(uid, invocation, parameters);
        else if (g_strcmp0(method_name, "migrate_external_image") == 0)
                ret = __handle_request_migrate_external_image(uid, invocation,
                                parameters);