From: Hwankyu Jhun Date: Mon, 5 Dec 2016 08:53:11 +0000 (+0900) Subject: Add internal APIs for system daemon X-Git-Tag: accepted/tizen/3.0.m2/mobile/20170104.122233^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F60%2F102260%2F1;p=platform%2Fcore%2Fappfw%2Flibrua.git Add internal APIs for system daemon Change-Id: Ica3435c455bf09b173471a8b8386373d7ee7fbe2 Signed-off-by: Hwankyu Jhun --- diff --git a/include/rua_internal.h b/include/rua_internal.h index 6158faf..619c962 100644 --- a/include/rua_internal.h +++ b/include/rua_internal.h @@ -25,6 +25,8 @@ #ifndef __RUA_INTERNAL_H__ #define __RUA_INTERNAL_H__ +#include +#include #include #include #include @@ -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 } diff --git a/include/rua_stat_internal.h b/include/rua_stat_internal.h index 838ce1a..082a3ca 100644 --- a/include/rua_stat_internal.h +++ b/include/rua_stat_internal.h @@ -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 } diff --git a/src/rua_internal.c b/src/rua_internal.c index 903c2ba..1a0abd7 100644 --- a/src/rua_internal.c +++ b/src/rua_internal.c @@ -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; diff --git a/src/rua_stat_internal.c b/src/rua_stat_internal.c index 38c3a06..ee68dd1 100644 --- a/src/rua_stat_internal.c +++ b/src/rua_stat_internal.c @@ -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; diff --git a/src/rua_util.c b/src/rua_util.c index 067e299..a5895b9 100644 --- a/src/rua_util.c +++ b/src/rua_util.c @@ -69,6 +69,7 @@ int _rua_util_open_db(sqlite3 **db, int flags, uid_t uid, char *db_name) } free(db_path); + return r; }