<request>
<domain name="_" />
</request>
+ <assign>
+ <filesystem path="/usr/bin/media-controller_create_db.sh" exec_label="System" />
+ </assign>
</manifest>
#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);
+int mc_db_connect(void **db_handle, bool needWrite);
int mc_db_disconnect(void *db_handle);
int mc_db_create_tables(void *handle);
int mc_db_create_server_table(void *handle, const char *server_name);
goto Error;
}
- ret = mc_db_connect(&_client->db_handle);
+ ret = mc_db_connect(&_client->db_handle, false);
if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("error in connecting to DB %d", ret);
goto Error;
return MEDIA_CONTROLLER_ERROR_NONE;
}
-int mc_db_connect(void **handle)
+int mc_db_connect(void **handle, bool needWrite)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
sqlite3 *db_handle = NULL;
mc_retvm_if(handle == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
/*Connect DB*/
- ret = db_util_open(tzplatform_mkpath(TZ_USER_DB, MC_DB_NAME), &db_handle, DB_UTIL_REGISTER_HOOK_METHOD);
+ if(needWrite) {
+ 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);
+ }
if (SQLITE_OK != ret) {
mc_error("error when db open");
*handle = NULL;
goto ERROR;
}
- ret = mc_db_connect(&(_server->db_handle));
+ ret = mc_db_connect(&(_server->db_handle), false);
if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("fail mc_db_connect [%d]", ret);
goto ERROR;
return result_psswd_rtn;
}
-int mc_db_util_connect(void **handle, uid_t uid)
+int mc_db_util_connect(void **handle, uid_t uid, bool needWrite)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
sqlite3 *db_handle = NULL;
mc_retvm_if(handle == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
/*Connect DB*/
- ret = db_util_open(__mc_get_db_name(uid), &db_handle, DB_UTIL_REGISTER_HOOK_METHOD);
+ if(needWrite) {
+ ret = db_util_open_with_options(__mc_get_db_name(uid), &db_handle, SQLITE_OPEN_READWRITE, NULL);
+ } else {
+ ret = db_util_open_with_options(__mc_get_db_name(uid), &db_handle, SQLITE_OPEN_READONLY, NULL);
+ }
if (SQLITE_OK != ret) {
mc_error("error when db open");
*handle = NULL;
#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);
+int mc_db_util_connect(void **handle, uid_t uid, bool needWrite);
int mc_db_util_update_db(void *handle, const char *sql_str);
int mc_db_util_disconnect(void *handle);
if (recv_msg.msg_type == MC_MSG_DB_UPDATE) {
/* Connect media controller DB*/
- if(mc_db_util_connect(&(mc_svc_data->db_handle), recv_msg.uid) != MEDIA_CONTROLLER_ERROR_NONE) {
+ if(mc_db_util_connect(&(mc_svc_data->db_handle), recv_msg.uid, true) != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("Failed to connect DB");
goto ERROR;
}