summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKévin THIERRY <kevin.thierry@open.eurogiciel.org>2014-03-13 13:28:48 +0100
committerKévin THIERRY <kevin.thierry@open.eurogiciel.org>2014-03-13 15:33:07 +0100
commitd89321911038079248de90043b93121d30221033 (patch)
tree4b69e9e1aa8ba3197f812e314cd40a58197184b9 /src
parentcc94b25aa675fc061d456568f60fe56d536a540f (diff)
downloadlibrua-d89321911038079248de90043b93121d30221033.tar.gz
librua-d89321911038079248de90043b93121d30221033.tar.bz2
librua-d89321911038079248de90043b93121d30221033.zip
Create a per user DB instead of a global DB
To fully support the multi-user architecture every user needs to have its own DB since, in the case of librua, a global (system) DB doesn't make much sense. Bug-Tizen: PTREL-339 Change-Id: Id7c5ab27748cfe60cb998a956f06d5280fe1fe50 Signed-off-by: Kévin THIERRY <kevin.thierry@open.eurogiciel.org>
Diffstat (limited to 'src')
-rw-r--r--src/rua.c9
1 files changed, 6 insertions, 3 deletions
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;