Add internal APIs for system daemon 60/102260/1 accepted/tizen_3.0.m2_mobile accepted/tizen_3.0.m2_tv accepted/tizen_3.0.m2_wearable tizen_3.0.m2 accepted/tizen/3.0.m2/mobile/20170104.122233 accepted/tizen/3.0.m2/tv/20170104.122636 accepted/tizen/3.0.m2/wearable/20170104.123007 accepted/tizen/3.0/common/20161222.075008 accepted/tizen/3.0/ivi/20161221.103940 accepted/tizen/3.0/mobile/20161221.103635 accepted/tizen/3.0/tv/20161221.103811 accepted/tizen/3.0/wearable/20161221.103921 accepted/tizen/common/20170109.202213 accepted/tizen/ivi/20170105.223137 accepted/tizen/mobile/20170105.223019 accepted/tizen/tv/20170105.223057 accepted/tizen/wearable/20170105.223116 submit/tizen/20170105.005252 submit/tizen_3.0.m2/20170104.093749 submit/tizen_3.0/20161221.012134
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 5 Dec 2016 08:53:11 +0000 (17:53 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 5 Dec 2016 08:53:11 +0000 (17:53 +0900)
Change-Id: Ica3435c455bf09b173471a8b8386373d7ee7fbe2
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/rua_internal.h
include/rua_stat_internal.h
src/rua_internal.c
src/rua_stat_internal.c
src/rua_util.c

index 6158faf..619c962 100644 (file)
@@ -25,6 +25,8 @@
 #ifndef __RUA_INTERNAL_H__
 #define __RUA_INTERNAL_H__
 
+#include <unistd.h>
+#include <sys/types.h>
 #include <sqlite3.h>
 #include <bundle.h>
 #include <time.h>
@@ -57,6 +59,7 @@ extern "C" {
  * @retval     -1 on failed
  */
 API int rua_db_delete_history(bundle *b);
+API int rua_usr_db_delete_history(bundle *b, uid_t uid);
 
 /**
  * @brief      Add application to recently used application list
@@ -66,6 +69,7 @@ API int rua_db_delete_history(bundle *b);
  * @retval     -1 on failed
  */
 API int rua_db_add_history(struct rua_rec *rec);
+API int rua_usr_db_add_history(struct rua_rec *rec, uid_t uid);
 
 #ifdef __cplusplus
 }
index 838ce1a..082a3ca 100644 (file)
@@ -57,6 +57,7 @@ int _rua_stat_init(sqlite3 **db, char *db_name, int flags, uid_t uid);
  * @retval     -1 on failed
  */
 API int rua_stat_db_update(char *caller, char *rua_stat_tag);
+API int rua_stat_usr_db_update(char *caller, char *rua_stat_tab, uid_t uid);
 
 #ifdef __cplusplus
 }
index 903c2ba..1a0abd7 100644 (file)
@@ -50,12 +50,13 @@ static int __create_table(sqlite3 *db)
        return 0;
 }
 
-static sqlite3 *__db_init()
+static sqlite3 *__db_init(uid_t uid)
 {
        int r;
        sqlite3 *db = NULL;
 
-       r = _rua_util_open_db(&db, SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE, getuid(), RUA_DB_NAME);
+       r = _rua_util_open_db(&db, SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE,
+                       uid, RUA_DB_NAME);
        if (r != SQLITE_OK)
                return NULL;
 
@@ -70,6 +71,11 @@ static sqlite3 *__db_init()
 
 int rua_db_delete_history(bundle *b)
 {
+       return rua_usr_db_delete_history(b, getuid());
+}
+
+int rua_usr_db_delete_history(bundle *b, uid_t uid)
+{
        int r;
        sqlite3 *db = NULL;
        char query[QUERY_MAXLEN];
@@ -78,7 +84,7 @@ int rua_db_delete_history(bundle *b)
        char *errmsg = NULL;
        int result = 0;
 
-       db = __db_init();
+       db = __db_init(uid);
        if (db == NULL) {
                LOGE("Error db null");
                return -1;
@@ -113,11 +119,16 @@ int rua_db_delete_history(bundle *b)
 
 int rua_db_add_history(struct rua_rec *rec)
 {
+       return rua_usr_db_add_history(rec, getuid());
+}
+
+int rua_usr_db_add_history(struct rua_rec *rec, uid_t uid)
+{
        int r;
        char query[QUERY_MAXLEN];
        sqlite3 *db = NULL;
 
-       db = __db_init();
+       db = __db_init(uid);
        if (db == NULL) {
                LOGE("Error db null");
                return -1;
index 38c3a06..ee68dd1 100644 (file)
@@ -190,6 +190,7 @@ static int __create_table(sqlite3 *db)
 int _rua_stat_init(sqlite3 **db, char *db_name, int flags, uid_t uid)
 {
        int r;
+
        r = _rua_util_open_db(db, flags, uid, db_name);
        r = __create_table(*db);
        if (r) {
@@ -206,13 +207,20 @@ int _rua_stat_init(sqlite3 **db, char *db_name, int flags, uid_t uid)
 
 int rua_stat_db_update(char *caller, char *rua_stat_tag)
 {
+       return rua_stat_usr_db_update(caller, rua_stat_tag, getuid());
+}
+
+int rua_stat_usr_db_update(char *caller, char *rua_stat_tag, uid_t uid)
+{
        int r;
        int affected_rows = 0;
        sqlite3 *db = NULL;
 
        LOGD("rua_stat_update start");
 
-       r = _rua_stat_init(&db, RUA_STAT_DB_NAME, SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE, getuid());
+       r = _rua_stat_init(&db, RUA_STAT_DB_NAME,
+                       SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE,
+                       uid);
        if (r == -1) {
                LOGE("__rua_stat_init fail");
                return -1;
index 067e299..a5895b9 100644 (file)
@@ -69,6 +69,7 @@ int _rua_util_open_db(sqlite3 **db, int flags, uid_t uid, char *db_name)
        }
 
        free(db_path);
+
        return r;
 }