summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2016-12-05 17:53:11 +0900
committerHwankyu Jhun <h.jhun@samsung.com>2016-12-05 17:53:11 +0900
commitab9c9a8657c7b84fbb447099056d87799f65666b (patch)
treed1a7c8adfb5af4643fbb8d5ee0d2c7423c892c27
parent6b18ee25061f9f909cc45340b038cbbc833c6f93 (diff)
downloadlibrua-ab9c9a8657c7b84fbb447099056d87799f65666b.tar.gz
librua-ab9c9a8657c7b84fbb447099056d87799f65666b.tar.bz2
librua-ab9c9a8657c7b84fbb447099056d87799f65666b.zip
Change-Id: Ica3435c455bf09b173471a8b8386373d7ee7fbe2 Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r--include/rua_internal.h4
-rw-r--r--include/rua_stat_internal.h1
-rw-r--r--src/rua_internal.c19
-rw-r--r--src/rua_stat_internal.c10
-rw-r--r--src/rua_util.c1
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;
}