Change journal mode (persist to wal) 52/65052/3 accepted/tizen/common/20160408.185141 accepted/tizen/ivi/20160408.104800 accepted/tizen/mobile/20160408.104707 accepted/tizen/tv/20160408.104721 accepted/tizen/wearable/20160408.104745 submit/tizen/20160408.060851
authorMinje Ahn <minje.ahn@samsung.com>
Thu, 7 Apr 2016 05:38:14 +0000 (14:38 +0900)
committerMinje ahn <minje.ahn@samsung.com>
Thu, 7 Apr 2016 05:56:08 +0000 (22:56 -0700)
Change-Id: I9c1eee2ddf1cacdc33a51311021b1469c60af69b
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
include/media_controller_db.h
packaging/media-controller_create_db.sh
src/media_controller_client.c
src/media_controller_db.c
src/media_controller_server.c
svc/media_controller_db_util.c
svc/media_controller_db_util.h
svc/media_controller_svc.c

index 87aeab31e675d6eb40cf347805288fe5d1101c55..6218fb3e4073e9253bbe10a93b5346d4669b1b73 100755 (executable)
@@ -59,7 +59,7 @@
 #define SQLITE3_SAFE_FREE(sql_string)  {if (sql_string) { sqlite3_free(sql_string); sql_string = NULL; } }
 #define SQLITE3_FINALIZE(x)    {if (x != NULL) sqlite3_finalize(x); }
 
-int mc_db_connect(void **db_handle, bool need_write);
+int mc_db_connect(void **db_handle);
 int mc_db_disconnect(void *db_handle);
 int mc_db_create_server_table(void *handle, const char *server_name);
 int mc_db_delete_server_table(void *handle, const char *server_name);
index 0c4a116a4fceb3f47b40cedce742e5be2055912c..ac71ac817215276f720750812d41ab43cb2d253a 100755 (executable)
@@ -8,12 +8,3 @@ mkdir -p $TZ_USER_DB
 sqlite3 ${TZ_USER_DB}/.media_controller.db 'PRAGMA journal_mode = PERSIST;
                CREATE TABLE IF NOT EXISTS latest_server (server_name TEXT PRIMARY KEY);
 '
-
-#Change permission
-chmod 644 ${TZ_USER_DB}/.media_controller.db
-chmod 644 ${TZ_USER_DB}/.media_controller.db-journal
-
-#Change group (6017: db_filemanager 5000: app)
-chgrp $TZ_SYS_USER_GROUP ${TZ_USER_DB}
-#chgrp 6017 ${TZ_USER_DB}/.media_controller.db
-#chgrp 6017 ${TZ_USER_DB}/.media_controller.db-journal
index 7292dc6f237f8657bdc659213ba6d522e72b35d0..2df2ba86b2632002b207e5fd0434d974a4ea5306 100755 (executable)
@@ -180,7 +180,7 @@ static int __mc_client_create(media_controller_client_s **mc_client)
                goto Error;
        }
 
-       ret = mc_db_connect(&_client->db_handle, false);
+       ret = mc_db_connect(&_client->db_handle);
        if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
                mc_error("error in connecting to DB %d", ret);
                goto Error;
index 8f9209d6e6cedbdc005e1c948fe2cdf51b818e7b..9d56b803777dbc828dbb583cac6a64a30e93ce7a 100755 (executable)
@@ -145,7 +145,7 @@ static int __mc_db_get_ulong_value_of_key(void *handle, const char *server_name,
        return MEDIA_CONTROLLER_ERROR_NONE;
 }
 
-int mc_db_connect(void **handle, bool need_write)
+int mc_db_connect(void **handle)
 {
        int ret = MEDIA_CONTROLLER_ERROR_NONE;
        sqlite3 *db_handle = NULL;
@@ -155,10 +155,7 @@ int mc_db_connect(void **handle, bool need_write)
        mc_retvm_if(handle == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
 
        /*Connect DB*/
-       if (need_write)
-               ret = db_util_open_with_options(tzplatform_mkpath(TZ_USER_DB, MC_DB_NAME), &db_handle, SQLITE_OPEN_READWRITE, NULL);
-       else
-               ret = db_util_open_with_options(tzplatform_mkpath(TZ_USER_DB, MC_DB_NAME), &db_handle, SQLITE_OPEN_READONLY, NULL);
+       ret = db_util_open_with_options(tzplatform_mkpath(TZ_USER_DB, MC_DB_NAME), &db_handle, SQLITE_OPEN_READWRITE, NULL);
 
        if (SQLITE_OK != ret) {
                mc_error("error when db open");
index 6a32d58e61d03d3e2932251a1dbb949dd9998662..ae244d66d6b90e0dccb4cf5367766aa6f6fda2e6 100755 (executable)
@@ -46,7 +46,7 @@ static int __mc_server_create(media_controller_server_s **mc_server)
                goto ERROR;
        }
 
-       ret = mc_db_connect(&(_server->db_handle), false);
+       ret = mc_db_connect(&(_server->db_handle));
        if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
                mc_error("fail mc_db_connect [%d]", ret);
                goto ERROR;
index e401cbe30de3fb6d03cd06b8da6239ae5510c8b3..e8eb5a68be81e7c84dfc1dc37b76f1b03be97c73 100755 (executable)
@@ -166,7 +166,7 @@ static char* __mc_get_db_name(uid_t uid)
        return result_psswd_rtn;
 }
 
-int mc_db_util_connect(void **handle, uid_t uid, bool need_write)
+int mc_db_util_connect(void **handle, uid_t uid)
 {
        int ret = MEDIA_CONTROLLER_ERROR_NONE;
        sqlite3 *db_handle = NULL;
@@ -183,10 +183,7 @@ int mc_db_util_connect(void **handle, uid_t uid, bool need_write)
        }
 
        /*Connect DB*/
-       if (need_write)
-               ret = db_util_open_with_options(db_name, &db_handle, SQLITE_OPEN_READWRITE, NULL);
-       else
-               ret = db_util_open_with_options(db_name, &db_handle, SQLITE_OPEN_READONLY, NULL);
+       ret = db_util_open_with_options(db_name, &db_handle, SQLITE_OPEN_READWRITE, NULL);
 
        MC_SAFE_FREE(db_name);
 
index a427212de268245b8dc0445f18957ed871a094c2..78386ff3ce214e8146e6073dc8f7c80bfafaee84 100755 (executable)
@@ -31,7 +31,7 @@
 #define SQLITE3_SAFE_FREE(sql_string)  {if (sql_string) {sqlite3_free(sql_string); sql_string = NULL; } }
 #define SQLITE3_FINALIZE(x)    {if (x != NULL) sqlite3_finalize(x); }
 
-int mc_db_util_connect(void **handle, uid_t uid, bool need_write);
+int mc_db_util_connect(void **handle, uid_t uid);
 int mc_db_util_disconnect(void *handle);
 int mc_db_util_create_tables(void *handle);
 int mc_db_util_update_db(void *handle, const char *sql_str);
index 46ad57bd2cbbb3e207b264290042a92bd21b1ac7..9e15586fa258d526ff64e0a346db9de605893bf2 100644 (file)
@@ -329,7 +329,7 @@ gboolean mc_svc_thread(void *data)
        }
 
        /* Connect media controller DB*/
-       if (mc_db_util_connect(&(mc_svc_data->db_handle), uid, true) != MEDIA_CONTROLLER_ERROR_NONE) {
+       if (mc_db_util_connect(&(mc_svc_data->db_handle), uid) != MEDIA_CONTROLLER_ERROR_NONE) {
                mc_error("Failed to connect DB");
                MC_SAFE_FREE(mc_svc_data);
                return FALSE;