summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/rua_db.sql9
-rw-r--r--include/db-schema.h14
-rwxr-xr-xinclude/rua.h2
-rw-r--r--packaging/librua.spec4
-rw-r--r--src/rua.c9
-rw-r--r--test/rua-test.c6
6 files changed, 16 insertions, 28 deletions
diff --git a/data/rua_db.sql b/data/rua_db.sql
deleted file mode 100644
index 4ae26ca..0000000
--- a/data/rua_db.sql
+++ /dev/null
@@ -1,9 +0,0 @@
-PRAGMA journal_mode = PERSIST;
-
-CREATE TABLE IF NOT EXISTS rua_history (
- id INTEGER PRIMARY KEY,
- pkg_name TEXT,
- app_path TEXT,
- arg TEXT,
- launch_time INTEGER
-);
diff --git a/include/db-schema.h b/include/db-schema.h
index f405aea..df05dbd 100644
--- a/include/db-schema.h
+++ b/include/db-schema.h
@@ -23,12 +23,14 @@
#define __RUA_SCHEMA_H__
#define CREATE_RUA_HISTORY_TABLE " \
-create table if not exists rua_history ( \
-id INTEGER PRIMARY KEY, \
-pkg_name TEXT, \
-app_path TEXT, \
-arg TEXT, \
-launch_time INTEGER \
+PRAGMA journal_mode = PERSIST; \
+\
+CREATE TABLE IF NOT EXISTS rua_history ( \
+ id INTEGER PRIMARY KEY, \
+ pkg_name TEXT, \
+ app_path TEXT, \
+ arg TEXT, \
+ launch_time INTEGER \
);"
/* table index */
diff --git a/include/rua.h b/include/rua.h
index 642e617..2bd8f51 100755
--- a/include/rua.h
+++ b/include/rua.h
@@ -20,7 +20,7 @@
*/
/**
- * @file rua.h
+ * @file rua.h
* @brief RUA API declaration header file.
* @author Jinwoo Nam (jwoo.nam@samsung.com)
* @version 0.1
diff --git a/packaging/librua.spec b/packaging/librua.spec
index b19b615..ca1c9e4 100644
--- a/packaging/librua.spec
+++ b/packaging/librua.spec
@@ -32,8 +32,6 @@ make %{?_smp_mflags}
%install
%make_install
-mkdir -p %{buildroot}%{TZ_SYS_DB}
-sqlite3 %{buildroot}%{TZ_SYS_DB}/.rua.db < data/rua_db.sql
%post -p /sbin/ldconfig
@@ -42,7 +40,6 @@ sqlite3 %{buildroot}%{TZ_SYS_DB}/.rua.db < data/rua_db.sql
%files
%manifest %{name}.manifest
%defattr(-,root,root,-)
-%config(noreplace) %attr(0660,root,%{TZ_SYS_USER_GROUP}) %{TZ_SYS_DB}/.rua.db*
%{_libdir}/librua.so.*
%license LICENSE
@@ -53,4 +50,3 @@ sqlite3 %{buildroot}%{TZ_SYS_DB}/.rua.db < data/rua_db.sql
%{_includedir}/rua/*.h
%{_libdir}/librua.so
%{_libdir}/pkgconfig/rua.pc
-
diff --git a/src/rua.c b/src/rua.c
index 9b5ef8b..1e70911 100644
--- a/src/rua.c
+++ b/src/rua.c
@@ -30,11 +30,13 @@
#include <db-util.h>
+/* For multi-user support */
+#include <tzplatform_config.h>
+
#include "rua.h"
#include "db-schema.h"
#include "perf-measure.h"
-#define RUA_DB_PATH "/opt/dbspace"
#define RUA_DB_NAME ".rua.db"
#define RUA_HISTORY "rua_history"
#define QUERY_MAXLEN 4096
@@ -281,7 +283,8 @@ int rua_init(void)
}
char defname[FILENAME_MAX];
- snprintf(defname, sizeof(defname), "%s/%s", RUA_DB_PATH, RUA_DB_NAME);
+ const char *rua_db_path = tzplatform_getenv(TZ_USER_DB);
+ snprintf(defname, sizeof(defname), "%s/%s", rua_db_path, RUA_DB_NAME);
_db = __db_init(defname);
if (_db == NULL)
@@ -340,7 +343,7 @@ static sqlite3 *__db_init(char *root)
int r;
sqlite3 *db = NULL;
- r = db_util_open(root, &db, 0);
+ r = db_util_open_with_options(root, &db, SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE, NULL);
if (r) {
db_util_close(db);
return NULL;
diff --git a/test/rua-test.c b/test/rua-test.c
index bcd6913..03a7032 100644
--- a/test/rua-test.c
+++ b/test/rua-test.c
@@ -34,9 +34,8 @@ int __add_history(char *pkgname)
{
int ret = 0;
struct rua_rec rec;
- char apppath[FILENAME_MAX] = "";
+ const char *apppath = tzplatform_mkpath(TZ_SYS_RW_APP, pkgname);
- apppath = tzplatform_mkpath(TZ_SYS_RW_APP, pkgname);
memset(&rec, 0, sizeof(rec));
rec.pkg_name = pkgname;
rec.app_path = apppath;
@@ -52,7 +51,6 @@ int __add_history(char *pkgname)
rua_fini();
return ret;
-
}
int main(int argc, char* argv[])
@@ -64,5 +62,3 @@ int main(int argc, char* argv[])
ret = __add_history(argv[1]);
return 0;
}
-
-