#ifndef __RUA_INTERNAL_H__
#define __RUA_INTERNAL_H__
+#include <unistd.h>
+#include <sys/types.h>
#include <sqlite3.h>
#include <bundle.h>
#include <time.h>
* @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
* @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
}
* @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
}
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;
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];
char *errmsg = NULL;
int result = 0;
- db = __db_init();
+ db = __db_init(uid);
if (db == NULL) {
LOGE("Error db null");
return -1;
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;
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) {
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;
}
free(db_path);
+
return r;
}