Change the processing slot for cleardata/clearcache
[platform/core/appfw/pkgmgr-server.git] / src / request.c
index 0c3d41f..ee0bfae 100644 (file)
@@ -1077,6 +1077,7 @@ static int __handle_request_cleardata(uid_t caller_uid,
 {
        uid_t target_uid = (uid_t)-1;
        char *pkgid = NULL;
+       char *pkgtype;
 
        g_variant_get(parameters, "(u&s)", &target_uid, &pkgid);
        if (target_uid == (uid_t)-1 || pkgid == NULL) {
@@ -1085,8 +1086,15 @@ static int __handle_request_cleardata(uid_t caller_uid,
                return -1;
        }
 
+       pkgtype = _get_pkgtype_from_pkgid(pkgid, target_uid);
+       if (pkgtype == NULL) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(is)", PKGMGR_R_ENOPKG, ""));
+               return -1;
+       }
+
        if (_push_queue(target_uid, caller_uid, NULL, REQUEST_TYPE_CLEARDATA,
-                               "pkgtool", pkgid, NULL)) {
+                               pkgtype, pkgid, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(i)", PKGMGR_R_ESYSTEM));
                return -1;
@@ -1103,6 +1111,7 @@ static int __handle_request_clearcache(uid_t caller_uid,
 {
        uid_t target_uid = (uid_t)-1;
        char *pkgid = NULL;
+       char *pkgtype;
 
        g_variant_get(parameters, "(u&s)", &target_uid, &pkgid);
        if (target_uid == (uid_t)-1 || pkgid == NULL) {
@@ -1111,8 +1120,18 @@ static int __handle_request_clearcache(uid_t caller_uid,
                return -1;
        }
 
+       if (strcmp(PKG_CLEAR_ALL_CACHE, pkgid) == 0)
+               pkgtype = strdup("pkgtool");
+       else
+               pkgtype = _get_pkgtype_from_pkgid(pkgid, target_uid);
+       if (pkgtype == NULL) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(is)", PKGMGR_R_ENOPKG, ""));
+               return -1;
+       }
+
        if (_push_queue(target_uid, caller_uid, NULL, REQUEST_TYPE_CLEARCACHE,
-                               "pkgtool",  pkgid, NULL)) {
+                               pkgtype,  pkgid, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(i)", PKGMGR_R_ESYSTEM));
                return -1;