mc_retvm_if(handle == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
mc_retvm_if(server_name == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "server_name is NULL");
mc_retvm_if(key == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "key is NULL");
+ mc_retvm_if(value == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "value is NULL");
- sql_str = sqlite3_mprintf("SELECT %s FROM '%q';", key, server_name);
+ sql_str = sqlite3_mprintf(SELECT_KEY_FROM_SERVER, key, server_name);
mc_retvm_if(!MC_STRING_VALID(sql_str), MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "SQL string is null");
ret = sqlite3_prepare_v2(db_handle, sql_str, strlen(sql_str), &stmt, NULL);
- if (SQLITE_OK != ret) {
- mc_error("prepare error [%s]", sqlite3_errmsg(db_handle));
- SQLITE3_SAFE_FREE(sql_str);
- return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
- }
+ SQLITE3_SAFE_FREE(sql_str);
+ mc_retvm_if(SQLITE_OK != ret, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "prepare error [%s]", sqlite3_errmsg(db_handle));
- ret = sqlite3_step(stmt);
- if (SQLITE_ROW != ret) {
+ if (sqlite3_step(stmt) == SQLITE_ROW) {
+ *value = sqlite3_column_int(stmt, 0);
+ } else {
mc_error("end of row [%s]", sqlite3_errmsg(db_handle));
SQLITE3_FINALIZE(stmt);
- SQLITE3_SAFE_FREE(sql_str);
return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
}
- while (SQLITE_ROW == ret) {
- *value = sqlite3_column_int(stmt, 0);
- ret = sqlite3_step(stmt);
- }
SQLITE3_FINALIZE(stmt);
- SQLITE3_SAFE_FREE(sql_str);
return MEDIA_CONTROLLER_ERROR_NONE;
}
mc_retvm_if(key == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "key is NULL");
mc_retvm_if(value == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "value is NULL");
- sql_str = sqlite3_mprintf("SELECT %s FROM '%q';", key, server_name);
+ sql_str = sqlite3_mprintf(SELECT_KEY_FROM_SERVER, key, server_name);
mc_retvm_if(!MC_STRING_VALID(sql_str), MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "SQL string is null");
ret = sqlite3_prepare_v2(db_handle, sql_str, strlen(sql_str), &stmt, NULL);
- if (SQLITE_OK != ret) {
- mc_error("prepare error [%s]", sqlite3_errmsg(db_handle));
- SQLITE3_SAFE_FREE(sql_str);
- return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
- }
+ SQLITE3_SAFE_FREE(sql_str);
+ mc_retvm_if(SQLITE_OK != ret, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "prepare error [%s]", sqlite3_errmsg(db_handle));
- ret = sqlite3_step(stmt);
- if (SQLITE_ROW != ret) {
+ if (sqlite3_step(stmt) == SQLITE_ROW) {
+ *value = (unsigned long long)sqlite3_column_int64(stmt, 0);
+ } else {
mc_error("end of row [%s]", sqlite3_errmsg(db_handle));
SQLITE3_FINALIZE(stmt);
- SQLITE3_SAFE_FREE(sql_str);
return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
}
- while (SQLITE_ROW == ret) {
- *value = (unsigned long long)sqlite3_column_int64(stmt, 0);
- ret = sqlite3_step(stmt);
- }
SQLITE3_FINALIZE(stmt);
- SQLITE3_SAFE_FREE(sql_str);
return MEDIA_CONTROLLER_ERROR_NONE;
}
mc_retvm_if(handle == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
mc_retvm_if(server_name == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "server_name is NULL");
mc_retvm_if(key == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "key is NULL");
+ mc_retvm_if(value == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "value is NULL");
- sql_str = sqlite3_mprintf("SELECT %s FROM '%q';", key, server_name);
+ sql_str = sqlite3_mprintf(SELECT_KEY_FROM_SERVER, key, server_name);
mc_retvm_if(!MC_STRING_VALID(sql_str), MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "SQL string is null");
ret = sqlite3_prepare_v2(db_handle, sql_str, strlen(sql_str), &stmt, NULL);
- if (SQLITE_OK != ret) {
- mc_error("prepare error [%s]", sqlite3_errmsg(db_handle));
- SQLITE3_SAFE_FREE(sql_str);
- return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
- }
+ SQLITE3_SAFE_FREE(sql_str);
+ mc_retvm_if(SQLITE_OK != ret, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "prepare error [%s]", sqlite3_errmsg(db_handle));
- ret = sqlite3_step(stmt);
- if (SQLITE_ROW != ret) {
+ if (sqlite3_step(stmt) == SQLITE_ROW) {
+ *value = g_strdup((const char *)sqlite3_column_text(stmt, 0));
+ } else {
mc_error("end of row [%s]", sqlite3_errmsg(db_handle));
SQLITE3_FINALIZE(stmt);
- SQLITE3_SAFE_FREE(sql_str);
return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
}
- while (SQLITE_ROW == ret) {
- *value = g_strdup((const char *)sqlite3_column_text(stmt, 0));
- ret = sqlite3_step(stmt);
- }
SQLITE3_FINALIZE(stmt);
- SQLITE3_SAFE_FREE(sql_str);
return MEDIA_CONTROLLER_ERROR_NONE;
}
ret = sqlite3_prepare_v2(db_handle, sql_str, strlen(sql_str), &stmt, NULL);
mc_retvm_if(SQLITE_OK != ret, 0, "prepare error [%s]", sqlite3_errmsg(db_handle));
- ret = sqlite3_step(stmt);
- if (SQLITE_ROW != ret)
- mc_error("end of row [%s]", sqlite3_errmsg(db_handle));
- else
+ if (sqlite3_step(stmt) == SQLITE_ROW)
count = sqlite3_column_int(stmt, 0);
+ else
+ mc_error("end of row [%s]", sqlite3_errmsg(db_handle));
SQLITE3_FINALIZE(stmt);
char *sql_str = NULL;
sqlite3_stmt *stmt = NULL;
sqlite3 *db_handle = (sqlite3 *)handle;
- char *server_name = NULL;
mc_retvm_if(handle == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
*latest_server_name = NULL;
- sql_str = sqlite3_mprintf("SELECT server_name FROM '%q';", MC_DB_TABLE_LATEST_SERVER);
+ sql_str = sqlite3_mprintf(SELECT_NAME_FROM_LATEST, MC_DB_TABLE_LATEST_SERVER);
mc_retvm_if(!MC_STRING_VALID(sql_str), MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "SQL string is null");
ret = sqlite3_prepare_v2(db_handle, sql_str, strlen(sql_str), &stmt, NULL);
- if (SQLITE_OK != ret) {
- mc_error("prepare error [%s]", sqlite3_errmsg(db_handle));
- SQLITE3_SAFE_FREE(sql_str);
- return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
- }
+ SQLITE3_SAFE_FREE(sql_str);
+ mc_retvm_if(SQLITE_OK != ret, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "prepare error [%s]", sqlite3_errmsg(db_handle));
- ret = sqlite3_step(stmt);
- if (SQLITE_ROW != ret) {
+ if (sqlite3_step(stmt) == SQLITE_ROW)
+ *latest_server_name = g_strdup((const char *)sqlite3_column_text(stmt, 0));
+ else
mc_error("[No-Error] No latest server [%s]", sqlite3_errmsg(db_handle));
- SQLITE3_FINALIZE(stmt);
- SQLITE3_SAFE_FREE(sql_str);
- return MEDIA_CONTROLLER_ERROR_NONE; /*There is no latest server yet. */
- }
-
- while (SQLITE_ROW == ret) {
- MC_SAFE_FREE(server_name);
- server_name = strdup((char *)sqlite3_column_text(stmt, 0));
- ret = sqlite3_step(stmt);
- }
-
- if (server_name)
- *latest_server_name = server_name;
SQLITE3_FINALIZE(stmt);
- SQLITE3_SAFE_FREE(sql_str);
return MEDIA_CONTROLLER_ERROR_NONE;
}
int mc_db_get_playback_info(void *handle, const char *server_name, mc_playback_h *playback)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
- mc_playback_states_e playback_state = MC_PLAYBACK_STATE_PLAYING;
- unsigned long long position = 0;
- char *playlist_name = NULL;
- char *index = NULL;
- mc_content_type_e content_type = MC_CONTENT_TYPE_UNDECIDED;
- mc_content_age_rating_e age_rating = MC_CONTENT_RATING_ALL;
media_controller_playback_s *_playback = NULL;
char *sql_str = NULL;
sqlite3_stmt *stmt = NULL;
mc_retvm_if(server_name == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "server_name is NULL");
mc_retvm_if(playback == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "playback is NULL");
- sql_str = sqlite3_mprintf("SELECT playback_state, playback_position, playlist_name, playlist_index, playback_content_type, age_rating FROM '%q';", server_name);
+ sql_str = sqlite3_mprintf(SELECT_PLAY_INFO_FROM_SERVER, server_name);
mc_retvm_if(!MC_STRING_VALID(sql_str), MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "SQL string is null");
ret = sqlite3_prepare_v2(db_handle, sql_str, strlen(sql_str), &stmt, NULL);
- if (SQLITE_OK != ret) {
- mc_error("prepare error [%s]", sqlite3_errmsg(db_handle));
- SQLITE3_SAFE_FREE(sql_str);
- return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
- }
+ SQLITE3_SAFE_FREE(sql_str);
+ mc_retvm_if(SQLITE_OK != ret, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "prepare error [%s]", sqlite3_errmsg(db_handle));
- ret = sqlite3_step(stmt);
- if (SQLITE_ROW != ret) {
+ if (sqlite3_step(stmt) == SQLITE_ROW) {
+ _playback = (media_controller_playback_s *)calloc(1, sizeof(media_controller_playback_s));
+ mc_retvm_if(!_playback, MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+
+ _playback->state = sqlite3_column_int(stmt, 0);
+ _playback->position = (unsigned long long)sqlite3_column_int64(stmt, 1);
+ _playback->playlist_name = g_strdup((const char *)sqlite3_column_text(stmt, 2));
+ _playback->index = g_strdup((const char *)sqlite3_column_text(stmt, 3));
+ _playback->content_type = sqlite3_column_int(stmt, 4);
+ _playback->age_rating = sqlite3_column_int(stmt, 5);
+
+ *playback = (mc_playback_h)_playback;
+ } else {
mc_error("end of row [%s]", sqlite3_errmsg(db_handle));
SQLITE3_FINALIZE(stmt);
- SQLITE3_SAFE_FREE(sql_str);
return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
}
- playback_state = sqlite3_column_int(stmt, 0);
- position = (unsigned long long)sqlite3_column_int64(stmt, 1);
- playlist_name = g_strdup((const char *)sqlite3_column_text(stmt, 2));
- index = g_strdup((const char *)sqlite3_column_text(stmt, 3));
- content_type = sqlite3_column_int(stmt, 4);
- age_rating = sqlite3_column_int(stmt, 5);
-
SQLITE3_FINALIZE(stmt);
- SQLITE3_SAFE_FREE(sql_str);
-
- _playback = (media_controller_playback_s *)calloc(1, sizeof(media_controller_playback_s));
- if (_playback == NULL) {
- mc_error("OUT_OF_MEMORY");
- MC_SAFE_FREE(playlist_name);
- MC_SAFE_FREE(index);
- return MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY;
- }
-
- _playback->state = playback_state;
- _playback->position = position;
- _playback->playlist_name = playlist_name;
- _playback->index = index;
- _playback->content_type = content_type;
- _playback->age_rating = age_rating;
-
- *playback = (mc_playback_h)_playback;
return MEDIA_CONTROLLER_ERROR_NONE;
}
mc_retvm_if(server_name == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "server_name is NULL");
mc_retvm_if(metadata == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "metadata is NULL");
- sql_str = sqlite3_mprintf("SELECT * FROM '%q';", server_name);
+ sql_str = sqlite3_mprintf(SELECT_FROM_SERVER, server_name);
mc_retvm_if(!MC_STRING_VALID(sql_str), MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "SQL string is null");
ret = sqlite3_prepare_v2(db_handle, sql_str, strlen(sql_str), &stmt, NULL);
- if (SQLITE_OK != ret) {
- mc_error("prepare error [%s]", sqlite3_errmsg(db_handle));
- SQLITE3_SAFE_FREE(sql_str);
- return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
- }
- ret = sqlite3_step(stmt);
- if (SQLITE_ROW != ret) {
+ SQLITE3_SAFE_FREE(sql_str);
+ mc_retvm_if(SQLITE_OK != ret, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "prepare error [%s]", sqlite3_errmsg(db_handle));
+
+ if (sqlite3_step(stmt) == SQLITE_ROW) {
+ ret = __mc_db_get_metadata(stmt, MC_SERVER_FIELD_TITLE, metadata);
+ } else {
mc_error("end of row [%s]", sqlite3_errmsg(db_handle));
- SQLITE3_FINALIZE(stmt);
- SQLITE3_SAFE_FREE(sql_str);
- return MEDIA_CONTROLLER_ERROR_NONE;
+ ret = MEDIA_CONTROLLER_ERROR_NONE;
}
- ret = __mc_db_get_metadata(stmt, MC_SERVER_FIELD_TITLE, metadata);
-
SQLITE3_FINALIZE(stmt);
- SQLITE3_SAFE_FREE(sql_str);
return ret;
}
int mc_db_get_server_state(void *handle, const char *server_name, mc_server_state_e *state)
{
- int ret = MEDIA_CONTROLLER_ERROR_NONE;
-
- mc_retvm_if(handle == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
- mc_retvm_if(server_name == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "server_name is NULL");
-
- ret = __mc_db_get_int_value_of_key(handle, server_name, "server_state", (int *)state);
-
- return ret;
+ return __mc_db_get_int_value_of_key(handle, server_name, "server_state", (int *)state);
}
int mc_db_get_shuffle_mode(void *handle, const char *server_name, mc_shuffle_mode_e *mode)
{
- int ret = MEDIA_CONTROLLER_ERROR_NONE;
-
- mc_retvm_if(handle == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
- mc_retvm_if(server_name == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "server_name is NULL");
-
- ret = __mc_db_get_int_value_of_key(handle, server_name, "shuffle_mode", (int *)mode);
-
- return ret;
+ return __mc_db_get_int_value_of_key(handle, server_name, "shuffle_mode", (int *)mode);
}
int mc_db_get_repeat_mode(void *handle, const char *server_name, mc_repeat_mode_e *mode)
{
- int ret = MEDIA_CONTROLLER_ERROR_NONE;
-
- mc_retvm_if(handle == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
- mc_retvm_if(server_name == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "server_name is NULL");
-
- ret = __mc_db_get_int_value_of_key(handle, server_name, "repeat_mode", (int *)mode);
-
- return ret;
+ return __mc_db_get_int_value_of_key(handle, server_name, "repeat_mode", (int *)mode);
}
int mc_db_get_icon_uri(void *handle, const char *server_name, char **uri)
{
- int ret = MEDIA_CONTROLLER_ERROR_NONE;
-
- mc_retvm_if(handle == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
- mc_retvm_if(server_name == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "server_name is NULL");
-
- ret = __mc_db_get_text_value_of_key(handle, server_name, "icon_uri", uri);
-
- return ret;
+ return __mc_db_get_text_value_of_key(handle, server_name, "icon_uri", uri);
}
static int __mc_db_get_ability(void *handle, const char *server_name, unsigned long long *decided, unsigned long long *supported)
mc_retvm_if(handle == NULL, 0, "invalid handle");
mc_retvm_if(server_name == NULL, 0, "invalid server_name");
- sql_str = sqlite3_mprintf("SELECT COUNT(DISTINCT playlist_name) from %s WHERE server_name = %Q", MC_DB_TABLE_PLAYLIST, server_name);
+ sql_str = sqlite3_mprintf(SELECT_COUNT_FROM_PLAYLIST, MC_DB_TABLE_PLAYLIST, server_name);
mc_retvm_if(!MC_STRING_VALID(sql_str), 0, "SQL string is null");
count = __mc_db_get_count(handle, sql_str);
mc_retvm_if(server_name == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "invalid server_name");
mc_retvm_if(callback == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "invalid callback");
- sql_str = sqlite3_mprintf("SELECT playlist_name from %s WHERE server_name = %Q GROUP BY playlist_name", MC_DB_TABLE_PLAYLIST, server_name);
+ sql_str = sqlite3_mprintf(SELECT_NAME_FROM_PLAYLIST, MC_DB_TABLE_PLAYLIST, server_name);
mc_retvm_if(!MC_STRING_VALID(sql_str), MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "SQL string is null");
ret = sqlite3_prepare_v2(db_handle, sql_str, strlen(sql_str), &stmt, NULL);
SQLITE3_SAFE_FREE(sql_str);
mc_retvm_if(SQLITE_OK != ret, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "prepare error [%s]", sqlite3_errmsg(db_handle));
- ret = sqlite3_step(stmt);
- if (SQLITE_ROW != ret)
- mc_secure_debug("[%s] has no playlist", server_name);
-
- while (SQLITE_ROW == ret) {
+ while (sqlite3_step(stmt) == SQLITE_ROW) {
mc_playlist_s *_playlist = (mc_playlist_s *)calloc(1, sizeof(mc_playlist_s));
if (_playlist == NULL) {
mc_error("OUT_OF_MEMORY");
}
mc_playlist_destroy((mc_playlist_h)_playlist);
-
- ret = sqlite3_step(stmt);
}
SQLITE3_FINALIZE(stmt);
mc_retvm_if(!server_name, FALSE, "Invalid server_name");
mc_retvm_if(!playlist_name, FALSE, "Invalid playlist_name");
- sql_str = sqlite3_mprintf("SELECT COUNT(*) FROM '%q' WHERE server_name = %Q AND playlist_name = %Q", MC_DB_TABLE_PLAYLIST, server_name, playlist_name);
+ sql_str = sqlite3_mprintf(SELECT_COUNT_FROM_PLAYLIST_WITH_NAME, MC_DB_TABLE_PLAYLIST, server_name, playlist_name);
mc_retvm_if(!MC_STRING_VALID(sql_str), MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "SQL string is null");
count = __mc_db_get_count(handle, sql_str);
mc_retvm_if(server_name == NULL, 0, "invalid server_name");
mc_retvm_if(playlist_name == NULL, 0, "invalid playlist_name");
- sql_str = sqlite3_mprintf("SELECT COUNT(*) from %s WHERE server_name = %Q and playlist_name = %Q and item_index IS NOT NULL", MC_DB_TABLE_PLAYLIST, server_name, playlist_name);
+ sql_str = sqlite3_mprintf(SELECT_ITEM_COUNT_FROM_PLAYLIST, MC_DB_TABLE_PLAYLIST, server_name, playlist_name);
mc_retvm_if(!MC_STRING_VALID(sql_str), 0, "SQL string is null");
count = __mc_db_get_count(handle, sql_str);
mc_retvm_if(playlist_name == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "invalid playlist_name");
mc_retvm_if(callback == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "invalid callback");
- sql_str = sqlite3_mprintf("SELECT * from %s WHERE server_name = %Q and playlist_name = %Q and item_index IS NOT NULL ORDER BY rowid", MC_DB_TABLE_PLAYLIST, server_name, playlist_name);
+ sql_str = sqlite3_mprintf(SELECT_ITEM_FROM_PLAYLIST, MC_DB_TABLE_PLAYLIST, server_name, playlist_name);
mc_retvm_if(!MC_STRING_VALID(sql_str), MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "SQL string is null");
ret = sqlite3_prepare_v2(db_handle, sql_str, strlen(sql_str), &stmt, NULL);
SQLITE3_SAFE_FREE(sql_str);
mc_retvm_if(SQLITE_OK != ret, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "prepare error [%s]", sqlite3_errmsg(db_handle));
- ret = sqlite3_step(stmt);
- if (SQLITE_ROW != ret)
- mc_secure_debug("[%s : %s] has no playlist item", server_name, playlist_name);
-
- while (SQLITE_ROW == ret) {
+ while (sqlite3_step(stmt) == SQLITE_ROW) {
ret = __mc_db_get_metadata(stmt, 3, &_metadata); //0 : server_name, 1 : playlist_name, 2 : item_index, from 3 : metadata such as title, artist
if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
mc_error("fail to __mc_db_get_metadata");
MC_SAFE_FREE(index);
mc_metadata_destroy(_metadata);
-
- ret = sqlite3_step(stmt);
}
SQLITE3_FINALIZE(stmt);
mc_debug("server name [%s]", server_name);
- sql_str = sqlite3_mprintf("SELECT COUNT(*) FROM SQLITE_MASTER WHERE type='table' and name='%q'", server_name);
+ sql_str = sqlite3_mprintf(SELECT_COUNT_FROM_MASTER, server_name);
mc_retvm_if(!MC_STRING_VALID(sql_str), FALSE, "SQL string is null");
count = __mc_db_get_count(handle, sql_str);
mc_secure_debug("client name [%s]", client_name);
- sql_str = sqlite3_mprintf("SELECT COUNT(*) FROM '%q' WHERE client_name='%q'", MC_DB_TABLE_CLIENT_LIST, client_name);
+ sql_str = sqlite3_mprintf(SELECT_COUNT_FROM_CLIENT, MC_DB_TABLE_CLIENT_LIST, client_name);
mc_retvm_if(!MC_STRING_VALID(sql_str), FALSE, "SQL string is null");
count = __mc_db_get_count(handle, sql_str);
mc_secure_debug("server name [%s]", server_name);
- sql_str = sqlite3_mprintf("SELECT COUNT(*) FROM '%q' WHERE server_name='%q'", MC_DB_TABLE_SERVER_LIST, server_name);
+ sql_str = sqlite3_mprintf(SELECT_COUNT_FROM_SERVER, MC_DB_TABLE_SERVER_LIST, server_name);
mc_retvm_if(!MC_STRING_VALID(sql_str), FALSE, "SQL string is null");
count = __mc_db_get_count(handle, sql_str);
mc_secure_debug("server name [%s]", server_name);
- sql_str = sqlite3_mprintf("SELECT COUNT(*) FROM '%q' WHERE server_name='%q'", MC_DB_TABLE_LATEST_SERVER, server_name);
+ sql_str = sqlite3_mprintf(SELECT_COUNT_FROM_LATEST, MC_DB_TABLE_LATEST_SERVER, server_name);
mc_retvm_if(!MC_STRING_VALID(sql_str), FALSE, "SQL string is null");
count = __mc_db_get_count(handle, sql_str);
mc_retvm_if(db_handle == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
- sql_str = sqlite3_mprintf("SELECT server_name FROM '%q';", MC_DB_TABLE_SERVER_LIST);
+ sql_str = sqlite3_mprintf(SELECT_NAME_FROM_SERVER, MC_DB_TABLE_SERVER_LIST);
mc_retvm_if(!MC_STRING_VALID(sql_str), MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "SQL string is null");
ret = sqlite3_prepare_v2(db_handle, sql_str, strlen(sql_str), &stmt, NULL);
- if (SQLITE_OK != ret) {
- mc_error("prepare error [%s]", sqlite3_errmsg(db_handle));
- SQLITE3_SAFE_FREE(sql_str);
- return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
- }
+ SQLITE3_SAFE_FREE(sql_str);
+ mc_retvm_if(SQLITE_OK != ret, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "prepare error [%s]", sqlite3_errmsg(db_handle));
ret = sqlite3_step(stmt);
if (SQLITE_ROW != ret) {
mc_error("[No-Error] There is no server list [%s]", sqlite3_errmsg(db_handle));
SQLITE3_FINALIZE(stmt);
- SQLITE3_SAFE_FREE(sql_str);
return MEDIA_CONTROLLER_ERROR_NONE;
}
mc_info("[ * Activated Server List - End * ]");
SQLITE3_FINALIZE(stmt);
- SQLITE3_SAFE_FREE(sql_str);
return MEDIA_CONTROLLER_ERROR_NONE;
}
sql_str = sqlite3_mprintf("SELECT client_name FROM '%q';", MC_DB_TABLE_CLIENT_LIST);
mc_retvm_if(!MC_STRING_VALID(sql_str), MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "SQL string is null");
ret = sqlite3_prepare_v2(db_handle, sql_str, strlen(sql_str), &stmt, NULL);
- if (SQLITE_OK != ret) {
- mc_error("prepare error [%s]", sqlite3_errmsg(db_handle));
- SQLITE3_SAFE_FREE(sql_str);
- return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
- }
+ SQLITE3_SAFE_FREE(sql_str);
+ mc_retvm_if(SQLITE_OK != ret, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "prepare error [%s]", sqlite3_errmsg(db_handle));
ret = sqlite3_step(stmt);
if (SQLITE_ROW != ret) {
mc_error("[No-Error] There is no client list [%s]", sqlite3_errmsg(db_handle));
SQLITE3_FINALIZE(stmt);
- SQLITE3_SAFE_FREE(sql_str);
return MEDIA_CONTROLLER_ERROR_NONE;
}
mc_info("[ * Activated Client List - End * ]");
SQLITE3_FINALIZE(stmt);
- SQLITE3_SAFE_FREE(sql_str);
return MEDIA_CONTROLLER_ERROR_NONE;
}