Add new feature to change app's icon
[platform/core/appfw/pkgmgr-server.git] / src / request.c
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);