aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/base/database.cpp135
-rw-r--r--src/base/database.hpp111
-rw-r--r--src/base/stats.cpp386
-rw-r--r--src/base/stats_database.cpp196
-rw-r--r--src/base/stats_database.hpp76
-rw-r--r--test/switches.inc0
-rw-r--r--test/test_libraries.lpi299
-rw-r--r--test/test_libraries.lpr31
8 files changed, 0 insertions, 1234 deletions
diff --git a/src/base/database.cpp b/src/base/database.cpp
deleted file mode 100644
index 998179c0..00000000
--- a/src/base/database.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * UltraStar Deluxe - Karaoke Game
- *
- * UltraStar Deluxe is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- */
-
-#include "database.hpp"
-#include <string.h>
-#include <sstream>
-
-namespace usdx
-{
- log4cxx::LoggerPtr Database::log = log4cxx::Logger::getLogger("usdx.base.Database");
-
- Database::Database(const std::string filename)
- {
- if (SQLITE_OK != sqlite3_open_v2(filename.c_str(), &this->database, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL)) {
- sqlite3_close(database);
- throw "Error opening database.";
- }
- }
-
- Database::~Database(void)
- {
- /* frees database */
- LOG4CXX_DEBUG(log, "Closing Database");
-
- sqlite3_close(database);
- database = NULL;
- }
-
- sqlite3_stmt *Database::sqlite_prepare(const std::wstring sqlStatement)
- {
- sqlite3_stmt *sqliteStatement;
- if (SQLITE_OK != sqlite3_prepare16_v2(database, sqlStatement.c_str(), sqlStatement.length(), &sqliteStatement, NULL)) {
- sqlite3_finalize(sqliteStatement);
-
- LOG4CXX_ERROR(log, L"Error '" << sqlite3_errmsg(database) << L"' in SQL '" << sqlStatement << L"'");
- throw "Error preparing statement.";
- }
-
- return sqliteStatement;
- }
-
- void Database::sqlite_exec(const std::wstring sqlStatement)
- {
- sqlite3_stmt *sqliteStatement = sqlite_prepare(sqlStatement);
- sqlite3_step(sqliteStatement);
- sqlite3_finalize(sqliteStatement);
- }
-
- const bool Database::sqlite_table_exists(const std::wstring table)
- {
- std::wstring sql = L"select [name] from [sqlite_master] where [type] = 'table' and [tbl_name] = ?1;";
- sqlite3_stmt *sqliteStatement = sqlite_prepare(sql);
-
- // bind table name to parameter 1 and execute statement
- sqlite3_bind_text16(sqliteStatement, 1, table.c_str(), table.length(), SQLITE_TRANSIENT);
- int rc = sqlite3_step(sqliteStatement);
-
- // if rc is SQLITE_ROW, than result has at lease one row and so
- // the table exists
- bool result = false;
- if (rc == SQLITE_ROW) {
- result = true;
- }
-
- sqlite3_finalize(sqliteStatement);
- return result;
- }
-
- const bool Database::sqlite_table_contains_column(const std::wstring table, const std::wstring column)
- {
- sqlite3_stmt *sqliteStatement = sqlite_prepare(L"PRAGMA TABLE_INFO([" + table + L"]);");
- bool result = false;
-
- int rc = sqlite3_step(sqliteStatement);
- while (rc == SQLITE_ROW) {
- const wchar_t *column_name = (const wchar_t*)sqlite3_column_blob(sqliteStatement, 1);
-
- if (column == std::wstring(column_name)) {
- result = true;
- break;
- }
-
- rc = sqlite3_step(sqliteStatement);
- }
-
- sqlite3_finalize(sqliteStatement);
- return result;
- }
-
- const int Database::get_version(void)
- {
- int result = -1;
- sqlite3_stmt *sqliteStatement = sqlite_prepare(L"PRAGMA user_version;");
-
- int rc = sqlite3_step(sqliteStatement);
- if (rc == SQLITE_ROW) {
- result = sqlite3_column_int(sqliteStatement, 0);
- }
-
- sqlite3_finalize(sqliteStatement);
- return result;
- }
-
- void Database::set_version(const int version)
- {
- // format the PRAGMA statement (PRAGMA does _not_ support parameters)
- std::wostringstream sqlStatementBuffer (std::wostringstream::out);
- sqlStatementBuffer << L"PRAGMA user_version = " << version << L";";
-
- sqlite_exec(sqlStatementBuffer.str());
- }
-};
diff --git a/src/base/database.hpp b/src/base/database.hpp
deleted file mode 100644
index 2a320f45..00000000
--- a/src/base/database.hpp
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * UltraStar Deluxe - Karaoke Game
- *
- * UltraStar Deluxe is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- */
-
-#ifndef DATABASE_HPP
-#define DATABASE_HPP
-
-#include <string>
-#include <sqlite3.h>
-#include <log4cxx/logger.h>
-
-namespace usdx
-{
- /**
- * Abstract base class for all sqlite databases.
- */
- class Database
- {
- private:
- static log4cxx::LoggerPtr log;
-
- protected:
- /**
- * Internal reference to the sqlite database handle of the open
- * sqlite database.
- */
- sqlite3 *database;
-
- Database(std::string filename);
- virtual ~Database(void);
-
- public:
- /**
- * Wrapper around the sqlite_prepare_v2 function with propper
- * logging and exception throwing on error.
- *
- * @param sqlStatement SQL Statement for preparing to
- * sqlite3_stmt
- * @return Pointer to a sqlite3_stmt used for binding
- * parameters and executing the statement. Need to be freed
- * with sqlite3_finalize.
- */
- sqlite3_stmt *sqlite_prepare(const std::wstring sqlStatement);
-
- /**
- * Just a quick alias for sqlite_prepare, sqlite3_step and
- * sqlite3_finalize.
- */
- void sqlite_exec(const std::wstring sqlStatement);
-
- /**
- * Check if the given table exists in the database.
- *
- * @param table Name to check if exists
- * @return true, if table exists, false if not
- */
- const bool sqlite_table_exists(const std::wstring table);
-
- /**
- * Check if the given table has the given column by name.
- *
- * @param table Table to examine
- * @param column Name of the column to check if exists
- * @return true, if column exists in that table, false if not
- */
- const bool sqlite_table_contains_column(const std::wstring table, const std::wstring column);
-
- /**
- * Queries the user version from the sqlite database. This is a
- * free settable additional field to identify the version of the
- * schemata in the database.
- *
- * @see set_version(const int version)
- * @return Value of the user_version setting of the sqlite
- * database
- */
- const int get_version(void);
-
- /**
- * Set the user version of the database.
- *
- * @see get_version(void)
- * @param version Current scheme version.
- */
- void set_version(const int version);
- };
-};
-
-#endif
diff --git a/src/base/stats.cpp b/src/base/stats.cpp
deleted file mode 100644
index 7ad32e74..00000000
--- a/src/base/stats.cpp
+++ /dev/null
@@ -1,386 +0,0 @@
-/*
- * UltraStar Deluxe - Karaoke Game
- *
- * UltraStar Deluxe is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- */
-
-#include "stats.hpp"
-
-namespace usdx
-{
- StatDatabase *Stats::db = NULL;
- std::string Stats::filename = std::string("");
-
- log4cxx::LoggerPtr Stats::log =
- log4cxx::Logger::getLogger("usdx.base.Stats");
-
- StatDatabase *Stats::get_database(void)
- {
- if (filename == "")
- {
- LOG4CXX_ERROR(log, "You have to set a filename first.");
- throw "You have to set a filename first.";
- }
-
- if (db == NULL) {
- db = new StatDatabase(filename);
- }
-
- return db;
- }
-
- int Stats::get_count(std::wstring query)
- {
- int result = 0;
- sqlite3_stmt *sqliteStatement =
- get_database()->sqlite_prepare(query);
-
- int rc = sqlite3_step(sqliteStatement);
- if (rc == SQLITE_ROW) {
- result = sqlite3_column_int(sqliteStatement, 0);
- }
-
- sqlite3_finalize(sqliteStatement);
- return result;
-
- }
-
- void Stats::set_filename(std::string filename)
- {
- Stats::filename = filename;
-
- // close old database
- delete db;
- db = NULL;
- }
-
- std::string Stats::get_filename(void)
- {
- return filename;
- }
-
- time_t Stats::get_stat_reset(void)
- {
- int result = -1;
-
- sqlite3_stmt *sqliteStatement = get_database()->sqlite_prepare(
- L"SELECT [ResetTime] FROM [" +
- get_database()->usdx_statistics_info + L"];");
-
- int rc = sqlite3_step(sqliteStatement);
- if (rc == SQLITE_ROW) {
- result = sqlite3_column_int(sqliteStatement, 0);
- }
-
- sqlite3_finalize(sqliteStatement);
- return (time_t)result;
- }
-
-/* void Stats::add_score(Song *song, int level, const char* player, int score)
- {
- // TODO
- // var
- // ID: integer;
- // TableData: TSQLiteTable;
- // begin
- // if not Assigned(ScoreDB) then
- // Exit;
-
- // // Prevent 0 Scores from being added EDIT: ==> UScreenTop5.pas!
- // //if (Score <= 0) then
- // // Exit;
-
- // TableData := nil;
-
- // try
-
- // ID := ScoreDB.GetTableValue(
- // 'SELECT [ID] FROM [' + cUS_Songs + '] ' +
- // 'WHERE [Artist] = ? AND [Title] = ?',
- // [Song.Artist, Song.Title]);
- // if (ID = 0) then
- // begin
- // // Create song if it does not exist
- // ScoreDB.ExecSQL(
- // 'INSERT INTO [' + cUS_Songs + '] ' +
- // '([ID], [Artist], [Title], [TimesPlayed]) VALUES ' +
- // '(NULL, ?, ?, 0);',
- // [Song.Artist, Song.Title]);
- // // Get song-ID
- // ID := ScoreDB.GetLastInsertRowID();
- // end;
- // // Create new entry
- // ScoreDB.ExecSQL(
- // 'INSERT INTO [' + cUS_Scores + '] ' +
- // '([SongID] ,[Difficulty], [Player], [Score], [Date]) VALUES ' +
- // '(?, ?, ?, ?, ?);',
- // [ID, Level, Name, Score, DateTimeToUnix(Now())]);
-
- // except on E: Exception do
- // Log.LogError(E.Message, 'TDataBaseSystem.AddScore');
- // end;
-
- // TableData.Free;
- }
-*/
-
-/* void Stats::add_song(Song *song)
- {
- // TODO
- // if not Assigned(ScoreDB) then
- // Exit;
-
- // try
- // // Increase TimesPlayed
- // ScoreDB.ExecSQL(
- // 'UPDATE [' + cUS_Songs + '] ' +
- // 'SET [TimesPlayed] = [TimesPlayed] + 1 ' +
- // 'WHERE [Title] = ? AND [Artist] = ?;',
- // [Song.Title, Song.Artist]);
- // except on E: Exception do
- // Log.LogError(E.Message, 'TDataBaseSystem.WriteScore');
- // end;
- }
-*/
-
- StatResultBestScores::StatResultBestScores(wchar_t *singer, unsigned short score, unsigned short difficulty,
- wchar_t* song_artist, wchar_t* song_title, time_t date)
- {
- this->singer = std::wstring(singer);
- this->score = score;
- this->difficulty = difficulty;
- this->song_artist = std::wstring(song_artist);
- this->song_title = std::wstring(song_title);
- this->date = date;
- this->next = NULL;
- }
-
- StatResultBestScores::StatResultBestScores(wchar_t* song_artist, wchar_t* song_title)
- {
- this->next = NULL;
-
- // get score for this song from db
- // TODO
- // var
- // TableData: TSQLiteUniTable;
- // Difficulty: integer;
- // I: integer;
- // PlayerListed: boolean;
- // begin
- // if not Assigned(ScoreDB) then
- // Exit;
-
- // TableData := nil;
- // try
- // // Search Song in DB
- // TableData := ScoreDB.GetUniTable(
- // 'SELECT [Difficulty], [Player], [Score], [Date] FROM [' + cUS_Scores + '] ' +
- // 'WHERE [SongID] = (' +
- // 'SELECT [ID] FROM [' + cUS_Songs + '] ' +
- // 'WHERE [Artist] = ? AND [Title] = ? ' +
- // 'LIMIT 1) ' +
- // 'ORDER BY [Score] DESC;', //no LIMIT! see filter below!
- // [Song.Artist, Song.Title]);
-
- // // Empty Old Scores
- // SetLength(Song.Score[0], 0); //easy
- // SetLength(Song.Score[1], 0); //medium
- // SetLength(Song.Score[2], 0); //hard
-
- // // Go through all Entrys
- // while (not TableData.EOF) do
- // begin
- // // Add one Entry to Array
- // Difficulty := TableData.FieldAsInteger(TableData.FieldIndex['Difficulty']);
- // if ((Difficulty >= 0) and (Difficulty <= 2)) and
- // (Length(Song.Score[Difficulty]) < 5) then
- // begin
- // //filter player
- // PlayerListed:=false;
- // if (Length(Song.Score[Difficulty])>0) then
- // begin
- // for I := 0 to Length(Song.Score[Difficulty]) - 1 do
- // begin
- // if (Song.Score[Difficulty, I].Name = TableData.FieldByName['Player']) then
- // begin
- // PlayerListed:=true;
- // break;
- // end;
- // end;
- // end;
-
- // if not PlayerListed then
- // begin
- // SetLength(Song.Score[Difficulty], Length(Song.Score[Difficulty]) + 1);
-
- // Song.Score[Difficulty, High(Song.Score[Difficulty])].Name :=
- // TableData.FieldByName['Player'];
- // Song.Score[Difficulty, High(Song.Score[Difficulty])].Score :=
- // TableData.FieldAsInteger(TableData.FieldIndex['Score']);
- // Song.Score[Difficulty, High(Song.Score[Difficulty])].Date :=
- // FormatDate(TableData.FieldAsInteger(TableData.FieldIndex['Date']));
- // end;
- // end;
-
- // TableData.Next;
- // end; // while
-
- // except
- // for Difficulty := 0 to 2 do
- // begin
- // SetLength(Song.Score[Difficulty], 1);
- // Song.Score[Difficulty, 1].Name := 'Error Reading ScoreDB';
- // end;
- // end;
-
- // TableData.Free;
- }
-
- StatResultBestScores::~StatResultBestScores(void)
- {
- if (next) {
- delete next;
- next = NULL;
- }
- }
-
- StatResultBestScores *StatResultBestScores::get_next()
- {
- return next;
- }
-
- int StatResultBestScores::get_count(void)
- {
- return Stats::get_count(L"SELECT COUNT([SongID]) FROM [" +
- get_database()->usdx_scores + L"];");
- }
-
- StatResultBestScores *StatResultBestScores::get_stats()
- {
- // TODO
- return NULL;
- }
-
-
-
- StatResultBestSingers::StatResultBestSingers(wchar_t *singer, unsigned short average_score)
- {
- this->singer = std::wstring(singer);
- this->average_score = average_score;
- this->next = NULL;
- }
-
- StatResultBestSingers::~StatResultBestSingers(void)
- {
- if (next) {
- delete next;
- next = NULL;
- }
- }
-
- StatResultBestSingers *StatResultBestSingers::get_next()
- {
- return next;
- }
-
- int StatResultBestSingers::get_count(void)
- {
- return Stats::get_count(
- L"SELECT COUNT(DISTINCT [Player]) FROM ["
- + get_database()->usdx_scores + L"];");
- }
-
- StatResultBestSingers *StatResultBestSingers::get_stats()
- {
- // TODO
- return NULL;
- }
-
-
- StatResultMostSungSong::StatResultMostSungSong(wchar_t* song_artist, wchar_t* song_title, unsigned short times_sung)
- {
- this->song_artist = std::wstring(song_artist);
- this->song_title = std::wstring(song_title);
- this->times_sung = times_sung;
- this->next = NULL;
- }
-
- StatResultMostSungSong::~StatResultMostSungSong(void)
- {
- if (next) {
- delete next;
- next = NULL;
- }
- }
-
- StatResultMostSungSong *StatResultMostSungSong::get_next()
- {
- return next;
- }
-
- int StatResultMostSungSong::get_count(void)
- {
- return Stats::get_count(L"SELECT COUNT([ID]) FROM [" +
- get_database()->usdx_scores + L"];");
- }
-
- StatResultMostSungSong *StatResultMostSungSong::get_stats()
- {
- // TODO
- return NULL;
- }
-
-
- StatResultMostSungBand::StatResultMostSungBand(wchar_t* song_artist, unsigned short times_sung)
- {
- this->song_artist = std::wstring(song_artist);
- this->times_sung = times_sung;
- this->next = NULL;
- }
-
- StatResultMostSungBand::~StatResultMostSungBand(void)
- {
- if (next) {
- delete next;
- next = NULL;
- }
- }
-
- StatResultMostSungBand *StatResultMostSungBand::get_next()
- {
- return next;
- }
-
- int StatResultMostSungBand::get_count(void)
- {
- return Stats::get_count(
- L"SELECT COUNT(DISTINCT [Artist]) FROM [" +
- get_database()->usdx_scores + L"];");
- }
-
- StatResultMostSungBand *StatResultMostSungBand::get_stats()
- {
- // TODO
- return NULL;
- }
-}
diff --git a/src/base/stats_database.cpp b/src/base/stats_database.cpp
deleted file mode 100644
index a46d9ccb..00000000
--- a/src/base/stats_database.cpp
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * UltraStar Deluxe - Karaoke Game
- *
- * UltraStar Deluxe is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- */
-
-#include "stats_database.hpp"
-
-namespace usdx
-{
- const int db_version = 1;
- const std::wstring StatDatabase::usdx_scores =
- L"us_scores";
-
- const std::wstring StatDatabase::usdx_songs =
- L"us_songs";
-
- const std::wstring StatDatabase::usdx_statistics_info =
- L"us_statistics_info";
-
- log4cxx::LoggerPtr StatDatabase::log =
- log4cxx::Logger::getLogger("usdx.base.StatDatabase");
-
- StatDatabase::StatDatabase(const std::string filename) :
- Database(filename)
- {
- LOG4CXX_DEBUG(log, "Initializing Database: " << filename);
-
- if (! sqlite_table_exists(usdx_statistics_info)) {
- // add table usdx_statistics_info, needed in the
- // conversion from 1.01 to 1.1
- LOG4CXX_INFO(log, L"Outdated song database found " <<
- L"- missing table'" <<
- usdx_statistics_info << L"'");
-
- sqlite_exec(L"CREATE TABLE IF NOT EXISTS [" +
- usdx_statistics_info +
- L"] ([ResetTime] Integer);");
-
- // insert creation timestamp
- sqlite3_stmt *sqliteStatement =
- sqlite_prepare(L"INSERT INTO [" +
- usdx_statistics_info +
- L"] ([ResetTime]) VALUES (?1);");
-
- sqlite3_bind_int(sqliteStatement, 1, time(NULL));
- sqlite3_step(sqliteStatement);
- sqlite3_finalize(sqliteStatement);
- }
-
- int version = get_version();
-
- bool finalizeConversion = false;
- if (version == 0 && sqlite_table_exists(L"US_Scores")) {
- // convert data from 1.01 to 1.1
- // part #1 - prearrangement: rename old tables
- // to be able to insert new table structures
- sqlite_exec(L"ALTER TABLE US_Scores RENAME TO us_scores_101;");
- sqlite_exec(L"ALTER TABLE US_Songs RENAME TO us_songs_101;");
- }
-
- if (version == 0) {
- // Set version number after creation
- set_version(db_version);
- }
-
- // SQLite does not handle VARCHAR(n) or INT(n) as expected.
- // Texts do not have a restricted length, no matter which type
- // is used, so use the native TEXT type. INT(n) is always
- // INTEGER. In addition, SQLiteTable3 will fail if other types
- // than the native SQLite types are used (especially
- // FieldAsInteger). Also take care to write the types in
- // upper-case letters although SQLite does not care about this -
- // SQLiteTable3 is very sensitive in this regard.
- std::wstring sqlStatement;
-
- sqlStatement = L"CREATE TABLE IF NOT EXISTS [";
- sqlStatement += usdx_scores;
- sqlStatement += L"] (";
- sqlStatement += L"[SongID] INTEGER NOT NULL, ";
- sqlStatement += L"[Difficulty] INTEGER NOT NULL, ";
- sqlStatement += L"[Player] TEXT NOT NULL, ";
- sqlStatement += L"[Score] INTEGER NOT NULL, ";
- sqlStatement += L"[Date] INTEGER NULL";
- sqlStatement += L");";
-
- sqlite_exec(sqlStatement);
-
- sqlStatement = L"CREATE TABLE IF NOT EXISTS [";
- sqlStatement += usdx_songs;
- sqlStatement += L"] (";
- sqlStatement += L"[ID] INTEGER PRIMARY KEY, ";
- sqlStatement += L"[Artist] TEXT NOT NULL, ";
- sqlStatement += L"[Title] TEXT NOT NULL, ";
- sqlStatement += L"[TimesPlayed] INTEGER NOT NULL, ";
- sqlStatement += L"[Rating] INTEGER NULL";
- sqlStatement += L");";
-
- sqlite_exec(sqlStatement);
-
- if (finalizeConversion) {
- // convert data from 1.01 to 1.1
- // part #2 - accomplishment
- LOG4CXX_INFO(log, L"Outdated song database found - " <<
- L"begin conversion from V1.01 to V1.1");
-
- // insert old values into new db-schemes (/tables)
- sqlStatement = L"INSERT INTO [";
- sqlStatement += usdx_scores;
- sqlStatement += L"] SELECT [SongID], ";
- sqlStatement += L"[Difficulty], [Player], ";
- sqlStatement += L"[Score] FROM [us_scores_101];";
- sqlite_exec(sqlStatement);
-
- sqlStatement = L"INSERT INTO [";
- sqlStatement += usdx_songs;
- sqlStatement += L"] SELECT [ID], [Artist], ";
- sqlStatement += L"[Title], [TimesPlayed], NULL ";
- sqlStatement += L"FROM [us_songs_101];";
- sqlite_exec(sqlStatement);
-
- // now drop old tables
- sqlite_exec(L"DROP TABLE us_scores_101;");
- sqlite_exec(L"DROP TABLE us_songs_101;");
- }
-
- // add column rating to cUS_Songs
- // just for users of nightly builds and developers!
- if (! sqlite_table_contains_column(usdx_songs, L"Rating")) {
- LOG4CXX_INFO(log, L"Outdated song database found - " <<
- L"adding column rating to '" <<
- usdx_songs << L"'");
-
- sqlite_exec(L"ALTER TABLE [" + usdx_songs +
- L"] ADD COLUMN [Rating] INTEGER NULL;");
- }
-
- //add column date to cUS-Scores
- if (! sqlite_table_contains_column(usdx_scores, L"Date")) {
- LOG4CXX_INFO(log, L"Outdated score database found - " <<
- L"adding column date to '" <<
- usdx_scores << L"'");
-
- sqlite_exec(L"ALTER TABLE [" + usdx_scores +
- L"] ADD COLUMN [Date] INTEGER NULL;");
- }
- }
-
- StatDatabase::~StatDatabase(void)
- {
- this->Database::~Database();
- }
-
- char* StatDatabase::format_date(char* time,
- size_t max,
- time_t timestamp)
- {
- if (timestamp != 0) {
- struct tm tmp;
-
- if (localtime_r(&timestamp, &tmp)) {
- strftime(time, max, "%d.%m.%y"
- /* TODO: Language.Translate("STAT_FORMAT_DATE")*/,
- &tmp);
- return time;
- }
- }
-
- if (max > 0) {
- time[0] = '\0';
- return time;
- }
-
- return NULL;
- }
-};
diff --git a/src/base/stats_database.hpp b/src/base/stats_database.hpp
deleted file mode 100644
index 6e7f0d01..00000000
--- a/src/base/stats_database.hpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * UltraStar Deluxe - Karaoke Game
- *
- * UltraStar Deluxe is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- */
-
-#ifndef STATS_DATABASE_HPP
-#define STATS_DATABASE_HPP
-
-#include <ctime>
-#include <string>
-#include <log4cxx/logger.h>
-#include "database.hpp"
-
-namespace usdx
-{
- /**
- * Wrapper for statistic database.
- */
- class StatDatabase : public Database
- {
- private:
- static log4cxx::LoggerPtr log;
-
- public:
- StatDatabase(std::string filename);
- ~StatDatabase(void);
-
- /**
- * Convert a timestamp to a data representation in a string.
- *
- * @param time Pointer to a char buffer that will contain the
- * the date string.
- * @param max Maximum bytes that could be written to the buffer.
- * @param timestamp Timestamp to convert to the string.
- * @return Pointer to the buffer supplied as first parameter,
- * containing:
- * - only a '\\0' at first position if timestamp was
- * 0 or if max was to short to contain the date
- * - the date string with the terminating '\\0'
- */
- static char* format_date(char* time, size_t max, time_t timestamp);
-
- static const std::wstring usdx_scores;
- static const std::wstring usdx_songs;
- static const std::wstring usdx_statistics_info;
-
-
-#ifdef STAT_DATABASE_TEST
- // for testing private members
- friend class StatDatabaseTest;
-#endif
- };
-};
-
-#endif
diff --git a/test/switches.inc b/test/switches.inc
deleted file mode 100644
index e69de29b..00000000
--- a/test/switches.inc
+++ /dev/null
diff --git a/test/test_libraries.lpi b/test/test_libraries.lpi
deleted file mode 100644
index cc3a6ddf..00000000
--- a/test/test_libraries.lpi
+++ /dev/null
@@ -1,299 +0,0 @@
-<?xml version="1.0"?>
-<CONFIG>
- <ProjectOptions>
- <PathDelim Value="/"/>
- <Version Value="6"/>
- <General>
- <MainUnit Value="0"/>
- <TargetFileExt Value=""/>
- <ActiveEditorIndexAtStart Value="0"/>
- </General>
- <VersionInfo>
- <ProjectVersion Value=""/>
- <Language Value=""/>
- <CharSet Value=""/>
- </VersionInfo>
- <PublishOptions>
- <Version Value="2"/>
- <IgnoreBinaries Value="False"/>
- <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
- <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
- </PublishOptions>
- <RunParams>
- <local>
- <FormatVersion Value="1"/>
- <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
- </local>
- </RunParams>
- <RequiredPackages Count="2">
- <Item1>
- <PackageName Value="FPCUnitConsoleRunner"/>
- </Item1>
- <Item2>
- <PackageName Value="FCL"/>
- </Item2>
- </RequiredPackages>
- <Units Count="3">
- <Unit0>
- <Filename Value="test_libraries.lpr"/>
- <IsPartOfProject Value="True"/>
- <UnitName Value="Test_Libraries"/>
- <CursorPos X="77" Y="17"/>
- <TopLine Value="1"/>
- <EditorIndex Value="1"/>
- <UsageCount Value="20"/>
- <Loaded Value="True"/>
- </Unit0>
- <Unit1>
- <Filename Value="testsqllite.pas"/>
- <IsPartOfProject Value="True"/>
- <UnitName Value="TestSQLLite"/>
- <CursorPos X="23" Y="57"/>
- <TopLine Value="39"/>
- <EditorIndex Value="0"/>
- <UsageCount Value="20"/>
- <Loaded Value="True"/>
- </Unit1>
- <Unit2>
- <Filename Value="../lib/SQLite/SQLiteTable3.pas"/>
- <UnitName Value="SQLiteTable3"/>
- <CursorPos X="37" Y="29"/>
- <TopLine Value="11"/>
- <EditorIndex Value="2"/>
- <UsageCount Value="10"/>
- <Loaded Value="True"/>
- </Unit2>
- </Units>
- <JumpHistory Count="11" HistoryIndex="10">
- <Position1>
- <Filename Value="testsqllite.pas"/>
- <Caret Line="8" Column="68" TopLine="1"/>
- </Position1>
- <Position2>
- <Filename Value="../lib/SQLite/SQLiteTable3.pas"/>
- <Caret Line="1" Column="1" TopLine="1"/>
- </Position2>
- <Position3>
- <Filename Value="../lib/SQLite/SQLiteTable3.pas"/>
- <Caret Line="37" Column="64" TopLine="14"/>
- </Position3>
- <Position4>
- <Filename Value="testsqllite.pas"/>
- <Caret Line="26" Column="34" TopLine="1"/>
- </Position4>
- <Position5>
- <Filename Value="testsqllite.pas"/>
- <Caret Line="13" Column="10" TopLine="1"/>
- </Position5>
- <Position6>
- <Filename Value="testsqllite.pas"/>
- <Caret Line="20" Column="29" TopLine="4"/>
- </Position6>
- <Position7>
- <Filename Value="testsqllite.pas"/>
- <Caret Line="28" Column="22" TopLine="5"/>
- </Position7>
- <Position8>
- <Filename Value="testsqllite.pas"/>
- <Caret Line="33" Column="42" TopLine="5"/>
- </Position8>
- <Position9>
- <Filename Value="testsqllite.pas"/>
- <Caret Line="21" Column="15" TopLine="5"/>
- </Position9>
- <Position10>
- <Filename Value="testsqllite.pas"/>
- <Caret Line="20" Column="38" TopLine="5"/>
- </Position10>
- <Position11>
- <Filename Value="testsqllite.pas"/>
- <Caret Line="61" Column="47" TopLine="39"/>
- </Position11>
- </JumpHistory>
- </ProjectOptions>
- <CompilerOptions>
- <Version Value="5"/>
- <CodeGeneration>
- <Generate Value="Faster"/>
- </CodeGeneration>
- <Other>
- <CompilerPath Value="$(CompPath)"/>
- </Other>
- </CompilerOptions>
- <Debugging>
- <BreakPoints Count="37">
- <Item1>
- <Source Value="../../../../../project_mutliloader/fmmultiloaderform.pas"/>
- <Line Value="370"/>
- </Item1>
- <Item2>
- <Source Value="../../../../../project_mutliloader/uploader_infomine.pas"/>
- <Line Value="1"/>
- </Item2>
- <Item3>
- <Source Value="../../../../../project_mutliloader/uploader_seek_publicweb.pas"/>
- <Line Value="515"/>
- </Item3>
- <Item4>
- <Source Value="../../../../../project_mutliloader/fmmultiloaderform.pas"/>
- <Line Value="803"/>
- </Item4>
- <Item5>
- <Source Value="../../../../../project_mutliloader/fmmultiloaderform.pas"/>
- <Line Value="822"/>
- </Item5>
- <Item6>
- <Source Value="../../../../../project_mutliloader/fmmultiloaderform.pas"/>
- <Line Value="824"/>
- </Item6>
- <Item7>
- <Source Value="../../../../../project_mutliloader/fmmultiloaderform.pas"/>
- <Line Value="1492"/>
- </Item7>
- <Item8>
- <Source Value="../../../../../project_mutliloader/fmmultiloaderform.pas"/>
- <Line Value="1536"/>
- </Item8>
- <Item9>
- <Source Value="../../../../../Common/aSpell/spellcheck_controlls.pas"/>
- <Line Value="425"/>
- </Item9>
- <Item10>
- <Source Value="../../../../../Common/aSpell/spellcheck_controlls.pas"/>
- <Line Value="455"/>
- </Item10>
- <Item11>
- <Source Value="../../../../../Common/aSpell/spellcheck_controlls.pas"/>
- <Line Value="574"/>
- </Item11>
- <Item12>
- <Source Value="../../../../../Common/aSpell/spellcheck_controlls.pas"/>
- <Line Value="602"/>
- </Item12>
- <Item13>
- <Source Value="../../../../../project_mutliloader/fmmultiloaderform.pas"/>
- <Line Value="1621"/>
- </Item13>
- <Item15>
- <Source Value="../../../../../project_SkyeDB/fmclient.pas"/>
- <Line Value="986"/>
- </Item15>
- <Item16>
- <Source Value="../../../../../project_SkyeDB/fmclient.pas"/>
- <Line Value="2065"/>
- </Item16>
- <Item17>
- <Source Value="../../../../../project_SkyeDB/fmclient.pas"/>
- <Line Value="1541"/>
- </Item17>
- <Item18>
- <Source Value="../../../../../project_SkyeDB/fmcandidate.pas"/>
- <Line Value="741"/>
- </Item18>
- <Item19>
- <Source Value="../../../../../project_SkyeDB/fmcandidate.pas"/>
- <Line Value="1633"/>
- </Item19>
- <Item20>
- <Source Value="../../../../../project_SkyeDB/fmclient.pas"/>
- <Line Value="3554"/>
- </Item20>
- <Item21>
- <Source Value="../../../../../project_SkyeDB/fmcandidate.pas"/>
- <Line Value="5037"/>
- </Item21>
- <Item22>
- <Source Value="../../../../../project_SkyeDB/fmcandidate.pas"/>
- <Line Value="2994"/>
- </Item22>
- <Item23>
- <Source Value="../../../../../common/asterisk/comManagerMessage.pas"/>
- <Line Value="564"/>
- </Item23>
- <Item24>
- <Source Value="../../../../../common/asterisk/comManagerMessage.pas"/>
- <Line Value="549"/>
- </Item24>
- <Item25>
- <Source Value="../../../../../common/asterisk/comManagerMessage.pas"/>
- <Line Value="438"/>
- </Item25>
- <Item26>
- <Source Value="../../../../../common/asterisk/comManagerMessage.pas"/>
- <Line Value="436"/>
- </Item26>
- <Item27>
- <Source Value="../../../../../project_SkyeDB/fmcandidate.pas"/>
- <Line Value="5648"/>
- </Item27>
- <Item28>
- <Source Value="../../../../../project_SkyeDB/fmcandidate.pas"/>
- <Line Value="636"/>
- </Item28>
- <Item29>
- <Source Value="../../../../../common/common/ConvertUnicode.pas"/>
- <Line Value="83"/>
- </Item29>
- <Item30>
- <Source Value="/usr/share/lazarus/components/uniqueinstance/uniqueinstance.pas"/>
- <Line Value="124"/>
- </Item30>
- <Item31>
- <Source Value="/usr/share/lazarus/components/uniqueinstance/uniqueinstance.pas"/>
- <Line Value="112"/>
- </Item31>
- <Item32>
- <Source Value="/usr/share/lazarus/components/uniqueinstance/uniqueinstance.pas"/>
- <Line Value="174"/>
- </Item32>
- <Item33>
- <Source Value="/usr/share/lazarus/components/uniqueinstance/uniqueinstance.pas"/>
- <Line Value="199"/>
- </Item33>
- <Item34>
- <Source Value="../../../../../common/asterisk/comManagerMessage.pas"/>
- <Line Value="800"/>
- </Item34>
- <Item35>
- <Source Value="../../../../../common/asterisk/comManagerMessage.pas"/>
- <Line Value="798"/>
- </Item35>
- <Item36>
- <Source Value="../../../../../common/asterisk/comManagerMessage.pas"/>
- <Line Value="778"/>
- </Item36>
- <Item37>
- <Source Value="../../../../../common/asterisk/comManagerMessage.pas"/>
- <Line Value="522"/>
- </Item37>
- </BreakPoints>
- <Watches Count="6">
- <Item1>
- <Expression Value="edSearchSummry.text"/>
- </Item1>
- <Item2>
- <Expression Value=" trim(edSearhSummary.text) "/>
- </Item2>
- <Item3>
- <Expression Value="lData"/>
- </Item3>
- <Item4>
- <Expression Value="ord(a)"/>
- </Item4>
- <Item5>
- <Expression Value="lHTTP.headers.text"/>
- </Item5>
- <Item6>
- <Expression Value="lSummaryContactName"/>
- </Item6>
- </Watches>
- <Exceptions Count="2">
- <Item1>
- <Name Value="ECodetoolError"/>
- </Item1>
- <Item2>
- <Name Value="EFOpenError"/>
- </Item2>
- </Exceptions>
- </Debugging>
-</CONFIG>
diff --git a/test/test_libraries.lpr b/test/test_libraries.lpr
deleted file mode 100644
index 3e3ae380..00000000
--- a/test/test_libraries.lpr
+++ /dev/null
@@ -1,31 +0,0 @@
-program Test_Libraries;
-
-{$mode objfpc}{$H+}
-
-uses
- Classes,
- consoletestrunner,
- TestSQLLite,
- SQLite3 in '../lib/SQLite/SQLite3.pas',
-
- SQLiteTable3 in '../lib/SQLite/SQLiteTable3.pas';
-
-type
-
- { TLazTestRunner }
-
- TMyTestRunner = class(TTestRunner)
- protected
- // override the protected methods of TTestRunner to customize its behavior
- end;
-
-var
- Application: TMyTestRunner;
-
-begin
- Application := TMyTestRunner.Create(nil);
- Application.Initialize;
- Application.Title := 'FPCUnit Console test runner';
- Application.Run;
- Application.Free;
-end.