From 138ceaf5835d6b3e0201a132abdeb96be45fa6fd Mon Sep 17 00:00:00 2001 From: David Solbach Date: Sun, 14 Nov 2010 07:01:47 +0100 Subject: [PATCH] new project for server --- buliscores-server/buliscores-server.pro | 23 ++++++++++++ buliscores-server/buliscoressrv.cpp | 26 ++++++++++++++ buliscores-server/buliscoressrv.h | 42 ++++++++++++++++++++++ buliscores-server/main.cpp | 59 +++++++++++++++++++++++++++++++ buliscores.pro.user | 56 ++--------------------------- src/src/backendkicker.cpp | 4 +++ 6 files changed, 156 insertions(+), 54 deletions(-) create mode 100644 buliscores-server/buliscores-server.pro create mode 100644 buliscores-server/buliscoressrv.cpp create mode 100644 buliscores-server/buliscoressrv.h create mode 100644 buliscores-server/main.cpp diff --git a/buliscores-server/buliscores-server.pro b/buliscores-server/buliscores-server.pro new file mode 100644 index 0000000..611fd92 --- /dev/null +++ b/buliscores-server/buliscores-server.pro @@ -0,0 +1,23 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2010-11-14T06:42:15 +# +#------------------------------------------------- + +QT += core +QT += network + +QT -= gui + +TARGET = buliscores-server +CONFIG += console +CONFIG -= app_bundle + +TEMPLATE = app + + +SOURCES += main.cpp \ + buliscoressrv.cpp + +HEADERS += \ + buliscoressrv.h diff --git a/buliscores-server/buliscoressrv.cpp b/buliscores-server/buliscoressrv.cpp new file mode 100644 index 0000000..05e26d6 --- /dev/null +++ b/buliscores-server/buliscoressrv.cpp @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2010 David Solbach + * + * This file is part of BuliScores. + * + * BuliScores is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * BiliScores 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "buliscoressrv.h" + +BuliScoresSrv::BuliScoresSrv(QObject *parent) : + QObject(parent) +{ +} diff --git a/buliscores-server/buliscoressrv.h b/buliscores-server/buliscoressrv.h new file mode 100644 index 0000000..0f8aa82 --- /dev/null +++ b/buliscores-server/buliscoressrv.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2010 David Solbach + * + * This file is part of BuliScores. + * + * BuliScores is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * BiliScores 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef BULISCORESSRV_H +#define BULISCORESSRV_H + +#include +#include + +class BuliScoresSrv : public QObject +{ + Q_OBJECT +private: + QTcpServer m_tcpServer; + +public: + explicit BuliScoresSrv(QObject *parent = 0); + +signals: + +public slots: + +}; + +#endif // BULISCORESSRV_H diff --git a/buliscores-server/main.cpp b/buliscores-server/main.cpp new file mode 100644 index 0000000..0ae31c6 --- /dev/null +++ b/buliscores-server/main.cpp @@ -0,0 +1,59 @@ +#include +#include +#include +#include + +void messageHandler(QtMsgType type, const char *msg) +{ + static QFile logfile; + static QTextStream fw; + static const QString LOGFILE_PATH = "/tmp/buliscores.log"; + static const QtMsgType LOGLEVEL = QtDebugMsg; + QString out; + + if (type < LOGLEVEL) { + return; + } + + if (logfile.isOpen() == false) { + logfile.setFileName(LOGFILE_PATH); + if (logfile.open(QIODevice::Append) == true) { + fw.setDevice((QIODevice*)&logfile); + fw << "Logfile Opened: " << QDateTime::currentDateTime().toString(); + } + } + + switch (type) { + case QtDebugMsg: + out = "%1 Debug: %2\n"; + break; + case QtWarningMsg: + out = "%1 Warning: %2\n"; + break; + case QtCriticalMsg: + out = "%1 Critical: %2\n"; + break; + case QtFatalMsg: + out = "%1 Fatal: %2\n"; + break; + } + + out = out.arg(QDateTime::currentDateTime().toString(), msg); + + if (logfile.isOpen()) { + fw << out; + fw.flush(); + } + printf("%s", out.toAscii().constData()); + + if (type == QtFatalMsg) { + qApp->exit(-1); + } +} + +int main(int argc, char *argv[]) +{ + QCoreApplication a(argc, argv); + + return a.exec(); +} diff --git a/buliscores.pro.user b/buliscores.pro.user index 59a8a9a..06b37e1 100644 --- a/buliscores.pro.user +++ b/buliscores.pro.user @@ -16,7 +16,7 @@ Desktop Qt4ProjectManager.Target.DesktopTarget 0 - 4 + 0 qmake @@ -87,58 +87,6 @@ 2 - cmdline_tester - Qt4ProjectManager.Qt4RunConfiguration - 2 - - qjson/tests/cmdline_tester/cmdline_tester.pro - false - false - - false - false - - - - parser - Qt4ProjectManager.Qt4RunConfiguration - 2 - - qjson/tests/parser/parser.pro - false - false - - false - false - - - - qobjecthelper - Qt4ProjectManager.Qt4RunConfiguration - 2 - - qjson/tests/qobjecthelper/qobjecthelper.pro - false - false - - false - false - - - - serializer - Qt4ProjectManager.Qt4RunConfiguration - 2 - - qjson/tests/serializer/serializer.pro - false - false - - false - false - - - src Qt4ProjectManager.Qt4RunConfiguration 2 @@ -151,7 +99,7 @@ false - 5 + 1 diff --git a/src/src/backendkicker.cpp b/src/src/backendkicker.cpp index f52755d..ad16b60 100644 --- a/src/src/backendkicker.cpp +++ b/src/src/backendkicker.cpp @@ -9,6 +9,7 @@ #include #include +#include #include "backendkicker.h" @@ -76,11 +77,14 @@ QVariant BackendKicker::serializableData() QList list; QListIterator iter(m_matchlist); Match* match; + QJson::Serializer serializer; + while (iter.hasNext()) { match = iter.next(); matchvariantmap = QJson::QObjectHelper::qobject2qvariant(match); + qDebug() << serializer.serialize(matchvariantmap); list.append(QVariant(matchvariantmap)); } -- 1.7.9.5