Add delete rua history feature 70/54070/15
authorhyunho kang <hhstark.kang@samsung.com>
Fri, 11 Dec 2015 07:12:02 +0000 (16:12 +0900)
committerHyunho Kang <hhstark.kang@samsung.com>
Fri, 18 Dec 2015 02:05:59 +0000 (11:05 +0900)
To resolve librua APIs permission problem,
provide indirect DB access method to librua.

Change-Id: Iffa94fd9da1331f464ae1ff0b3fa6666fc09a90b
Signed-off-by: hyunho kang <hhstark.kang@samsung.com>
am_daemon/amd_request.c
include/app_sock.h
include/aul.h
src/app_sock.c
src/pkginfo.c
src/service.c

index f1a788e..a9722ab 100644 (file)
@@ -625,6 +625,21 @@ err_out:
        return -1;
 }
 
+static int __dispatch_remove_history(int clifd, const app_pkt_t *pkt, struct ucred *cr)
+{
+/*
+       int result = 0;
+       bundle *b = NULL;
+       b = bundle_decode(pkt->data, pkt->len);
+       result = rua_delete_history_from_db(b);
+       bundle_free(b);
+
+       __send_result_data(clifd, APP_REMOVE_HISTORY,
+                       (unsigned char *)&result, sizeof(int));
+*/
+       return 0;
+}
+
 static int __dispatch_app_group_get_window(int clifd, const app_pkt_t *pkt, struct ucred *cr)
 {
        bundle *b;
@@ -1141,6 +1156,7 @@ static app_cmd_dispatch_func dispatch_table[APP_CMD_MAX] = {
        [APP_CANCEL] = __dispatch_app_result,
        [APP_KILL_BY_PID] = __dispatch_app_term,
        [APP_ADD_HISTORY] = NULL,
+       [APP_REMOVE_HISTORY] = __dispatch_remove_history,
        [APP_RUNNING_INFO] = __dispatch_app_running_info,
        [APP_RUNNING_INFO_RESULT] = NULL,
        [APP_IS_RUNNING] = __dispatch_app_is_running,
index 1bedcfd..0a0065c 100644 (file)
@@ -40,6 +40,7 @@ enum app_cmd {
        APP_CANCEL,
        APP_KILL_BY_PID,
        APP_ADD_HISTORY,
+       APP_REMOVE_HISTORY,
        APP_RUNNING_INFO,
        APP_RUNNING_INFO_RESULT,
        APP_IS_RUNNING,
index 0176d76..0ff2c5e 100644 (file)
@@ -113,6 +113,11 @@ typedef enum _aul_type{
 /** AUL public key - To support rua stat */
 #define AUL_SVC_K_RUA_STAT_CALLER "__K_RUA_STAT_CALLER__"
 #define AUL_SVC_K_RUA_STAT_TAG    "__K_RUA_STAT_TAG__"
+/** AUL public key - To support rua delete */
+#define AUL_K_RUA_PKGNAME "__K_RUA_PKGNAME"
+/** AUL public key - To support rua delete */
+#define AUL_K_RUA_APPPATH "__K_RUA_APPPATH"
+
 
 
 /** AUL internal private key */
@@ -1966,6 +1971,37 @@ int aul_remove_loader(int loader_id);
  */
 int aul_app_get_pid(const char *appid);
 
+
+/**
+ * @par Description:
+ * This function delete rua history.
+ *
+ * @param[in] b Bundle object Target Package name or app path. If NULL or has no value, delete all rua history.
+ *
+ * @return 0 if success, negative value(<0) if fail
+ * @see None
+ * @remarks This API is only for Appfw internally.
+ *
+ * @par Sample code:
+ * @code
+#include <aul.h>
+
+...
+{
+    int r;
+    bundle *b = bundle_create();
+    if (pkg_name)
+        bundle_add_str(b, AUL_K_RUA_PKGNAME, pkg_name);
+    else if (app_path)
+        bundle_add_str(b, AUL_K_RUA_APPPATH, app_path);
+
+    r = aul_delete_rua_history(b);
+}
+
+ * @endcode
+ **/
+int aul_delete_rua_history(bundle *b);
+
 #ifdef __cplusplus
        }
 #endif
index a0862b5..0297492 100644 (file)
@@ -909,7 +909,8 @@ app_pkt_t *__app_send_cmd_with_result_for_uid(int pid, uid_t uid, int cmd, unsig
        }
        pkt->cmd = cmd;
        pkt->len = datalen;
-       memcpy(pkt->data, kb_data, pkt->len);
+       if (kb_data)
+               memcpy(pkt->data, kb_data, pkt->len);
 
        while (sent != AUL_PKT_HEADER_SIZE + pkt->len) {
                len = send(fd, pkt, AUL_PKT_HEADER_SIZE + pkt->len - sent, 0);
index fc6ea6a..82d8e35 100644 (file)
@@ -255,3 +255,31 @@ SLPAPI int aul_app_get_pkgid_bypid(int pid, char *pkgid, int len)
        return aul_app_get_pkgid_bypid_for_uid(pid, pkgid, len, getuid());
 }
 
+SLPAPI int aul_delete_rua_history(bundle *b)
+{
+       app_pkt_t *ret = NULL;
+       bundle_raw *br = NULL;
+       int datalen = 0;
+       int result = 0;
+
+       /* b can be NULL if b is NULL delete all rua history */
+       if (b != NULL)
+               bundle_encode(b, &br, &datalen);
+
+       ret = __app_send_cmd_with_result(AUL_UTIL_PID, APP_REMOVE_HISTORY, br,
+                       datalen);
+
+       if (ret != NULL) {
+               if (ret->len > 0) {
+                       memcpy(&result, ret->data, ret->len);
+               } else {
+                       if (br != NULL)
+                               free(br);
+                       return -1;
+               }
+       }
+       if (br != NULL)
+               free(br);
+       return result;
+}
+
index c7b9cc1..73d9d14 100755 (executable)
@@ -31,6 +31,7 @@
 #include "aul.h"
 #include "aul_api.h"
 #include "aul_svc.h"
+#include "app_sock.h"
 #include "aul_svc_db.h"
 #include "simple_util.h"
 #include "aul_svc_priv_key.h"