From c6da7b0d357cd5920006a20e2046ddf746f29bc7 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 9 Dec 2013 16:39:31 +0000 Subject: [PATCH] removing unneeded code refs #81 --- client.pro | 13 - samples/com_client/CMakeLists.txt | 9 - samples/com_client/client.cpp | 38 --- samples/com_client/client.h | 19 -- samples/com_client/main.cpp | 20 -- samples/com_client/sample_com_client.pro | 25 -- samples/com_server/CMakeLists.txt | 9 - samples/com_server/main.cpp | 20 -- samples/com_server/sample_com_server.pro | 24 -- samples/com_server/server.cpp | 40 --- samples/com_server/server.h | 32 --- samples/config/CMakeLists.txt | 6 - samples/config/config/config.ini | 0 samples/config/config/position.cfg | 3 - samples/config/config/test.cfg | 2 - samples/config/main.cpp | 31 --- samples/config/sample_config.pro | 21 -- samples/dbusclient/dbus/aircraftmanager.xml | 8 - samples/dbusclient/dbus/atcmanager.xml | 6 - samples/dbusclient/dbus/fsdclient.xml | 11 - samples/dbusclient/dbusclient.cpp | 95 ------- samples/dbusclient/dbusclient.h | 44 --- samples/dbusclient/main.cpp | 32 --- samples/dbusclient/remote_aircraft.cpp | 58 ---- samples/dbusclient/remote_aircraft.h | 85 ------ samples/dbusclient/sample_dbusclient.pro | 26 -- samples/dbusserver/aircraft_manager.cpp | 30 -- samples/dbusserver/aircraft_manager.h | 64 ----- .../dbusserver/aircraft_manager_handler.cpp | 29 -- samples/dbusserver/aircraft_manager_handler.h | 53 ---- samples/dbusserver/atc_manager.cpp | 28 -- samples/dbusserver/atc_manager.h | 57 ---- samples/dbusserver/atc_manager_handler.cpp | 33 --- samples/dbusserver/atc_manager_handler.h | 49 ---- samples/dbusserver/dbus/aircraftmanager.xml | 8 - samples/dbusserver/dbus/atcmanager.xml | 6 - samples/dbusserver/dbus/fsdclient.xml | 11 - samples/dbusserver/fsd_client.cpp | 18 -- samples/dbusserver/fsd_client.h | 42 --- samples/dbusserver/fsd_client_handler.cpp | 29 -- samples/dbusserver/fsd_client_handler.h | 52 ---- samples/dbusserver/main.cpp | 48 ---- samples/dbusserver/remote_aircraft.cpp | 68 ----- samples/dbusserver/remote_aircraft.h | 92 ------- samples/dbusserver/sample_dbusserver.pro | 35 --- src/blackbox/CMakeLists.txt | 29 -- src/blackbox/blackbox.cpp | 50 ---- src/blackbox/blackbox.h | 37 --- src/blackbox/blackbox.pro | 21 -- src/blackbox/blackbox.ui | 59 ---- src/blackbox/dialog_chat.cpp | 21 -- src/blackbox/dialog_chat.h | 27 -- src/blackbox/dialog_chat.ui | 74 ----- src/blackbox/dialog_connect.cpp | 67 ----- src/blackbox/dialog_connect.h | 36 --- src/blackbox/dialog_connect.ui | 171 ------------ src/blackbox/main.cpp | 24 -- src/blackcore/atclistmgr.cpp | 35 --- src/blackcore/atclistmgr.h | 82 ------ src/blackcore/fsd_client.cpp | 187 ------------- src/blackcore/fsd_client.h | 131 --------- src/blackcore/fsd_messages.cpp | 96 ------- src/blackcore/fsd_messages.h | 149 ---------- src/blackcore/fsd_protocol.h | 61 ---- src/blackcore/multiplayer.cpp | 102 ------- src/blackcore/multiplayer.h | 100 ------- src/blackcore/plane.cpp | 54 ---- src/blackcore/plane.h | 80 ------ src/blackcore/sim_callbacks.h | 6 - src/blackcore/simulator.cpp | 152 ---------- src/blackcore/simulator.h | 260 ------------------ src/blackmisc/atclist.h | 111 -------- src/blackmisc/com_client.cpp | 186 ------------- src/blackmisc/com_client.h | 121 -------- src/blackmisc/com_client_buffer.cpp | 59 ---- src/blackmisc/com_client_buffer.h | 52 ---- src/blackmisc/com_handler.cpp | 127 --------- src/blackmisc/com_handler.h | 77 ------ src/blackmisc/com_server.cpp | 136 --------- src/blackmisc/com_server.h | 105 ------- src/blackmisc/config.cpp | 239 ---------------- src/blackmisc/config.h | 168 ----------- src/blackmisc/config_manager.cpp | 98 ------- src/blackmisc/config_manager.h | 74 ----- src/blackmisc/dbus_handler.cpp | 30 -- src/blackmisc/dbus_handler.h | 59 ---- src/blackmisc/gui_messages.h | 115 -------- src/blackmisc/message.cpp | 15 - src/blackmisc/message.h | 73 ----- src/blackmisc/message_dispatcher.cpp | 32 --- src/blackmisc/message_dispatcher.h | 55 ---- src/blackmisc/message_factory.cpp | 48 ---- src/blackmisc/message_factory.h | 61 ---- src/blackmisc/message_handler.cpp | 25 -- src/blackmisc/message_handler.h | 75 ----- src/blackmisc/message_system.cpp | 17 -- src/blackmisc/message_system.h | 26 -- src/blackmisc/serialize.h | 26 -- src/blackmisc/type_info.cpp | 21 -- src/blackmisc/type_info.h | 27 -- tests/blackcore/testnetmediators.cpp | 66 ----- tests/blackcore/testnetmediators.h | 76 ----- 102 files changed, 5940 deletions(-) delete mode 100644 samples/com_client/CMakeLists.txt delete mode 100644 samples/com_client/client.cpp delete mode 100644 samples/com_client/client.h delete mode 100644 samples/com_client/main.cpp delete mode 100644 samples/com_client/sample_com_client.pro delete mode 100644 samples/com_server/CMakeLists.txt delete mode 100644 samples/com_server/main.cpp delete mode 100644 samples/com_server/sample_com_server.pro delete mode 100644 samples/com_server/server.cpp delete mode 100644 samples/com_server/server.h delete mode 100644 samples/config/CMakeLists.txt delete mode 100644 samples/config/config/config.ini delete mode 100644 samples/config/config/position.cfg delete mode 100644 samples/config/config/test.cfg delete mode 100644 samples/config/main.cpp delete mode 100644 samples/config/sample_config.pro delete mode 100644 samples/dbusclient/dbus/aircraftmanager.xml delete mode 100644 samples/dbusclient/dbus/atcmanager.xml delete mode 100644 samples/dbusclient/dbus/fsdclient.xml delete mode 100644 samples/dbusclient/dbusclient.cpp delete mode 100644 samples/dbusclient/dbusclient.h delete mode 100644 samples/dbusclient/main.cpp delete mode 100644 samples/dbusclient/remote_aircraft.cpp delete mode 100644 samples/dbusclient/remote_aircraft.h delete mode 100644 samples/dbusclient/sample_dbusclient.pro delete mode 100644 samples/dbusserver/aircraft_manager.cpp delete mode 100644 samples/dbusserver/aircraft_manager.h delete mode 100644 samples/dbusserver/aircraft_manager_handler.cpp delete mode 100644 samples/dbusserver/aircraft_manager_handler.h delete mode 100644 samples/dbusserver/atc_manager.cpp delete mode 100644 samples/dbusserver/atc_manager.h delete mode 100644 samples/dbusserver/atc_manager_handler.cpp delete mode 100644 samples/dbusserver/atc_manager_handler.h delete mode 100644 samples/dbusserver/dbus/aircraftmanager.xml delete mode 100644 samples/dbusserver/dbus/atcmanager.xml delete mode 100644 samples/dbusserver/dbus/fsdclient.xml delete mode 100644 samples/dbusserver/fsd_client.cpp delete mode 100644 samples/dbusserver/fsd_client.h delete mode 100644 samples/dbusserver/fsd_client_handler.cpp delete mode 100644 samples/dbusserver/fsd_client_handler.h delete mode 100644 samples/dbusserver/main.cpp delete mode 100644 samples/dbusserver/remote_aircraft.cpp delete mode 100644 samples/dbusserver/remote_aircraft.h delete mode 100644 samples/dbusserver/sample_dbusserver.pro delete mode 100644 src/blackbox/CMakeLists.txt delete mode 100644 src/blackbox/blackbox.cpp delete mode 100644 src/blackbox/blackbox.h delete mode 100644 src/blackbox/blackbox.pro delete mode 100644 src/blackbox/blackbox.ui delete mode 100644 src/blackbox/dialog_chat.cpp delete mode 100644 src/blackbox/dialog_chat.h delete mode 100644 src/blackbox/dialog_chat.ui delete mode 100644 src/blackbox/dialog_connect.cpp delete mode 100644 src/blackbox/dialog_connect.h delete mode 100644 src/blackbox/dialog_connect.ui delete mode 100644 src/blackbox/main.cpp delete mode 100644 src/blackcore/atclistmgr.cpp delete mode 100644 src/blackcore/atclistmgr.h delete mode 100644 src/blackcore/fsd_client.cpp delete mode 100644 src/blackcore/fsd_client.h delete mode 100644 src/blackcore/fsd_messages.cpp delete mode 100644 src/blackcore/fsd_messages.h delete mode 100644 src/blackcore/fsd_protocol.h delete mode 100644 src/blackcore/multiplayer.cpp delete mode 100644 src/blackcore/multiplayer.h delete mode 100644 src/blackcore/plane.cpp delete mode 100644 src/blackcore/plane.h delete mode 100644 src/blackcore/sim_callbacks.h delete mode 100644 src/blackcore/simulator.cpp delete mode 100644 src/blackcore/simulator.h delete mode 100644 src/blackmisc/atclist.h delete mode 100644 src/blackmisc/com_client.cpp delete mode 100644 src/blackmisc/com_client.h delete mode 100644 src/blackmisc/com_client_buffer.cpp delete mode 100644 src/blackmisc/com_client_buffer.h delete mode 100644 src/blackmisc/com_handler.cpp delete mode 100644 src/blackmisc/com_handler.h delete mode 100644 src/blackmisc/com_server.cpp delete mode 100644 src/blackmisc/com_server.h delete mode 100644 src/blackmisc/config.cpp delete mode 100644 src/blackmisc/config.h delete mode 100644 src/blackmisc/config_manager.cpp delete mode 100644 src/blackmisc/config_manager.h delete mode 100644 src/blackmisc/dbus_handler.cpp delete mode 100644 src/blackmisc/dbus_handler.h delete mode 100644 src/blackmisc/gui_messages.h delete mode 100644 src/blackmisc/message.cpp delete mode 100644 src/blackmisc/message.h delete mode 100644 src/blackmisc/message_dispatcher.cpp delete mode 100644 src/blackmisc/message_dispatcher.h delete mode 100644 src/blackmisc/message_factory.cpp delete mode 100644 src/blackmisc/message_factory.h delete mode 100644 src/blackmisc/message_handler.cpp delete mode 100644 src/blackmisc/message_handler.h delete mode 100644 src/blackmisc/message_system.cpp delete mode 100644 src/blackmisc/message_system.h delete mode 100644 src/blackmisc/serialize.h delete mode 100644 src/blackmisc/type_info.cpp delete mode 100644 src/blackmisc/type_info.h delete mode 100644 tests/blackcore/testnetmediators.cpp delete mode 100644 tests/blackcore/testnetmediators.h diff --git a/client.pro b/client.pro index d09e750ea..3d0c14079 100644 --- a/client.pro +++ b/client.pro @@ -6,8 +6,6 @@ include (externals.pri) WITH_BLACKMISC = ON WITH_BLACKCORE = ON -WITH_BLACKD = ON -WITH_BLACKBOX = ON WITH_SAMPLES = ON #WITH_DRIVER_FSX = ON @@ -25,12 +23,6 @@ equals(WITH_BLACKCORE, ON) { SUBDIRS += src/blackcore } -equals(WITH_BLACKD, ON) { - SUBDIRS += src/blackd -} - -equals(WITH_BLACKBOX, ON) { - SUBDIRS += src/blackbox } equals(WITH_DRIVER_FSX, ON) { @@ -47,9 +39,6 @@ equals(WITH_DRIVER_XPLANE, ON) { equals(WITH_SAMPLES, ON) { SUBDIRS += samples/cli_client/sample_cli_client.pro - SUBDIRS += samples/com_client/sample_com_client.pro - SUBDIRS += samples/com_server/sample_com_server.pro - SUBDIRS += samples/config/sample_config.pro SUBDIRS += samples/interpolator/sample_interpolator.pro SUBDIRS += samples/logging/sample_logging.pro SUBDIRS += samples/plugin/sample_plugin.pro @@ -57,8 +46,6 @@ equals(WITH_SAMPLES, ON) { SUBDIRS += samples/blackmiscvectorgeo/sample_vector_geo.pro SUBDIRS += samples/blackmiscquantities/sample_quantities_avionics.pro SUBDIRS += samples/blackmiscquantities_dbus/sample_quantities_avionics_dbus.pro - SUBDIRS += samples/dbusserver/sample_dbusserver.pro - SUBDIRS += samples/dbusclient/sample_dbusclient.pro } equals(WITH_UNITTESTS, ON) { diff --git a/samples/com_client/CMakeLists.txt b/samples/com_client/CMakeLists.txt deleted file mode 100644 index e09876dd0..000000000 --- a/samples/com_client/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -FILE(GLOB sample_com_client_SOURCES *.cpp) -SET(sample_com_client_HEADERS client.h) - -QT4_WRAP_CPP(sample_com_client_HEADERS_MOC ${sample_com_client_HEADERS}) - -ADD_EXECUTABLE(sample_com_client ${sample_com_client_SOURCES} ${sample_com_client_HEADERS_MOC}) - -TARGET_LINK_LIBRARIES(sample_com_client blackmisc ${QT_LIBRARIES}) -SET_TARGET_PROPERTIES(sample_com_client PROPERTIES PROJECT_LABEL "Samples - Com client") \ No newline at end of file diff --git a/samples/com_client/client.cpp b/samples/com_client/client.cpp deleted file mode 100644 index 4f1eb8a1c..000000000 --- a/samples/com_client/client.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include "client.h" -#include - -using namespace BlackMisc; - -Client::Client(QObject *parent) : QObject(parent), comclient(IContext::getInstance()) -{ - connect(&comclient, &BlackMisc::CComClient::doError, - this, &Client::onError); - connect(&comclient, &BlackMisc::CComClient::doConnected, - this, &Client::onClientConnected); - - QString address = "127.0.0.1"; - comclient.connectTo(address, 6809); -} - -Client::~Client() -{ -} - -void Client::onError(QAbstractSocket::SocketError /* error */, QString message) -{ - bAppWarning << "Socket error!"; -} - -void Client::onClientConnected() -{ - QByteArray message_data; - QDataStream out(&message_data, QIODevice::WriteOnly); - - IMessage* testmsg = new TestMessage(); - - *testmsg >> out; - - comclient.sendMessage(testmsg->getID(), message_data); - delete testmsg; -} diff --git a/samples/com_client/client.h b/samples/com_client/client.h deleted file mode 100644 index 3bbd1d9c0..000000000 --- a/samples/com_client/client.h +++ /dev/null @@ -1,19 +0,0 @@ -#include "blackmisc/message_system.h" -#include "blackmisc/com_client.h" - -class Client : public QObject -{ - Q_OBJECT - -public: - explicit Client(QObject *parent = NULL); - ~Client(); - -protected slots: - - void onError(QAbstractSocket::SocketError,QString); - void onClientConnected(); - -private: - BlackMisc::CComClient comclient; -}; diff --git a/samples/com_client/main.cpp b/samples/com_client/main.cpp deleted file mode 100644 index 4f1a2f4a5..000000000 --- a/samples/com_client/main.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include - -#include "blackmisc/context.h" -#include "client.h" - -using namespace BlackMisc; - -int main(int argc, char *argv[]) -{ - QCoreApplication a(argc, argv); - - BlackMisc::CApplicationContext ctx; - BlackMisc::IContext::setInstance(ctx); - BlackMisc::CDebug debug; - ctx.setObject(debug); - - Client client; - - return a.exec(); -} diff --git a/samples/com_client/sample_com_client.pro b/samples/com_client/sample_com_client.pro deleted file mode 100644 index ba2388745..000000000 --- a/samples/com_client/sample_com_client.pro +++ /dev/null @@ -1,25 +0,0 @@ -QT += core network -QT -= gui - -TARGET = com_client - -CONFIG += console c++11 -CONFIG -= app_bundle - -TEMPLATE = app - -DEPENDPATH += . ../../src -INCLUDEPATH += . ../../src - -SOURCES += *.cpp -HEADERS += *.h - -LIBS += -L../../lib -lblackmisc - -win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib -else: PRE_TARGETDEPS += ../../lib/libblackmisc.a - -DESTDIR = ../../bin - - - diff --git a/samples/com_server/CMakeLists.txt b/samples/com_server/CMakeLists.txt deleted file mode 100644 index 5df290a3a..000000000 --- a/samples/com_server/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -FILE(GLOB sample_com_server_SOURCES *.cpp) -SET(sample_com_server_HEADERS server.h) - -QT4_WRAP_CPP(sample_com_server_HEADERS_MOC ${sample_com_server_HEADERS}) - -ADD_EXECUTABLE(sample_com_server ${sample_com_server_SOURCES} ${sample_com_server_HEADERS_MOC}) - -TARGET_LINK_LIBRARIES(sample_com_server blackmisc ${QT_LIBRARIES}) -SET_TARGET_PROPERTIES(sample_com_server PROPERTIES PROJECT_LABEL "Samples - Com Server") \ No newline at end of file diff --git a/samples/com_server/main.cpp b/samples/com_server/main.cpp deleted file mode 100644 index bb937fb3f..000000000 --- a/samples/com_server/main.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include - -#include "blackmisc/context.h" -#include "server.h" - -using namespace BlackMisc; - -int main(int argc, char *argv[]) -{ - QCoreApplication a(argc, argv); - - BlackMisc::CApplicationContext ctx; - BlackMisc::IContext::setInstance(ctx); - BlackMisc::CDebug debug; - ctx.setObject(debug); - - Server server; - - return a.exec(); -} diff --git a/samples/com_server/sample_com_server.pro b/samples/com_server/sample_com_server.pro deleted file mode 100644 index 68c6521e8..000000000 --- a/samples/com_server/sample_com_server.pro +++ /dev/null @@ -1,24 +0,0 @@ -QT += core network -QT -= gui - -TARGET = com_server -TEMPLATE = app - -CONFIG += console c++11 -CONFIG -= app_bundle - -DEPENDPATH += . ../../src -INCLUDEPATH += . ../../src - -SOURCES += *.cpp -HEADERS += *.h - -LIBS += -L../../lib -lblackmisc - -win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib -else: PRE_TARGETDEPS += ../../lib/libblackmisc.a - -DESTDIR = ../../bin - - - diff --git a/samples/com_server/server.cpp b/samples/com_server/server.cpp deleted file mode 100644 index e47a9aa87..000000000 --- a/samples/com_server/server.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "blackmisc/debug.h" -#include "server.h" - -using namespace BlackMisc; - -Server::Server(QObject *parent) : QObject(parent), server(IContext::getInstance()) -{ - QHostAddress local = QHostAddress(QHostAddress::LocalHost); - - server.Host(local, 6809); - - connect(&server, static_cast(&BlackMisc::CComServer::doMessageReceived), - this, &Server::onData); - - CMessageSystem myMessageSystem; - - bAppInfo << "Com Server running. \n"; -} - -Server::~Server() -{ -} - -void Server::onData(QString &messageID, QByteArray &message) -{ - BlackMisc::IMessage* test = BlackMisc::CMessageFactory::getInstance().create(messageID); - QDataStream stream(&message, QIODevice::ReadOnly); - - Q_ASSERT(test); - *test << stream; - - CMessageDispatcher::getInstance().append(test); - CMessageDispatcher::getInstance().dispatch(); - -} - -void TestMessageHandler::onTestMessage(const TestMessage *testmessage) -{ - bAppDebug << "Message ID: " << testmessage->getID() << " with text: " << testmessage->getTestString(); -} diff --git a/samples/com_server/server.h b/samples/com_server/server.h deleted file mode 100644 index 481cfbfcb..000000000 --- a/samples/com_server/server.h +++ /dev/null @@ -1,32 +0,0 @@ -#include "blackmisc/message_system.h" -#include "blackmisc/com_server.h" - -class TestMessageHandler : public BlackMisc::CMessageHandler -{ -public: - TestMessageHandler() - { - registerMessageFunction(this, &TestMessageHandler::onTestMessage); - } -private: - - void onTestMessage(const BlackMisc::TestMessage *testmessage); - -}; - -class Server : public QObject -{ - Q_OBJECT - -public: - explicit Server(QObject *parent = NULL); - ~Server(); - -protected slots: - - void onData(QString &messageID, QByteArray& message); - -private: - BlackMisc::CComServer server; - TestMessageHandler myHandler; -}; diff --git a/samples/config/CMakeLists.txt b/samples/config/CMakeLists.txt deleted file mode 100644 index 4db634be2..000000000 --- a/samples/config/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -FILE(GLOB SRC *.cpp) - -ADD_EXECUTABLE(sample_config ${SRC}) - -TARGET_LINK_LIBRARIES(sample_config blackmisc ${QT_LIBRARIES}) -SET_TARGET_PROPERTIES(sample_config PROPERTIES PROJECT_LABEL "Samples - Config") \ No newline at end of file diff --git a/samples/config/config/config.ini b/samples/config/config/config.ini deleted file mode 100644 index e69de29bb..000000000 diff --git a/samples/config/config/position.cfg b/samples/config/config/position.cfg deleted file mode 100644 index cd05ebc1a..000000000 --- a/samples/config/config/position.cfg +++ /dev/null @@ -1,3 +0,0 @@ -Longitude=48.999999 -Latitude=11.9999999 -Altitude=300 \ No newline at end of file diff --git a/samples/config/config/test.cfg b/samples/config/config/test.cfg deleted file mode 100644 index 6b6b9ee37..000000000 --- a/samples/config/config/test.cfg +++ /dev/null @@ -1,2 +0,0 @@ -TestString = Hallo -TestString2 = Welt \ No newline at end of file diff --git a/samples/config/main.cpp b/samples/config/main.cpp deleted file mode 100644 index 7874fbcb2..000000000 --- a/samples/config/main.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include "blackmisc/debug.h" -#include "blackmisc/config_manager.h" -#include "blackmisc/config.h" -#include -#include - -using namespace BlackMisc; - -int main(int argc, char *argv[]) -{ - QCoreApplication a(argc, argv); - - BlackMisc::CApplicationContext ctx; - BlackMisc::IContext::setInstance(ctx); - BlackMisc::CDebug debug; - ctx.setObject(debug); - - CConfigManager::getInstance().setConfigPath(QString("config")); - if (!CConfigManager::getInstance().readConfig()) - { - bAppWarning << "To run this sample, there must be a config folder"; - bAppWarning << "in the same directory, containing *.cfg files."; - } - - CConfig *myConfig = CConfigManager::getInstance().getConfig("position"); - Q_ASSERT(myConfig); - myConfig->display(); - - return a.exec(); -} diff --git a/samples/config/sample_config.pro b/samples/config/sample_config.pro deleted file mode 100644 index f6a151727..000000000 --- a/samples/config/sample_config.pro +++ /dev/null @@ -1,21 +0,0 @@ -QT += core network -QT -= gui - -TARGET = sample_config -TEMPLATE = app -CONFIG += c++11 - -DEPENDPATH += . ../../src -INCLUDEPATH += . ../../src - -SOURCES += *.cpp - -LIBS += -L../../lib -lblackmisc - -win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib -else: PRE_TARGETDEPS += ../../lib/libblackmisc.a - -DESTDIR = ../../bin - - - diff --git a/samples/dbusclient/dbus/aircraftmanager.xml b/samples/dbusclient/dbus/aircraftmanager.xml deleted file mode 100644 index a70131d7f..000000000 --- a/samples/dbusclient/dbus/aircraftmanager.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/samples/dbusclient/dbus/atcmanager.xml b/samples/dbusclient/dbus/atcmanager.xml deleted file mode 100644 index c78196aa5..000000000 --- a/samples/dbusclient/dbus/atcmanager.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/samples/dbusclient/dbus/fsdclient.xml b/samples/dbusclient/dbus/fsdclient.xml deleted file mode 100644 index 4a50e30da..000000000 --- a/samples/dbusclient/dbus/fsdclient.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/samples/dbusclient/dbusclient.cpp b/samples/dbusclient/dbusclient.cpp deleted file mode 100644 index abf72b63d..000000000 --- a/samples/dbusclient/dbusclient.cpp +++ /dev/null @@ -1,95 +0,0 @@ -#include -#include - -#include "remote_aircraft.h" - -#include "dbusclient.h" - - -DBusClient::DBusClient(QObject *parent) : - QObject(parent), m_connection("daemon") -{ - m_connection = QDBusConnection::connectToPeer("tcp:host=127.0.0.1,port=45000", "daemon"); - - if(!m_connection.isConnected()) - { - qWarning() << m_connection.lastError().message(); - } - - aircraftManagerIface = new org::vatsim::pilotClient::AircraftManager("org.vatsim.PilotClient", "/AircraftManager", m_connection, this); - atcManagerIface = new org::vatsim::pilotClient::AtcManager("org.vatsim.PilotClien", "/AtcManager", m_connection, this); - fsdClientIface = new org::vatsim::pilotClient::FsdClient("org.vatsim.PilotClient", "/FsdClient", m_connection, this); - connect(fsdClientIface, &org::vatsim::pilotClient::FsdClient::connectedTo, this, &DBusClient::slot_connected); -} - -DBusClient::~DBusClient() -{ - -} - -void DBusClient::connectTo(const QString &host) -{ - fsdClientIface->connectTo(host); -} - -void DBusClient::disconnectFrom() -{ -} - -void DBusClient::slot_connected( const QString & host) -{ - qDebug() << "Conntected to " << host; - qDebug() << "Retrieve all visible aircrafts and controllers..."; - - - printPilotList(); - printAtcList(); -} - -void DBusClient::slot_disconnected() -{ - qDebug() << "Disconntected from Vatsim"; -} - -void DBusClient::printPilotList() -{ - Q_ASSERT(aircraftManagerIface); - - qDebug() << "Online aircrafts: "; - - CRemoteAircraftList aircrafts = aircraftManagerIface->aircraftList(); - if (aircrafts.isEmpty()) - { - qWarning() << "Got no aircrafts. Something went wrong!"; - return; - } - foreach(CRemoteAircraft aircraft, aircrafts) - { - qDebug() << aircraft.getCallsign(); - } -} - -void DBusClient::printAtcList() -{ - Q_ASSERT(atcManagerIface); - - qDebug() << "Online controllers: "; - - QStringList controllers = atcManagerIface->atcList(); - - if (controllers.isEmpty()) - { - qWarning() << "Got no controllers. Something went wrong!"; - return; - } - - foreach(QString controller, controllers) - { - qDebug() << controller; - } -} - -void DBusClient::printError() -{ - qWarning() << m_connection.lastError().message(); -} diff --git a/samples/dbusclient/dbusclient.h b/samples/dbusclient/dbusclient.h deleted file mode 100644 index 49b97ec4b..000000000 --- a/samples/dbusclient/dbusclient.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef DBUSCLIENT_H -#define DBUSCLIENT_H - -#include -#include -#include - -#include "aircraftmanager_interface.h" -#include "atcmanager_interface.h" -#include "fsdclient_interface.h" - -class DBusClient : public QObject -{ - Q_OBJECT - -private: - QDBusConnection m_connection; - org::vatsim::pilotClient::AircraftManager *aircraftManagerIface; - org::vatsim::pilotClient::AtcManager *atcManagerIface; - org::vatsim::pilotClient::FsdClient *fsdClientIface; - -public: - explicit DBusClient(QObject *parent = 0); - ~DBusClient(); - - void connectTo(const QString &host); - void disconnectFrom(); - - void printPilotList(); - void printAtcList(); - - void printError(); - -signals: - -public slots: - -private slots: - void slot_connected(const QString &host); - void slot_disconnected(); - -}; - -#endif // DBUSCLIENT_H diff --git a/samples/dbusclient/main.cpp b/samples/dbusclient/main.cpp deleted file mode 100644 index 9d6a20c25..000000000 --- a/samples/dbusclient/main.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -#include "dbusclient.h" -#include "remote_aircraft.h" - -int main(int argc, char *argv[]) -{ - QCoreApplication a(argc, argv); - - qDebug() << "***********************************************"; - qDebug() << "******* Welcome to DBus Client sample *********"; - qDebug() << "* This samples demonstrates the communication *"; - qDebug() << "* between two different processes, simulating *"; - qDebug() << "* a client connection to DBusSever by P2P and *"; - qDebug() << "* and asking for online aircrafts and ATC *"; - qDebug() << "* controllers. Use DBusServer sample to get *"; - qDebug() << "* aircraft and contoller objects from the *"; - qDebug() << "* FSD network They can be accessed by the *"; - qDebug() << "* client after they have been transfered. Be *"; - qDebug() << "* aware: All objects are simulated and not *"; - qDebug() << "* VATSIM realtime traffic. *"; - qDebug() << "***********************************************"; - qDebug(); - - DBusClient client; - - CRemoteAircraft::registerMetaType(); - - client.connectTo("dev.vatsim-germany.org"); - - return a.exec(); -} diff --git a/samples/dbusclient/remote_aircraft.cpp b/samples/dbusclient/remote_aircraft.cpp deleted file mode 100644 index 899164392..000000000 --- a/samples/dbusclient/remote_aircraft.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "remote_aircraft.h" - -CRemoteAircraft::CRemoteAircraft() : - m_callsign(), m_heading(0), m_groundSpeed(0), m_wakeTurbulence() -{ -} - -CRemoteAircraft::CRemoteAircraft(const CRemoteAircraft &other) : - m_callsign(other.m_callsign), - m_heading(other.m_heading), - m_groundSpeed(other.m_groundSpeed), - m_wakeTurbulence(other.m_wakeTurbulence) -{ -} - -CRemoteAircraft &CRemoteAircraft::operator =(const CRemoteAircraft &other) -{ - if (this != &other) - { - m_callsign = other.m_callsign; - m_heading = other.m_heading; - m_groundSpeed = other.m_groundSpeed; - m_wakeTurbulence = other.m_wakeTurbulence; - } - - return *this; -} - -void CRemoteAircraft::registerMetaType() -{ - qRegisterMetaType("CRemoteAircraft"); - qDBusRegisterMetaType(); - qDBusRegisterMetaType(); -} - -QDBusArgument &operator<<(QDBusArgument &argument, const CRemoteAircraft& remoteAircraft) -{ - argument.beginStructure(); - argument << remoteAircraft.m_callsign; - argument << remoteAircraft.m_heading; - argument << remoteAircraft.m_groundSpeed; - argument << remoteAircraft.m_wakeTurbulence; - argument.endStructure(); - - return argument; -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, CRemoteAircraft &remoteAircraft) -{ - argument.beginStructure(); - argument >> remoteAircraft.m_callsign; - argument >> remoteAircraft.m_heading; - argument >> remoteAircraft.m_groundSpeed; - argument >> remoteAircraft.m_wakeTurbulence; - argument.endStructure(); - - return argument; -} diff --git a/samples/dbusclient/remote_aircraft.h b/samples/dbusclient/remote_aircraft.h deleted file mode 100644 index ce2ee787d..000000000 --- a/samples/dbusclient/remote_aircraft.h +++ /dev/null @@ -1,85 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef REMOTE_AIRCRAFT_H -#define REMOTE_AIRCRAFT_H - -#include - - -/*! - * \brief Remove Aircraft - * \details This class represents a aircraft from another user in the network - * \author Roland Winklmeier - * \version 0.1 - * \date July 2013 - */ -class CRemoteAircraft -{ - QString m_callsign; //!< Aircrafts callsign - - double m_heading; //!< Aircrafts heading. - - double m_groundSpeed; //!< Aircrafts groundspeed in knots - - QString m_wakeTurbulence; //!< wake turbulence classification - -public: - - /*! - * \brief Constructor - */ - CRemoteAircraft(); - - /*! - * \brief Copy constructor - * \param other - */ - CRemoteAircraft(const CRemoteAircraft &other); - - /*! - * \brief Assignment operator - * \param other - */ - CRemoteAircraft &operator=(const CRemoteAircraft &other); - - /*! - * \brief Destructor - */ - ~CRemoteAircraft() {} - - friend QDBusArgument &operator<<(QDBusArgument &argument, const CRemoteAircraft &remoteAircraft); - friend const QDBusArgument &operator>>(const QDBusArgument &argument, CRemoteAircraft &remoteAircraft); - - /*! - * \brief Aircrafts Callsign - */ - QString getCallsign() const { return m_callsign; } - - /*! - * \brief Aircrafts heading - */ - double getHeading() const { return m_heading; } - - /*! - * \brief Aircrafts ground speed - */ - double getGroundSpeed() const { return m_groundSpeed; } - - /*! - * \brief Aircrafts wake turbulence classification - */ - QString getWakeTurbulence() const { return m_wakeTurbulence; } - - static void registerMetaType(); - -}; - -typedef QList CRemoteAircraftList; - -Q_DECLARE_METATYPE(CRemoteAircraft) -Q_DECLARE_METATYPE(CRemoteAircraftList) - -#endif // REMOTE_AIRCRAFT_H diff --git a/samples/dbusclient/sample_dbusclient.pro b/samples/dbusclient/sample_dbusclient.pro deleted file mode 100644 index d47c55d9a..000000000 --- a/samples/dbusclient/sample_dbusclient.pro +++ /dev/null @@ -1,26 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2013-07-07T15:31:07 -# -#------------------------------------------------- - -QT += core dbus - -QT -= gui - -TARGET = DBusClient -CONFIG += console -CONFIG -= app_bundle - -TEMPLATE = app - -DBUS_INTERFACES += dbus/aircraftmanager.xml dbus/atcmanager.xml dbus/fsdclient.xml - -QDBUSXML2CPP_INTERFACE_HEADER_FLAGS = -i remote_aircraft.h -QDBUSXML2CPP_ADAPTOR_HEADER_FLAGS = -i remote_aircraft.h - -DEPENDPATH += . ../../src -INCLUDEPATH += . ../../src - -HEADERS += *.h -SOURCES += *.cpp diff --git a/samples/dbusserver/aircraft_manager.cpp b/samples/dbusserver/aircraft_manager.cpp deleted file mode 100644 index 909c4c135..000000000 --- a/samples/dbusserver/aircraft_manager.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include -#include "aircraft_manager.h" - -CAircraftManager::CAircraftManager(QObject *parent) : - QObject(parent) -{ -} - -CAircraftManager::~CAircraftManager() -{ -} - -QList CAircraftManager::aircraftList() const -{ - return m_aircraftList; -} - -void CAircraftManager::addAircraft(const CRemoteAircraft &aircraft) -{ - if (m_aircraftList.indexOf(aircraft) == -1) - { - qDebug() << "Got new aircraft from FSD with callsign: " << aircraft.getCallsign(); - m_aircraftList << aircraft; - } -} diff --git a/samples/dbusserver/aircraft_manager.h b/samples/dbusserver/aircraft_manager.h deleted file mode 100644 index 67beb1080..000000000 --- a/samples/dbusserver/aircraft_manager.h +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef AIRCRAFTMANAGER_H -#define AIRCRAFTMANAGER_H - -#include -#include -#include - -#include "remote_aircraft.h" - -/*! - * \brief Plane Manager - * \details This class manages all plane objects visible to the user - * \author Roland Winklmeier - * \version 0.1 - * \date July 2013 - */ -class CAircraftManager : public QObject -{ - Q_OBJECT - - QList m_aircraftList; //!< List of all aircrafts with their callsigns - -public: - - /*! - * \brief Constructor - * \param parent - */ - CAircraftManager(QObject *parent = 0); - - /*! - * \brief Destructor - */ - ~CAircraftManager(); - - /*! - * \brief Returns a list of all pilots with their callsigns - * \return pilotList - */ - QStringList pilotList() const; - - /*! - * \brief Returns a list of all pilots with their callsigns - * \return pilotList - */ - QList aircraftList() const; - - /*! - * \brief Adds new aircraft - * \return aircraft - */ - void addAircraft( const CRemoteAircraft &aircraft ); - -signals: - -public slots: -}; - -#endif // AIRCRAFTMANAGER_H diff --git a/samples/dbusserver/aircraft_manager_handler.cpp b/samples/dbusserver/aircraft_manager_handler.cpp deleted file mode 100644 index 282d9a659..000000000 --- a/samples/dbusserver/aircraft_manager_handler.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include - -#include "aircraft_manager_handler.h" -#include "aircraft_manager.h" - -/** - * It is really IMPORTANT to include the following header. - * Otherwise it won't be generated by qmake and the - * project can't be build - */ -#include "aircraftmanager_adaptor.h" - -CAircraftManagerHandler::CAircraftManagerHandler(QObject *parent) : - IDBusHandler(parent) -{ - setDBusObjectPath("/AircraftManager"); - new AircraftManagerAdaptor(this); -} - -QList CAircraftManagerHandler::aircraftList() const -{ - qDebug() << "Client requested the list of aircrafts. Sending to him..."; - return qobject_cast(m_parent)->aircraftList(); -} diff --git a/samples/dbusserver/aircraft_manager_handler.h b/samples/dbusserver/aircraft_manager_handler.h deleted file mode 100644 index 76681f93a..000000000 --- a/samples/dbusserver/aircraft_manager_handler.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef PLANEMANAGERHANDLER_H -#define PLANEMANAGERHANDLER_H - -#include -#include - -#include "blackmisc/dbus_handler.h" -#include "remote_aircraft.h" - -class CAircraftManager; - -/*! - * \brief Plane Manager wrapper for DBus - * \details This class handles the DBus communication for the PlaneManager - * \author Roland Winklmeier - * \version 0.1 - * \date July 2013 - */ -class CAircraftManagerHandler : public BlackMisc::IDBusHandler -{ - Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "org.vatsim.pilotClient.PlaneManager") - Q_PROPERTY( QList aircraftList READ aircraftList) - - QList aircraftList() const; - -public: - - /*! - * \brief Default constructor - * \param parent - */ - CAircraftManagerHandler(QObject *parent); - - /*! - * \brief Destructor - */ - ~CAircraftManagerHandler() {} - -signals: - -public slots: - -private: - -}; - -#endif // PLANEMANAGERHANDLER_H diff --git a/samples/dbusserver/atc_manager.cpp b/samples/dbusserver/atc_manager.cpp deleted file mode 100644 index 8da22d9aa..000000000 --- a/samples/dbusserver/atc_manager.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "atc_manager.h" - -/** - * Constructor - */ -CAtcManager::CAtcManager(QObject *parent) : - QObject(parent) -{ -} - -/** - * Return QStringList of controller callsigns - */ -QStringList CAtcManager::atcList() const -{ - return m_atcList; -} - -void CAtcManager::addATC(const QString &controller) -{ - if (m_atcList.indexOf(controller) == -1) - m_atcList << controller; -} diff --git a/samples/dbusserver/atc_manager.h b/samples/dbusserver/atc_manager.h deleted file mode 100644 index 6523929f0..000000000 --- a/samples/dbusserver/atc_manager.h +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef ATCMANAGER_H -#define ATCMANAGER_H - -#include -#include - -/*! - * \brief ATC Controller Managing class - * \details This class is used hold a map of all controllers in the network and visible to the user - * \author Roland Winklmeier - * \version 0.1 - * \date July 2013 - */ - -class CAtcManager : public QObject -{ - Q_OBJECT - - QStringList m_atcList; //!< List of all controllers with their callsigns - -public: - - /*! - * \brief Default constructor - * \param parent - */ - CAtcManager(QObject *parent = 0); - - /*! - * \brief Destructor - */ - ~CAtcManager() {} - - /*! - * \brief Returns a list of all controllers with their callsigns - * \return atcList - */ - QStringList atcList() const; - - /*! - * \brief Add new ATC controller - * \return controller - */ - void addATC( const QString &controller ); - -signals: - -public slots: - -}; - -#endif // ATCMANAGER_H diff --git a/samples/dbusserver/atc_manager_handler.cpp b/samples/dbusserver/atc_manager_handler.cpp deleted file mode 100644 index f56c68039..000000000 --- a/samples/dbusserver/atc_manager_handler.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "atc_manager.h" -#include "blackcore/dbus_server.h" -#include "atc_manager_handler.h" - -/** - * It is really IMPORTANT to include the following header. - * Otherwise it won't be generated by qmake and the - * project can't be build - */ -#include "atcmanager_adaptor.h" - -CAtcManagerHandler::CAtcManagerHandler(QObject *parent) : - IDBusHandler(parent) -{ - setDBusObjectPath("/AtcManager"); - new AtcManagerAdaptor(this); -} - -CAtcManagerHandler::~CAtcManagerHandler() -{ - -} - -QStringList CAtcManagerHandler::atcList() const -{ - qDebug() << "Client requested the list of controllers. Sending to him..."; - return qobject_cast(m_parent)->atcList(); -} diff --git a/samples/dbusserver/atc_manager_handler.h b/samples/dbusserver/atc_manager_handler.h deleted file mode 100644 index 8f695e414..000000000 --- a/samples/dbusserver/atc_manager_handler.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef ATCMANAGERHANDLER_H -#define ATCMANAGERHANDLER_H - -#include -#include -#include "blackmisc/dbus_handler.h" - -class CAtcManager; - -/*! - * \brief ATC Manager Wrapper for DBus - * \details This class handles the DBus communication for the ATC manager - * \author Roland Winklmeier - * \version 0.1 - * \date July 2013 - */ -class CAtcManagerHandler : public BlackMisc::IDBusHandler -{ - Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "org.vatsim.pilotClient.AtcManager") - Q_PROPERTY( QStringList atcList READ atcList) - - /** - * Return QStringList of controller callsigns - * This needs to be private, since you should not call this - * directly in your application. Use the parents method instead. - */ - QStringList atcList() const; - -public: - - /*! - * \brief Default constructor - * \param parent - */ - CAtcManagerHandler(QObject *parent); - - /*! - * \brief Destructor - */ - ~CAtcManagerHandler(); -}; - -#endif // ATCMANAGERHANDLER_H diff --git a/samples/dbusserver/dbus/aircraftmanager.xml b/samples/dbusserver/dbus/aircraftmanager.xml deleted file mode 100644 index a70131d7f..000000000 --- a/samples/dbusserver/dbus/aircraftmanager.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/samples/dbusserver/dbus/atcmanager.xml b/samples/dbusserver/dbus/atcmanager.xml deleted file mode 100644 index c78196aa5..000000000 --- a/samples/dbusserver/dbus/atcmanager.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/samples/dbusserver/dbus/fsdclient.xml b/samples/dbusserver/dbus/fsdclient.xml deleted file mode 100644 index 4a50e30da..000000000 --- a/samples/dbusserver/dbus/fsdclient.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/samples/dbusserver/fsd_client.cpp b/samples/dbusserver/fsd_client.cpp deleted file mode 100644 index 8b3ec69e9..000000000 --- a/samples/dbusserver/fsd_client.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include - -#include "fsd_client.h" - -CFsdClient::CFsdClient(QObject *parent) : - QObject(parent) -{ -} - -void CFsdClient::connectTo(const QString &host) -{ - qDebug() << "Client requests to connect to " << host; -} diff --git a/samples/dbusserver/fsd_client.h b/samples/dbusserver/fsd_client.h deleted file mode 100644 index 9b98cf977..000000000 --- a/samples/dbusserver/fsd_client.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef FSDCLIENT_H -#define FSDCLIENT_H - -#include - -/*! - * \brief FSD client - * \details This class implements methods to connect to a FSD server - * \author Roland Winklmeier - * \version 0.1 - * \date July 2013 - */ - -class CFsdClient : public QObject -{ - Q_OBJECT -public: - - /*! - * \brief Constructor - * \param parent - */ - CFsdClient(QObject *parent = 0); - - /*! - * \brief Starts connection to FSD server - * \param host - */ - void connectTo(const QString &host); - -signals: - -public slots: - -}; - -#endif // FSDCLIENT_H diff --git a/samples/dbusserver/fsd_client_handler.cpp b/samples/dbusserver/fsd_client_handler.cpp deleted file mode 100644 index 88085f8d0..000000000 --- a/samples/dbusserver/fsd_client_handler.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "blackcore/dbus_server.h" -#include "fsd_client_handler.h" -#include "fsd_client.h" - -/** - * It is really IMPORTANT to include the following header. - * Otherwise it won't be generated by qmake and the - * project can't be build - */ -#include "fsdclient_adaptor.h" - -CFsdClientHandler::CFsdClientHandler(QObject *parent) : - IDBusHandler(parent) -{ - setDBusObjectPath("/FsdClient"); - new FsdClientAdaptor(this); -} - -void CFsdClientHandler::connectTo(const QString &host) -{ - CFsdClient *fsdClient = qobject_cast(m_parent); - fsdClient->connectTo(host); - emit connectedTo(host); -} diff --git a/samples/dbusserver/fsd_client_handler.h b/samples/dbusserver/fsd_client_handler.h deleted file mode 100644 index 5eddca071..000000000 --- a/samples/dbusserver/fsd_client_handler.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef FSDCLIENTHANDLER_H -#define FSDCLIENTHANDLER_H - -#include - -#include - -class CFsdClient; - -/*! - * \brief FSD client wrapper for DBus - * \details This class handles the DBus communication for the FSD client - * \author Roland Winklmeier - * \version 0.1 - * \date July 2013 - */ -class CFsdClientHandler : public BlackMisc::IDBusHandler -{ - Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "org.vatsim.pilotClient.FsdClient") -public: - - /*! - * \brief Default constructor - * \param parent - */ - CFsdClientHandler(QObject *parent); - - /*! - * \brief Destructor - */ - ~CFsdClientHandler() {} - - /*! - * \brief Starts connection to FSD server - * \param host - */ - Q_INVOKABLE void connectTo(const QString &host); - -signals: - void connectedTo( const QString &host); - -public slots: - -}; - -#endif // FSDCLIENTHANDLER_H diff --git a/samples/dbusserver/main.cpp b/samples/dbusserver/main.cpp deleted file mode 100644 index bc47cae6e..000000000 --- a/samples/dbusserver/main.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include -#include "blackcore/dbus_server.h" -#include "aircraft_manager_handler.h" -#include "aircraft_manager.h" -#include "atc_manager_handler.h" -#include "atc_manager.h" -#include "fsd_client.h" -#include "fsd_client_handler.h" - -int main(int argc, char *argv[]) -{ - QCoreApplication a(argc, argv); - - CRemoteAircraft::registerMetaType(); - - BlackCore::CDBusServer server("tcp:host=127.0.0.1,port=45000"); - - // Setting up our objects - CAircraftManager aircraftManager; - - aircraftManager.addAircraft(CRemoteAircraft("DLH456")); - aircraftManager.addAircraft(CRemoteAircraft("DLH555")); - aircraftManager.addAircraft(CRemoteAircraft("DLH666")); - - CAtcManager atcManager; - - atcManager.addATC("EDDM_N_TWR"); - atcManager.addATC("KJFK_GND"); - atcManager.addATC("LOWW_CTR"); - - CFsdClient fsdclient; - - - // Setting up the handler to expose the objects via DBus - CAircraftManagerHandler aircraftManagerHandler(&aircraftManager); - CAtcManagerHandler atcManagerHandler(&atcManager); - CFsdClientHandler fsdClientHandler (&fsdclient); - - // Pass the DBus server to the handlers. This registers also - // the handler in the DBus server and makes it available - // via the interface. - aircraftManagerHandler.setDBusServer(&server); - atcManagerHandler.setDBusServer(&server); - fsdClientHandler.setDBusServer(&server); - - return a.exec(); -} diff --git a/samples/dbusserver/remote_aircraft.cpp b/samples/dbusserver/remote_aircraft.cpp deleted file mode 100644 index f5dc090a0..000000000 --- a/samples/dbusserver/remote_aircraft.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "remote_aircraft.h" - -CRemoteAircraft::CRemoteAircraft() : - m_callsign(), m_heading(0), m_groundSpeed(0), m_wakeTurbulence() -{ -} - -CRemoteAircraft::CRemoteAircraft(const QString &callsign) : - m_callsign(callsign), m_heading(0), m_groundSpeed(0), m_wakeTurbulence("M") -{ -} - -CRemoteAircraft::CRemoteAircraft(const CRemoteAircraft &other) : - m_callsign(other.m_callsign), - m_heading(other.m_heading), - m_groundSpeed(other.m_groundSpeed), - m_wakeTurbulence(other.m_wakeTurbulence) -{ -} - -CRemoteAircraft &CRemoteAircraft::operator =(const CRemoteAircraft &other) -{ - if (this != &other) - { - m_callsign = other.m_callsign; - m_heading = other.m_heading; - m_groundSpeed = other.m_groundSpeed; - m_wakeTurbulence = other.m_wakeTurbulence; - } - - return *this; -} - -bool CRemoteAircraft::operator ==(const CRemoteAircraft &other) -{ - return (m_callsign == other.m_callsign); -} - -void CRemoteAircraft::registerMetaType() -{ - qRegisterMetaType("CRemoteAircraft"); - qDBusRegisterMetaType(); - qDBusRegisterMetaType(); -} - -QDBusArgument &operator<<(QDBusArgument &argument, const CRemoteAircraft& remoteAircraft) -{ - argument.beginStructure(); - argument << remoteAircraft.m_callsign; - argument << remoteAircraft.m_heading; - argument << remoteAircraft.m_groundSpeed; - argument << remoteAircraft.m_wakeTurbulence; - argument.endStructure(); - - return argument; -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, CRemoteAircraft &remoteAircraft) -{ - argument.beginStructure(); - argument >> remoteAircraft.m_callsign; - argument >> remoteAircraft.m_heading; - argument >> remoteAircraft.m_groundSpeed; - argument >> remoteAircraft.m_wakeTurbulence; - argument.endStructure(); - - return argument; -} diff --git a/samples/dbusserver/remote_aircraft.h b/samples/dbusserver/remote_aircraft.h deleted file mode 100644 index 72c8b52d1..000000000 --- a/samples/dbusserver/remote_aircraft.h +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef REMOTE_AIRCRAFT_H -#define REMOTE_AIRCRAFT_H - -#include - - -/*! - * \brief Remove Aircraft - * \details This class represents a aircraft from another user in the network - * \author Roland Winklmeier - * \version 0.1 - * \date July 2013 - */ -class CRemoteAircraft -{ - QString m_callsign; //!< Aircrafts callsign - - double m_heading; //!< Aircrafts heading. - - double m_groundSpeed; //!< Aircrafts groundspeed in knots - - QString m_wakeTurbulence; //!< wake turbulence classification - -public: - - /*! - * \brief Constructor - */ - CRemoteAircraft(); - CRemoteAircraft(const QString &callsign); - - /*! - * \brief Copy constructor - * \param other - */ - CRemoteAircraft(const CRemoteAircraft &other); - - /*! - * \brief Assignment operator - * \param other - */ - CRemoteAircraft &operator=(const CRemoteAircraft &other); - - /*! - * \brief Compare operator - * \param other - */ - bool operator==(const CRemoteAircraft &other); - - /*! - * \brief Destructor - */ - ~CRemoteAircraft() {} - - friend QDBusArgument &operator<<(QDBusArgument &argument, const CRemoteAircraft &remoteAircraft); - friend const QDBusArgument &operator>>(const QDBusArgument &argument, CRemoteAircraft &remoteAircraft); - - /*! - * \brief Aircrafts Callsign - */ - QString getCallsign() const { return m_callsign; } - - /*! - * \brief Aircrafts heading - */ - double getHeading() const { return m_heading; } - - /*! - * \brief Aircrafts ground speed - */ - double getGroundSpeed() const { return m_groundSpeed; } - - /*! - * \brief Aircrafts wake turbulence classification - */ - QString getWakeTurbulence() const { return m_wakeTurbulence; } - - static void registerMetaType(); - -}; - -typedef QList CRemoteAircraftList; - -Q_DECLARE_METATYPE(CRemoteAircraft) -Q_DECLARE_METATYPE(CRemoteAircraftList) - -#endif // REMOTE_AIRCRAFT_H diff --git a/samples/dbusserver/sample_dbusserver.pro b/samples/dbusserver/sample_dbusserver.pro deleted file mode 100644 index 9a6c39388..000000000 --- a/samples/dbusserver/sample_dbusserver.pro +++ /dev/null @@ -1,35 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2013-07-06T22:37:57 -# -#------------------------------------------------- - -QT += core dbus - -QT -= gui - -TARGET = DBusServer -CONFIG += console -CONFIG -= app_bundle - -TEMPLATE = app - -DBUS_ADAPTORS += dbus/aircraftmanager.xml dbus/atcmanager.xml dbus/fsdclient.xml - -DEPENDPATH += . ../../src -INCLUDEPATH += . ../../src - -HEADERS += *.h -SOURCES += *.cpp - -QDBUSXML2CPP_INTERFACE_HEADER_FLAGS = -i remote_aircraft.h -QDBUSXML2CPP_ADAPTOR_HEADER_FLAGS = -i remote_aircraft.h - -LIBS += -L../../lib -lblackcore -lblackmisc - -win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib \ - ../../lib/blackcore.lib -else: PRE_TARGETDEPS += ../../lib/libblackmisc.a \ - ../../lib/libblackcore.a - -DESTDIR = ../../bin diff --git a/src/blackbox/CMakeLists.txt b/src/blackbox/CMakeLists.txt deleted file mode 100644 index 03a3bee87..000000000 --- a/src/blackbox/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -FILE(GLOB blackbox_SOURCES *.cpp) -FILE(GLOB blackbox_HEADERS *.h) -SET(blackbox_HEADERS_QOBJECT - blackbox.h - dialog_connect.h - dialog_chat.h) - -SET(blackbox_FORMS blackbox.ui - dialog_connect.ui - dialog_chat.ui) -SET(blackbox_RESOURCES ) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) - -QT4_WRAP_CPP(blackbox_HEADERS_MOC ${blackbox_HEADERS_QOBJECT}) -QT4_WRAP_UI(blackbox_FORMS_HEADERS ${blackbox_FORMS}) -QT4_ADD_RESOURCES(blackbox_RESOURCES_RCC ${blackbox_RESOURCES}) - -SOURCE_GROUP(QtGeneratedMocSrc FILES ${blackbox_HEADERS_MOC}) -SOURCE_GROUP (QtResources FILES ${blackbox_RESOURCES_RCC}) -SOURCE_GROUP (QtForms FILES ${blackbox_FORMS_HEADERS}) - -ADD_EXECUTABLE(blackbox WIN32 MACOSX_BUNDLE ${blackbox_SOURCES} - ${blackbox_HEADERS_MOC} - ${blackbox_FORMS_HEADERS} - ${blackbox_RESOURCES_RCC}) - -TARGET_LINK_LIBRARIES(blackbox blackmisc ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY}) -SET_TARGET_PROPERTIES(blackbox PROPERTIES PROJECT_LABEL "BlackBox GUI - BlackBox") \ No newline at end of file diff --git a/src/blackbox/blackbox.cpp b/src/blackbox/blackbox.cpp deleted file mode 100644 index 89a748a6d..000000000 --- a/src/blackbox/blackbox.cpp +++ /dev/null @@ -1,50 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#include "dialog_connect.h" -#include "dialog_chat.h" - -#include "blackbox.h" -#include "ui_blackbox.h" - -BlackBox::BlackBox(QWidget *parent) : - QDialog(parent), - ui(new Ui::BlackBox) -{ - ui->setupUi(this); - - m_dlg_connect = new CDialogConnect(); - m_dlg_connect->hide(); - - m_dlg_chat = new CDialogChat(); - m_dlg_chat->hide(); - - connect(ui->bt_Connect, &QPushButton::clicked, - this, &BlackBox::onConnect); - connect(ui->bt_Chat, &QPushButton::clicked, - this, &BlackBox::onButtonChat); -} - -BlackBox::~BlackBox() -{ - delete ui; -} - -void BlackBox::onConnect() -{ - if (m_dlg_connect->isHidden()) - { - m_dlg_connect->show(); - } - -} - -void BlackBox::onButtonChat() -{ - if (m_dlg_chat->isHidden()) - { - m_dlg_chat->show(); - } -} diff --git a/src/blackbox/blackbox.h b/src/blackbox/blackbox.h deleted file mode 100644 index 063b0ecae..000000000 --- a/src/blackbox/blackbox.h +++ /dev/null @@ -1,37 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#ifndef BLACKBOX_H -#define BLACKBOX_H - -#include - -class CDialogConnect; -class CDialogChat; - -namespace Ui { -class BlackBox; -} - -class BlackBox : public QDialog -{ - Q_OBJECT - -public: - explicit BlackBox(QWidget *parent = 0); - ~BlackBox(); - -protected slots: - void onConnect(); - void onButtonChat(); - -private: - Ui::BlackBox *ui; - - CDialogConnect *m_dlg_connect; - CDialogChat *m_dlg_chat; -}; - -#endif // BLACKBOX_H diff --git a/src/blackbox/blackbox.pro b/src/blackbox/blackbox.pro deleted file mode 100644 index d6b26bb9c..000000000 --- a/src/blackbox/blackbox.pro +++ /dev/null @@ -1,21 +0,0 @@ -QT += core gui xml svg network - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -INCLUDEPATH += . .. - -TARGET = blackbox -TEMPLATE = app -CONFIG += c++11 - -SOURCES += *.cpp -HEADERS += *.h - -FORMS += blackbox.ui dialog_connect.ui dialog_chat.ui - -LIBS += -L../../lib -lblackmisc - -win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib -else: PRE_TARGETDEPS += ../../lib/libblackmisc.a - -DESTDIR = ../../bin diff --git a/src/blackbox/blackbox.ui b/src/blackbox/blackbox.ui deleted file mode 100644 index 9072e879e..000000000 --- a/src/blackbox/blackbox.ui +++ /dev/null @@ -1,59 +0,0 @@ - - - BlackBox - - - - 0 - 0 - 400 - 300 - - - - BlackBox - - - - - 40 - 40 - 75 - 23 - - - - Connect - - - - - - 130 - 40 - 75 - 23 - - - - Settings - - - - - - 40 - 80 - 75 - 23 - - - - Chat - - - - - - - diff --git a/src/blackbox/dialog_chat.cpp b/src/blackbox/dialog_chat.cpp deleted file mode 100644 index 1266eac00..000000000 --- a/src/blackbox/dialog_chat.cpp +++ /dev/null @@ -1,21 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#include "dialog_chat.h" -#include "ui_dialog_chat.h" - -CDialogChat::CDialogChat(QWidget *parent) : - QDialog(parent), - ui(new Ui::CDialogChat) -{ - ui->setupUi(this); - ui->chatGeneral->textCursor().insertText("Testline"); - ui->chatGeneral->centerCursor(); -} - -CDialogChat::~CDialogChat() -{ - delete ui; -} diff --git a/src/blackbox/dialog_chat.h b/src/blackbox/dialog_chat.h deleted file mode 100644 index 3e72c1c4b..000000000 --- a/src/blackbox/dialog_chat.h +++ /dev/null @@ -1,27 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#ifndef DIALOG_CHAT_H -#define DIALOG_CHAT_H - -#include - -namespace Ui { -class CDialogChat; -} - -class CDialogChat : public QDialog -{ - Q_OBJECT - -public: - explicit CDialogChat(QWidget *parent = 0); - ~CDialogChat(); - -private: - Ui::CDialogChat *ui; -}; - -#endif // DIALOG_CHAT_H diff --git a/src/blackbox/dialog_chat.ui b/src/blackbox/dialog_chat.ui deleted file mode 100644 index 03acea211..000000000 --- a/src/blackbox/dialog_chat.ui +++ /dev/null @@ -1,74 +0,0 @@ - - - CDialogChat - - - - 0 - 0 - 400 - 300 - - - - Dialog - - - - - - QTabWidget::South - - - 1 - - - - General - - - - - 0 - 0 - 381 - 261 - - - - - - - Unicom - - - - - 0 - 0 - 381 - 261 - - - - - - - - - - Qt::Horizontal - - - - - PushButton - - - - - - - - - diff --git a/src/blackbox/dialog_connect.cpp b/src/blackbox/dialog_connect.cpp deleted file mode 100644 index 73aad4914..000000000 --- a/src/blackbox/dialog_connect.cpp +++ /dev/null @@ -1,67 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#include "dialog_connect.h" -#include "ui_dialog_connect.h" - -#include "blackmisc/debug.h" -#include "blackmisc/message.h" -#include "blackmisc/gui_messages.h" -#include "blackmisc/context.h" - -using namespace BlackMisc; - -CDialogConnect::CDialogConnect(QWidget *parent) : - QDialog(parent), - ui(new Ui::CDialogConnect), - comclient(IContext::getInstance()), - m_hasComConnection(false) -{ - ui->setupUi(this); - - connect(&comclient, &BlackMisc::CComClient::doError, - this, &CDialogConnect::onError); - connect(&comclient, &BlackMisc::CComClient::doConnected, - this, &CDialogConnect::onClientConnected); - connect(ui->bt_FSDConnect, &QPushButton::clicked, - this, &CDialogConnect::onFSDConnect); - - QString address = "127.0.0.1"; - comclient.connectTo(address, 42000); -} - -CDialogConnect::~CDialogConnect() -{ - delete ui; -} - -void CDialogConnect::onFSDConnect() -{ - QByteArray message_data; - QDataStream out(&message_data, QIODevice::WriteOnly); - MSG_CONNECT_TO_VATSIM* msgConnect = new MSG_CONNECT_TO_VATSIM(); - - msgConnect->setHost(ui->m_host->text()); - msgConnect->setCallsign(ui->m_callsign->text()); - msgConnect->setUserID(ui->m_ID->text()); - msgConnect->setPassword(ui->m_password->text()); - msgConnect->setPort(ui->m_port->text().toUInt()); - msgConnect->setRealName(ui->m_name->text()); - - *msgConnect >> out; - - comclient.sendMessage(msgConnect->getID(), message_data); - delete msgConnect; -} - -void CDialogConnect::onError(QAbstractSocket::SocketError,QString) -{ - -} - -void CDialogConnect::onClientConnected() -{ - m_hasComConnection = true; -} diff --git a/src/blackbox/dialog_connect.h b/src/blackbox/dialog_connect.h deleted file mode 100644 index 612af11c8..000000000 --- a/src/blackbox/dialog_connect.h +++ /dev/null @@ -1,36 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#ifndef DIALOG_CONNECT_H -#define DIALOG_CONNECT_H - -#include -#include "blackmisc/com_client.h" - -namespace Ui { -class CDialogConnect; -} - -class CDialogConnect : public QDialog -{ - Q_OBJECT - -public: - explicit CDialogConnect(QWidget *parent = 0); - ~CDialogConnect(); - -protected slots: - void onFSDConnect(); - void onError(QAbstractSocket::SocketError, QString); - void onClientConnected(); - -private: - Ui::CDialogConnect *ui; - BlackMisc::CComClient comclient; - - bool m_hasComConnection; -}; - -#endif // DIALOG_CONNECT_H diff --git a/src/blackbox/dialog_connect.ui b/src/blackbox/dialog_connect.ui deleted file mode 100644 index d6d1ba334..000000000 --- a/src/blackbox/dialog_connect.ui +++ /dev/null @@ -1,171 +0,0 @@ - - - CDialogConnect - - - - 0 - 0 - 286 - 279 - - - - Dialog - - - - - - Connect - - - - - - - 10 - - - - Host: - - - - - - - vatsim-germany.org - - - - - - - - 10 - - - - Port: - - - - - - - 6809 - - - - - - - - 10 - - - - Callsign: - - - - - - - DLH123 - - - - - - - - 10 - - - - ID: - - - - - - - Qt::Horizontal - - - - 31 - 20 - - - - - - - - 123456 - - - - - - - - 10 - - - - Password: - - - - - - - 123456 - - - - - - - - 10 - - - - Real Name: - - - - - - - Roland - - - - - - - - - - Connect - - - - - - - Cancel - - - - - - - - diff --git a/src/blackbox/main.cpp b/src/blackbox/main.cpp deleted file mode 100644 index 0336b7977..000000000 --- a/src/blackbox/main.cpp +++ /dev/null @@ -1,24 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#include "blackbox.h" -#include -#include "blackmisc/context.h" -#include "blackmisc/debug.h" - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - - BlackMisc::CApplicationContext ctx; - BlackMisc::IContext::setInstance(ctx); - BlackMisc::CDebug debug; - ctx.setObject(debug); - - BlackBox w; - w.show(); - - return a.exec(); -} diff --git a/src/blackcore/atclistmgr.cpp b/src/blackcore/atclistmgr.cpp deleted file mode 100644 index 4b3ff7437..000000000 --- a/src/blackcore/atclistmgr.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / authors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "atclistmgr.h" -#include "network.h" - -BlackCore::CAtcListManager::CAtcListManager(BlackMisc::IContext &ctx) -{ - INetwork *net = &ctx.getObject(); - - connect(net, &INetwork::atcPositionUpdate, this, &CAtcListManager::update, Qt::QueuedConnection); - connect(net, &INetwork::atcDisconnected, this, &CAtcListManager::remove, Qt::QueuedConnection); - connect(net, &INetwork::connectionStatusDisconnected, this, &CAtcListManager::clear, Qt::QueuedConnection); -} - -void BlackCore::CAtcListManager::update(const QString& callsign, const BlackMisc::PhysicalQuantities::CFrequency& freq, - const BlackMisc::Geo::CCoordinateGeodetic& pos, const BlackMisc::PhysicalQuantities::CLength& range) -{ - m_list.insert(BlackMisc::CAtcListEntry(callsign, freq, pos, range)); - emit listChanged(m_list); -} - -void BlackCore::CAtcListManager::remove(const QString& callsign) -{ - m_list.remove(callsign); - emit listChanged(m_list); -} - -void BlackCore::CAtcListManager::clear() -{ - m_list.clear(); - emit listChanged(m_list); -} \ No newline at end of file diff --git a/src/blackcore/atclistmgr.h b/src/blackcore/atclistmgr.h deleted file mode 100644 index 545fa32ed..000000000 --- a/src/blackcore/atclistmgr.h +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / authors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/*! - \file -*/ - -#ifndef BLACKCORE_ATCLISTMGR_H -#define BLACKCORE_ATCLISTMGR_H - -#include "blackmisc/atclist.h" -#include - -namespace BlackCore -{ - - /*! - * Abstract base class that manages and provides access to a list of available ATC stations. - */ - class IAtcListManager : public QObject - { - Q_OBJECT - Q_PROPERTY(BlackMisc::CAtcList list READ getList NOTIFY listChanged) - - public: - /*! - * Virtual destructor. - */ - virtual ~IAtcListManager() {} - - /*! - * Immutable getter. - * \return - */ - virtual const BlackMisc::CAtcList &getList() const = 0; - - signals: - /*! - * Emitted whenever there is a change in the ATC list. - * \param list The new list - */ - void listChanged(const BlackMisc::CAtcList &list); - }; - - /*! - * Concrete ATC list manager. Implementation of IAtcListManager. - * - * Has a dependency on INetwork. An INetwork must be available through the IContext singleton. - */ - class CAtcListManager : public IAtcListManager - { - Q_OBJECT - - public: - /*! - * Constructor. - * \param context - */ - CAtcListManager(BlackMisc::IContext &context); - - virtual const BlackMisc::CAtcList& getList() const { return m_list; } - - public slots: - /*! - * CAtcListManager is responsible for connecting these slots. - * \{ - */ - void update(const QString& callsign, const BlackMisc::PhysicalQuantities::CFrequency& freq, - const BlackMisc::Geo::CCoordinateGeodetic& pos, const BlackMisc::PhysicalQuantities::CLength& range); - void remove(const QString& callsign); - void clear(); - /*! \} */ - - private: - BlackMisc::CAtcList m_list; - }; - -}//namespace BlackCore - -#endif //BLACKCORE_ATCLISTMGR_H \ No newline at end of file diff --git a/src/blackcore/fsd_client.cpp b/src/blackcore/fsd_client.cpp deleted file mode 100644 index 07796e03e..000000000 --- a/src/blackcore/fsd_client.cpp +++ /dev/null @@ -1,187 +0,0 @@ -#include "blackcore/fsd_client.h" -#include "blackcore/fsd_messages.h" -#include -#include -#include -#include - -namespace FSD -{ - - using namespace BlackMisc; - - - CFSDClient::CFSDClient(IContext &context) - : m_context(context), m_tcp_socket(NULL), m_port(0), m_simType(FSD::SIM_UNKNOWN) - { - init(); - } - - void CFSDClient::connectTo(const QString &host, quint16 port) - { - m_host = host; - m_port = port; - - if ( isConnected() ) - return; - - bDebug(m_context) << "Connecting to FSD server: " << m_host << ":" << m_port; - - m_tcp_socket->connectToHost(m_host, m_port); - } - - void CFSDClient::disconnectFrom() - { - bDebug(m_context) << "Disconnecting from host."; - - m_tcp_socket->disconnectFromHost(); - m_port = 0; - m_host.clear(); - } - - void CFSDClient::reconnect() - { - - } - - void CFSDClient::updateClientInfo(TClientInfo &clientInfo ) - { - m_host = clientInfo.m_host; - m_port = clientInfo.m_port; - m_password = clientInfo.m_password; - m_callsign = clientInfo.m_callsign; - m_userid = clientInfo.m_userid; - m_simType = clientInfo.m_simType; - m_realName = clientInfo.m_realName; - } - - bool CFSDClient::isConnected() - { - return m_tcp_socket->state() == QAbstractSocket::ConnectedState; - } - - QString CFSDClient::getErrorMessage(QAbstractSocket::SocketError /* error */) - { - return QString("Unknown"); - } - - void CFSDClient::onConnected() - { - bDebug(m_context) << "Connected successfully to remote host."; - bDebug(m_context) << "Sending #AP now..."; - - QString line; - - FSD_MSG_AddPilot addPilot; - addPilot.setSource(m_callsign); - addPilot.setDest("SERVER"); - addPilot.setUserID(m_userid); - addPilot.setPassword(m_password); - addPilot.setSimulator((quint16)m_simType); - addPilot.setRealName(m_realName); - - QTextStream stream(&line); - addPilot >> stream; - - sendMessage(line); - - emit doConnected(); - } - - void CFSDClient::onDisconnected() - { - bDebug(m_context) << "Disconnected successfully from remote host."; - emit doDisconnected(); - } - - void CFSDClient::onError(QAbstractSocket::SocketError error) - { - - if ( error != 0 ) - { - bError(m_context) << "Received socket error: " << error << " - Disconnecting..."; - } - - disconnectFrom(); - emit doError(error, getErrorMessage(error) ); - } - - void CFSDClient::onReceivingData() - { - QTextStream input(m_tcp_socket); - QString line; - - do - { - line = input.readLine(); - if (!line.isNull()) - processLine(line); - } while(!line.isNull()); - } - - bool CFSDClient::sendMessage(const QString &message) - { - if (!isConnected()) - { - bError(m_context) << "Cannot send data in disconnected state!"; - return false; - } - - qint64 message_size = message.size(); - - qint64 bytes = m_tcp_socket->write(message.toLatin1()); - if (bytes < 0 || bytes != message_size) - { - bWarning(m_context) << "Error writing to socket!"; - return false; - } - - return true; - } - - void CFSDClient::init() - { - m_tcp_socket = new QTcpSocket(this); - Q_ASSERT(m_tcp_socket); - - Q_ASSERT ( QObject::connect( m_tcp_socket, SIGNAL( connected() ), this, SLOT( onConnected() ) ) ); - Q_ASSERT ( QObject::connect( m_tcp_socket, SIGNAL( disconnected() ), this, SLOT( onDisconnected() ) ) ); - Q_ASSERT ( QObject::connect( m_tcp_socket, SIGNAL( error(QAbstractSocket::SocketError) ), this, SLOT( onError(QAbstractSocket::SocketError) ) ) ); - - Q_ASSERT ( QObject::connect( m_tcp_socket, SIGNAL( readyRead() ), this, SLOT( onReceivingData() ) ) ); - - registerMessages(); - } - - void CFSDClient::registerMessages() - { - REGISTER_MESSAGE(FSD::FSD_MSG_TextMessage, #TM); - } - - void CFSDClient::processLine(QString &line) - { - QString header; - for (int ii = 0; ii < MAX_FSD_HEADERS; ii++) - { - QString head = FSD::Headers[ii]; - if(line.startsWith( head )) - { - header = FSD::Headers[ii]; - line.remove(0, FSD::Headers[ii].length()); - } - } - - if (header.isEmpty()) - return; - - QTextStream stream(&line); - IMessage* fsd_message = CMessageFactory::getInstance().create(header); - Q_ASSERT(fsd_message); - *fsd_message << stream; - - CMessageDispatcher::getInstance().append(fsd_message); - } - - - -} // namespace FSD diff --git a/src/blackcore/fsd_client.h b/src/blackcore/fsd_client.h deleted file mode 100644 index 40aa11650..000000000 --- a/src/blackcore/fsd_client.h +++ /dev/null @@ -1,131 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#ifndef FSD_CLIENT_H -#define FSD_CLIENT_H - -#include -#include -#include -#include -#include - -namespace BlackMisc -{ - class IContext; -} - -namespace FSD -{ - -typedef struct { - QString m_host; - quint16 m_port; - QString m_callsign; - QString m_userid; - QString m_password; - FSD::SimulatorType m_simType; - QString m_realName; -} TClientInfo; - -class CFSDClient : public QObject -{ - Q_OBJECT - -public: - CFSDClient(BlackMisc::IContext &context); - - void connectTo(const QString &host, quint16 port); - void disconnectFrom(); - void reconnect(); - - void updateClientInfo(TClientInfo &clientInfo ); - - TClientInfo& clientInfo(); - - bool isConnected(); - - //! Returns a human readable description of the last error that occurred. - QString getErrorMessage(QAbstractSocket::SocketError error); - - bool sendMessage(const QString &message); - - ////////////////////////////////// - // FSD specific senders functions - ////////////////////////////////// - - void sendText ( QString &message); - - void sendTextonRadios ( QList &frequencies, QString &message); - - void sendClientQuery ( TQueryType type, QString &callsign); - - void sendClientQueryReponse ( TQueryType type, QString &data); - - void sendPilotPosition ( TPositionMessage *posMessage ); - - void sendFlightPlan (); - -signals: - - //! emitted when new data were received - void doReceivedMessage(QString &messageID, QByteArray &message); - - //! emitted when cliebt connected - void doConnected(); - - //! emitted when client disconnected - void doDisconnected(); - - //! emitted when an error has occured - void doError(QAbstractSocket::SocketError error, const QString& error_message); - -protected slots: - - //! Call this slot . - /*! - \param data Reference to the raw byte data to be sent. - \return Returns true if sending was successfull, otherwise false. - */ - void onConnected(); - void onDisconnected(); - void onError(QAbstractSocket::SocketError error); - void onReceivingData(); - -protected: - - void sendAddPilot(); - - - -private: - - CFSDClient( const CFSDClient& other); - const CFSDClient& operator = ( const CFSDClient& other); - - void init(); - void registerMessages(); - - void processLine(QString &line); - - BlackMisc::IContext& m_context; - - QTcpSocket* m_tcp_socket; - - QString m_host; - quint16 m_port; - QString m_callsign; - QString m_userid; - QString m_password; - FSD::SimulatorType m_simType; - QString m_realName; - - QString m_last_error; - -}; - -} // namespace FSD - -#endif // FSD_CLIENT_H diff --git a/src/blackcore/fsd_messages.cpp b/src/blackcore/fsd_messages.cpp deleted file mode 100644 index e8209d92a..000000000 --- a/src/blackcore/fsd_messages.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include "blackcore/fsd_messages.h" -#include "blackmisc/debug.h" - -using namespace BlackMisc; - -namespace FSD -{ - qint32 FSD_MSG::unpack(const QString &line, QStringVector &tokens) - { - const QString separator(":"); - - int begin = 0; - int end = 0; - int token_position = 0; - - qint32 count = line.count(separator); - tokens.resize(count+1); - - while ( (end = line.indexOf(separator, begin, Qt::CaseInsensitive)) != -1) - { - if (token_position < tokens.size()) - { - tokens.replace(token_position, line.mid(begin, end - begin)); - begin = end + separator.size(); - ++token_position; - } - else - { - bAppError << "Cannot split message. Vector is to small"; - return -1; - } - } - if (begin < line.size() && token_position < tokens.size()) - { - tokens.replace(token_position, line.mid(begin)); - } - else - return -1; - - return token_position + 1; - } - - QString FSD_MSG::pack(const QStringVector &tokens) const - { - QString line; - int length = 0; - const QString separator(":"); - const QString line_feed("\r\n"); - const int size = tokens.size(); - - // Calculate the total message length - for (int ii = 0; ii < size; ++ii) - length += tokens.at(ii).size(); - - // Add the size of the separator - length += separator.size() * (size - 1); - - // Add size of the line feed - length += line_feed.size(); - - // Add size of message ID - length += getID().size(); - - if (length == 0) - return line; - - line.reserve(length); - - line = getID(); - for (int ii = 0; ii < size; ++ii) - { - if (ii) - line += separator; - line += tokens.at(ii); - } - - line += line_feed; - - return line; - } - - QTextStream& FSD_MSG_Plane_Position::operator<< ( QTextStream& in) - { - QString message = in.readAll(); - qint32 size = unpack(message, m_message_tokens); - Q_ASSERT ( size == 10 ); - - return in; - } - - QTextStream& FSD_MSG_Plane_Position::operator>> (QTextStream& out) const - { - out << pack(m_message_tokens); - return out; - } -} diff --git a/src/blackcore/fsd_messages.h b/src/blackcore/fsd_messages.h deleted file mode 100644 index ce0af2870..000000000 --- a/src/blackcore/fsd_messages.h +++ /dev/null @@ -1,149 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#ifndef FSD_MESSAGES_H -#define FSD_MESSAGES_H - -#include "blackmisc/message_system.h" - -#define VATSIM_PROTOCOL_REV 9 - -// Qt includes -#include -#include - -typedef QVector QStringVector; - -namespace FSD -{ -class FSD_MSG : public BlackMisc::IMessage -{ -public: - FSD_MSG(QString id) : IMessage(id) - { - - } - - void setSource(const QString &source) {m_source = source; } - void setDest(const QString &destination) {m_destination = destination; } - -protected: - qint32 unpack(const QString &line, QStringVector &tokens); - QString pack(const QStringVector &tokens) const; - - QString m_destination; - QString m_source; -}; - -class FSD_MSG_AddPilot : public FSD_MSG -{ -public: - FSD_MSG_AddPilot() : FSD_MSG("#AP"), m_rating(1), m_revision(VATSIM_PROTOCOL_REV) {} - void setUserID(const QString &userID) { m_userID = userID; } - void setPassword(const QString &password) { m_password = password; } - void setSimulator(const quint16 &simulator) { m_simulator = simulator; } - void setRealName(const QString &name) { m_realName = name; } - - virtual QDataStream &operator<< (QDataStream &in) { return in; } - virtual QDataStream &operator>> (QDataStream &out) const { return out; } - - virtual QTextStream &operator<< (QTextStream &in) - { return in; } - virtual QTextStream &operator>> (QTextStream &out) const - { - QStringVector tokens; - tokens << m_source << m_destination << m_userID << m_password; - tokens << QString("%1").arg(m_rating) << QString("%1").arg(m_revision); - tokens << QString("%1").arg(m_simulator) << m_realName; - out << pack(tokens); - return out; - } - -private: - - QString m_userID; - QString m_password; - quint16 m_rating; - quint16 m_revision; - quint16 m_simulator; - QString m_realName; -}; - -class FSD_MSG_TextMessage : public FSD_MSG -{ -public: - FSD_MSG_TextMessage() : FSD_MSG(QString("#TM")) {} - virtual QDataStream &operator<< (QDataStream &in) { return in; } - virtual QDataStream &operator>> (QDataStream &out) const { return out;} - virtual QTextStream &operator<< (QTextStream &in) - { - QString message = in.readAll(); - QStringVector tokens; - - //tokens.resize(3); - unpack(message, tokens); - m_source = tokens.at(0); - m_destination = tokens.at(1); - int size = tokens.size(); - QString m_textmessage; - for (int ii = 2; ii < size; ++ii) - m_textmessage += tokens.at(ii); - bAppInfo << m_textmessage; - return in; - } - - virtual QTextStream &operator>> (QTextStream &out) const - { - QStringVector tokens; - tokens << m_source << m_destination; - out << pack(tokens); - return out; - } -}; - -class FSD_MSG_Plane_Position : public FSD_MSG -{ -public: - - FSD_MSG_Plane_Position() : FSD_MSG(QString("@")) - { - m_message_tokens.resize(10); - } - - inline QString SquawkMode() const { return m_message_tokens.at(0); } - inline QString Callsign() const { return m_message_tokens.at(1); } - inline QString Squawk() const { return m_message_tokens.at(2); } - inline quint16 Rating() const { return m_message_tokens.at(3).toUInt(); } - inline double Latitude() const { return m_message_tokens.at(4).toDouble(); } - inline double Longitude() const { return m_message_tokens.at(5).toDouble(); } - inline double Altitude() const { return m_message_tokens.at(6).toDouble(); } - inline qint32 Speed() const { return m_message_tokens.at(7).toInt(); } - inline quint32 PBH() const { return m_message_tokens.at(8).toUInt(); } - inline qint32 AltDiff() const { return m_message_tokens.at(9).toInt(); } - - inline void setSquawkMode(const QString &squawk_mode) { m_message_tokens.replace(0, squawk_mode); } - inline void setCallsign(const QString &callsign) { m_message_tokens.replace(1, callsign); } - inline void setSquawk(const QString &squawk) { m_message_tokens.replace(2, squawk); } - inline void setRating(const quint16 rating) { m_message_tokens.replace(3, QString("%1").arg(rating)); } - inline void setLatitude(const double latitude) { m_message_tokens.replace(4, QString("%1").arg(latitude)); } - inline void setLongitude(const double longitude) { m_message_tokens.replace(5, QString("%1").arg(longitude)); } - inline void setAltitude(const double altitude) { m_message_tokens.replace(6, QString("%1").arg(altitude)); } - inline void setSpeed(const qint32 speed) { m_message_tokens.replace(7, QString("%1").arg(speed)); } - inline void setPBH(const quint32 pbh) { m_message_tokens.replace(8, QString("%1").arg(pbh)); } - inline void setAltDiff(const qint32 altdiff) { m_message_tokens.replace(9, QString("%1").arg(altdiff)); } - - virtual QTextStream &operator<< (QTextStream &in); - virtual QTextStream &operator>> (QTextStream &out) const; - - virtual QDataStream &operator<< (QDataStream &in) { return in; } - virtual QDataStream &operator>> (QDataStream &out) const { return out;} - -private: - QStringVector m_message_tokens; -}; - -} // namespace FSD - -#endif // FSD_MESSAGES_H diff --git a/src/blackcore/fsd_protocol.h b/src/blackcore/fsd_protocol.h deleted file mode 100644 index dd877b1f4..000000000 --- a/src/blackcore/fsd_protocol.h +++ /dev/null @@ -1,61 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#ifndef FSD_PROTOCOL_H -#define FSD_PROTOCOL_H - -#include - -namespace FSD -{ - enum SimulatorType { - SIM_UNKNOWN = -1, - }; - - typedef enum { - Query_FP, - Query_Frequency, - Query_Server, - Query_RealName, - Query_isATC, - Query_Capabilities, - Query_IP - } TQueryType; - - typedef enum { - TMode_Standby = 'S', - TMode_Charly = 'N', - TMode_Ident = 'Y' - } TTransponderMode; - - typedef struct { - TTransponderMode transponderMode; - quint16 squawk; - quint8 rating; - double latitude; - double longitude; - qint32 altitude; - qint32 groundSpeed; - double pitch; - double bank; - double heading; - qint32 diffPressureTrueAlt; - } TPositionMessage; - - - const QString Headers[] = { - "@", - "%", - "#AA", - "#AP", - "#DA", - "#DP", - "#TM" - }; - -#define MAX_FSD_HEADERS 7 -} - -#endif // FSD_PROTOCOL_H diff --git a/src/blackcore/multiplayer.cpp b/src/blackcore/multiplayer.cpp deleted file mode 100644 index 017e59390..000000000 --- a/src/blackcore/multiplayer.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "blackcore/simulator.h" -#include "blackmisc/coordinategeodetic.h" -#include "blackcore/plane.h" -#include "blackcore/multiplayer.h" -#include "blackmisc/avheading.h" - -using namespace BlackMisc::Geo; -using namespace BlackMisc::PhysicalQuantities; -using namespace BlackMisc::Aviation; - -namespace BlackCore -{ - -CMultiPlayer::CMultiPlayer() : m_isRunning(false) -{ - registerMessageFunction(this, &CMultiPlayer::onPositionUpdate); - m_simulator = ISimulator::createDriver(ISimulator::FSX); -} - -void CMultiPlayer::start() -{ - if (m_isRunning) return; - m_isRunning = true; -} - -void CMultiPlayer::stop() -{ - if (!m_isRunning) return; - m_isRunning = false; -} - -void CMultiPlayer::run() -{ - TPlaneManager::iterator it; - for (it = m_multiplayer_planes.begin(); it != m_multiplayer_planes.end(); ++it) - { - if (needsToRemoved(it.value())) - { - removePlane(it.value()); - it = m_multiplayer_planes.erase(it); - } - - if (areAIPlanesEnabled()) - it.value()->render(); - } -} - -bool CMultiPlayer::isKnown(const QString &callsign) const -{ - return m_multiplayer_planes.contains(callsign); -} - -CPlane *CMultiPlayer::getPlane(const QString &callsign) -{ - return m_multiplayer_planes.value(callsign); -} - -void CMultiPlayer::onPositionUpdate(const FSD::FSD_MSG_Plane_Position *plane_position) -{ - QString callsign = plane_position->Callsign(); - CPlane *plane; - - plane = getPlane(callsign); - if (!plane) - { - plane = new CPlane(callsign, m_simulator); - addPlane(plane); - } - - - CCoordinateGeodetic position(plane_position->Latitude(), plane_position->Longitude(), plane_position->Altitude()); - FS_PBH pitchBankHeading; - pitchBankHeading.pbh = plane_position->PBH(); - - // TODO: Pitch Bank Heading and a timestamp - // TODO: Usage of physical quantities with FSD::FSD_MSG_Plane_Position - - plane->addPosition(position, - CSpeed(plane_position->Speed(), CSpeedUnit::kts()), - CHeading((qint32)pitchBankHeading.hdg, CHeading::True, CAngleUnit::deg()), - CAngle((qint32)pitchBankHeading.pitch, CAngleUnit::deg()), - CAngle((qint32)pitchBankHeading.bank, CAngleUnit::deg())); - -} - -void CMultiPlayer::addPlane(CPlane *plane) -{ - m_multiplayer_planes.insert(plane->callsign(), plane); -} - -void CMultiPlayer::removePlane(CPlane * /** plane **/) -{ - qint32 id = 0; - m_simulator->removePlane(id); -} - -} // namespace diff --git a/src/blackcore/multiplayer.h b/src/blackcore/multiplayer.h deleted file mode 100644 index c61863383..000000000 --- a/src/blackcore/multiplayer.h +++ /dev/null @@ -1,100 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#ifndef MULTIPLAYER_H -#define MULTIPLAYER_H - -#include -#include -#include -#include "blackmisc/message_system.h" -#include "blackcore/fsd_messages.h" - -namespace BlackCore { - - class CPlane; - class ISimulator; - - union FS_PBH { - quint32 pbh; - struct { - quint32 unused : 1; - quint32 onground : 1; - quint32 hdg : 10; - quint32 bank : 10; - quint32 pitch : 10; - }; - }; - - class CMultiPlayer : public BlackMisc::CMessageHandler - { - public: - CMultiPlayer(); - - //! Starts the multiplayer mode. - void start (); - - //! Stops the multiplayer mode. - void stop (); - - //! Returns true if the multiplayer mode has been started. Otherwise false. \sa start() - /*! - \return Return true if running, otherwise false. - */ - inline bool isRunning() const { return m_isRunning; } - - //! This is the trigger, to do all frequent calculations and send everything to the simulator. - //! CMultiPlayer does nothing by itself, the parent has to call this. - void run(); - - //! Returns true the plane is known, othwewise false. - /*! - \return Return true if the given plane is in the hash map, otherwise false. - */ - bool isKnown(const QString &callsign) const; - - //! Enables or disables the injection of AI planes - /*! - \param enable If enable is true, injection is enabled, otherwise it will be disabled - */ - void enableAIPlanes(bool enable); - - //! Returns true if rendering of AI planes is enabled - /*! - \return Return true if enabled, otherwise false. - */ - bool areAIPlanesEnabled() const; - - - //! Use this method if you need a specific plane object. - /*! - \param callsign Callsign of the players plane - \return Returns the pointer to the Plane object. - */ - CPlane *getPlane ( const QString &callsign); - - private: - - void onPositionUpdate(const FSD::FSD_MSG_Plane_Position *plane_position); - - void addPlane(CPlane *plane); - - void removePlane(CPlane *); - - bool needsToRemoved(CPlane *plane); - - typedef QHash TPlaneManager; - TPlaneManager m_multiplayer_planes; - - bool m_isRunning; - - bool m_enableAIPlanes; - - ISimulator *m_simulator; - }; - -} //! namespace BlackCore - -#endif // MULTIPLAYER_H diff --git a/src/blackcore/plane.cpp b/src/blackcore/plane.cpp deleted file mode 100644 index cc12185b2..000000000 --- a/src/blackcore/plane.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "blackcore/plane.h" - -using namespace BlackMisc::Geo; -using namespace BlackMisc::PhysicalQuantities; - -namespace BlackCore -{ - -/* - * Default constructor - */ -CPlane::CPlane() : m_interpolator(0), m_driver(0) { } - -/* - * Constructor - */ -CPlane::CPlane(const QString &callsign, ISimulator *driver) : m_callsign(callsign), m_interpolator(NULL), m_driver(driver) -{ - m_interpolator = new CInterpolator(); - Q_ASSERT(m_interpolator); - Q_ASSERT(driver); -} - -/* - * Add a position - */ -void CPlane::addPosition(const CCoordinateGeodetic &position, const CSpeed &groundVelocity, const BlackMisc::Aviation::CHeading &heading, const CAngle &pitch, const CAngle &bank) -{ - Q_ASSERT(m_interpolator); - m_interpolator->pushUpdate(position, groundVelocity, heading, pitch, bank); -} - -/* - * Render this object - */ -void CPlane::render() -{ - // void -} - -/* - * Last update timestamp - */ -double CPlane::getLastUpdateTime() const -{ - return 0; -} - -} // namespace BlackCore diff --git a/src/blackcore/plane.h b/src/blackcore/plane.h deleted file mode 100644 index c8f079a16..000000000 --- a/src/blackcore/plane.h +++ /dev/null @@ -1,80 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef BLACKCORE_PLANE_H -#define BLACKCORE_PLANE_H -#include "blackcore/interpolator.h" - -namespace BlackCore -{ - -class ISimulator; - -/*! - * \brief Plane class - */ -class CPlane -{ -public: - - enum ESquawkMode {Standby = 'S', - Charlie = 'N', - Ident = 'Y' - }; - - /*! - * \brief Default constructor - */ - CPlane(); - - /*! - * \brief Constructor - * \param callsign - * \param driver - */ - CPlane(const QString &callsign, ISimulator *driver); - - /*! - * \brief Add a position (for the interpolator) - * \param position - * \param groundVelocity - * \param heading - * \param pitch - * \param bank - */ - void addPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, - const BlackMisc::PhysicalQuantities::CSpeed &groundVelocity, - const BlackMisc::Aviation::CHeading &heading, - const BlackMisc::PhysicalQuantities::CAngle &pitch, - const BlackMisc::PhysicalQuantities::CAngle &bank); - - /*! - * \brief Returns the callsign of the multiplayer plane - * \return - */ - QString callsign() { return m_callsign; } - - - /*! - * \brief render - */ - void render(); - - /*! - * \brief Last updated timestamp - * \return - */ - double getLastUpdateTime() const; - -private: - - QString m_callsign; - CInterpolator *m_interpolator; - ISimulator *m_driver; -}; - -} // namespace BlackCore - -#endif // guard diff --git a/src/blackcore/sim_callbacks.h b/src/blackcore/sim_callbacks.h deleted file mode 100644 index e9e77684d..000000000 --- a/src/blackcore/sim_callbacks.h +++ /dev/null @@ -1,6 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -//TODO remove this file diff --git a/src/blackcore/simulator.cpp b/src/blackcore/simulator.cpp deleted file mode 100644 index 3056c8fb2..000000000 --- a/src/blackcore/simulator.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2013 by Roland Winklmeier * - * roland.m.winklmeier@googlemail.com * - * * - * For license information see LICENSE in the root folder of the * - * source code. * - * * - * 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 Lesser General Public License for more details. * - * * - ***************************************************************************/ - -#include "blackcore/simulator.h" -#include "blackmisc/debug.h" -#include "blackmisc/context.h" -#include -#include - -namespace BlackCore { - - const quint32 ISimulator::InterfaceVersionMajor = 0; - const quint32 ISimulator::InterfaceVersionMinor = 1; - - typedef ISimulator* (*createISimulatorInstance)(); - const char *IDRV_CREATE_SIM_INTERFACE = "BB_createISimulatorInstance"; - - typedef quint32 (*getDriverVersionMajor)(void); - const char *DRIVER_VERSION_MAJOR = "BB_InterfaceVersionMajor"; - - typedef quint32 (*getDriverVersionMinor)(void); - const char *DRIVER_VERSION_MINOR = "BB_InterfaceVersionMinor"; - - void ISimulator::setLibraryContext(BlackMisc::IContext *context) - { - m_libraryContext = context; - } - - ISimulator *ISimulator::createDriver(ESimulator sim) - { - QLibrary myLib; - ISimulator *result = NULL; - - getDriverVersionMajor driverVersionMajor; - //getDriverVersionMinor driverVersionMinor; - createISimulatorInstance createDriver; - - switch (sim) - { - #ifdef Q_OS_WIN - case FS9: - { - myLib.setFileName(SHARED_LIBRARY_NAME_FS9); - if (! myLib.load()) - { - //TODO throw - } - - driverVersionMajor = (getDriverVersionMajor) myLib.resolve(DRIVER_VERSION_MAJOR); - if (driverVersionMajor) - { - if (driverVersionMajor() != ISimulator::InterfaceVersionMajor) - { - //TODO throw - } - } - - createDriver = (createISimulatorInstance) myLib.resolve(IDRV_CREATE_SIM_INTERFACE); - if (createDriver) - { - bAppInfo << "Loaded successfully shared library 'bb_driver_fs9'"; - result = createDriver(); - } - } - break; - - case FSX: - myLib.setFileName(SHARED_LIBRARY_NAME_FSX); - if (! myLib.load()) - { - //TODO throw - } - - driverVersionMajor = (getDriverVersionMajor) myLib.resolve(DRIVER_VERSION_MAJOR); - if (driverVersionMajor) - { - if (driverVersionMajor() != ISimulator::InterfaceVersionMajor) - { - //TODO throw - } - } - - createDriver = (createISimulatorInstance) myLib.resolve(IDRV_CREATE_SIM_INTERFACE); - if (createDriver) - { - bAppInfo << "Loaded successfully shared library 'bb_driver_fsx'"; - result = createDriver(); - } - break; - #endif - case XPLANE: - myLib.setFileName(SHARED_LIBRARY_NAME_XPLANE); - if (! myLib.load()) - { - //TODO throw - } - - driverVersionMajor = (getDriverVersionMajor) myLib.resolve(DRIVER_VERSION_MAJOR); - if (driverVersionMajor) - { - if (driverVersionMajor() != ISimulator::InterfaceVersionMajor) - { - //TODO throw - } - } - - createDriver = (createISimulatorInstance) myLib.resolve(IDRV_CREATE_SIM_INTERFACE); - if (createDriver) - { - bAppInfo << "Loaded successfully shared library 'bb_driver_xplane'"; - result = createDriver(); - } - break; - default: - break; - } - - return result; - } - - void ISimulator::setcbSimStarted(const cbSimStarted &func) - { - m_cbSimStarted = func; - } - - void ISimulator::setcbChangedAvionicsState(const cbChangedAvionicsState &func) - { - m_cbChangedAvionicsState = func; - } - - void ISimulator::setcbChangedAnimationState(const cbChangedAnimationState &func) - { - m_cbChangedAnimationState = func; - } - - void ISimulator::setcbChangedModel(const cbChangedModel &func) - { - m_cbChangedModel = func; - } - -} //! namespace BlackCore diff --git a/src/blackcore/simulator.h b/src/blackcore/simulator.h deleted file mode 100644 index a81dd869c..000000000 --- a/src/blackcore/simulator.h +++ /dev/null @@ -1,260 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#ifndef SIMULATOR_H -#define SIMULATOR_H - -#include "blackcore/sim_callbacks.h" -#include "blackmisc/coordinategeodetic.h" -#include "blackmisc/mathvector3d.h" -#include - - -#if defined(_MSC_VER) && _MSC_VER >= 1600 -# include -# include -#else -# include -# include -#endif - - -#define SHARED_LIBRARY_NAME_FS9 "bb_driver_fs9" -#define SHARED_LIBRARY_NAME_FSX "bb_driver_fsx" -#define SHARED_LIBRARY_NAME_XPLANE "bb_driver_xplane" - -/*! - * \file Simulator driver interface. - */ - -namespace BlackMisc -{ - -class IContext; - -} - -namespace BlackCore -{ - -/*! - * A struct to hold data about an aircraft model and repaint. - */ -class CPlaneModel -{ -public: - QString name; //!< full name of the aircraft model, arbitrary string (hopefully unique) - QString typeCode; //!< ICAO aircraft type code - QString airlineCode; //!< ICAO air operator code -}; - -/*! - * A struct for passing around the physical state of an aircraft. - */ -class CPhysicalState -{ -public: - //! Constructor, initialize to zero. - CPhysicalState() : headingDegrees(0), pitchDegrees(0), bankDegrees(0), groundSpeedKnots(0) {} - BlackMisc::Geo::CCoordinateGeodetic position; //!< geographical position - float headingDegrees; //!< heading in degrees - float pitchDegrees; //!< pitch in degrees - float bankDegrees; //!< bank in degrees - float groundSpeedKnots; //!< ground speed in knots - BlackMisc::Math::CVector3D trueSpeedMetersPerSec; //!< needed by FSX -}; - -/*! - * A struct for passing around the avionics state of an aircraft. - */ -class CAvionicsState -{ - //! Constructor, initialize to zero. - CAvionicsState() : squawkCode(0), squawkModeC(false), squawkIdent(false), - com1FreqHz(0), com2FreqHz(0) - {} - qint16 squawkCode; //!< decimal squawk code - bool squawkModeC; //!< true if squawking mode C - bool squawkIdent; //!< true if squawking ident - qint32 com1FreqHz; //!< COM1 radio frequency in Hz - qint32 com2FreqHz; //!< COM2 radio frequency in Hz -}; - -/*! - * A struct for passing around the animation state of an aircraft. - */ -class CAnimationState -{ -public: - //! Constructor, initialize to zero. - CAnimationState() : gearPercent(0), flapsPercent(0), landingLights(false), - taxiLights(false), navLights(false), strobeLights(false), beaconLights(false) - {} - qint8 gearPercent; //!< 0 = retracted, 100 = extended - qint8 flapsPercent; //!< 0 = ratracted, 100 = extended - bool landingLights; //!< true if landing lights on - bool taxiLights; //!< true if taxi lights on - bool navLights; //!< true if nav lights on - bool strobeLights; //!< true if strobe lights on - bool beaconLights; //!< true if beacon lights on -}; - -#ifdef Q_OS_WIN - -//! A callback that is called when the simulator is started. -typedef std::tr1::function cbSimStarted; - -//! A callback that is called when the user's plane changes its avionics state. -typedef std::tr1::function cbChangedAvionicsState; - -//! A callback that is called when the user's plane changes its animation state. -typedef std::tr1::function cbChangedAnimationState; - -//! A callback that is called when the user's plane changes its model. -typedef std::tr1::function cbChangedModel; - -#else -//! A callback that is called when the simulator is started. -typedef std::function cbSimStarted; - -//! A callback that is called when the user's plane changes its avionics state. -typedef std::function cbChangedAvionicsState; - -//! A callback that is called when the user's plane changes its animation state. -typedef std::function cbChangedAnimationState; - -//! A callback that is called when the user's plane changes its model. -typedef std::function cbChangedModel; -#endif - -/*! - * The interface that is implemented by each simulator driver. - * - * Simulator drivers are responsible for communicating with the simulator on the user's - * computer and keeping it in sync with the client. - */ -class ISimulator -{ -public: - // Version of the driver interface. To increment when the interface change. - static const quint32 InterfaceVersionMajor; - static const quint32 InterfaceVersionMinor; - - //! Enumeration to describe which simulator is desired. - enum ESimulator - { - FS9 = 0, //!< Microsoft Flight Simulator 9 - FSX, //!< Microsoft Flight Simulator 10 - XPLANE //!< X-Plane - }; - - //! Constructor. - ISimulator() {} - - //! Destructor. - virtual ~ISimulator() {} - - //! Provide the driver with a pointer to the global context. - virtual void setLibraryContext(BlackMisc::IContext *context); - - //! Factory method. - static ISimulator *createDriver(ESimulator sim); - - //! Initialize the driver. - virtual int init() = 0; - - //! Connect to the simulator. - virtual int connect() = 0; - - //! Provide a callback to be called when the simulation starts. - virtual void setcbSimStarted(const cbSimStarted &func); - - //! Query whether the driver is connected to the simulator. - virtual bool isConnected() = 0; - - //! If there has been an error, return the associated message. - virtual QString getLastErrorMessage() = 0; - - //! Provide a callback to be called when the user plane changes avionics state. - virtual void setcbChangedAvionicsState(const cbChangedAvionicsState &func); - - //! Provide a callback to be called when the user plane changes animation state. - virtual void setcbChangedAnimationState(const cbChangedAnimationState &func); - - //! Provide a callback to be called when the user plane changes model. - virtual void setcbChangedModel(const cbChangedModel &func); - - //! Returns true if the user plane is in contact with the ground. - virtual bool isOnGround() = 0; - - /*! - * Returns the physical state of the user plane. - * \warning This might block - use QtConcurrent::run if that is a problem. - */ - virtual CPhysicalState getPhysicalState() = 0; - - /*! - * Adds a plane to the simulator traffic and returns its handle. - * \warning This might block - use QtConcurrent::run if that is a problem - */ - virtual qint32 addPlane(const QString &callsign) = 0; - - /*! - * Remove a plane from the simulator traffic. - * \param planeID a handle that was returned by addPlane(). - */ - virtual bool removePlane(const qint32 planeID) = 0; - - /*! - * Set the model of an aircraft in the simulator traffic. - * \param planeID a handle that was returned by addPlane(). - */ - virtual void setModel(const qint32 planeID, const CPlaneModel &model) = 0; - - /*! - * Set the physical state of an aircraft in the simulator traffic. - * \param planeID a handle that was returned by addPlane(). - */ - virtual bool setPhysicalState(const qint32 planeID, const CPhysicalState &state) = 0; - - /*! - * Set the animation state of an aircraft in the simulator traffic. - * \param planeID a handle that was returned by addPlane(). - */ - virtual bool setAnimationState(const qint32 planeID, const CAnimationState &state) = 0; - - //! Calls the supplied visitor function once for every model available in the simulator. - -#ifdef Q_OS_WIN - virtual void visitAllModels(const std::tr1::function &visitor) = 0; -#else - virtual void visitAllModels(const std::function &visitor) = 0; -#endif - - /*! - * Fills container with all models. - * Class T must be a container of CPlaneModel objects and must support push_back. - */ -#ifdef Q_OS_WIN - template - void getAllModels(T &container) { visitAllModels(std::tr1::bind(T::push_back, container)); } -#else - template - void getAllModels(T &container) { visitAllModels(std::bind(T::push_back, container)); } -#endif - - -protected: - BlackMisc::IContext *m_libraryContext; //!< The global context. - - cbSimStarted m_cbSimStarted; //!< Callback to call when the sim starts. - cbChangedAvionicsState m_cbChangedAvionicsState; //!< Callback to call when the user plane changes avionics state. - cbChangedAnimationState m_cbChangedAnimationState; //!< Callback to call when the user plane changes animation state. - cbChangedModel m_cbChangedModel; //!< Callback to call when the user plane changes model. -}; - -} //! namespace BlackCore - -#endif // SIMULATOR_H diff --git a/src/blackmisc/atclist.h b/src/blackmisc/atclist.h deleted file mode 100644 index f6f14a145..000000000 --- a/src/blackmisc/atclist.h +++ /dev/null @@ -1,111 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / authors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/*! - \file -*/ - -#ifndef BLACKMISC_ATCLIST_H -#define BLACKMISC_ATCLIST_H - -#include "pqfrequency.h" -#include "pqlength.h" -#include "coordinategeodetic.h" -#include "context.h" -#include -#include -#include - -namespace BlackMisc -{ - - /*! - * Value object encapsulating information about an ATC station. - */ - class CAtcListEntry - { - public: - /*! - * Default constructor. - */ - CAtcListEntry() {} - - /*! - * Constructor. - */ - CAtcListEntry(const QString &callsign, const BlackMisc::PhysicalQuantities::CFrequency &freq, - const BlackMisc::Geo::CCoordinateGeodetic &pos, const BlackMisc::PhysicalQuantities::CLength &range) - : m_callsign(callsign), m_freq(freq), m_pos(pos), m_range(range) - {} - - /*! - * Get callsign. - * \return - */ - const QString &getCallsign() const { return m_callsign; } - - /*! - * Get frequency. - * \return - */ - const BlackMisc::PhysicalQuantities::CFrequency &getFrequency() const { return m_freq; } - - /*! - * Get the position of the center of the controller's area of visibility. - * \return - */ - const BlackMisc::Geo::CCoordinateGeodetic &getPosition() const { return m_pos; } - - /*! - * Get the radius of the controller's area of visibility. - * \return - */ - const BlackMisc::PhysicalQuantities::CLength &getAtcRange() const { return m_range; } - - private: - QString m_callsign; - BlackMisc::PhysicalQuantities::CFrequency m_freq; - BlackMisc::Geo::CCoordinateGeodetic m_pos; - BlackMisc::PhysicalQuantities::CLength m_range; - }; - - /*! - * Value object encapsulating a list of ATC stations. - */ - class CAtcList - { - public: - /*! - * Immutable getter for the internal map. - * \return - */ - const QMap &constMap() const { return m_map; } - - /*! - * Insert an ATC station into the list. - * \param entry - */ - void insert(const CAtcListEntry &entry) { m_map.insert(entry.getCallsign(), entry); } - - /*! - * Remove an ATC station from the list. - * \param callsign - */ - void remove(const QString &callsign) { m_map.remove(callsign); } - - /*! - * Remove all ATC stations from the list. - */ - void clear() { m_map.clear(); } - - private: - QMap m_map; - }; - -} //namespace BlackMisc - -Q_DECLARE_METATYPE(BlackMisc::CAtcList) - -#endif //BLACKMISC_ATCLIST_H \ No newline at end of file diff --git a/src/blackmisc/com_client.cpp b/src/blackmisc/com_client.cpp deleted file mode 100644 index bfeda8e93..000000000 --- a/src/blackmisc/com_client.cpp +++ /dev/null @@ -1,186 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#include "blackmisc/com_client.h" -#include "blackmisc/context.h" -#include "blackmisc/debug.h" -#include -#include - -namespace BlackMisc -{ - - CComClient::CComClient(IContext &context, QObject *parent) - : IComHandler(context, parent), m_context(context), m_tcp_socket(NULL), m_port(0) - { - init(); - } - - CComClient::~CComClient() - { - if ( isConnected() ) - disconnect(); - - if ( m_tcp_socket != NULL ) - delete m_tcp_socket; - - m_tcp_socket = NULL; - } - - bool CComClient::init() - { - m_tcp_socket = new QTcpSocket(this); - Q_ASSERT(m_tcp_socket); - - Q_ASSERT ( QObject::connect( m_tcp_socket, SIGNAL( connected() ), this, SLOT( onConnected() ) ) ); - Q_ASSERT ( QObject::connect( m_tcp_socket, SIGNAL( disconnected() ), this, SLOT( onDisconnected() ) ) ); - Q_ASSERT ( QObject::connect( m_tcp_socket, SIGNAL( error(QAbstractSocket::SocketError) ), this, SLOT( onError(QAbstractSocket::SocketError) ) ) ); - - Q_ASSERT ( QObject::connect( m_tcp_socket, SIGNAL( readyRead() ), this, SLOT( onReceivingData() ) ) ); - - return true; - } - - void CComClient::connectTo( const QString& hostName, quint16 port) - { - Q_ASSERT ( ! hostName.isEmpty() ); - Q_ASSERT ( port > 0 ); - - m_hostName = hostName; - m_port = port; - - if ( isConnected() ) - return; - - bDebug(m_context) << "Connecting to host: " << hostName << ":" << port; - - m_receive_buffer.clear(); - - m_tcp_socket->connectToHost(hostName, port); - - } - - bool CComClient::isConnected() const - { - return m_tcp_socket->state() == QAbstractSocket::ConnectedState; - } - - void CComClient::disconnectFrom() - { - bDebug(m_context) << "Disconnecting from host."; - - m_tcp_socket->disconnectFromHost(); - m_port = 0; - m_hostName.clear(); - } - - bool CComClient::sendMessage(const QString& messageID, const QByteArray &message) - { - if (!isConnected()) - { - bError(m_context) << "Cannot send data in disconnected state!"; - return false; - } - - createFrame(messageID, message); - - qint64 sender_buffer_size = m_sender_buffer.size(); - - qint64 bytes = m_tcp_socket->write(m_sender_buffer); - if (bytes < 0 || bytes != sender_buffer_size) - { - bWarning(m_context) << "Error writing to socket!"; - return false; - } - - return true; - } - - QString CComClient::getErrorMessage(QAbstractSocket::SocketError error) - { - QString message; - - /* - ConnectionRefusedError, - RemoteHostClosedError, - HostNotFoundError, - SocketAccessError, - SocketResourceError, - SocketTimeoutError, - DatagramTooLargeError, - NetworkError, - AddressInUseError, - SocketAddressNotAvailableError, - UnsupportedSocketOperationError, - UnfinishedSocketOperationError, - ProxyAuthenticationRequiredError, - SslHandshakeFailedError, - ProxyConnectionRefusedError, - ProxyConnectionClosedError, - ProxyConnectionTimeoutError, - ProxyNotFoundError, - ProxyProtocolError, - UnknownSocketError = -1 */ - - switch (error) - { - case QAbstractSocket::ConnectionRefusedError: - message = "Connection refused by host!"; - break; - - case QAbstractSocket::RemoteHostClosedError: - message = "Connection closed by host!"; - break; - - case QAbstractSocket::HostNotFoundError: - message = "Host not found!"; - break; - - default: - case QAbstractSocket::UnknownSocketError: - message = "Unknown error!"; - break; - } - - return message; - } - - void CComClient::onConnected() - { - bDebug(m_context) << "Connected successfully to remote host."; - emit doConnected(); - } - - void CComClient::onDisconnected() - { - bDebug(m_context) << "Disconnected successfully from remote host."; - emit doDisconnected(); - } - - void CComClient::onError(QAbstractSocket::SocketError error) - { - if ( error != 0 ) - { - bError(m_context) << "Received socket error: " << error << " - Disconnecting..."; - } - - disconnect(); - emit doError(error, getErrorMessage(error) ); - } - - void CComClient::onReceivingData() - { - QString messageID; - QByteArray message; - m_receive_buffer.append(m_tcp_socket->readAll()); - while (parseFrame(messageID, message)) - { - emit doReceivedMessage(messageID, message); - } - } - -} // namespace BlackMisc - - diff --git a/src/blackmisc/com_client.h b/src/blackmisc/com_client.h deleted file mode 100644 index 04168dc67..000000000 --- a/src/blackmisc/com_client.h +++ /dev/null @@ -1,121 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#ifndef COM_CLIENT_H -#define COM_CLIENT_H - -#include "blackmisc/com_handler.h" -#include -#include - -class QTcpSocket; - -namespace BlackMisc -{ - -class IContext; - -class CComClient : public IComHandler -{ - Q_OBJECT - -public: - - //! Constructor - /*! - \param parent Pointer to the parent QObject - */ - CComClient(IContext &context, QObject *parent = 0); - - //! Destructor - ~CComClient(); - - //! This method initializes the client - virtual bool init(); - - //! Connects to the host address. - /*! - \param host Host address of the remote host. - \param port Port number of the remote host. - \return Returns true if connecting was successfull, otherwise false. - */ - void connectTo(const QString &hostName, quint16 port); - - //! Returns the connection status - /*! - \return Returns true if connected, otherwise false - */ - bool isConnected() const; - - //! Disconnects from the current server - void disconnectFrom(); - - //! Sends a message to the remote host. - /*! - \param data Reference to the raw byte data to be sent. - \return Returns true if sending was successfull, otherwise false. - */ - bool sendMessage(const QString &messageID, const QByteArray &message); - - //! Returns a human readable description of the last error that occurred. - QString getErrorMessage(QAbstractSocket::SocketError error); - -signals: - - //! emitted when new data were received - void doReceivedMessage(QString &messageID, QByteArray &message); - - //! emitted when cliebt connected - void doConnected(); - - //! emitted when client disconnected - void doDisconnected(); - - //! emitted when an error has occured - void doError(QAbstractSocket::SocketError error, const QString &error_message); - -protected slots: - - //! Call this slot, when connected succesfully - void onConnected(); - - //! Call this slot, when disconnected succesfully - void onDisconnected(); - - //! Call this slot, when an error appeared - void onError(QAbstractSocket::SocketError error); - - //! Call this slot, when data has been received - void onReceivingData(); - -private: - IContext &m_context; - -protected: - - //! TCP Socket - /*! - Pointer to the tcp socket. - */ - QTcpSocket *m_tcp_socket; - - //! Remote hostname - QString m_hostName; - - //! Remote host port - quint16 m_port; - - //! This variable holds the last appeared error - QString m_last_error; - -private: - - CComClient(const CComClient &other); - const CComClient &operator = (const CComClient &other); -}; - -} // namespace BlackMisc - -#endif // COM_CLIENT_H diff --git a/src/blackmisc/com_client_buffer.cpp b/src/blackmisc/com_client_buffer.cpp deleted file mode 100644 index 579936643..000000000 --- a/src/blackmisc/com_client_buffer.cpp +++ /dev/null @@ -1,59 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#include "blackmisc/com_client_buffer.h" -#include "blackmisc/debug.h" -#include "blackmisc/context.h" -#include - -namespace BlackMisc -{ - -CComClientBuffer::CComClientBuffer(IContext &context, uint clientID, QTcpSocket *socket, QObject *parent) - : IComHandler(context, parent), m_context(context), m_tcp_socket(socket), m_client_id(clientID) -{ - connect(m_tcp_socket, SIGNAL(readyRead()), this, SLOT(onReceivingData())); - connect(m_tcp_socket, SIGNAL(disconnected()), this, SLOT(onClientDisconnected())); -} -CComClientBuffer::~CComClientBuffer() -{ - m_tcp_socket->deleteLater(); -} - -bool CComClientBuffer::sendMessage(const QString &id, const QByteArray &message) -{ - createFrame(id, message); - - qint64 sender_buffer_size = m_sender_buffer.size(); - - qint64 bytes = m_tcp_socket->write(m_sender_buffer); - if (bytes < 0 || bytes != sender_buffer_size) - { - bWarning(m_context) << "Error writing to socket!"; - return false; - } - - return true; -} - -void CComClientBuffer::onReceivingData() -{ - QByteArray message; - QString messageID; - - m_receive_buffer.append(m_tcp_socket->readAll()); - while (parseFrame(messageID, message)) - { - emit doReceivedMessage(m_client_id, messageID, message); - } -} - -void CComClientBuffer::onClientDisconnected() -{ - bInfo(m_context) << "Client disconnected!"; - emit doDisconnected(m_client_id); -} - -} // namespace BlackMisc diff --git a/src/blackmisc/com_client_buffer.h b/src/blackmisc/com_client_buffer.h deleted file mode 100644 index 4e6c93f85..000000000 --- a/src/blackmisc/com_client_buffer.h +++ /dev/null @@ -1,52 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#ifndef COM_CLIENT_BUFFER_H -#define COM_CLIENT_BUFFER_H - -#include "blackmisc/com_handler.h" -#include - -class QTcpSocket; - -namespace BlackMisc -{ - -class IContext; - -class CComClientBuffer : public IComHandler -{ - Q_OBJECT - -public: - CComClientBuffer(IContext &context, uint clientID, QTcpSocket *socket, QObject *parent = 0); - - virtual ~CComClientBuffer(); - - //! Sends a message to the remote host. - /*! - \param data Reference to the raw byte data to be sent. - \return Returns true if sending was successfull, otherwise false. - */ - bool sendMessage(const QString &id, const QByteArray &message); - -signals: - - void doReceivedMessage(uint clientID, QString &messageID, QByteArray &message); - void doDisconnected(uint clientID); - -protected slots: - void onReceivingData(); - void onClientDisconnected(); - -protected: - IContext &m_context; - QTcpSocket *m_tcp_socket; - uint m_client_id; -}; - -} // namespace BlackMisc - -#endif // COM_CLIENT_BUFFER_H diff --git a/src/blackmisc/com_handler.cpp b/src/blackmisc/com_handler.cpp deleted file mode 100644 index 582e81ab0..000000000 --- a/src/blackmisc/com_handler.cpp +++ /dev/null @@ -1,127 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#include "blackmisc/com_handler.h" -#include "blackmisc/debug.h" -#include "blackmisc/context.h" -#include -#include - -namespace BlackMisc -{ - - IComHandler::IComHandler(IContext &context, QObject *parent) : - QObject(parent), - m_context(context) - { - } - - void IComHandler::createFrame(const QString& messageID, const QByteArray &data) - { - m_sender_buffer.clear(); - - QDataStream stream(&m_sender_buffer, QIODevice::WriteOnly); - - qint32 message_size = data.size(); - quint16 crc = qChecksum(data.constData(), message_size); - - stream << (qint32)Sync_Marker - << (qint32)message_size - << (QString)messageID; - stream.writeRawData(data.constData(), message_size); - stream << (quint16)crc; - } - - bool IComHandler::parseFrame(QString &messageID, QByteArray &data) - { - if (m_receive_buffer.isEmpty()) - return false; - - qint32 total_length = 0; - qint32 min_size = 3 * (int)sizeof(qint32); - - if (m_receive_buffer.size() < min_size) - { - bDebug(m_context) << "Received data is to small to read SYNC and frame length!"; - return false; - } - - bool found_sync = false; - QDataStream stream (m_receive_buffer); - - ///////////////////////////////////////////////// - // Read the Sync - ///////////////////////////////////////////////// - - do - { - qint32 sync = 0; - stream >> sync; - if (sync == Sync_Marker) - found_sync = true; - } - while (!found_sync && !stream.atEnd()); - - if (!found_sync) - { - bWarning(m_context) << "Could not find sync pattern in the stream. Discarding all data!"; - m_receive_buffer.clear(); - return false; - } - - total_length += (int)sizeof(qint32); // Sync - - ///////////////////////////////////////////////// - // Read size of the message itself - ///////////////////////////////////////////////// - - qint32 message_length = 0; - stream >> message_length; - - total_length += (int)sizeof(qint32); // Length - total_length += message_length; // Data - - ///////////////////////////////////////////////// - // Read the message id - ///////////////////////////////////////////////// - - stream >> messageID; - total_length += sizeof(QChar) * messageID.length() + (int)sizeof(quint32); // ID - - if (m_receive_buffer.size() < (total_length + (int)sizeof (quint16))) - { - bDebug(m_context) << "Received data is to small to read data block!"; - return false; - } - - ///////////////////////////////////////////////// - // Read the data - ///////////////////////////////////////////////// - - data.resize(message_length); - // creates warning when compiled as RELEASE - qint32 bytes = stream.readRawData(data.data(), message_length); - Q_ASSERT (bytes == message_length); - Q_ASSERT (data.size() == message_length); - - quint16 crc_calc = qChecksum (data.constData(), data.size()); - quint16 crc_recv = 0; - stream >> crc_recv; - - total_length += (int)sizeof(quint16); - - m_receive_buffer.remove(0, total_length); - - if (crc_calc != crc_recv) - { - bWarning(m_context) << "Message CRC error!"; - data.clear(); - return false; - } - - return true; - } - -} // namespace BlackMisc diff --git a/src/blackmisc/com_handler.h b/src/blackmisc/com_handler.h deleted file mode 100644 index ec7d28e2d..000000000 --- a/src/blackmisc/com_handler.h +++ /dev/null @@ -1,77 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#ifndef COM_HANDLER_H -#define COM_HANDLER_H - -#include - -class QTcpSocket; - -const qint32 Sync_Marker = 0x1ACFFC1D; - -namespace BlackMisc -{ - class IContext; - - //! IComHandler Interface. - /*! - This interface implements the basic class for every InterCommunikation - objects. It creates the frames in which the data is packed and - deframes it, when it receives something from the TCP socket. - \sa CComClient CComServer - */ - class IComHandler : public QObject - { - Q_OBJECT - - public: - //! Constructor - /*! - \param parent Pointer to the parent QObject - */ - IComHandler(IContext &context, QObject *parent = 0); - - //! Virtual destructor - virtual ~IComHandler() {} - - protected: - - //! Creates a sendable frame containing some data. - /*! - \param messageID QString with the unique messageID - \param message The actual data - \sa IMessage - */ - void createFrame (const QString &messageID, const QByteArray &data); - - //! Parses a new frame and constructs messageID and data out of it - /*! - \param messageID Reference to the QString messageID - \param message Reference where the data will be stored in. - \sa IMessage - */ - bool parseFrame(QString &messageID, QByteArray &data); - - //! Context. - IContext &m_context; - - //! Receive Buffer - /*! - Data received from the TCP socket, will stored in here. - */ - QByteArray m_receive_buffer; - - //! Sender Buffer - /*! - Sending data via the TCP socket, should be stored in here. - */ - QByteArray m_sender_buffer; - - }; - -} // namespace BlackMisc - -#endif // COM_HANDLER_H diff --git a/src/blackmisc/com_server.cpp b/src/blackmisc/com_server.cpp deleted file mode 100644 index 510f920b9..000000000 --- a/src/blackmisc/com_server.cpp +++ /dev/null @@ -1,136 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#include "blackmisc/com_server.h" -#include "blackmisc/com_client_buffer.h" -#include "blackmisc/debug.h" -#include "blackmisc/context.h" -#include -#include - -namespace BlackMisc -{ - -CComServer::CComServer(IContext &context, QObject *parent) - : QObject(parent), m_context(context), m_tcp_server(NULL), m_port(0) -{ - init(); -} - -CComServer::~CComServer() -{ - //QObject::disconnect(m_tcp_server, SIGNAL(newConnection()), this, SLOT(onIncomingConnection()) ); - - TClientBufferHash::iterator it = m_client_buffers.begin(); - while (it != m_client_buffers.end()) - { - it.value()->deleteLater(); - ++it; - } - - m_tcp_server->close(); - m_tcp_server->deleteLater(); -} - -bool CComServer::init() -{ - m_tcp_server = new QTcpServer(this); - Q_ASSERT(m_tcp_server); - Q_ASSERT(QObject::connect(m_tcp_server, SIGNAL(newConnection()), this, SLOT(onIncomingConnection()))); - - return true; -} - -void CComServer::Host(const QHostAddress &address, const quint16 port) -{ - if (isHosting()) return; - - Q_ASSERT(! address.isNull()); - Q_ASSERT(port > 0); - - if (!m_tcp_server->listen(address, port)) - { - bError(m_context) << "Hosting failed"; - emit doHostClosed(); - } - else - { - bDebug(m_context) << "Hosting successfull"; - emit doHosting(); - } -} - -bool CComServer::isHosting() const -{ - return m_tcp_server->isListening(); -} - -void CComServer::close() -{ - m_tcp_server->close(); -} - -void CComServer::sendToClient(const uint clientID, const QString &messageID, const QByteArray &data) -{ - if (!m_client_buffers.contains(clientID)) - { - bWarning(m_context) << "Cannot send data to client - unknown client!"; - return; - } - m_client_buffers.value(clientID)->sendMessage(messageID, data); -} - -void CComServer::sendToAll(const QString &messageID, const QByteArray &data) -{ - TClientBufferHash::const_iterator it = m_client_buffers.constBegin(); - while (it != m_client_buffers.constEnd()) - { - it.value()->sendMessage(messageID, data); - ++it; - } -} - -QString CComServer::getErrorMessage(const QAbstractSocket::SocketError /** error **/) -{ - return QString(); -} - -void CComServer::onIncomingConnection() -{ - while (m_tcp_server->hasPendingConnections()) - { - QTcpSocket *socket = m_tcp_server->nextPendingConnection(); - uint clientID = qHash(socket); - - // Create new ClientBuffer object. This new object gets the owner of the socket - CComClientBuffer *clientbuf = new CComClientBuffer(m_context, clientID, socket, this); - Q_ASSERT(clientbuf); - - connect(clientbuf, SIGNAL(doDisconnected(uint)), this, SLOT(onClientDisconnected(uint))); - connect(clientbuf, SIGNAL(doReceivedMessage(uint, QString &, QByteArray &)), this, SLOT(onClientMessageReceived(uint, QString &, QByteArray &))); - - m_client_buffers.insert(clientID, clientbuf); - - emit doClientConnected(); - } -} - -void CComServer::onClientDisconnected(uint clientID) -{ - if (!m_client_buffers.contains(clientID)) - { - bWarning(m_context) << "Disconnected unknown client!"; - return; - } - - m_client_buffers.take(clientID)->deleteLater(); -} - -void CComServer::onClientMessageReceived(uint /** clientID **/, QString &messageID, QByteArray &message) -{ - emit doMessageReceived(messageID, message); -} - -} // namespace BlackMisc diff --git a/src/blackmisc/com_server.h b/src/blackmisc/com_server.h deleted file mode 100644 index 0d73de7dd..000000000 --- a/src/blackmisc/com_server.h +++ /dev/null @@ -1,105 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#ifndef TCP_SERVER_H -#define TCP_SERVER_H - -#include -#include -#include - -class QTcpServer; - -namespace BlackMisc -{ - - class CComClientBuffer; - class IContext; - - class CComServer : public QObject - { - Q_OBJECT - - public: - - //! Constructor - /*! - \param context - \param parent Pointer to the parent QObject - */ - CComServer(IContext &context, QObject *parent = 0); - - //! Destructor - ~CComServer(); - - //! This method initializes the server - /*! - \return Returns true, if successfull, otherwise false - */ - bool init (); - - //! Call this method to start hosting - void Host ( const QHostAddress & address, const quint16 port); - - //! Hosting status - /*! - \return Returns true if hosting, otherwise false - */ - bool isHosting () const; - - //! Closes the opened hosting session - void close(); - - //! Sends data to a client - /*! - \param clientID ID of the target client - \param messageID ID of the message, to be sent to the client - \param data The actual data/message - */ - void sendToClient(const quint32 clientID, const QString &messageID, const QByteArray& data); - - //! Sends data to all clients - /*! - \param messageID ID of the message, to be sent to the client - \param data The actual data/message - */ - void sendToAll(const QString &messageID, const QByteArray& data); - - //! Call this method to get last error - /*! - \return Returns a string representation of the last error. - */ - QString getErrorMessage( const QAbstractSocket::SocketError error); - - signals: - - void doHostClosed(); - void doHosting(); - void doClientConnected(); - void doClientDisconnected(); - void doMessageReceived(QString &, QByteArray &); - void doMessageReceived(); - - protected slots: - - void onIncomingConnection(); - - void onClientDisconnected(uint clientID); - - void onClientMessageReceived(uint clientHash, QString &messageID, QByteArray &message); - - protected: - - IContext& m_context; - QTcpServer* m_tcp_server; - QHostAddress m_address; - quint16 m_port; - typedef QHash TClientBufferHash; - TClientBufferHash m_client_buffers; - }; - -} // namespace BlackMisc - -#endif // TCP_SERVER_H diff --git a/src/blackmisc/config.cpp b/src/blackmisc/config.cpp deleted file mode 100644 index da9afb02d..000000000 --- a/src/blackmisc/config.cpp +++ /dev/null @@ -1,239 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#include "blackmisc/config.h" -#include "blackmisc/debug.h" -#include "blackmisc/context.h" -#include -#include - -namespace BlackMisc -{ -CValue::CValue() : m_bool_value(false), m_double_value(0.0), m_int_value(0), - m_type(CONFIG_UNKOWN), m_value("") -{ - -} - -CValue::CValue(const QString &value) : m_bool_value(false), m_double_value(0.0), m_int_value(0), - m_type(CONFIG_UNKOWN), m_value(value) -{ - init(); -} - -void CValue::init() -{ - bool result = false; - qint32 int_value = 0; - double double_value = 0.0; - - int_value = m_value.toInt(&result); - if (result) - { - m_type = CONFIG_INT; - m_int_value = int_value; - m_double_value = int_value; - m_bool_value = false; - return; - } - - double_value = m_value.toDouble(&result); - if (result) - { - m_type = CONFIG_DOUBLE; - m_int_value = 0; - m_double_value = double_value; - m_bool_value = false; - return; - } - - if (m_value.compare("false", Qt::CaseInsensitive) == 0) - { - m_type = CONFIG_BOOL; - m_int_value = 0; - m_double_value = 0.0; - m_bool_value = false; - return; - } - - if (m_value.compare("true", Qt::CaseInsensitive) == 0) - { - m_type = CONFIG_BOOL; - m_int_value = 0; - m_double_value = 0.0; - m_bool_value = true; - return; - } - - m_type = CONFIG_STRING; - m_int_value = 0; - m_double_value = 0.0; - m_bool_value = false; -} - -qint32 CValue::asInt(bool *ok) -{ - bool result = true; - if (m_type != CONFIG_INT) - { - result = false; - } - - if (ok != NULL) - *ok = result; - return m_int_value; -} - -double CValue::asDouble(bool *ok) -{ - bool result = true; - if (m_type != CONFIG_DOUBLE) - { - result = false; - } - - if (ok != NULL) - *ok = result; - return m_double_value; -} - -bool CValue::asBool(bool *ok) -{ - bool result = true; - if (m_type != CONFIG_BOOL) - { - result = false; - } - - if (ok != NULL) - *ok = result; - return m_bool_value; -} - -CConfig::CConfig(IContext &context, const QString &filename, const QString &separator, bool /*isRelative*/) - : m_context(context), m_configfile(filename), m_separator(separator) -{ -} - -bool CConfig::load() -{ - return load(m_configfile); -} - -bool CConfig::load(const QString &filename) -{ - m_configfile = filename; - - m_value_map.clear(); - - if (m_configfile.isEmpty()) - { - bError(m_context) << "Can't open emtpy config file!"; - return false; - } - QFile input(m_configfile); - if (!input.open(QIODevice::ReadOnly)) - { - bError(m_context) << "Failed to open config file !" << m_configfile; - input.close(); - return false; - } - - bool error = false; - quint32 no_line = 0; - - QTextStream instream(&input); - - while (!instream.atEnd()) - { - ++no_line; - - QString line = instream.readLine(); - - // Remove any whitespace from the start and end - line = line.trimmed(); - - // Search for the comment operator and discard it - int pos = line.indexOf(QChar('#')); - if (pos != -1) - line = line.left(pos).trimmed(); - - // Check if we have a empty line - if (line.isEmpty()) - continue; - - // Separate between key and value - QStringList tags = line.split(m_separator); - if (tags.count() != 2) - { - bWarning(m_context) << "Could not parse line " << no_line << " in file " << m_configfile << "!"; - error = true; - continue; - } - QString key = tags[0].trimmed(); - CValue value = CValue(tags[1].trimmed()); - - setValue(key, value); - } - - input.close(); - return !error; -} - -void CConfig::setValue(const QString &key, const CValue &value) -{ - if (contains(key)) - update(key, value); - else - add(key, value); -} - -CValue CConfig::value(const QString &key) const -{ - if (m_value_map.contains(key)) - return m_value_map.value(key); - else - return CValue(); -} - -bool CConfig::contains(const QString &key) const -{ - return m_value_map.contains(key); -} - -void CConfig::remove(const QString &key) -{ - m_value_map.remove(key); -} - -void CConfig::add(const QString &key, const CValue &value) -{ - // Paranoid... - if (contains(key)) - { - update(key, value); - } - else - { - m_value_map.insert(key, value); - } -} - -void CConfig::update(const QString &key, const CValue &value) -{ - m_value_map[key] = value; -} - -void CConfig::display() -{ - TValueMap::const_iterator it; - for (it = m_value_map.begin(); it != m_value_map.end(); ++it) - { - CValue value = it.value(); - bDebug(m_context) << "Key: " << it.key() << " - Value: " << value.asString(); - } -} - -} //! namespace BlackMisc diff --git a/src/blackmisc/config.h b/src/blackmisc/config.h deleted file mode 100644 index 14c8b1b08..000000000 --- a/src/blackmisc/config.h +++ /dev/null @@ -1,168 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#ifndef CONFIG_H -#define CONFIG_H - -#include -#include -#include -#include - - -namespace BlackMisc -{ - -class IContext; - -class CValue -{ -public: - - //! Configuration type enum. - /*! This enum lists the three different values, used in the config file. */ - typedef enum { CONFIG_STRING = 0, /*!< Type String. */ - CONFIG_INT, /*!< Type Integer. */ - CONFIG_DOUBLE, /*!< Type Double. */ - CONFIG_BOOL, /*!< Type Bool. */ - CONFIG_UNKOWN /*!< Type Unknown. */ - } TConfigType; - - CValue(); - - CValue(const QString &value); - - void init(); - - QString &asString() { return m_value; } - - qint32 asInt(bool *ok = NULL); - - bool asBool(bool *ok = NULL); - - double asDouble(bool *result); - - inline bool isValid() {return m_type != CONFIG_UNKOWN;} - - inline bool isInt() { return m_type == CONFIG_INT; } - inline bool isDouble() { return m_type == CONFIG_DOUBLE; } - inline bool isBool() { return m_type == CONFIG_BOOL; } - -protected: - - bool m_bool_value; - double m_double_value; - qint32 m_int_value; - TConfigType m_type; - QString m_value; - -}; - -//! Configuration class. -/*! - This class implements the configuration part of the library. - \warning it is not safe to use this from within -*/ -class CConfig -{ -public: - - CConfig(IContext &context, const QString &filename, const QString &separator = "=", bool isRelative = false); - - //! Sets the value of the specified key. - /*! - \param key Key, which value should be set. - \param value The actual value as T. - */ - void setValue(const QString &key, const CValue &value); - - //! Returns the value from key. - /*! - \param key Specified key. - \return The value to key 'key' as T& - */ - CValue value(const QString &key) const; - - //! Function to check if the key is in the config. - /*! - \param key Specified key. - \return Returns true, if key is in the config. - */ - void add(const QString &key, const CValue &value); - - //! Function to check if the key is in the config. - /*! - \param key Specified key. - \return Returns true, if key is in the config. - */ - void update(const QString &key, const CValue &value); - - //! Function to check if the key is in the config. - /*! - \param key Specified key. - \return Returns true, if key is in the config. - */ - bool contains(const QString &key) const; - - //! Removes the key and its value from the config. - /*! - \param key Key, which has to be removed. - */ - void remove(const QString &key); - - //! Displays the configuration to the debug output. - /*! - More info. - */ - void display(); - - /*! - * Config File section - */ - - //! Returns the config filename of this config object. - /*! - \return filename of this config. - */ - const QString &configFile() const {return m_configfile; } - - //! Loads the config file. - /*! - \return Returns true if loading went well. - */ - bool load(); - - //! Loads the config file. - /*! - \param filename Specify a different filename. - \return Returns true if loading went well. - */ - bool load(const QString &filename); - - //! Saves the config to file. - /*! - \return Returns true if loading went well. - */ - bool save() { return false; } // TODO - - //! Saves the config to file. - /*! - \param filename Specify a different filename. - \return Returns true if loading went well. - */ - bool save(const QString &filename) { qDebug() << filename; return false; } // TODO - -protected: - - IContext &m_context; - QString m_configfile; - QString m_separator; - typedef QMap TValueMap; - TValueMap m_value_map; - -}; -} //! namespace BlackMisc - -#endif // CONFIG_H diff --git a/src/blackmisc/config_manager.cpp b/src/blackmisc/config_manager.cpp deleted file mode 100644 index b8748e13e..000000000 --- a/src/blackmisc/config_manager.cpp +++ /dev/null @@ -1,98 +0,0 @@ -#include "blackmisc/config_manager.h" -#include "blackmisc/config.h" -#include "blackmisc/debug.h" -#include -#include - -namespace BlackMisc -{ - SINGLETON_CLASS_IMPLEMENTATION(CConfigManager) - - CConfigManager::CConfigManager() - : m_context(IContext::getInstance()) - { - } - - CConfigManager::CConfigManager(IContext &context) - : m_context(context) - { - } - - void CConfigManager::setConfigPath(QString path) - { - m_config_path = QDir(path).absolutePath(); - } - - int CConfigManager::readConfig(bool forceReload) - { - /*! - Foreach *.cfg file in the config path, - create a new CConfig object and parse it into. - Then append the pointer to this object into - the config map. - */ - - if (forceReload) - clear(); - - QDir directory(m_config_path); - QStringList filters; - filters << "*.cfg"; - directory.setNameFilters(filters); - - QStringList files = directory.entryList(); - - QStringList::const_iterator constIterator; - for (constIterator = files.constBegin(); constIterator != files.constEnd(); ++constIterator) - { - int index = (*constIterator).indexOf("."); - QString section = (*constIterator).left(index); - - if (!m_config_map.contains(section)) - { - QString filePath = m_config_path + QDir::separator() + (*constIterator); - CConfig *config = new CConfig(m_context, filePath); - config->load(); - - m_config_map.insert(section, config); - } - } - - return m_config_map.size(); - } - - int CConfigManager::writeConfig() - { - /*! - Foreach config object in the map, - create a file with all values, from - the object. Filename is created - from the section name - */ - return m_config_map.size(); - } - - void CConfigManager::clear() - { - TConfigMap::iterator iterator; - for (iterator = m_config_map.begin(); iterator != m_config_map.end(); ++iterator) - { - delete iterator.value(); - } - - m_config_map.clear(); - } - - CConfig *CConfigManager::getConfig(const QString §ion) - { - if (m_config_map.contains(section)) - return m_config_map.value(section); - else - { - //@@@ should we throw an exception here? - bAppError << "Could not find config section: " << section; - return NULL; - } - } - -} // namespace BlackMisc diff --git a/src/blackmisc/config_manager.h b/src/blackmisc/config_manager.h deleted file mode 100644 index 43cfaba8b..000000000 --- a/src/blackmisc/config_manager.h +++ /dev/null @@ -1,74 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#ifndef BLACKMISC_CONFIGMANAGER_H -#define BLACKMISC_CONFIGMANAGER_H - -#include -#include - -#include "blackmisc/context.h" - -namespace BlackMisc -{ - - class CConfig; - - class CConfigManager : public QObject - { - Q_OBJECT - - // safe singleton declaration - SINGLETON_CLASS_DECLARATION(CConfigManager) - - public: - /*! - Default constructor. - \deprecated Do not use. - \todo Remove this when removing SINGLETON_CLASS_DECLARATION. - */ - CConfigManager(); - - /*! - Constructor. - \param context - */ - CConfigManager(IContext &context); - - //! Configuration Manager error codes. - /*! This enum lists all errors, which can appear. If you need - * a readable output then consider using /sa getErrorString() - */ - typedef enum { UNKNOWN_PATH = 0, /*!< Type String. */ - - } TErrorCodes; - - //! Sets the global path, where all the config files are located - /*! - \param path absolute pathname - */ - void setConfigPath(QString path); - - int readConfig(bool forceReload = false); - - int writeConfig(); - - void clear(); - - CConfig *getConfig(const QString §ion); - - private: - - IContext &m_context; - - typedef QMap TConfigMap; - TConfigMap m_config_map; - - QString m_config_path; - - }; -} // namespace BlackLib - -#endif // BLACKMISC_CONFIGMANAGER_H diff --git a/src/blackmisc/dbus_handler.cpp b/src/blackmisc/dbus_handler.cpp deleted file mode 100644 index 90f061028..000000000 --- a/src/blackmisc/dbus_handler.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "blackcore/dbus_server.h" -#include "blackmisc/dbus_handler.h" - -namespace BlackMisc -{ - - IDBusHandler::IDBusHandler(QObject *parent) : - QObject(parent), m_dbusserver(0), m_parent(parent) - { - } - - void IDBusHandler::setDBusServer(BlackCore::CDBusServer *dbusServer) - { - m_dbusserver = dbusServer; - - if (m_dbusserver) - m_dbusserver->addObject(m_dbusPath, this); - } - - void IDBusHandler::setDBusObjectPath(const QString &dbusPath) - { - m_dbusPath = dbusPath; - } - -} // namespace BlackMisc diff --git a/src/blackmisc/dbus_handler.h b/src/blackmisc/dbus_handler.h deleted file mode 100644 index 7166ad467..000000000 --- a/src/blackmisc/dbus_handler.h +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef DBUS_HANDLER_BASE_H -#define DBUS_HANDLER_BASE_H - -#include - -namespace BlackCore { - class CDBusServer; -} - -namespace BlackMisc -{ - - /*! - * \brief DBus Handler Base class - * \details This class implements the basic methods any DBus handler class needs to use. If you want - * to implement your own DBus handler derive it from this one. - */ - - class IDBusHandler : public QObject - { - Q_OBJECT - - protected: - - BlackCore::CDBusServer *m_dbusserver; //!< Our DBusServer - QString m_dbusPath; //!< DBus object path - - QObject *m_parent; //!< Pointer to the parent plane manager object - - public: - - /*! - * \brief Default constructor - * \param parent - */ - IDBusHandler(QObject *parent = 0); - - /*! - * \brief Sets the DBusServer - * \param dbusServer - */ - void setDBusServer(BlackCore::CDBusServer *dbusServer); - - void setDBusObjectPath( const QString &dbusPath); - - signals: - - public slots: - - }; - -} // namespace BlackMisc - -#endif // DBUS_HANDLER_BASE_H diff --git a/src/blackmisc/gui_messages.h b/src/blackmisc/gui_messages.h deleted file mode 100644 index 95c5aee4b..000000000 --- a/src/blackmisc/gui_messages.h +++ /dev/null @@ -1,115 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#ifndef GUI_MESSAGES_H -#define GUI_MESSAGES_H - -#include "blackmisc/message.h" - -namespace BlackMisc -{ - class MSG_CONNECT_TO_VATSIM : public IMessage - { - public: - MSG_CONNECT_TO_VATSIM() : IMessage(QString("MSG_ID_CONNECT_TO_VATSIM")) - { - } - - QString getHost () const { return m_host; } - quint16 getPort () const { return m_port; } - QString getCallsign () const { return m_callsign; } - QString getUserID () const { return m_userid; } - QString getPassword () const { return m_password; } - QString getRealName () const { return m_realName; } - - void setHost (const QString &host) { m_host = host; } - void setPort (const quint16 &port) { m_port = port; } - void setCallsign (const QString &callsign) { m_callsign = callsign; } - void setUserID (const QString &id) { m_userid = id; } - void setPassword (const QString &password) { m_password = password; } - void setRealName (const QString &realname) { m_realName = realname; } - - virtual QDataStream& operator<< ( QDataStream& in) - { - in >> m_message_id; - in >> m_host; - in >> m_port; - in >> m_callsign; - in >> m_userid; - in >> m_password; - in >> m_realName; - return in; - } - - virtual QDataStream& operator>> (QDataStream& out) const - { - out << m_message_id; - out << m_host; - out << m_port; - out << m_callsign; - out << m_userid; - out << m_password; - out << m_realName; - return out; - } - - virtual QTextStream& operator<< ( QTextStream& in) { return in; } - virtual QTextStream& operator>> (QTextStream& out) const { return out; } - - protected: - - private: - QString m_host; - quint16 m_port; - QString m_callsign; - QString m_userid; - QString m_password; - QString m_realName; - }; - - class MSG_CHAT_MESSAGE : public IMessage - { - public: - MSG_CHAT_MESSAGE() : IMessage(QString("MSG_ID_CHAT_MESSAGE")) - { - } - - void setSource (const QString &source) { m_source = source; } - void setDestination (const QString &destination) { m_destination = destination; } - void setText (const QString &text) { m_source = text; } - - QString getSource() const {return m_source;} - QString getDestination() const {return m_destination;} - QString getText() const {return m_text;} - - virtual QDataStream& operator<< ( QDataStream& in) - { - in >> m_message_id; - in >> m_source; - in >> m_destination; - return in; - } - - virtual QDataStream& operator>> (QDataStream& out) const - { - out << m_message_id; - out << m_source; - out << m_destination; - return out; - } - - virtual QTextStream& operator<< ( QTextStream& in) { return in; } - virtual QTextStream& operator>> (QTextStream& out) const { return out; } - - protected: - - private: - QString m_source; - QString m_destination; - QString m_text; - }; -} - -#endif // GUI_MESSAGES_H diff --git a/src/blackmisc/message.cpp b/src/blackmisc/message.cpp deleted file mode 100644 index c5d85de9c..000000000 --- a/src/blackmisc/message.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "blackmisc/message.h" - -namespace BlackMisc -{ - IMessage::IMessage(QString id) - { - m_message_id = id; - } - - QString IMessage::getID() const - { - return m_message_id; - } - -} // namespace BlackMisc diff --git a/src/blackmisc/message.h b/src/blackmisc/message.h deleted file mode 100644 index 94b533acd..000000000 --- a/src/blackmisc/message.h +++ /dev/null @@ -1,73 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#ifndef MESSAGE_H -#define MESSAGE_H - -#include -#include -#include -#include "blackmisc/serialize.h" - -namespace BlackMisc -{ - - class IMessage : public ISerialize - { - public: - IMessage(QString id); - - QString getID() const; - - virtual QDataStream& operator<< ( QDataStream& in) = 0; - virtual QDataStream& operator>> (QDataStream& out) const = 0; - - virtual QTextStream& operator<< ( QTextStream& in) = 0; - virtual QTextStream& operator>> (QTextStream& out) const = 0; - - - protected: - - QString m_message_id; - }; - - class TestMessage : public IMessage - { - public: - TestMessage() : IMessage("MSG_ID_TestMessage") - { - testString = "This is a test message!"; - } - - QString getTestString () const { return testString; } - - //QDataStream &operator>>(qint8 &i); - - virtual QDataStream& operator<< ( QDataStream& in) - { - in >> m_message_id; - in >> testString; - return in; - } - - virtual QDataStream& operator>> (QDataStream& out) const - { - out << m_message_id; - out << testString; - return out; - } - - virtual QTextStream& operator<< ( QTextStream& in) { return in; } - virtual QTextStream& operator>> (QTextStream& out) const { return out; } - - protected: - - private: - QString testString; - }; - -} // namespace BlackMisc - -#endif // MESSAGE_H diff --git a/src/blackmisc/message_dispatcher.cpp b/src/blackmisc/message_dispatcher.cpp deleted file mode 100644 index afeead7a1..000000000 --- a/src/blackmisc/message_dispatcher.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "blackmisc/message_handler.h" -#include "blackmisc/message_dispatcher.h" - -namespace BlackMisc -{ -SINGLETON_CLASS_IMPLEMENTATION(CMessageDispatcher) - -void CMessageDispatcher::append(IMessage *message) -{ - m_messageQueue.enqueue(message); -} - -void CMessageDispatcher::dispatch() -{ - IMessage *message = NULL; - - if (m_messageQueue.isEmpty()) - return; - - message = m_messageQueue.dequeue(); - - if (message != NULL) - { - CTypeInfo typeinfo = CTypeInfo(typeid(*message)); - QList neededHandlers = m_messageHander.values(typeinfo); - int handlerSize = neededHandlers.size(); - for (int i = 0; i < handlerSize; ++i) - neededHandlers.at(i)->handleMessage(message); - } -} - -} // namespace BlackMisc diff --git a/src/blackmisc/message_dispatcher.h b/src/blackmisc/message_dispatcher.h deleted file mode 100644 index 5e4491748..000000000 --- a/src/blackmisc/message_dispatcher.h +++ /dev/null @@ -1,55 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#ifndef BLACKMISC_MESSAGE_DISPATCHER_H -#define BLACKMISC_MESSAGE_DISPATCHER_H - -#include "blackmisc/message.h" -#include "blackmisc/context.h" -#include "blackmisc/type_info.h" -#include -#include - -namespace BlackMisc -{ - class CMessageHandler; - - class CMessageDispatcher : public QObject - { - Q_OBJECT - - // safe singleton declaration - SINGLETON_CLASS_DECLARATION(CMessageDispatcher) - - CMessageDispatcher() {} - - public: - virtual ~CMessageDispatcher() {} - - void dispatch (); - void append ( IMessage* message); - - bool empty () - { - return m_messageQueue.size() == 0; - } - - template - void registerClass(T* object, CTypeInfo typeinfo) - { - m_messageHander.insert(typeinfo, object); - } - - private: - typedef QQueue TMessageQueue; - TMessageQueue m_messageQueue; - - typedef QMultiMap TMessageHandlerMap; - TMessageHandlerMap m_messageHander; - }; - -} // namespace BlackMisc - -#endif // BLACKMISC_MESSAGE_DISPATCHER_H diff --git a/src/blackmisc/message_factory.cpp b/src/blackmisc/message_factory.cpp deleted file mode 100644 index 0f28a3b96..000000000 --- a/src/blackmisc/message_factory.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "blackmisc/message_factory.h" - -namespace BlackMisc -{ - SINGLETON_CLASS_IMPLEMENTATION(CMessageFactory) - - IMessageCreator::IMessageCreator(const QString &messageID) - { - CMessageFactory::getInstance().registerMessage(messageID, this); - } - - IMessage* CMessageFactory::create(const QString &messageID) - { - if (m_creators.contains(messageID)) - { - IMessageCreator* creator = m_creators.value(messageID); - IMessage* msg = creator->create(); - return msg; - } - else - return (IMessage*)NULL; - } - - CMessageFactory::~CMessageFactory() - { - TMessageCreatorHash::iterator it = m_creators.begin(); - while (it != m_creators.end()) - { - IMessageCreator* creator = it.value(); - if (creator) - delete creator; - ++it; - } - } - - void CMessageFactory::registerMessage(const QString &messageID, IMessageCreator *creator) - { - m_creators.insert(messageID, creator); - } - - void CMessageFactory::registerMessages() - { - REGISTER_MESSAGE(TestMessage, MSG_ID_TestMessage); - REGISTER_MESSAGE(MSG_CONNECT_TO_VATSIM, MSG_ID_CONNECT_TO_VATSIM); - REGISTER_MESSAGE(MSG_CHAT_MESSAGE, MSG_ID_CHAT_MESSAGE); - } - -} // namespace BlackMisc diff --git a/src/blackmisc/message_factory.h b/src/blackmisc/message_factory.h deleted file mode 100644 index 93dbd2196..000000000 --- a/src/blackmisc/message_factory.h +++ /dev/null @@ -1,61 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#ifndef BLACKMISC_MESSAGE_FACTORY_H -#define BLACKMISC_MESSAGE_FACTORY_H - -#include -#include "blackmisc/message.h" -#include "blackmisc/gui_messages.h" -#include "blackmisc/debug.h" -#include "blackmisc/context.h" - -#define REGISTER_MESSAGE(classname, msgName) new MessageCreatorImpl(#msgName); - - -namespace BlackMisc -{ -class IMessageCreator -{ -public: - IMessageCreator(const QString &messageID); - virtual IMessage *create() = 0; - virtual ~IMessageCreator() {} -}; - -template -class MessageCreatorImpl : public IMessageCreator -{ -public: - MessageCreatorImpl(const QString &messageID) : IMessageCreator(messageID) {} - virtual IMessage *create() { return new T; } -}; - -class CMessageFactory : public QObject -{ - Q_OBJECT - - // safe singleton declaration - SINGLETON_CLASS_DECLARATION(CMessageFactory) - - CMessageFactory() { } -public: - - virtual ~CMessageFactory(); - - IMessage *create(const QString &messageID); - - void registerMessage(const QString &messageID, IMessageCreator *creator); - static void registerMessages(); - -private: - - typedef QHash TMessageCreatorHash; - TMessageCreatorHash m_creators; -}; - -} // namespace BlackMisc - -#endif // BLACKMISC_MESSAGE_FACTORY_H diff --git a/src/blackmisc/message_handler.cpp b/src/blackmisc/message_handler.cpp deleted file mode 100644 index c5fb6c5e1..000000000 --- a/src/blackmisc/message_handler.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "blackmisc/message_handler.h" - -namespace BlackMisc -{ - CMessageHandler::~CMessageHandler() - { - TFunctionHandlerMap::iterator it = m_messagehandler.begin(); - while (it != m_messagehandler.end()) - { - delete it.value(); - ++it; - } - m_messagehandler.clear(); - } - - void CMessageHandler::handleMessage(const IMessage * message) - { - TFunctionHandlerMap::iterator it = m_messagehandler.find(CTypeInfo(typeid(*message))); - if (it != m_messagehandler.end()) - { - it.value()->exec(message); - } - } - -} // namespace BlackMisc diff --git a/src/blackmisc/message_handler.h b/src/blackmisc/message_handler.h deleted file mode 100644 index ba4f45df0..000000000 --- a/src/blackmisc/message_handler.h +++ /dev/null @@ -1,75 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#ifndef MESSAGE_HANDLER_H -#define MESSAGE_HANDLER_H - -#include "blackmisc/message_dispatcher.h" -#include "blackmisc/message.h" -#include "blackmisc/debug.h" -#include "blackmisc/type_info.h" -#include - -namespace BlackMisc -{ - - class IFunctionHandler - { - public: - virtual ~IFunctionHandler() {} - void exec (const IMessage* message) - { - call (message); - } - - private: - virtual void call (const IMessage*) = 0; - }; - - template - class MemberFunctionHandler : public IFunctionHandler - { - public: - typedef void (T::*MemberFunction)(MessageT*); - MemberFunctionHandler(T* instance, MemberFunction memfunc) : m_instance(instance), m_function(memfunc) {} - - void call(const IMessage* message) - { - (m_instance->*m_function)(static_cast(message)); - } - - private: - T* m_instance; - MemberFunction m_function; - }; - - - class CMessageHandler - { - public: - ~CMessageHandler(); - - void handleMessage(const IMessage* message); - - template - void registerMessageFunction(T*, void (T::*memfunc)(MessageT*)); - - private: - typedef QMap TFunctionHandlerMap; - TFunctionHandlerMap m_messagehandler; - }; - - template - void CMessageHandler::registerMessageFunction(T* obj, void (T::*memfunc)(MessageT*)) - { - CTypeInfo typeinfo = CTypeInfo(typeid(MessageT)); - m_messagehandler[typeinfo]= new MemberFunctionHandler(obj, memfunc); - CMessageDispatcher::getInstance().registerClass(obj, typeinfo); - } - - -} // namespace BlackMisc - -#endif // MESSAGE_HANDLER_H diff --git a/src/blackmisc/message_system.cpp b/src/blackmisc/message_system.cpp deleted file mode 100644 index f236119d0..000000000 --- a/src/blackmisc/message_system.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "blackmisc/message_system.h" - -namespace BlackMisc -{ - - -CMessageSystem::CMessageSystem() -{ - init(); -} - -void CMessageSystem::init() -{ - CMessageFactory::registerMessages(); -} - -} // namespace BlackMisc diff --git a/src/blackmisc/message_system.h b/src/blackmisc/message_system.h deleted file mode 100644 index 003e35e9c..000000000 --- a/src/blackmisc/message_system.h +++ /dev/null @@ -1,26 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#ifndef MESSAGE_SYSTEM_H -#define MESSAGE_SYSTEM_H - -#include "blackmisc/message_handler.h" -#include "blackmisc/message_dispatcher.h" -#include "blackmisc/message_factory.h" - -namespace BlackMisc -{ - -class CMessageSystem -{ -public: - CMessageSystem(); - - static void init(); -}; - -} // namespace BlackMisc - -#endif // MESSAGE_SYSTEM_H diff --git a/src/blackmisc/serialize.h b/src/blackmisc/serialize.h deleted file mode 100644 index cf305f65f..000000000 --- a/src/blackmisc/serialize.h +++ /dev/null @@ -1,26 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#ifndef SERIALIZE_H -#define SERIALIZE_H -#include - -namespace BlackMisc -{ - -/*! - * \brief Serialize interface - */ -class ISerialize -{ -public: - ISerialize() {} - virtual ~ISerialize() {} - virtual QDataStream &operator<< (QDataStream &in) = 0; - virtual QDataStream &operator>> (QDataStream &out) const = 0; -}; -} - -#endif // SERIALIZE_H diff --git a/src/blackmisc/type_info.cpp b/src/blackmisc/type_info.cpp deleted file mode 100644 index d689816a3..000000000 --- a/src/blackmisc/type_info.cpp +++ /dev/null @@ -1,21 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#include "blackmisc/type_info.h" - -namespace BlackMisc -{ - - CTypeInfo::CTypeInfo(const std::type_info& info) - : m_typeinfo(info) - { - } - - bool CTypeInfo::operator <(const CTypeInfo& rhs) const - { - return m_typeinfo.before(rhs.m_typeinfo) != 0; - } - -} // namespace BlackMisc diff --git a/src/blackmisc/type_info.h b/src/blackmisc/type_info.h deleted file mode 100644 index 6ed97623f..000000000 --- a/src/blackmisc/type_info.h +++ /dev/null @@ -1,27 +0,0 @@ -//! Copyright (C) 2013 Roland Winklmeier -//! This Source Code Form is subject to the terms of the Mozilla Public -//! License, v. 2.0. If a copy of the MPL was not distributed with this -//! file, You can obtain one at http://mozilla.org/MPL/2.0/ - -#ifndef TYPE_INFO_H -#define TYPE_INFO_H - -#include - -namespace BlackMisc -{ - - class CTypeInfo - { - public: - explicit CTypeInfo(const std::type_info& info); - - bool operator < (const CTypeInfo& rhs) const; - - private: - const std::type_info& m_typeinfo; - }; - -} // namespace BlackMisc - -#endif // TYPE_INFO_H diff --git a/tests/blackcore/testnetmediators.cpp b/tests/blackcore/testnetmediators.cpp deleted file mode 100644 index db26daf63..000000000 --- a/tests/blackcore/testnetmediators.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "testnetmediators.h" -#include "blackmisc/context.h" -#include - -namespace BlackCoreTest -{ - - using namespace BlackCore; - using namespace BlackMisc; - using namespace BlackMisc::PhysicalQuantities; - using namespace BlackMisc::Geo; - - void CTestNetMediators::initTestCase() - { - m_context.setObject(m_networkDummy); - } - - void CTestNetMediators::cleanupTestCase() - { - m_context.removeObject(); - } - - void CTestNetMediators::atcListManagerTest() - { - CAtcListManager mgr(m_context); - AtcListConsumer cons; - - QObject::connect(&mgr, &IAtcListManager::listChanged, &cons, &AtcListConsumer::listChanged); - - QVERIFY(cons.m_list.constMap().size() == 0); - - emit m_networkDummy.atcPositionUpdate("EGLL_TWR", CFrequency(118.7, CFrequencyUnit::MHz()), CCoordinateGeodetic(51.4775, 0.46139, 0), CLength(50, CLengthUnit::m())); - QCoreApplication::processEvents(); - QVERIFY(cons.m_list.constMap().size() == 1); - - emit m_networkDummy.atcPositionUpdate("EGLL_GND", CFrequency(121.9, CFrequencyUnit::MHz()), CCoordinateGeodetic(51.4775, 0.46139, 0), CLength(20, CLengthUnit::m())); - QCoreApplication::processEvents(); - QVERIFY(cons.m_list.constMap().size() == 2); - - emit m_networkDummy.atcPositionUpdate("EGLL_TWR", CFrequency(118.5, CFrequencyUnit::MHz()), CCoordinateGeodetic(51.4775, 0.46139, 0), CLength(50, CLengthUnit::m())); - QCoreApplication::processEvents(); - QVERIFY(cons.m_list.constMap().size() == 2); - - emit m_networkDummy.atcDisconnected("EGLL_TWR"); - QCoreApplication::processEvents(); - QVERIFY(cons.m_list.constMap().size() == 1); - - emit m_networkDummy.connectionStatusDisconnected(); - QCoreApplication::processEvents(); - QVERIFY(cons.m_list.constMap().size() == 0); - - emit m_networkDummy.atcPositionUpdate("EGLL_TWR", CFrequency(118.5, CFrequencyUnit::MHz()), CCoordinateGeodetic(51.4775, 0.46139, 0), CLength(50, CLengthUnit::m())); - QCoreApplication::processEvents(); - QVERIFY(cons.m_list.constMap().contains("EGLL_TWR")); - QVERIFY(cons.m_list.constMap()["EGLL_TWR"].getCallsign() == "EGLL_TWR"); - QVERIFY(cons.m_list.constMap()["EGLL_TWR"].getFrequency() == CFrequency(118.5, CFrequencyUnit::MHz())); - QVERIFY(cons.m_list.constMap()["EGLL_TWR"].getPosition() == CCoordinateGeodetic(51.4775, 0.46139, 0)); - QVERIFY(cons.m_list.constMap()["EGLL_TWR"].getAtcRange() == CLength(50, CLengthUnit::m())); - } - -} //namespace BlackCoreTest \ No newline at end of file diff --git a/tests/blackcore/testnetmediators.h b/tests/blackcore/testnetmediators.h deleted file mode 100644 index 6dada2a07..000000000 --- a/tests/blackcore/testnetmediators.h +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright (C) 2013 VATSIM Community / contributors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef BLACKCORETEST_TESTNETMEDIATORS_H -#define BLACKCORETEST_TESTNETMEDIATORS_H - -#include "blackcore/atclistmgr.h" -#include "blackcoretest.h" -#include "blackcore/network.h" -#include - -namespace BlackCoreTest -{ - - /*! - * Network mediator classes tests - */ - class CTestNetMediators : public QObject - { - Q_OBJECT - - public: - /*! - * Constructor. - * \param parent - */ - explicit CTestNetMediators(QObject *parent = 0) : QObject(parent) {} - - private slots: - /*! - * Called before the first test. - */ - void initTestCase(); - - /*! - * Test CAtcListManager - */ - void atcListManagerTest(); - - /*! - * Called after the last test. - */ - void cleanupTestCase(); - - private: - BlackMisc::CApplicationContext m_context; - BlackCore::NetworkDummy m_networkDummy; - }; - - /*! - * Helper class that connects to CAtcListManager signals - */ - class AtcListConsumer : public QObject - { - Q_OBJECT - - public: - //! List is updated by the slot - BlackMisc::CAtcList m_list; - - public slots: - /*! - * Slot updates the list - * \param list - */ - void listChanged(const BlackMisc::CAtcList &list) - { - m_list = list; - } - }; - -} //namespace BlackCoreTest - -#endif //BLACKCORETEST_TESTNETMEDIATORS_H \ No newline at end of file