Dedicated server no longer depends on qt. Added code for utf-8 conversion on windows and linux (without qt). Some small issues remain (like the data-dir and charset for the server).

This commit is contained in:
lotodore
2007-10-01 00:33:05 +00:00
parent c17be5af25
commit b4a1ce8bd5
18 changed files with 465 additions and 60 deletions
+2
View File
@@ -182,6 +182,8 @@ SOURCES += \
src/pokerth.cpp \ src/pokerth.cpp \
src/gui/qt/sound/sdlplayer.cpp \ src/gui/qt/sound/sdlplayer.cpp \
src/gui/qt/guiwrapper.cpp \ src/gui/qt/guiwrapper.cpp \
src/gui/qt/qttools/qttoolswrapper.cpp \
src/gui/qt/qttools/qthelper/qthelper.cpp \
src/gui/qt/mainwindow/mainwindowimpl.cpp \ src/gui/qt/mainwindow/mainwindowimpl.cpp \
src/gui/qt/mainwindow/mycardspixmaplabel.cpp \ src/gui/qt/mainwindow/mycardspixmaplabel.cpp \
src/gui/qt/mainwindow/mysetlabel.cpp \ src/gui/qt/mainwindow/mysetlabel.cpp \
+2 -7
View File
@@ -9,7 +9,6 @@ INCLUDEPATH += . \
src/gui \ src/gui \
src/gui/qt \ src/gui/qt \
src/gui/qt/qttools \ src/gui/qt/qttools \
src/gui/qt/qttools/qthelper \
src/net \ src/net \
src/engine/local_engine \ src/engine/local_engine \
src/engine/network_engine \ src/engine/network_engine \
@@ -95,8 +94,6 @@ HEADERS += \
src/engine/network_engine/clientplayer.h \ src/engine/network_engine/clientplayer.h \
src/engine/network_engine/clientbero.h \ src/engine/network_engine/clientbero.h \
src/gui/qttoolsinterface.h \ src/gui/qttoolsinterface.h \
src/gui/qt/qttools/qttoolswrapper.h \
src/gui/qt/qttools/qthelper/qthelper.h \
src/gui/generic/serverguiwrapper.h src/gui/generic/serverguiwrapper.h
SOURCES += \ SOURCES += \
@@ -163,10 +160,8 @@ SOURCES += \
src/net/common/receiverhelper.cpp \ src/net/common/receiverhelper.cpp \
src/net/common/irccallback.cpp \ src/net/common/irccallback.cpp \
src/net/common/ircthread.cpp \ src/net/common/ircthread.cpp \
src/gui/qttoolsinterface.cpp \ src/gui/generic/serverguiwrapper.cpp \
src/gui/qt/qttools/qttoolswrapper.cpp \ src/gui/qttoolsinterface.cpp
src/gui/qt/qttools/qthelper/qthelper.cpp \
src/gui/generic/serverguiwrapper.cpp
win32{ win32{
DEPENDPATH += src/net/win32/ src/core/win32 DEPENDPATH += src/net/win32/ src/core/win32
+23 -16
View File
@@ -3,6 +3,16 @@
TEMPLATE = app TEMPLATE = app
CODECFORSRC = UTF-8 CODECFORSRC = UTF-8
#CONFIG += thread console embed_manifest_exe warn_on release
CONFIG += thread console embed_manifest_exe warn_on debug
UI_DIR = uics
TARGET = bin/pokerth_server
MOC_DIR = mocs
OBJECTS_DIR = obj
# QMAKE_CXXFLAGS_DEBUG += -g
DEFINES += POKERTH_DEDICATED_SERVER
INSTALLS += TARGET INSTALLS += TARGET
TARGET.files += bin/* TARGET.files += bin/*
TARGET.path = /usr/bin/ TARGET.path = /usr/bin/
@@ -13,7 +23,7 @@ INCLUDEPATH += . \
src/gui \ src/gui \
src/gui/qt \ src/gui/qt \
src/gui/qt/qttools \ src/gui/qt/qttools \
src/gui/qt/qttools/qthelper \ src/gui/qt/qttools/nonqthelper \
src/net \ src/net \
src/engine/local_engine \ src/engine/local_engine \
src/engine/network_engine \ src/engine/network_engine \
@@ -66,6 +76,8 @@ HEADERS += \
src/net/socket_startup.h \ src/net/socket_startup.h \
src/core/tinyxml/tinystr.h \ src/core/tinyxml/tinystr.h \
src/core/tinyxml/tinyxml.h \ src/core/tinyxml/tinyxml.h \
src/core/pokerthexception.h \
src/core/convhelper.h \
src/engine/local_engine/cardsvalue.h \ src/engine/local_engine/cardsvalue.h \
src/engine/local_engine/localboard.h \ src/engine/local_engine/localboard.h \
src/engine/local_engine/localenginefactory.h \ src/engine/local_engine/localenginefactory.h \
@@ -84,18 +96,21 @@ HEADERS += \
src/engine/network_engine/clientplayer.h \ src/engine/network_engine/clientplayer.h \
src/engine/network_engine/clientbero.h \ src/engine/network_engine/clientbero.h \
src/gui/qttoolsinterface.h \ src/gui/qttoolsinterface.h \
src/gui/qt/qttools/qttoolswrapper.h \ src/gui/qt/qttools/nonqttoolswrapper.h \
src/gui/qt/qttools/qthelper/qthelper.h \ src/gui/qt/qttools/nonqthelper/nonqthelper.h \
src/gui/generic/serverguiwrapper.h \ src/gui/generic/serverguiwrapper.h
src/core/pokerthexception.h \
src/engine/local_engine/localexception.h
SOURCES += \ SOURCES += \
src/pokerth_server.cpp src/pokerth_server.cpp \
src/gui/qt/qttools/nonqttoolswrapper.cpp \
src/gui/qt/qttools/nonqthelper/nonqthelper.cpp
win32 { win32 {
DEPENDPATH += src/net/win32/ src/core/win32 DEPENDPATH += src/net/win32/ src/core/win32
INCLUDEPATH += ../boost/ ../OpenSSL/include INCLUDEPATH += ../boost/ ../OpenSSL/include
SOURCES += src/core/win32/convhelper.cpp
LIBPATH += ../boost/stage/lib ../OpenSSL/lib LIBPATH += ../boost/stage/lib ../OpenSSL/lib
LIBPATH += Release/lib LIBPATH += Release/lib
@@ -120,6 +135,7 @@ win32 {
!win32 { !win32 {
DEPENDPATH += src/net/linux/ src/core/linux DEPENDPATH += src/net/linux/ src/core/linux
SOURCES += src/core/linux/daemon.c SOURCES += src/core/linux/daemon.c
SOURCES += src/core/win32/convhelper.cpp
} }
unix : !mac { unix : !mac {
@@ -164,12 +180,3 @@ unix : !mac {
## My release static libs ## My release static libs
#LIBS += -lcrypto #LIBS += -lcrypto
} }
#CONFIG += qt thread console embed_manifest_exe warn_on release
CONFIG += qt thread console embed_manifest_exe warn_on debug
UI_DIR = uics
TARGET = bin/pokerth_server
MOC_DIR = mocs
OBJECTS_DIR = obj
QT -= gui
# QMAKE_CXXFLAGS_DEBUG += -g
+7 -13
View File
@@ -18,8 +18,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include "configfile.h" #include "configfile.h"
#include <qttoolsinterface.h>
#include <qttoolswrapper.h>
#define MODUS 0711 #define MODUS 0711
@@ -28,8 +27,6 @@
#include <direct.h> #include <direct.h>
#endif #endif
#include <boost/filesystem.hpp>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <cstdlib> #include <cstdlib>
@@ -40,16 +37,16 @@
using namespace std; using namespace std;
class QtToolsWrapper; QtToolsInterface *CreateQtToolsWrapper();
ConfigFile::ConfigFile(int argc, char **argv) : noWriteAccess(0) ConfigFile::ConfigFile(int argc, char **argv) : noWriteAccess(0)
{ {
myArgv = argv; myArgv0 = argv[0];
int i; int i;
myQtToolsInterface = new QtToolsWrapper; myQtToolsInterface = CreateQtToolsWrapper();
for (i=1; i<argc; i++) { for (i=1; i<argc; i++) {
if(strcmp(argv[i], "--nowriteaccess") == 0) { noWriteAccess = 1; } if(strcmp(argv[i], "--nowriteaccess") == 0) { noWriteAccess = 1; }
@@ -145,12 +142,10 @@ ConfigFile::ConfigFile(int argc, char **argv) : noWriteAccess(0)
claNoWriteAccess = "1"; claNoWriteAccess = "1";
} }
boost::filesystem::path startPath(argv[0]);
ostringstream tempIntToString; ostringstream tempIntToString;
tempIntToString << configRev; tempIntToString << configRev;
configList.push_back(ConfigInfo("ConfigRevision", CONFIG_TYPE_INT, tempIntToString.str())); configList.push_back(ConfigInfo("ConfigRevision", CONFIG_TYPE_INT, tempIntToString.str()));
configList.push_back(ConfigInfo("AppDataDir", CONFIG_TYPE_STRING, myQtToolsInterface->getDataPathStdString(startPath.remove_leaf().directory_string()))); configList.push_back(ConfigInfo("AppDataDir", CONFIG_TYPE_STRING, myQtToolsInterface->getDataPathStdString(argv[0])));
configList.push_back(ConfigInfo("Language", CONFIG_TYPE_INT, myQtToolsInterface->getDefaultLanguage())); configList.push_back(ConfigInfo("Language", CONFIG_TYPE_INT, myQtToolsInterface->getDefaultLanguage()));
configList.push_back(ConfigInfo("ShowLeftToolBox", CONFIG_TYPE_INT, "1")); configList.push_back(ConfigInfo("ShowLeftToolBox", CONFIG_TYPE_INT, "1"));
configList.push_back(ConfigInfo("ShowRightToolBox", CONFIG_TYPE_INT, "1")); configList.push_back(ConfigInfo("ShowRightToolBox", CONFIG_TYPE_INT, "1"));
@@ -266,7 +261,7 @@ ConfigFile::ConfigFile(int argc, char **argv) : noWriteAccess(0)
if (tmpStr) tempAppDataPath = tmpStr; if (tmpStr) tempAppDataPath = tmpStr;
} }
if (tempRevision < configRev || tempAppDataPath != myQtToolsInterface->getDataPathStdString(startPath.remove_leaf().directory_string()) ) { /*löschen()*/ if (tempRevision < configRev || tempAppDataPath != myQtToolsInterface->getDataPathStdString(argv[0]) ) { /*löschen()*/
myConfigState = OLD; myConfigState = OLD;
updateConfig(myConfigState) ; updateConfig(myConfigState) ;
} }
@@ -381,7 +376,6 @@ void ConfigFile::writeBuffer() const {
void ConfigFile::updateConfig(ConfigState myConfigState) { void ConfigFile::updateConfig(ConfigState myConfigState) {
boost::recursive_mutex::scoped_lock lock(m_configMutex); boost::recursive_mutex::scoped_lock lock(m_configMutex);
boost::filesystem::path startPath(myArgv[0]);
size_t i; size_t i;
@@ -453,7 +447,7 @@ void ConfigFile::updateConfig(ConfigState myConfigState) {
TiXmlElement * confElement1 = new TiXmlElement( "AppDataDir" ); TiXmlElement * confElement1 = new TiXmlElement( "AppDataDir" );
config->LinkEndChild( confElement1 ); config->LinkEndChild( confElement1 );
confElement1->SetAttribute("value", myQtToolsInterface->getDataPathStdString(startPath.remove_leaf().directory_string())); confElement1->SetAttribute("value", myQtToolsInterface->getDataPathStdString(myArgv0));
TiXmlHandle oldDocHandle( &oldDoc ); TiXmlHandle oldDocHandle( &oldDoc );
+1 -1
View File
@@ -80,7 +80,7 @@ private:
ConfigState myConfigState; ConfigState myConfigState;
QtToolsInterface *myQtToolsInterface; QtToolsInterface *myQtToolsInterface;
char **myArgv; char *myArgv0;
}; };
#endif #endif
+34
View File
@@ -0,0 +1,34 @@
/***************************************************************************
* Copyright (C) 2007 by Lothar May *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/* Helper class for character conversion functions. */
#ifndef _CRYPTHELPER_H_
#define _CRYPTHELPER_H_
#include <string>
class ConvHelper
{
public:
static std::string NativeToUtf8(const std::string &inStr);
static std::string Utf8ToNative(const std::string &inStr);
};
#endif
+95
View File
@@ -0,0 +1,95 @@
/***************************************************************************
* Copyright (C) 2007 by Lothar May *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "convhelper.h"
#ifdef _WIN32
#error This file is not for Windows.
#endif
#include <string>
#include <iostream>
#include <iconv.h>
#include <errno.h>
using namespace std;
string
ConvHelper::NativeToUtf8(const std::string &inStr)
{
string retStr(inStr);
size_t insize = inStr.length();
char *inbuf = const_cast<char *>(inStr.data());
const size_t c_outsize = insize * 6; // max size of utf-8 char is 6 per input char
size_t outsize = c_outsize;
char *c_outbuf = new char[outsize];
char *outbuf = c_outbuf;
//nl_langinfo(CODESET)
iconv_t conversion = iconv_open("UTF-8", "ISO-8859-1");
if (conversion == (iconv_t)(-1))
cout << "iconv_open() failed: " << strerror(errno) << endl;
else
{
size_t retval = iconv(conversion, &inbuf, &insize, &outbuf, &outsize);
if (retval == -1)
cout << "iconv() failed: " << strerror(errno) << endl;
retStr = string(c_outbuf, c_outsize - outsize);
}
delete[] c_outbuf;
iconv_close(conversion);
return retStr;
}
string
ConvHelper::Utf8ToNative(const std::string &inStr)
{
string retStr(inStr);
size_t insize = inStr.length();
char *inbuf = const_cast<char *>(inStr.data());
const size_t c_outsize = insize;
size_t outsize = c_outsize;
char *c_outbuf = new char[outsize];
char *outbuf = c_outbuf;
iconv_t conversion = iconv_open("ISO-8859-1", "UTF-8");
if (conversion == (iconv_t)(-1))
cout << "iconv_open() failed: " << strerror(errno) << endl;
else
{
size_t retval = iconv(conversion, &inbuf, &insize, &outbuf, &outsize);
if (retval == -1)
cout << "iconv() failed: " << strerror(errno) << endl;
retStr = string(c_outbuf, c_outsize - outsize);
}
delete[] c_outbuf;
iconv_close(conversion);
return retStr;
}
+76
View File
@@ -0,0 +1,76 @@
/***************************************************************************
* Copyright (C) 2007 by Lothar May *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "convhelper.h"
#ifndef _WIN32
#error This file is Windows only.
#endif
#include <windows.h>
using namespace std;
static string
Convert(const std::string &inStr, int fromCP, int toCP)
{
// convert str from current Windows source to target charset
string retStr(inStr);
if (!inStr.empty())
{
int len = (int)inStr.length() + 1;
int reqLen = ::MultiByteToWideChar(fromCP, 0, inStr.c_str(), len, NULL, 0);
if (reqLen)
{
wchar_t *wstr = new wchar_t[reqLen];
wstr[0] = L'\0';
if (::MultiByteToWideChar(fromCP, 0, inStr.c_str(), len, wstr, reqLen) == (int)reqLen)
{
len = reqLen;
reqLen = ::WideCharToMultiByte(toCP, 0, wstr, len, NULL, 0, NULL, NULL);
if (reqLen)
{
char *str = new char[reqLen];
if (::WideCharToMultiByte(toCP, 0, wstr, len, str, reqLen, NULL, NULL) == (int)reqLen)
retStr = str;
delete[] str;
}
}
delete[] wstr;
}
}
return retStr;
}
string
ConvHelper::NativeToUtf8(const std::string &inStr)
{
return Convert(inStr, CP_ACP, CP_UTF8);
}
string
ConvHelper::Utf8ToNative(const std::string &inStr)
{
return Convert(inStr, CP_UTF8, CP_ACP);
}
@@ -0,0 +1,51 @@
/***************************************************************************
* Copyright (C) 2007 by Lothar May *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "nonqthelper.h"
#include <core/convhelper.h>
#include <boost/filesystem.hpp>
NonQtHelper::NonQtHelper()
{
}
NonQtHelper::~NonQtHelper()
{
}
std::string
NonQtHelper::stringToUtf8(const std::string &myString)
{
return ConvHelper::NativeToUtf8(myString);
}
std::string
NonQtHelper::getDefaultLanguage()
{
return "en";
}
std::string
NonQtHelper::getDataPathStdString(const char *argv0)
{
boost::filesystem::path startPath(argv0);
return stringToUtf8(startPath.remove_leaf().directory_string() + "data/");
}
@@ -0,0 +1,44 @@
/***************************************************************************
* Copyright (C) 2007 by Lothar May *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef NONQTHELPER_H
#define NONQTHELPER_H
#ifndef POKERTH_DEDICATED_SERVER
#error This file is only for the server.
#endif
#include <string>
class NonQtHelper
{
public:
NonQtHelper();
~NonQtHelper();
std::string stringToUtf8(const std::string &);
std::string getDefaultLanguage();
std::string getDataPathStdString(const char *argv0);
};
#endif
+50
View File
@@ -0,0 +1,50 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "nonqttoolswrapper.h"
#include <nonqthelper/nonqthelper.h>
using namespace std;
QtToolsInterface *CreateQtToolsWrapper()
{
return new NonQtToolsWrapper;
}
NonQtToolsWrapper::NonQtToolsWrapper() : myQtHelper(0)
{
myQtHelper = new NonQtHelper();
}
NonQtToolsWrapper::~NonQtToolsWrapper()
{
delete myQtHelper;
myQtHelper = 0;
}
std::string NonQtToolsWrapper::stringToUtf8(const std::string &myString) { return myQtHelper->stringToUtf8(myString); }
std::string NonQtToolsWrapper::getDefaultLanguage() { return myQtHelper->getDefaultLanguage(); }
std::string NonQtToolsWrapper::getDataPathStdString(const char * argv0) { return myQtHelper->getDataPathStdString(argv0); }
+45
View File
@@ -0,0 +1,45 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef NONQTTOOLSWRAPPER_H
#define NONQTTOOLSWRAPPER_H
#include <qttoolsinterface.h>
#include <string>
class NonQtHelper;
class NonQtToolsWrapper : public QtToolsInterface
{
public:
NonQtToolsWrapper();
~NonQtToolsWrapper();
std::string stringToUtf8(const std::string &myString);
std::string getDefaultLanguage();
std::string getDataPathStdString(const char *argv0);
private:
NonQtHelper *myQtHelper;
};
#endif
+4 -3
View File
@@ -11,6 +11,7 @@
// //
#include "qthelper.h" #include "qthelper.h"
QtHelper::QtHelper() QtHelper::QtHelper()
{ {
} }
@@ -32,7 +33,7 @@ std::string QtHelper::getDefaultLanguage() { return QLocale::system().name().toS
QString QtHelper::getDataPath() QString QtHelper::getDataPath()
{ {
QString path = QCoreApplication::instance()->applicationDirPath(); QString path(QCoreApplication::instance()->applicationDirPath());
#ifdef _WIN32 #ifdef _WIN32
path += "/data/"; path += "/data/";
@@ -57,9 +58,9 @@ QString QtHelper::getDataPath()
return QDir::cleanPath(path) + "/"; return QDir::cleanPath(path) + "/";
} }
std::string QtHelper::getDataPathStdString(const std::string &appPath) std::string QtHelper::getDataPathStdString(const char * /*argv0*/)
{ {
QString path(appPath.c_str()); QString path(QCoreApplication::instance()->applicationDirPath());
#ifdef _WIN32 #ifdef _WIN32
path += "/data/"; path += "/data/";
+13 -9
View File
@@ -12,23 +12,27 @@
#ifndef QTHELPER_H #ifndef QTHELPER_H
#define QTHELPER_H #define QTHELPER_H
#ifdef POKERTH_DEDICATED_SERVER
#error This file is not for the server.
#endif
#include <QtCore> #include <QtCore>
/** /**
@author FThauer FHammer <webmaster@pokerth.net> @author FThauer FHammer <webmaster@pokerth.net>
*/ */
class QtHelper : public QObject{ class QtHelper
Q_OBJECT {
public: public:
QtHelper(); QtHelper();
~QtHelper(); ~QtHelper();
std::string stringToUtf8(const std::string &); std::string stringToUtf8(const std::string &);
std::string getDefaultLanguage(); std::string getDefaultLanguage();
QString getDataPath();
std::string getDataPathStdString(const std::string &appPath);
QString getDataPath();
std::string getDataPathStdString(const char *argv0);
}; };
#endif #endif
+9 -2
View File
@@ -19,11 +19,18 @@
***************************************************************************/ ***************************************************************************/
#include "qttoolswrapper.h" #include "qttoolswrapper.h"
#include <qthelper.h>
#include <qthelper/qthelper.h>
using namespace std; using namespace std;
QtToolsInterface *CreateQtToolsWrapper()
{
return new QtToolsWrapper;
}
QtToolsWrapper::QtToolsWrapper() : myQtHelper(0) QtToolsWrapper::QtToolsWrapper() : myQtHelper(0)
{ {
@@ -39,5 +46,5 @@ QtToolsWrapper::~QtToolsWrapper()
std::string QtToolsWrapper::stringToUtf8(const std::string &myString) { return myQtHelper->stringToUtf8(myString); } std::string QtToolsWrapper::stringToUtf8(const std::string &myString) { return myQtHelper->stringToUtf8(myString); }
std::string QtToolsWrapper::getDefaultLanguage() { return myQtHelper->getDefaultLanguage(); } std::string QtToolsWrapper::getDefaultLanguage() { return myQtHelper->getDefaultLanguage(); }
std::string QtToolsWrapper::getDataPathStdString(const std::string &appPath) { return myQtHelper->getDataPathStdString(appPath); } std::string QtToolsWrapper::getDataPathStdString(const char * argv0) { return myQtHelper->getDataPathStdString(argv0); }
+1 -1
View File
@@ -35,7 +35,7 @@ public:
std::string stringToUtf8(const std::string &myString); std::string stringToUtf8(const std::string &myString);
std::string getDefaultLanguage(); std::string getDefaultLanguage();
std::string getDataPathStdString(const std::string &appPath); std::string getDataPathStdString(const char *argv0);
private: private:
+1 -1
View File
@@ -29,7 +29,7 @@ public:
//qthelper.cpp //qthelper.cpp
virtual std::string stringToUtf8(const std::string &) =0; virtual std::string stringToUtf8(const std::string &) =0;
virtual std::string getDefaultLanguage() =0; virtual std::string getDefaultLanguage() =0;
virtual std::string getDataPathStdString(const std::string &) =0; virtual std::string getDataPathStdString(const char *argv0) =0;
}; };
+7 -7
View File
@@ -88,7 +88,7 @@ void irc_handle_server_error(irc_session_t *session, unsigned irc_error_code)
} }
void void
irc_event_connect(irc_session_t *session, const char */*irc_event*/, const char *origin, const char **/*params*/, unsigned /*count*/) irc_event_connect(irc_session_t *session, const char * /*irc_event*/, const char *origin, const char ** /*params*/, unsigned /*count*/)
{ {
IrcContext *context = (IrcContext *) irc_get_ctx(session); IrcContext *context = (IrcContext *) irc_get_ctx(session);
@@ -97,7 +97,7 @@ irc_event_connect(irc_session_t *session, const char */*irc_event*/, const char
} }
void void
irc_event_join(irc_session_t *session, const char */*irc_event*/, const char *origin, const char **/*params*/, unsigned /*count*/) irc_event_join(irc_session_t *session, const char * /*irc_event*/, const char *origin, const char ** /*params*/, unsigned /*count*/)
{ {
// someone joined the channel. // someone joined the channel.
IrcContext *context = (IrcContext *) irc_get_ctx(session); IrcContext *context = (IrcContext *) irc_get_ctx(session);
@@ -109,7 +109,7 @@ irc_event_join(irc_session_t *session, const char */*irc_event*/, const char *or
} }
void void
irc_event_nick(irc_session_t *session, const char */*irc_event*/, const char *origin, const char **params, unsigned count) irc_event_nick(irc_session_t *session, const char * /*irc_event*/, const char *origin, const char **params, unsigned count)
{ {
// someone changed his/her nick // someone changed his/her nick
IrcContext *context = (IrcContext *) irc_get_ctx(session); IrcContext *context = (IrcContext *) irc_get_ctx(session);
@@ -123,7 +123,7 @@ irc_event_nick(irc_session_t *session, const char */*irc_event*/, const char *or
} }
void void
irc_event_kick(irc_session_t *session, const char */*irc_event*/, const char *origin, const char **params, unsigned count) irc_event_kick(irc_session_t *session, const char * /*irc_event*/, const char *origin, const char **params, unsigned count)
{ {
// someone got kicked // someone got kicked
IrcContext *context = (IrcContext *) irc_get_ctx(session); IrcContext *context = (IrcContext *) irc_get_ctx(session);
@@ -141,7 +141,7 @@ irc_event_kick(irc_session_t *session, const char */*irc_event*/, const char *or
} }
void void
irc_event_leave(irc_session_t *session, const char */*irc_event*/, const char *origin, const char **/*params*/, unsigned /*count*/) irc_event_leave(irc_session_t *session, const char * /*irc_event*/, const char *origin, const char ** /*params*/, unsigned /*count*/)
{ {
// someone left the channel. // someone left the channel.
IrcContext *context = (IrcContext *) irc_get_ctx(session); IrcContext *context = (IrcContext *) irc_get_ctx(session);
@@ -150,7 +150,7 @@ irc_event_leave(irc_session_t *session, const char */*irc_event*/, const char *o
} }
void void
irc_event_channel(irc_session_t *session, const char */*irc_event*/, const char *origin, const char **params, unsigned count) irc_event_channel(irc_session_t *session, const char * /*irc_event*/, const char *origin, const char **params, unsigned count)
{ {
IrcContext *context = (IrcContext *) irc_get_ctx(session); IrcContext *context = (IrcContext *) irc_get_ctx(session);
@@ -163,7 +163,7 @@ irc_event_channel(irc_session_t *session, const char */*irc_event*/, const char
} }
void void
irc_event_numeric(irc_session_t * session, unsigned irc_event, const char */*origin*/, const char **params, unsigned count) irc_event_numeric(irc_session_t * session, unsigned irc_event, const char * /*origin*/, const char **params, unsigned count)
{ {
switch (irc_event) switch (irc_event)
{ {