diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..29b09046
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,21 @@
+# exclude changes done by make process
+Makefile
+Makefile.chatcleaner
+Makefile.pokerth_db
+Makefile.pokerth_game
+Makefile.pokerth_lib
+Makefile.pokerth_protocol
+Makefile.pokerth_server
+Makefile.pokerth_dbofficial
+bin/
+chatcleaner
+lib/
+mocs/
+obj/
+pokerth
+qrc_pokerth.cpp
+uics/
+make.sh
+gitpush_serverstuff_stable
+pokerth_server
+
diff --git a/INSTALL b/INSTALL
index ff5c6195..b9a65066 100644
--- a/INSTALL
+++ b/INSTALL
@@ -15,7 +15,7 @@ Linux:
- libSDL_mixer, libSDL --> http://www.libsdl.org/
- libSQLite3 --> http://sqlite.org/
- libtinyxml > 2.0 --> http://www.sourceforge.net/projects/tinyxml
-- protoc >= 2.3.0 (during build), libprotobuf >= 2.3.0 -> http://code.google.com/p/protobuf/downloads/list
+- protoc >= 2.3.0 (during build), libprotobuf >= 2.3.0 -> https://github.com/google/protobuf
- For the server: libircclient 1.3 --> http://www.sourceforge.net/projects/libircclient/
Windows:
@@ -28,7 +28,7 @@ Basic Installation
Linux:
1. Type "cd path/to/the/sources". Then do for example "/usr/qt/4/bin/qmake pokerth.pro" to configure the makefile for your system.
- Pay attention that the QTDIR environment varialbe points to Qt4 not Qt3. For example QTDIR=/usr/qt/4.
+ Pay attention that the QTDIR environment variable points to Qt4 not Qt3. For example QTDIR=/usr/qt/4.
You can set this variable typing: "export QTDIR=/usr/qt/4"
2. Type "make" to compile the package.
diff --git a/pokerth.pro b/pokerth.pro
index 181b1e2d..18ab00e3 100755
--- a/pokerth.pro
+++ b/pokerth.pro
@@ -1,10 +1,17 @@
# QMake pro-file for PokerTH
TEMPLATE = subdirs
-SUBDIRS = pokerth_protocol.pro pokerth_db.pro pokerth_lib.pro pokerth_game.pro
-!mac:!gui_800x480:!client {
- SUBDIRS += pokerth_server.pro chatcleaner.pro
+SUBDIRS = pokerth_protocol.pro pokerth_db.pro pokerth_lib.pro
+official_server {
+ SUBDIRS += pokerth_dbofficial.pro
}
+client: {
+ SUBDIRS += pokerth_game.pro
+}
+!mac:!gui_800x480:!client:!qml-client {
+ SUBDIRS += pokerth_server.pro chatcleaner.pro
+}
+
CONFIG += ordered
OTHER_FILES += \
diff --git a/pokerth_dbofficial.pro b/pokerth_dbofficial.pro
new file mode 100644
index 00000000..6dd7a128
--- /dev/null
+++ b/pokerth_dbofficial.pro
@@ -0,0 +1,92 @@
+# QMake pro-file for PokerTH official server DB backend
+TEMPLATE = lib
+CODECFORSRC = UTF-8
+CONFIG += staticlib \
+ thread \
+ exceptions \
+ rtti \
+ stl \
+ warn_on
+UI_DIR = uics
+TARGET = lib/pokerth_dbofficial
+MOC_DIR = mocs
+OBJECTS_DIR = obj
+QT -= core \
+ gui
+
+# PRECOMPILED_HEADER = dbofficial/pch_lib.h
+INCLUDEPATH += . \
+ ./src
+DEPENDPATH += . \
+ ./src
+
+# Input
+HEADERS += src/dbofficial/asyncdbauth.h \
+ src/dbofficial/asyncdbcreategame.h \
+ src/dbofficial/asyncdbgameplace.h \
+ src/dbofficial/asyncdbupdatescore.h \
+ src/dbofficial/asyncdbquery.h \
+ src/dbofficial/serverdbthread.h \
+ src/dbofficial/serverdbfactoryinternal.h \
+ src/dbofficial/compositeasyncdbquery.h \
+ src/dbofficial/singleasyncdbquery.h \
+ src/dbofficial/querycontext.h \
+ src/dbofficial/asyncdbendgame.h \
+ src/dbofficial/db_table_defs.h \
+ src/dbofficial/asyncdblogin.h \
+ src/dbofficial/asyncdbreportavatar.h \
+ src/dbofficial/asyncdbreportgame.h \
+ src/dbofficial/asyncdbavatarblacklist.h \
+ src/dbofficial/asyncdbadminplayers.h \
+ src/dbofficial/asyncdbblockplayer.h \
+ src/dbofficial/dbidmanager.h
+SOURCES += src/dbofficial/asyncdbauth.cpp \
+ src/dbofficial/asyncdbcreategame.cpp \
+ src/dbofficial/asyncdbgameplace.cpp \
+ src/dbofficial/asyncdbupdatescore.cpp \
+ src/dbofficial/asyncdbquery.cpp \
+ src/dbofficial/serverdbthread.cpp \
+ src/dbofficial/serverdbfactoryinternal.cpp \
+ src/dbofficial/singleasyncdbquery.cpp \
+ src/dbofficial/compositeasyncdbquery.cpp \
+ src/dbofficial/querycontext.cpp \
+ src/dbofficial/asyncdbendgame.cpp \
+ src/dbofficial/asyncdblogin.cpp \
+ src/dbofficial/asyncdbreportavatar.cpp \
+ src/dbofficial/asyncdbreportgame.cpp \
+ src/dbofficial/asyncdbavatarblacklist.cpp \
+ src/dbofficial/asyncdbadminplayers.cpp \
+ src/dbofficial/asyncdbblockplayer.cpp \
+ src/dbofficial/dbidmanager.cpp
+win32 {
+ DEFINES += _WIN32_WINNT=0x0501
+ INCLUDEPATH += ../../../boost/ \
+ ../../../GnuTLS/include \
+ ../../../curl/include \
+ ../../../mysql/include \
+ ../../../mysql++/lib \
+ ../../../zlib
+}
+!win32 {
+ # #### My release static build options
+ # QMAKE_CXXFLAGS += -ffunction-sections -fdata-sections
+ INCLUDEPATH += /usr/include \
+ /usr/include/mysql \
+ /usr/include/mysql++
+ INCLUDEPATH += /opt/boost/include
+}
+mac {
+ # make it universal
+ CONFIG += x86
+ CONFIG -= ppc
+ QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4
+
+ # for universal-compilation on PPC-Mac uncomment the following line
+ # on Intel-Mac you have to comment this line out or build will fail.
+ # QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk/
+ INCLUDEPATH += /Developer/SDKs/MacOSX10.5.sdk/usr/include/
+ INCLUDEPATH += /Library/Frameworks/SDL.framework/Headers
+ INCLUDEPATH += /Library/Frameworks/SDL_mixer.framework/Headers
+ INCLUDEPATH += /opt/local/include/mysql++ \
+ /opt/local/include/mysql5/mysql
+}
diff --git a/pokerth_game.pro b/pokerth_game.pro
index d660452e..581ad33c 100644
--- a/pokerth_game.pro
+++ b/pokerth_game.pro
@@ -408,6 +408,7 @@ unix:!mac {
LIBPATH += $${PREFIX}/lib /opt/gsasl/lib
LIB_DIRS = $${PREFIX}/lib \
$${PREFIX}/lib64 \
+ $${PREFIX}/lib/x86_64-linux-gnu \
$$system(qmake -query QT_INSTALL_LIBS)
}
android{
@@ -601,7 +602,7 @@ mac {
OTHER_FILES += docs/infomessage-id-desc.txt
official_server {
LIBPATH += pkth_stat/daemon_lib/lib
- LIBS += -lpokerth_closed \
+ LIBS += -lpokerth_dbofficial \
-lmysqlpp
DEFINES += POKERTH_OFFICIAL_SERVER
}
diff --git a/pokerth_lib.pro b/pokerth_lib.pro
index 6db489d8..2c056cfa 100644
--- a/pokerth_lib.pro
+++ b/pokerth_lib.pro
@@ -226,9 +226,49 @@ android|android_test{
SOURCES += src/engine/local_engine/tools_android.cpp
}
-official_server{
- INCLUDEPATH += pkth_stat/daemon_lib/src
+official_server:!win32:!gui_800x480:!client:{
+ # INCLUDEPATH += pkth_stat/daemon_lib/src # note: relict from former official/closed db build
DEFINES += POKERTH_OFFICIAL_SERVER
+ HEADERS += src/dbofficial/asyncdbauth.h \
+ src/dbofficial/asyncdbcreategame.h \
+ src/dbofficial/asyncdbgameplace.h \
+ src/dbofficial/asyncdbupdatescore.h \
+ src/dbofficial/asyncdbquery.h \
+ src/dbofficial/serverdbthread.h \
+ src/dbofficial/serverdbfactoryinternal.h \
+ src/dbofficial/compositeasyncdbquery.h \
+ src/dbofficial/singleasyncdbquery.h \
+ src/dbofficial/querycontext.h \
+ src/dbofficial/asyncdbendgame.h \
+ src/dbofficial/db_table_defs.h \
+ src/dbofficial/asyncdblogin.h \
+ src/dbofficial/asyncdbreportavatar.h \
+ src/dbofficial/asyncdbreportgame.h \
+ src/dbofficial/asyncdbavatarblacklist.h \
+ src/dbofficial/asyncdbadminplayers.h \
+ src/dbofficial/asyncdbblockplayer.h \
+ src/dbofficial/dbidmanager.h
+ SOURCES += src/dbofficial/asyncdbauth.cpp \
+ src/dbofficial/asyncdbcreategame.cpp \
+ src/dbofficial/asyncdbgameplace.cpp \
+ src/dbofficial/asyncdbupdatescore.cpp \
+ src/dbofficial/asyncdbquery.cpp \
+ src/dbofficial/serverdbthread.cpp \
+ src/dbofficial/serverdbfactoryinternal.cpp \
+ src/dbofficial/singleasyncdbquery.cpp \
+ src/dbofficial/compositeasyncdbquery.cpp \
+ src/dbofficial/querycontext.cpp \
+ src/dbofficial/asyncdbendgame.cpp \
+ src/dbofficial/asyncdblogin.cpp \
+ src/dbofficial/asyncdbreportavatar.cpp \
+ src/dbofficial/asyncdbreportgame.cpp \
+ src/dbofficial/asyncdbavatarblacklist.cpp \
+ src/dbofficial/asyncdbadminplayers.cpp \
+ src/dbofficial/asyncdbblockplayer.cpp \
+ src/dbofficial/dbidmanager.cpp
+ INCLUDEPATH += /usr/include \
+ /usr/include/mysql \
+ /usr/include/mysql++
}
win32{
diff --git a/pokerth_protocol.pro b/pokerth_protocol.pro
index 7a331df5..03fb36ce 100644
--- a/pokerth_protocol.pro
+++ b/pokerth_protocol.pro
@@ -37,6 +37,12 @@ unix : !mac {
system(protoc pokerth.proto --cpp_out=src/third_party/protobuf)
system(protoc chatcleaner.proto --cpp_out=src/third_party/protobuf)
system(protoc pokerth.proto --java_out=tests/src)
+
+ android {
+ system(wine protoc.exe pokerth.proto --cpp_out=src/third_party/protobuf)
+ system(wine protoc.exe chatcleaner.proto --cpp_out=src/third_party/protobuf)
+ system(wine protoc.exe pokerth.proto --java_out=tests/src)
+ }
}
mac {
# make it x86_64 only
diff --git a/pokerth_server.pro b/pokerth_server.pro
index 706475f7..05bca1c4 100644
--- a/pokerth_server.pro
+++ b/pokerth_server.pro
@@ -175,6 +175,8 @@ unix : !mac {
LIBPATH += lib $${PREFIX}/lib /opt/gsasl/lib
INCLUDEPATH += $${PREFIX}/include
+ # see issue https://github.com/pokerth/pokerth/issues/282
+ INCLUDEPATH += $${PREFIX}/include/libircclient
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system(qmake -query QT_INSTALL_LIBS)
BOOST_FS = boost_filesystem boost_filesystem-mt
BOOST_THREAD = boost_thread boost_thread-mt
@@ -320,7 +322,7 @@ mac {
official_server {
LIBPATH += pkth_stat/daemon_lib/lib
- LIBS += -lpokerth_closed -lmysqlpp
+ LIBS += -lpokerth_dbofficial -lmysqlpp
DEFINES += POKERTH_OFFICIAL_SERVER
}
diff --git a/src/config/configfile.cpp b/src/config/configfile.cpp
index 701199f5..dc5d2510 100644
--- a/src/config/configfile.cpp
+++ b/src/config/configfile.cpp
@@ -311,6 +311,7 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
configList.push_back(ConfigInfo("DBServerDatabaseName", CONFIG_TYPE_STRING, "pokerth"));
configList.push_back(ConfigInfo("DBServerEncryptionKey", CONFIG_TYPE_STRING, ""));
configList.push_back(ConfigInfo("GameNameBadWordList", CONFIG_TYPE_STRING_LIST, "Regex"));
+ configList.push_back(ConfigInfo("ServerRestrictGuestLogin", CONFIG_TYPE_INT, "0"));
//fill tempList firstTime
configBufferList = configList;
diff --git a/src/core/common/avatarmanager.cpp b/src/core/common/avatarmanager.cpp
index d9b9fd41..d137a5c4 100644
--- a/src/core/common/avatarmanager.cpp
+++ b/src/core/common/avatarmanager.cpp
@@ -61,7 +61,7 @@ using namespace std;
using namespace boost::filesystem;
struct AvatarFileState {
- ifstream inputStream;
+ std::ifstream inputStream;
};
AvatarManager::AvatarManager(bool useExternalServer, const std::string &externalServerAddress,
@@ -363,7 +363,7 @@ AvatarManager::StoreAvatarInCache(const MD5Buf &md5buf, AvatarFileType avatarFil
path tmpPath(cacheDir);
tmpPath /= (md5buf.ToString() + ext);
string fileName(tmpPath.file_string());
- ofstream o(fileName.c_str(), ios_base::out | ios_base::binary | ios_base::trunc);
+ std::ofstream o(fileName.c_str(), ios_base::out | ios_base::binary | ios_base::trunc);
if (!o.fail()) {
o.write((const char *)data, size);
o.close();
diff --git a/src/core/common/loghelper_server.cpp b/src/core/common/loghelper_server.cpp
index f79e4cae..a0d0350e 100644
--- a/src/core/common/loghelper_server.cpp
+++ b/src/core/common/loghelper_server.cpp
@@ -67,7 +67,7 @@ void
internal_log_err(const string &msg)
{
if (!g_logFile.empty()) {
- ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
+ std::ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
if (!o.fail()) {
o << second_clock::local_time() << " ERR: " << msg;
o.flush();
@@ -80,7 +80,7 @@ internal_log_msg(const std::string &msg)
{
if (g_logLevel) {
if (!g_logFile.empty()) {
- ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
+ std::ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
if (!o.fail())
o << second_clock::local_time() << " MSG: " << msg;
}
@@ -92,7 +92,7 @@ internal_log_level(const std::string &msg, int logLevel)
{
if (g_logLevel >= logLevel) {
if (!g_logFile.empty()) {
- ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
+ std::ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
if (!o.fail())
o << second_clock::local_time() << " OUT: " << msg;
}
diff --git a/src/dbofficial/asyncdbadminplayers.cpp b/src/dbofficial/asyncdbadminplayers.cpp
new file mode 100644
index 00000000..304b8b25
--- /dev/null
+++ b/src/dbofficial/asyncdbadminplayers.cpp
@@ -0,0 +1,76 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+
+#include
+#include
+
+
+using namespace std;
+
+
+AsyncDBAdminPlayers::AsyncDBAdminPlayers(unsigned queryId, const string &preparedName)
+ : SingleAsyncDBQuery(queryId, preparedName, list())
+{
+}
+
+AsyncDBAdminPlayers::~AsyncDBAdminPlayers()
+{
+}
+
+void
+AsyncDBAdminPlayers::Init(DBIdManager& /*idManager*/)
+{
+}
+
+void
+AsyncDBAdminPlayers::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ list adminPlayers;
+ for (size_t i = 0; i < result.num_rows(); ++i) {
+ if (!result[i].empty()) {
+ adminPlayers.push_back(result[i][0]);
+ }
+ }
+ service.post(boost::bind(&ServerDBCallback::PlayerAdminList, &cb, GetId(), adminPlayers));
+}
+
+void
+AsyncDBAdminPlayers::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ // This query should always produce a result.
+ HandleError(service, cb);
+}
+
+void
+AsyncDBAdminPlayers::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ service.post(boost::bind(&ServerDBCallback::QueryError, &cb, "AsyncDBAdminPlayers: Failure."));
+}
diff --git a/src/dbofficial/asyncdbadminplayers.h b/src/dbofficial/asyncdbadminplayers.h
new file mode 100644
index 00000000..89cf425d
--- /dev/null
+++ b/src/dbofficial/asyncdbadminplayers.h
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+/* Async database query for all admin players. */
+
+#ifndef _ASYNCDBADMINPLAYERS_H_
+#define _ASYNCDBADMINPLAYERS_H_
+
+#include
+
+
+class AsyncDBAdminPlayers : public SingleAsyncDBQuery
+{
+public:
+ AsyncDBAdminPlayers(unsigned queryId, const std::string &preparedName);
+ virtual ~AsyncDBAdminPlayers();
+
+ virtual void Init(DBIdManager& idManager);
+
+ virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
+ virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
+ virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
+
+ virtual bool RequiresResultSet() const
+ {
+ return true;
+ }
+};
+
+#endif
diff --git a/src/dbofficial/asyncdbauth.cpp b/src/dbofficial/asyncdbauth.cpp
new file mode 100644
index 00000000..56c0e75e
--- /dev/null
+++ b/src/dbofficial/asyncdbauth.cpp
@@ -0,0 +1,84 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+
+#include
+#include
+
+
+using namespace std;
+
+
+AsyncDBAuth::AsyncDBAuth(unsigned queryId, const string &preparedName, const list ¶ms)
+ : SingleAsyncDBQuery(queryId, preparedName, params)
+{
+}
+
+AsyncDBAuth::~AsyncDBAuth()
+{
+}
+
+void
+AsyncDBAuth::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ if (result.num_rows() != 1) {
+ service.post(boost::bind(&ServerDBCallback::PlayerLoginFailed, &cb, GetId()));
+ } else {
+ int blocked = result[0][2];
+ int active = result[0][5];
+ if ((active != 1) || (blocked != 0)) {
+ service.post(boost::bind(&ServerDBCallback::PlayerLoginBlocked, &cb, GetId()));
+ } else {
+ mysqlpp::String secret(result[0][1]);
+ mysqlpp::String country(result[0][3]);
+ mysqlpp::String last_login(result[0][4]);
+ boost::shared_ptr tmpData(new DBPlayerData);
+ tmpData->id = result[0][0];
+ secret.to_string(tmpData->secret);
+ if (!country.is_null())
+ country.to_string(tmpData->country);
+ last_login.to_string(tmpData->last_login);
+
+ service.post(boost::bind(&ServerDBCallback::PlayerLoginSuccess, &cb, GetId(), tmpData));
+ }
+ }
+}
+
+void
+AsyncDBAuth::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ HandleError(service, cb);
+}
+
+void
+AsyncDBAuth::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ service.post(boost::bind(&ServerDBCallback::PlayerLoginFailed, &cb, GetId()));
+}
diff --git a/src/dbofficial/asyncdbauth.h b/src/dbofficial/asyncdbauth.h
new file mode 100644
index 00000000..d775a9d9
--- /dev/null
+++ b/src/dbofficial/asyncdbauth.h
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+/* Async database auth query. */
+
+#ifndef _ASYNCDBAUTH_H_
+#define _ASYNCDBAUTH_H_
+
+#include
+
+
+class AsyncDBAuth : public SingleAsyncDBQuery
+{
+public:
+ AsyncDBAuth(unsigned queryId, const std::string &preparedName, const std::list ¶ms);
+ virtual ~AsyncDBAuth();
+
+ virtual void Init(DBIdManager& /*idManager*/) {}
+
+ virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
+ virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
+ virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
+
+ virtual bool RequiresResultSet() const
+ {
+ return true;
+ }
+};
+
+#endif
diff --git a/src/dbofficial/asyncdbavatarblacklist.cpp b/src/dbofficial/asyncdbavatarblacklist.cpp
new file mode 100644
index 00000000..16800007
--- /dev/null
+++ b/src/dbofficial/asyncdbavatarblacklist.cpp
@@ -0,0 +1,68 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+
+#include
+#include
+
+
+using namespace std;
+
+
+AsyncDBAvatarBlacklist::AsyncDBAvatarBlacklist(unsigned queryId, const string &preparedName, const list ¶ms)
+ : SingleAsyncDBQuery(queryId, preparedName, params)
+{
+}
+
+AsyncDBAvatarBlacklist::~AsyncDBAvatarBlacklist()
+{
+}
+
+void
+AsyncDBAvatarBlacklist::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ if (result.num_rows() == 0)
+ service.post(boost::bind(&ServerDBCallback::AvatarIsOK, &cb, GetId()));
+ else
+ service.post(boost::bind(&ServerDBCallback::AvatarIsBlacklisted, &cb, GetId()));
+}
+
+void
+AsyncDBAvatarBlacklist::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ HandleError(service, cb);
+}
+
+void
+AsyncDBAvatarBlacklist::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ // If query failed: Avatar is blacklisted.
+ service.post(boost::bind(&ServerDBCallback::AvatarIsBlacklisted, &cb, GetId()));
+}
diff --git a/src/dbofficial/asyncdbavatarblacklist.h b/src/dbofficial/asyncdbavatarblacklist.h
new file mode 100644
index 00000000..09f75b74
--- /dev/null
+++ b/src/dbofficial/asyncdbavatarblacklist.h
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+/* Async database avatar blacklist query. */
+
+#ifndef _ASYNCDBAVATARBLACKLIST_H_
+#define _ASYNCDBAVATARBLACKLIST_H_
+
+#include
+
+
+class AsyncDBAvatarBlacklist : public SingleAsyncDBQuery
+{
+public:
+ AsyncDBAvatarBlacklist(unsigned queryId, const std::string &preparedName, const std::list ¶ms);
+ virtual ~AsyncDBAvatarBlacklist();
+
+ virtual void Init(DBIdManager& /*idManager*/) {}
+
+ virtual void HandleResult(mysqlpp::Query &query, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
+ virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& /*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb);
+ virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
+
+ virtual bool RequiresResultSet() const
+ {
+ return true;
+ }
+};
+
+#endif
diff --git a/src/dbofficial/asyncdbblockplayer.cpp b/src/dbofficial/asyncdbblockplayer.cpp
new file mode 100644
index 00000000..e1caf369
--- /dev/null
+++ b/src/dbofficial/asyncdbblockplayer.cpp
@@ -0,0 +1,71 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+
+#include
+#include
+#include
+
+
+using namespace std;
+
+
+AsyncDBBlockPlayer::AsyncDBBlockPlayer(unsigned queryId, unsigned replyId, const string &preparedName, const list ¶ms)
+ : SingleAsyncDBQuery(queryId, preparedName, params), m_replyId(replyId)
+{
+}
+
+AsyncDBBlockPlayer::~AsyncDBBlockPlayer()
+{
+}
+
+void
+AsyncDBBlockPlayer::Init(DBIdManager &/*idManager*/)
+{
+}
+
+void
+AsyncDBBlockPlayer::HandleResult(mysqlpp::Query &/*query*/, DBIdManager &/*idManager*/, mysqlpp::StoreQueryResult &/*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ // This query does not produce a result.
+ HandleError(service, cb);
+}
+
+void
+AsyncDBBlockPlayer::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager &/*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ service.post(boost::bind(&ServerDBCallback::BlockPlayerSuccess, &cb, GetId(), m_replyId));
+}
+
+void
+AsyncDBBlockPlayer::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ service.post(boost::bind(&ServerDBCallback::BlockPlayerFailed, &cb, GetId(), m_replyId));
+}
diff --git a/src/dbofficial/asyncdbblockplayer.h b/src/dbofficial/asyncdbblockplayer.h
new file mode 100644
index 00000000..4c1bd103
--- /dev/null
+++ b/src/dbofficial/asyncdbblockplayer.h
@@ -0,0 +1,60 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+/* Async database update to block a player. */
+
+#ifndef _ASYNCDBBLOCKPLAYER_H_
+#define _ASYNCDBBLOCKPLAYER_H_
+
+#include
+
+
+class AsyncDBBlockPlayer : public SingleAsyncDBQuery
+{
+public:
+ AsyncDBBlockPlayer(unsigned queryId, unsigned replyId, const std::string &preparedName, const std::list ¶ms);
+ virtual ~AsyncDBBlockPlayer();
+
+ virtual void Init(DBIdManager& idManager);
+
+ virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
+ virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
+ virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
+
+ virtual bool RequiresResultSet() const
+ {
+ return false;
+ }
+
+private:
+ unsigned m_replyId;
+};
+
+#endif
diff --git a/src/dbofficial/asyncdbcreategame.cpp b/src/dbofficial/asyncdbcreategame.cpp
new file mode 100644
index 00000000..656ca0da
--- /dev/null
+++ b/src/dbofficial/asyncdbcreategame.cpp
@@ -0,0 +1,76 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+
+#include
+#include
+#include
+
+
+using namespace std;
+
+
+AsyncDBCreateGame::AsyncDBCreateGame(unsigned queryId, const string &preparedName, const list ¶ms)
+ : SingleAsyncDBQuery(queryId, preparedName, params)
+{
+}
+
+AsyncDBCreateGame::~AsyncDBCreateGame()
+{
+}
+
+void
+AsyncDBCreateGame::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& /*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ // This query does not produce a result.
+ HandleError(service, cb);
+}
+
+void
+AsyncDBCreateGame::HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ query.reset();
+ query
+ << "SELECT LAST_INSERT_ID()";
+ mysqlpp::StoreQueryResult tmpResult = query.store();
+ DB_id insertId = tmpResult[0][0];
+ if (!tmpResult || tmpResult.num_rows() != 1 || insertId == 0) {
+ service.post(boost::bind(&ServerDBCallback::CreateGameFailed, &cb, GetId()));
+ } else {
+ service.post(boost::bind(&ServerDBCallback::CreateGameSuccess, &cb, GetId()));
+ idManager.AddGameId(GetId(), insertId);
+ }
+}
+
+void
+AsyncDBCreateGame::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ service.post(boost::bind(&ServerDBCallback::CreateGameFailed, &cb, GetId()));
+}
diff --git a/src/dbofficial/asyncdbcreategame.h b/src/dbofficial/asyncdbcreategame.h
new file mode 100644
index 00000000..15bd8983
--- /dev/null
+++ b/src/dbofficial/asyncdbcreategame.h
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+/* Async database create game query. */
+
+#ifndef _ASYNCDBCREATEGAME_H_
+#define _ASYNCDBCREATEGAME_H_
+
+#include
+
+
+class AsyncDBCreateGame : public SingleAsyncDBQuery
+{
+public:
+ AsyncDBCreateGame(unsigned queryId, const std::string &preparedName, const std::list ¶ms);
+ virtual ~AsyncDBCreateGame();
+
+ virtual void Init(DBIdManager& /*idManager*/) {}
+
+ virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
+ virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
+ virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
+
+ virtual bool RequiresResultSet() const
+ {
+ return false;
+ }
+};
+
+#endif
diff --git a/src/dbofficial/asyncdbendgame.cpp b/src/dbofficial/asyncdbendgame.cpp
new file mode 100644
index 00000000..44da5d06
--- /dev/null
+++ b/src/dbofficial/asyncdbendgame.cpp
@@ -0,0 +1,77 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+
+#include
+#include
+
+
+using namespace std;
+
+
+AsyncDBEndGame::AsyncDBEndGame(unsigned queryId, const string &preparedName, const std::list ¶ms)
+ : SingleAsyncDBQuery(queryId, preparedName, params)
+{
+}
+
+AsyncDBEndGame::~AsyncDBEndGame()
+{
+}
+
+void
+AsyncDBEndGame::Init(DBIdManager& idManager)
+{
+ std::list params;
+ GetParams(params);
+ ostringstream paramStream;
+ paramStream << idManager.GetGameDBId(GetId());
+ // Add game id as last parameter (where-clause).
+ params.push_back(paramStream.str());
+ SetParams(params);
+}
+
+void
+AsyncDBEndGame::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& /*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ // This query does not produce a result.
+ HandleError(service, cb);
+}
+
+void
+AsyncDBEndGame::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
+{
+ // Nothing to do.
+}
+
+void
+AsyncDBEndGame::HandleError(boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
+{
+ // Ignore errors for now (as nothing important is done).
+}
diff --git a/src/dbofficial/asyncdbendgame.h b/src/dbofficial/asyncdbendgame.h
new file mode 100644
index 00000000..d14ecd5f
--- /dev/null
+++ b/src/dbofficial/asyncdbendgame.h
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+/* Async database end game query. */
+
+#ifndef _ASYNCDBENDGAME_H_
+#define _ASYNCDBENDGAME_H_
+
+#include
+
+
+class AsyncDBEndGame : public SingleAsyncDBQuery
+{
+public:
+ AsyncDBEndGame(unsigned queryId, const std::string &preparedName, const std::list ¶ms);
+ virtual ~AsyncDBEndGame();
+
+ virtual void Init(DBIdManager& idManager);
+
+ virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
+ virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
+ virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
+
+ virtual bool RequiresResultSet() const
+ {
+ return false;
+ }
+};
+
+#endif
diff --git a/src/dbofficial/asyncdbgameplace.cpp b/src/dbofficial/asyncdbgameplace.cpp
new file mode 100644
index 00000000..46e86d50
--- /dev/null
+++ b/src/dbofficial/asyncdbgameplace.cpp
@@ -0,0 +1,78 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+
+#include
+#include
+#include
+
+
+using namespace std;
+
+
+AsyncDBGamePlace::AsyncDBGamePlace(unsigned queryId, const string &preparedName, const list ¶ms)
+ : SingleAsyncDBQuery(queryId, preparedName, params)
+{
+}
+
+AsyncDBGamePlace::~AsyncDBGamePlace()
+{
+}
+
+void
+AsyncDBGamePlace::Init(DBIdManager& idManager)
+{
+ std::list params;
+ GetParams(params);
+ ostringstream paramStream;
+ paramStream << idManager.GetGameDBId(GetId());
+ // Add game id as first parameter (according to the order in insert).
+ params.push_front(paramStream.str());
+ SetParams(params);
+}
+
+void
+AsyncDBGamePlace::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& /*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ // This query does not produce a result.
+ HandleError(service, cb);
+}
+
+void
+AsyncDBGamePlace::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
+{
+ // No action required.
+}
+
+void
+AsyncDBGamePlace::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ service.post(boost::bind(&ServerDBCallback::QueryError, &cb, "AsyncDBGamePlace: Failure."));
+}
diff --git a/src/dbofficial/asyncdbgameplace.h b/src/dbofficial/asyncdbgameplace.h
new file mode 100644
index 00000000..071623b4
--- /dev/null
+++ b/src/dbofficial/asyncdbgameplace.h
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+/* Async database set place query. */
+
+#ifndef _ASYNCDBGAMEPLACE_H_
+#define _ASYNCDBGAMEPLACE_H_
+
+#include
+
+
+class AsyncDBGamePlace : public SingleAsyncDBQuery
+{
+public:
+ AsyncDBGamePlace(unsigned queryId, const std::string &preparedName, const std::list ¶ms);
+ virtual ~AsyncDBGamePlace();
+
+ virtual void Init(DBIdManager& idManager);
+
+ virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
+ virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
+ virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
+
+ virtual bool RequiresResultSet() const
+ {
+ return false;
+ }
+};
+
+#endif
diff --git a/src/dbofficial/asyncdblogin.cpp b/src/dbofficial/asyncdblogin.cpp
new file mode 100644
index 00000000..ad44cb95
--- /dev/null
+++ b/src/dbofficial/asyncdblogin.cpp
@@ -0,0 +1,65 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+
+#include
+#include
+
+
+using namespace std;
+
+
+AsyncDBLogin::AsyncDBLogin(unsigned queryId, const string &preparedName, const list ¶ms)
+ : SingleAsyncDBQuery(queryId, preparedName, params)
+{
+}
+
+AsyncDBLogin::~AsyncDBLogin()
+{
+}
+
+void
+AsyncDBLogin::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& /*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ // This query does not produce a result.
+ HandleError(service, cb);
+}
+
+void
+AsyncDBLogin::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
+{
+ // No action required.
+}
+
+void
+AsyncDBLogin::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ service.post(boost::bind(&ServerDBCallback::QueryError, &cb, "AsyncDBLogin: Failure."));
+}
diff --git a/src/dbofficial/asyncdblogin.h b/src/dbofficial/asyncdblogin.h
new file mode 100644
index 00000000..3e171415
--- /dev/null
+++ b/src/dbofficial/asyncdblogin.h
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+/* Async database login query. */
+
+#ifndef _ASYNCDBLOGIN_H_
+#define _ASYNCDBLOGIN_H_
+
+#include
+
+
+class AsyncDBLogin : public SingleAsyncDBQuery
+{
+public:
+ AsyncDBLogin(unsigned queryId, const std::string &preparedName, const std::list ¶ms);
+ virtual ~AsyncDBLogin();
+
+ virtual void Init(DBIdManager& /*idManager*/) {}
+
+ virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
+ virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
+ virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
+
+ virtual bool RequiresResultSet() const
+ {
+ return false;
+ }
+};
+
+#endif
diff --git a/src/dbofficial/asyncdbquery.cpp b/src/dbofficial/asyncdbquery.cpp
new file mode 100644
index 00000000..010c3320
--- /dev/null
+++ b/src/dbofficial/asyncdbquery.cpp
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+
+#include
+
+
+using namespace std;
+
+
+AsyncDBQuery::~AsyncDBQuery()
+{
+}
diff --git a/src/dbofficial/asyncdbquery.h b/src/dbofficial/asyncdbquery.h
new file mode 100644
index 00000000..373bfa1a
--- /dev/null
+++ b/src/dbofficial/asyncdbquery.h
@@ -0,0 +1,61 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+/* Async database query. */
+
+#ifndef _ASYNCDBQUERY_H_
+#define _ASYNCDBQUERY_H_
+
+#include
+#include
+#include
+#include
+
+class DBIdManager;
+
+class AsyncDBQuery
+{
+public:
+ virtual ~AsyncDBQuery();
+
+ virtual void Init(DBIdManager& idManager) = 0;
+
+ virtual std::string GetPreparedName() const = 0;
+ virtual void GetParams(std::list ¶ms) const = 0;
+ virtual void SetParams(const std::list ¶ms) = 0;
+
+ virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb) = 0;
+ virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb) = 0;
+ virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb) = 0;
+ virtual bool RequiresResultSet() const = 0;
+ virtual bool Next() = 0;
+};
+
+#endif
diff --git a/src/dbofficial/asyncdbreportavatar.cpp b/src/dbofficial/asyncdbreportavatar.cpp
new file mode 100644
index 00000000..4982594e
--- /dev/null
+++ b/src/dbofficial/asyncdbreportavatar.cpp
@@ -0,0 +1,65 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+
+#include
+#include
+
+
+using namespace std;
+
+
+AsyncDBReportAvatar::AsyncDBReportAvatar(unsigned queryId, unsigned replyId, const string &preparedName, const list ¶ms)
+ : SingleAsyncDBQuery(queryId, preparedName, params), m_replyId(replyId)
+{
+}
+
+AsyncDBReportAvatar::~AsyncDBReportAvatar()
+{
+}
+
+void
+AsyncDBReportAvatar::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& /*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ // This query does not produce a result.
+ HandleError(service, cb);
+}
+
+void
+AsyncDBReportAvatar::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ service.post(boost::bind(&ServerDBCallback::ReportAvatarSuccess, &cb, GetId(), m_replyId));
+}
+
+void
+AsyncDBReportAvatar::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ service.post(boost::bind(&ServerDBCallback::ReportAvatarFailed, &cb, GetId(), m_replyId));
+}
diff --git a/src/dbofficial/asyncdbreportavatar.h b/src/dbofficial/asyncdbreportavatar.h
new file mode 100644
index 00000000..be0dd35c
--- /dev/null
+++ b/src/dbofficial/asyncdbreportavatar.h
@@ -0,0 +1,60 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+/* Async database report inappropriate avatar query. */
+
+#ifndef _ASYNCDBREPORTAVATAR_H_
+#define _ASYNCDBREPORTAVATAR_H_
+
+#include
+
+
+class AsyncDBReportAvatar : public SingleAsyncDBQuery
+{
+public:
+ AsyncDBReportAvatar(unsigned queryId, unsigned replyId, const std::string &preparedName, const std::list ¶ms);
+ virtual ~AsyncDBReportAvatar();
+
+ virtual void Init(DBIdManager& /*idManager*/) {}
+
+ virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
+ virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
+ virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
+
+ virtual bool RequiresResultSet() const
+ {
+ return false;
+ }
+
+private:
+ unsigned m_replyId;
+};
+
+#endif
diff --git a/src/dbofficial/asyncdbreportgame.cpp b/src/dbofficial/asyncdbreportgame.cpp
new file mode 100644
index 00000000..2a3387d4
--- /dev/null
+++ b/src/dbofficial/asyncdbreportgame.cpp
@@ -0,0 +1,83 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+
+#include
+#include
+#include
+
+
+using namespace std;
+
+
+AsyncDBReportGame::AsyncDBReportGame(unsigned queryId, unsigned replyId, unsigned gameId, const string &preparedName, const list ¶ms)
+ : SingleAsyncDBQuery(queryId, preparedName, params), m_replyId(replyId), m_gameId(gameId)
+{
+}
+
+AsyncDBReportGame::~AsyncDBReportGame()
+{
+}
+
+void
+AsyncDBReportGame::Init(DBIdManager& idManager)
+{
+ std::list params;
+ GetParams(params);
+ ostringstream paramStream;
+ unsigned tmpGameId = idManager.GetGameDBId(m_gameId);
+ if (tmpGameId) {
+ paramStream << idManager.GetGameDBId(m_gameId);
+ // Add game id as last parameter (where-clause).
+ params.push_back(paramStream.str());
+ } else {
+ params.push_back("NULL");
+ }
+ SetParams(params);
+}
+
+void
+AsyncDBReportGame::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& /*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ // This query does not produce a result.
+ HandleError(service, cb);
+}
+
+void
+AsyncDBReportGame::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ service.post(boost::bind(&ServerDBCallback::ReportGameSuccess, &cb, GetId(), m_replyId));
+}
+
+void
+AsyncDBReportGame::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ service.post(boost::bind(&ServerDBCallback::ReportGameFailed, &cb, GetId(), m_replyId));
+}
diff --git a/src/dbofficial/asyncdbreportgame.h b/src/dbofficial/asyncdbreportgame.h
new file mode 100644
index 00000000..a6acde1f
--- /dev/null
+++ b/src/dbofficial/asyncdbreportgame.h
@@ -0,0 +1,61 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+/* Async database report inappropriate avatar query. */
+
+#ifndef _ASYNCDBREPORTGAME_H_
+#define _ASYNCDBREPORTGAME_H_
+
+#include
+
+
+class AsyncDBReportGame : public SingleAsyncDBQuery
+{
+public:
+ AsyncDBReportGame(unsigned queryId, unsigned replyId, unsigned gameId, const std::string &preparedName, const std::list ¶ms);
+ virtual ~AsyncDBReportGame();
+
+ virtual void Init(DBIdManager& idManager);
+
+ virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
+ virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
+ virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
+
+ virtual bool RequiresResultSet() const
+ {
+ return false;
+ }
+
+private:
+ unsigned m_replyId;
+ unsigned m_gameId;
+};
+
+#endif
diff --git a/src/dbofficial/asyncdbupdatescore.cpp b/src/dbofficial/asyncdbupdatescore.cpp
new file mode 100644
index 00000000..5f4b62f4
--- /dev/null
+++ b/src/dbofficial/asyncdbupdatescore.cpp
@@ -0,0 +1,80 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+
+#include
+#include
+
+
+using namespace std;
+
+
+AsyncDBUpdateScore::AsyncDBUpdateScore(unsigned queryId, const string &preparedName, const std::list ¶ms)
+ : SingleAsyncDBQuery(queryId, preparedName, params)
+{
+}
+
+AsyncDBUpdateScore::~AsyncDBUpdateScore()
+{
+}
+
+void
+AsyncDBUpdateScore::Init(DBIdManager& idManager)
+{
+ std::list params;
+ GetParams(params);
+ ostringstream paramStream;
+ paramStream << idManager.GetGameDBId(GetId());
+ // Add game id as first parameter (param for stored procedure).
+ params.push_front(paramStream.str());
+ SetParams(params);
+ // Ensure that "update score" is only called once for a game.
+ // This game id cannot be used any more, without re-init.
+ idManager.RemoveGameId(GetId());
+}
+
+void
+AsyncDBUpdateScore::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& /*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ // This query does not produce a result.
+ HandleError(service, cb);
+}
+
+void
+AsyncDBUpdateScore::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& idManager, boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
+{
+ idManager.RemoveGameId(GetId());
+}
+
+void
+AsyncDBUpdateScore::HandleError(boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
+{
+ // Ignore errors for now (as nothing important is done).
+}
diff --git a/src/dbofficial/asyncdbupdatescore.h b/src/dbofficial/asyncdbupdatescore.h
new file mode 100644
index 00000000..3dfbf3af
--- /dev/null
+++ b/src/dbofficial/asyncdbupdatescore.h
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+/* Async database query to update the score. */
+
+#ifndef _ASYNCDBUPDATESCORE_H_
+#define _ASYNCDBUPDATESCORE_H_
+
+#include
+
+
+class AsyncDBUpdateScore : public SingleAsyncDBQuery
+{
+public:
+ AsyncDBUpdateScore(unsigned queryId, const std::string &preparedName, const std::list ¶ms);
+ virtual ~AsyncDBUpdateScore();
+
+ virtual void Init(DBIdManager& idManager);
+
+ virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
+ virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
+ virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
+
+ virtual bool RequiresResultSet() const
+ {
+ return false;
+ }
+};
+
+#endif
diff --git a/src/dbofficial/compositeasyncdbquery.cpp b/src/dbofficial/compositeasyncdbquery.cpp
new file mode 100644
index 00000000..fbe3dfa7
--- /dev/null
+++ b/src/dbofficial/compositeasyncdbquery.cpp
@@ -0,0 +1,120 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+
+#include
+
+
+using namespace std;
+
+
+CompositeAsyncDBQuery::CompositeAsyncDBQuery(const AsyncQueryList &queries)
+ : m_list(queries), m_errorFlag(false), m_lastGameDBId(0)
+{
+ m_currentQuery = m_list.begin();
+}
+
+CompositeAsyncDBQuery::~CompositeAsyncDBQuery()
+{
+}
+
+void
+CompositeAsyncDBQuery::Init(DBIdManager& idManager)
+{
+ (*m_currentQuery)->Init(idManager);
+}
+
+std::string
+CompositeAsyncDBQuery::GetPreparedName() const
+{
+ return (*m_currentQuery)->GetPreparedName();
+}
+
+void
+CompositeAsyncDBQuery::GetParams(std::list ¶ms) const
+{
+ (*m_currentQuery)->GetParams(params);
+}
+
+void
+CompositeAsyncDBQuery::SetParams(const std::list ¶ms)
+{
+ (*m_currentQuery)->SetParams(params);
+}
+
+void
+CompositeAsyncDBQuery::HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ (*m_currentQuery)->HandleResult(query, idManager, result, service, cb);
+}
+
+void
+CompositeAsyncDBQuery::HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ (*m_currentQuery)->HandleNoResult(query, idManager, service, cb);
+}
+
+void
+CompositeAsyncDBQuery::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
+{
+ (*m_currentQuery)->HandleError(service, cb);
+ m_errorFlag = true;
+}
+
+bool
+CompositeAsyncDBQuery::RequiresResultSet() const
+{
+ return (*m_currentQuery)->RequiresResultSet();
+}
+
+bool
+CompositeAsyncDBQuery::Next()
+{
+ bool retVal = false;
+ AsyncQueryList::iterator pos = m_currentQuery;
+ ++pos;
+ if (!m_errorFlag && pos != m_list.end()) {
+ m_currentQuery = pos;
+ retVal = true;
+ }
+ return retVal;
+}
+
+unsigned
+CompositeAsyncDBQuery::GetLastGameDBId() const
+{
+ return m_lastGameDBId;
+}
+
+void
+CompositeAsyncDBQuery::SetLastGameDBId(unsigned id)
+{
+ m_lastGameDBId = id;
+}
diff --git a/src/dbofficial/compositeasyncdbquery.h b/src/dbofficial/compositeasyncdbquery.h
new file mode 100644
index 00000000..62c4daeb
--- /dev/null
+++ b/src/dbofficial/compositeasyncdbquery.h
@@ -0,0 +1,72 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+/* Composite async database query. */
+
+#ifndef _COMPOSITEASYNCDBQUERY_H_
+#define _COMPOSITEASYNCDBQUERY_H_
+
+#include
+#include
+
+
+class CompositeAsyncDBQuery : public AsyncDBQuery, public QueryContext
+{
+public:
+ typedef std::list > AsyncQueryList;
+ // Note: This list must contain at least one query.
+ CompositeAsyncDBQuery(const AsyncQueryList &queries);
+ virtual ~CompositeAsyncDBQuery();
+
+ virtual void Init(DBIdManager& idManager);
+
+ virtual std::string GetPreparedName() const;
+ virtual void GetParams(std::list ¶ms) const;
+ virtual void SetParams(const std::list ¶ms);
+
+ virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
+ virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
+ // One error will cancel the rest of the composite query.
+ virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
+
+ virtual bool RequiresResultSet() const;
+ virtual bool Next();
+
+ virtual unsigned GetLastGameDBId() const;
+ virtual void SetLastGameDBId(unsigned id);
+
+private:
+ AsyncQueryList m_list;
+ AsyncQueryList::iterator m_currentQuery;
+ bool m_errorFlag;
+ unsigned m_lastGameDBId;
+};
+
+#endif
diff --git a/src/dbofficial/db_table_defs.h b/src/dbofficial/db_table_defs.h
new file mode 100644
index 00000000..0e9db6af
--- /dev/null
+++ b/src/dbofficial/db_table_defs.h
@@ -0,0 +1,78 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+
+#ifndef _DB_TABLE_DEFS_H_
+#define _DB_TABLE_DEFS_H_
+
+#define DB_TABLE_PLAYER "player"
+#define DB_TABLE_PLAYER_COL_ID "player_id"
+#define DB_TABLE_PLAYER_COL_USERNAME "username"
+#define DB_TABLE_PLAYER_COL_PASSWORD "password"
+#define DB_TABLE_PLAYER_COL_VALID "blocked"
+#define DB_TABLE_PLAYER_COL_COUNTRY "country_iso"
+#define DB_TABLE_PLAYER_COL_LASTLOGIN "last_login"
+#define DB_TABLE_PLAYER_COL_ACTIVE "active"
+#define DB_TABLE_PLAYER_COL_AVATARHASH "avatar_hash"
+#define DB_TABLE_PLAYER_COL_AVATARTYPE "avatar_mime"
+
+#define DB_TABLE_GAME "game"
+#define DB_TABLE_GAME_COL_ID "idgame"
+#define DB_TABLE_GAME_COL_NAME "name"
+#define DB_TABLE_GAME_COL_STARTTIME "start_time"
+#define DB_TABLE_GAME_COL_ENDTIME "end_time"
+
+#define DB_TABLE_GAMEPLAYER "game_has_player"
+#define DB_TABLE_GAMEPLAYER_COL_GAMEID "game_idgame"
+#define DB_TABLE_GAMEPLAYER_COL_PLAYERID "player_idplayer"
+#define DB_TABLE_GAMEPLAYER_COL_PLACE "place"
+
+#define DB_TABLE_REP_AVATAR "reported_avatar"
+#define DB_TABLE_REP_AVATAR_COL_PLAYERID "idplayer"
+#define DB_TABLE_REP_AVATAR_COL_AVATARHASH "avatar_hash"
+#define DB_TABLE_REP_AVATAR_COL_AVATARTYPE "avatar_type"
+#define DB_TABLE_REP_AVATAR_COL_BY_PLAYERID "by_idplayer"
+#define DB_TABLE_REP_AVATAR_COL_TIMESTAMP "timestamp"
+
+#define DB_TABLE_REP_GAME "reported_gamename"
+#define DB_TABLE_REP_GAME_COL_CREATOR "game_creator_idplayer"
+#define DB_TABLE_REP_GAME_COL_GAMEID "game_idgame"
+#define DB_TABLE_REP_GAME_COL_GAMENAME "game_name"
+#define DB_TABLE_REP_GAME_COL_BY_PLAYERID "by_idplayer"
+#define DB_TABLE_REP_GAME_COL_TIMESTAMP "timestamp"
+
+#define DB_TABLE_AVATAR_BLACKLIST "avatar_blacklist"
+#define DB_TABLE_AVATAR_BLACKLIST_COL_ID "id"
+#define DB_TABLE_AVATAR_BLACKLIST_COL_AVATAR_HASH "avatar_hash"
+
+#define DB_TABLE_ADMIN_PLAYER "admin_player"
+#define DB_TABLE_ADMIN_PLAYER_COL_PLAYERID "admin_idplayer"
+
+#endif // DB_TABLE_DEFS_H
diff --git a/src/dbofficial/dbidmanager.cpp b/src/dbofficial/dbidmanager.cpp
new file mode 100644
index 00000000..c6e2a6cb
--- /dev/null
+++ b/src/dbofficial/dbidmanager.cpp
@@ -0,0 +1,61 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+
+#include
+
+
+void
+DBIdManager::AddGameId(unsigned gameId, DB_id databaseId)
+{
+ boost::mutex::scoped_lock lock(m_gameIdMapMutex);
+ m_gameIdMap[gameId] = databaseId;
+}
+
+void
+DBIdManager::RemoveGameId(unsigned gameId)
+{
+ boost::mutex::scoped_lock lock(m_gameIdMapMutex);
+ m_gameIdMap.erase(gameId);
+}
+
+DB_id
+DBIdManager::GetGameDBId(unsigned gameId) const
+{
+ DB_id retVal = DB_ID_INVALID;
+
+ boost::mutex::scoped_lock lock(m_gameIdMapMutex);
+ DBMap::const_iterator pos = m_gameIdMap.find(gameId);
+ if (pos != m_gameIdMap.end()) {
+ retVal = pos->second;
+ }
+ return retVal;
+}
+
diff --git a/src/dbofficial/dbidmanager.h b/src/dbofficial/dbidmanager.h
new file mode 100644
index 00000000..2d13d971
--- /dev/null
+++ b/src/dbofficial/dbidmanager.h
@@ -0,0 +1,56 @@
+/*****************************************************************************
+ * PokerTH - The open source texas holdem engine *
+ * Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU Affero General Public License as *
+ * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Affero General Public License *
+ * along with this program. If not, see . *
+ * *
+ * *
+ * Additional permission under GNU AGPL version 3 section 7 *
+ * *
+ * If you modify this program, or any covered work, by linking or *
+ * combining it with the OpenSSL project's OpenSSL library (or a *
+ * modified version of that library), containing parts covered by the *
+ * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
+ * (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
+ * permission to convey the resulting work. *
+ * Corresponding Source for a non-source form of such a combination *
+ * shall include the source code for the parts of OpenSSL used as well *
+ * as that of the covered work. *
+ *****************************************************************************/
+/* Manager for database internal ids */
+
+#ifndef _DBIDMANAGER_H_
+#define _DBIDMANAGER_H_
+
+#include
+#include
+#include