Move server configuration to dedicated server only. Separate error logging for client and server, in preparation of creating a log file on the dedicated server.

This commit is contained in:
lotodore
2007-11-22 00:57:03 +00:00
parent e28220a8ad
commit c5bae66142
10 changed files with 230 additions and 41 deletions
+5 -1
View File
@@ -95,6 +95,7 @@ HEADERS += \
src/gamedata.h \
src/config/configfile.h \
src/core/thread.h \
src/core/loghelper.h \
src/engine/boardinterface.h \
src/engine/enginefactory.h \
src/engine/handinterface.h \
@@ -115,6 +116,7 @@ HEADERS += \
src/net/socket_helper.h \
src/net/socket_msg.h \
src/net/socket_startup.h \
src/net/net_helper.h \
src/core/tinyxml/tinystr.h \
src/core/tinyxml/tinyxml.h \
src/engine/local_engine/cardsvalue.h \
@@ -221,7 +223,9 @@ SOURCES += \
src/gui/qt/mymessagedialog/mymessagedialogimpl.cpp \
src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp \
src/gui/qt/gamelobbydialog/mygamelisttreewidget.cpp \
src/gui/qt/gamelobbydialog/lobbychat/lobbychat.cpp
src/gui/qt/gamelobbydialog/lobbychat/lobbychat.cpp \
src/net/common/net_helper_client.cpp \
src/core/common/loghelper_client.cpp
TRANSLATIONS = \
ts/pokerth_de.ts \
+5 -1
View File
@@ -75,10 +75,12 @@ HEADERS += \
src/net/socket_helper.h \
src/net/socket_msg.h \
src/net/socket_startup.h \
src/net/net_helper.h \
src/core/tinyxml/tinystr.h \
src/core/tinyxml/tinyxml.h \
src/core/pokerthexception.h \
src/core/convhelper.h \
src/core/loghelper.h \
src/engine/local_engine/cardsvalue.h \
src/engine/local_engine/localboard.h \
src/engine/local_engine/localenginefactory.h \
@@ -104,7 +106,9 @@ HEADERS += \
SOURCES += \
src/pokerth_server.cpp \
src/gui/qt/qttools/nonqttoolswrapper.cpp \
src/gui/qt/qttools/nonqthelper/nonqthelper.cpp
src/gui/qt/qttools/nonqthelper/nonqthelper.cpp \
src/net/common/net_helper_server.cpp \
src/core/common/loghelper_server.cpp
win32 {
DEPENDPATH += src/net/win32/ src/core/win32
+3 -7
View File
@@ -18,6 +18,7 @@
***************************************************************************/
#include "avatarmanager.h"
#include <net/net_helper.h>
#include <net/socket_msg.h>
#include <core/loghelper.h>
#include <core/crypthelper.h>
@@ -30,13 +31,8 @@
#include <fstream>
#include <cstring>
#ifdef POKERTH_DEDICATED_SERVER
#define MAX_NUMBER_OF_FILES 1024
#define MAX_AVATAR_CACHE_AGE 2592000 // 1 Month
#else
#define MAX_NUMBER_OF_FILES 256
#define MAX_AVATAR_CACHE_AGE 86400
#endif
#define MAX_NUMBER_OF_FILES GetMaxNumberOfAvatarFiles()
#define MAX_AVATAR_CACHE_AGE GetMaxAvatarCacheAgeSec()
#define PNG_HEADER "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a"
#define PNG_HEADER_SIZE (sizeof(PNG_HEADER) - 1)
+41
View File
@@ -0,0 +1,41 @@
/***************************************************************************
* 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. *
***************************************************************************/
#ifdef POKERTH_DEDICATED_SERVER
#error This file is only for the client.
#endif
#include <core/loghelper.h>
#include <iostream>
using namespace std;
void
internal_log_err(const string &msg)
{
cout << msg;
}
void
internal_log_msg(const std::string &msg)
{
cout << msg;
}
+54
View File
@@ -0,0 +1,54 @@
/***************************************************************************
* 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 POKERTH_DEDICATED_SERVER
#error This file is only for the server.
#endif
#include <core/loghelper.h>
#ifdef _WIN32
#include <iostream>
#else
#include <syslog.h>
#include <stdarg.h>
#endif
using namespace std;
void
internal_log_err(const string &msg)
{
#ifdef _WIN32
cout << msg;
#else
syslog(LOG_ERR, "%s", msg.c_str());
#endif
}
void
internal_log_msg(const std::string &msg)
{
#ifdef _WIN32
cout << msg;
#else
syslog(LOG_INFO, "%s", msg.c_str());
#endif
}
+21 -30
View File
@@ -21,37 +21,28 @@
#ifndef _LOGHELPER_H_
#define _LOGHELPER_H_
#ifndef _WIN32
#ifdef POKERTH_DEDICATED_SERVER
#include <sstream>
#include <syslog.h>
#include <stdarg.h>
#define LOG_ERROR(e) \
do \
{ \
std::ostringstream outStream; \
outStream << e << std::endl; \
syslog(LOG_ERR, "%s", outStream.str().c_str()); \
} \
while(false)
#define LOG_MSG(e) \
do \
{ \
std::ostringstream outStream; \
outStream << e << std::endl; \
syslog(LOG_INFO, "%s", outStream.str().c_str()); \
} \
while(false)
#endif
#endif
#include <string>
#include <sstream>
#ifndef LOG_ERROR
#include <iostream>
#define LOG_ERROR(e) \
std::cout << e << std::endl
#define LOG_MSG(e) \
std::cout << e << std::endl
#endif
void internal_log_err(const std::string &msg);
void internal_log_msg(const std::string &msg);
#define LOG_ERROR(e) \
do \
{ \
std::ostringstream outStream; \
outStream << e << std::endl; \
internal_log_err(outStream.str()); \
} \
while(false)
#define LOG_MSG(e) \
do \
{ \
std::ostringstream outStream; \
outStream << e << std::endl; \
internal_log_msg(outStream.str()); \
} \
while(false)
#endif
+37
View File
@@ -0,0 +1,37 @@
/***************************************************************************
* 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. *
***************************************************************************/
#ifdef POKERTH_DEDICATED_SERVER
#error This file is only for the client.
#endif
#include <net/net_helper.h>
unsigned
GetMaxNumberOfAvatarFiles()
{
return 256;
}
unsigned
GetMaxAvatarCacheAgeSec()
{
return 604800; // 1 Week
}
+37
View File
@@ -0,0 +1,37 @@
/***************************************************************************
* 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 POKERTH_DEDICATED_SERVER
#error This file is only for the server.
#endif
#include <net/net_helper.h>
unsigned
GetMaxNumberOfAvatarFiles()
{
return 2048;
}
unsigned
GetMaxAvatarCacheAgeSec()
{
return 2592000; // 1 Month
}
+27
View File
@@ -0,0 +1,27 @@
/***************************************************************************
* 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. *
***************************************************************************/
/* Retrieve internal configuration values. */
#ifndef _NET_HELPER_H_
#define _NET_HELPER_H_
unsigned GetMaxNumberOfAvatarFiles();
unsigned GetMaxAvatarCacheAgeSec();
#endif
-2
View File
@@ -56,9 +56,7 @@ bool Session::init()
{
myAvatarManager.reset(new AvatarManager);
bool retVal = myAvatarManager->Init(myConfig->readConfigString("AppDataDir"), myConfig->readConfigString("CacheDir"));
#ifndef POKERTH_DEDICATED_SERVER
myAvatarManager->AddSingleAvatar(myConfig->readConfigString("MyAvatar"));
#endif
myAvatarManager->RemoveOldAvatarCacheEntries();
return retVal;
}