*latest_server_name = NULL;
sql_str = sqlite3_mprintf("SELECT name, server_state FROM %q WHERE name IN (SELECT name FROM %q)", MC_DB_TABLE_SERVER_INFO, 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(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(handle));
-
- if (sqlite3_step(stmt) == SQLITE_ROW) {
+ ret = __mc_db_get_record(handle, sql_str, &stmt);
+ if (ret == MEDIA_CONTROLLER_ERROR_NONE) {
*latest_server_name = g_strdup((const char *)sqlite3_column_text(stmt, 0));
*state = sqlite3_column_int(stmt, 1);
+
+ SQLITE3_FINALIZE(stmt);
+ } else if (ret == TIZEN_ERROR_NO_DATA) {
+ mc_info("No latest server");
+ ret = MEDIA_CONTROLLER_ERROR_NONE;
} else {
- mc_error("[No-Error] No latest server [%s]", sqlite3_errmsg(handle));
+ mc_error("__mc_db_get_record failed [%d]", ret);
}
- SQLITE3_FINALIZE(stmt);
-
- return MEDIA_CONTROLLER_ERROR_NONE;
+ return ret;
}
int mc_db_get_playback_info(sqlite3 *handle, const char *server_name, mc_playback_h *playback)