diff options
author | Hwankyu Jhun <h.jhun@samsung.com> | 2016-12-05 17:53:11 +0900 |
---|---|---|
committer | Hwankyu Jhun <h.jhun@samsung.com> | 2016-12-05 17:53:11 +0900 |
commit | ab9c9a8657c7b84fbb447099056d87799f65666b (patch) | |
tree | d1a7c8adfb5af4643fbb8d5ee0d2c7423c892c27 | |
parent | 6b18ee25061f9f909cc45340b038cbbc833c6f93 (diff) | |
download | librua-ab9c9a8657c7b84fbb447099056d87799f65666b.tar.gz librua-ab9c9a8657c7b84fbb447099056d87799f65666b.tar.bz2 librua-ab9c9a8657c7b84fbb447099056d87799f65666b.zip |
Add internal APIs for system daemonsubmit/tizen_3.0/20161221.012134submit/tizen_3.0.m2/20170104.093749submit/tizen/20170105.005252accepted/tizen/wearable/20170105.223116accepted/tizen/tv/20170105.223057accepted/tizen/mobile/20170105.223019accepted/tizen/ivi/20170105.223137accepted/tizen/common/20170109.202213accepted/tizen/3.0/wearable/20161221.103921accepted/tizen/3.0/tv/20161221.103811accepted/tizen/3.0/mobile/20161221.103635accepted/tizen/3.0/ivi/20161221.103940accepted/tizen/3.0/common/20161222.075008accepted/tizen/3.0.m2/wearable/20170104.123007accepted/tizen/3.0.m2/tv/20170104.122636accepted/tizen/3.0.m2/mobile/20170104.122233tizen_3.0.m2accepted/tizen_3.0.m2_wearableaccepted/tizen_3.0.m2_tvaccepted/tizen_3.0.m2_mobile
Change-Id: Ica3435c455bf09b173471a8b8386373d7ee7fbe2
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r-- | include/rua_internal.h | 4 | ||||
-rw-r--r-- | include/rua_stat_internal.h | 1 | ||||
-rw-r--r-- | src/rua_internal.c | 19 | ||||
-rw-r--r-- | src/rua_stat_internal.c | 10 | ||||
-rw-r--r-- | src/rua_util.c | 1 |
5 files changed, 30 insertions, 5 deletions
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 <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 } 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; } |