diff --git a/samples/dbusclient/dbus/aircraftmanager.xml b/samples/dbusclient/dbus/aircraftmanager.xml
new file mode 100644
index 000000000..a70131d7f
--- /dev/null
+++ b/samples/dbusclient/dbus/aircraftmanager.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/samples/dbusclient/atcmanager.xml b/samples/dbusclient/dbus/atcmanager.xml
similarity index 100%
rename from samples/dbusclient/atcmanager.xml
rename to samples/dbusclient/dbus/atcmanager.xml
diff --git a/samples/dbusclient/fsdclient.xml b/samples/dbusclient/dbus/fsdclient.xml
similarity index 100%
rename from samples/dbusclient/fsdclient.xml
rename to samples/dbusclient/dbus/fsdclient.xml
diff --git a/samples/dbusclient/dbusclient.cpp b/samples/dbusclient/dbusclient.cpp
index cfd198363..abf72b63d 100644
--- a/samples/dbusclient/dbusclient.cpp
+++ b/samples/dbusclient/dbusclient.cpp
@@ -1,20 +1,22 @@
#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=6668", "daemon");
+ m_connection = QDBusConnection::connectToPeer("tcp:host=127.0.0.1,port=45000", "daemon");
if(!m_connection.isConnected())
{
qWarning() << m_connection.lastError().message();
}
- pilotManagerIface = new org::vatsim::pilotClient::PlaneManager("org.vatsim.PilotClient", "/PlaneManager", m_connection, this);
+ 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);
@@ -32,19 +34,16 @@ void DBusClient::connectTo(const QString &host)
void DBusClient::disconnectFrom()
{
- //iface->disconnectFrom();
}
void DBusClient::slot_connected( const QString & host)
{
qDebug() << "Conntected to " << host;
- qDebug() << "So lets collect some information... ";
+ qDebug() << "Retrieve all visible aircrafts and controllers...";
printPilotList();
printAtcList();
-
- //qDebug() << iface->getMetar("EDDM");
}
void DBusClient::slot_disconnected()
@@ -54,20 +53,19 @@ void DBusClient::slot_disconnected()
void DBusClient::printPilotList()
{
- Q_ASSERT(pilotManagerIface);
+ Q_ASSERT(aircraftManagerIface);
- qDebug() << "Online pilots: ";
+ qDebug() << "Online aircrafts: ";
- QStringList planes = pilotManagerIface->pilotList();
- if (planes.isEmpty())
+ CRemoteAircraftList aircrafts = aircraftManagerIface->aircraftList();
+ if (aircrafts.isEmpty())
{
- qWarning() << "Got no pilots. Something went wrong!";
+ qWarning() << "Got no aircrafts. Something went wrong!";
return;
}
-
- foreach(QString plane, planes)
+ foreach(CRemoteAircraft aircraft, aircrafts)
{
- qDebug() << plane;
+ qDebug() << aircraft.getCallsign();
}
}
@@ -78,6 +76,7 @@ void DBusClient::printAtcList()
qDebug() << "Online controllers: ";
QStringList controllers = atcManagerIface->atcList();
+
if (controllers.isEmpty())
{
qWarning() << "Got no controllers. Something went wrong!";
diff --git a/samples/dbusclient/dbusclient.h b/samples/dbusclient/dbusclient.h
index af9ffddd1..49b97ec4b 100644
--- a/samples/dbusclient/dbusclient.h
+++ b/samples/dbusclient/dbusclient.h
@@ -5,7 +5,7 @@
#include
#include
-#include "planemanager_interface.h"
+#include "aircraftmanager_interface.h"
#include "atcmanager_interface.h"
#include "fsdclient_interface.h"
@@ -15,7 +15,7 @@ class DBusClient : public QObject
private:
QDBusConnection m_connection;
- org::vatsim::pilotClient::PlaneManager *pilotManagerIface;
+ org::vatsim::pilotClient::AircraftManager *aircraftManagerIface;
org::vatsim::pilotClient::AtcManager *atcManagerIface;
org::vatsim::pilotClient::FsdClient *fsdClientIface;
diff --git a/samples/dbusclient/main.cpp b/samples/dbusclient/main.cpp
index e17953f9c..9d6a20c25 100644
--- a/samples/dbusclient/main.cpp
+++ b/samples/dbusclient/main.cpp
@@ -1,11 +1,31 @@
#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/planemanager.xml b/samples/dbusclient/planemanager.xml
deleted file mode 100644
index c7b38e162..000000000
--- a/samples/dbusclient/planemanager.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/samples/dbusclient/remote_aircraft.cpp b/samples/dbusclient/remote_aircraft.cpp
new file mode 100644
index 000000000..899164392
--- /dev/null
+++ b/samples/dbusclient/remote_aircraft.cpp
@@ -0,0 +1,58 @@
+#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
new file mode 100644
index 000000000..ce2ee787d
--- /dev/null
+++ b/samples/dbusclient/remote_aircraft.h
@@ -0,0 +1,85 @@
+/* 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
index 96aada047..1dbd9b3d2 100644
--- a/samples/dbusclient/sample_dbusclient.pro
+++ b/samples/dbusclient/sample_dbusclient.pro
@@ -14,11 +14,16 @@ CONFIG -= app_bundle
TEMPLATE = app
-DBUS_INTERFACES += planemanager.xml atcmanager.xml fsdclient.xml
+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
SOURCES += main.cpp \
- dbusclient.cpp
+ dbusclient.cpp \
+ remote_aircraft.cpp
HEADERS += \
- dbusclient.h
+ dbusclient.h \
+ remote_aircraft.h
diff --git a/samples/dbusserver/aircraft_manager.cpp b/samples/dbusserver/aircraft_manager.cpp
new file mode 100644
index 000000000..909c4c135
--- /dev/null
+++ b/samples/dbusserver/aircraft_manager.cpp
@@ -0,0 +1,30 @@
+/* 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
new file mode 100644
index 000000000..67beb1080
--- /dev/null
+++ b/samples/dbusserver/aircraft_manager.h
@@ -0,0 +1,64 @@
+/* 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
new file mode 100644
index 000000000..282d9a659
--- /dev/null
+++ b/samples/dbusserver/aircraft_manager_handler.cpp
@@ -0,0 +1,29 @@
+/* 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
new file mode 100644
index 000000000..76681f93a
--- /dev/null
+++ b/samples/dbusserver/aircraft_manager_handler.h
@@ -0,0 +1,53 @@
+/* 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
new file mode 100644
index 000000000..8da22d9aa
--- /dev/null
+++ b/samples/dbusserver/atc_manager.cpp
@@ -0,0 +1,28 @@
+/* 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
new file mode 100644
index 000000000..6523929f0
--- /dev/null
+++ b/samples/dbusserver/atc_manager.h
@@ -0,0 +1,57 @@
+/* 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
new file mode 100644
index 000000000..f56c68039
--- /dev/null
+++ b/samples/dbusserver/atc_manager_handler.cpp
@@ -0,0 +1,33 @@
+/* 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
new file mode 100644
index 000000000..8f695e414
--- /dev/null
+++ b/samples/dbusserver/atc_manager_handler.h
@@ -0,0 +1,49 @@
+/* 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/atcmanager.cpp b/samples/dbusserver/atcmanager.cpp
deleted file mode 100644
index ed9bc3134..000000000
--- a/samples/dbusserver/atcmanager.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-#include "atcmanager.h"
-
-CAtcManager::CAtcManager(QObject *parent) :
- QObject(parent)
-{
- m_atcList << "EDDM_N_TWR" << "KJFK_GND" << "LOVV_CTR";
-}
-
-QStringList CAtcManager::atcList() const
-{
- return m_atcList;
-}
diff --git a/samples/dbusserver/atcmanager.h b/samples/dbusserver/atcmanager.h
deleted file mode 100644
index b1f2fd9b2..000000000
--- a/samples/dbusserver/atcmanager.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef ATCMANAGER_H
-#define ATCMANAGER_H
-
-#include
-#include
-
-
-class CAtcManager : public QObject
-{
- Q_OBJECT
-
- QStringList m_atcList; //!< List of all controllers with their callsigns
-
-public:
- CAtcManager(QObject *parent = 0);
- ~CAtcManager() {}
-
- /*!
- * \brief Returns a list of all controllers with their callsigns
- * \return atcList
- */
- QStringList atcList() const;
-
-signals:
-
-public slots:
-
-};
-
-#endif // ATCMANAGER_H
diff --git a/samples/dbusserver/atcmanagerhandler.cpp b/samples/dbusserver/atcmanagerhandler.cpp
deleted file mode 100644
index d83c76415..000000000
--- a/samples/dbusserver/atcmanagerhandler.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-#include "atcmanager.h"
-#include "blackcore/dbusserver.h"
-
-#include "atcmanagerhandler.h"
-
-// It is really IMPORTANT to include this header.
-// Otherwise it won't be generated by qmake and the
-// project can't be build
-#include "atcmanager_adaptor.h"
-
-CAtcManagerHandler::CAtcManagerHandler(QObject *parent) :
- QObject(parent), m_dbusserver(0), m_parent(0)
-{
- m_dbusPath = "/AtcManager";
- m_parent = qobject_cast(parent);
-
- new AtcManagerAdaptor(this);
-}
-
-CAtcManagerHandler::~CAtcManagerHandler()
-{
-
-}
-
-void CAtcManagerHandler::setDBusServer(BlackCore::CDBusServer *dbusServer)
-{
- m_dbusserver = dbusServer;
-
- if (m_dbusserver)
- m_dbusserver->addObject(m_dbusPath, this);
-}
-
-QStringList CAtcManagerHandler::atcList() const
-{
- qDebug() << "Somebody requested the list of controllers. Here you go...";
- return m_parent->atcList();
-}
diff --git a/samples/dbusserver/atcmanagerhandler.h b/samples/dbusserver/atcmanagerhandler.h
deleted file mode 100644
index 20a1e0f48..000000000
--- a/samples/dbusserver/atcmanagerhandler.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef ATCMANAGERHANDLER_H
-#define ATCMANAGERHANDLER_H
-
-#include
-#include
-
-namespace BlackCore
-{
- class CDBusServer;
-}
-
-class CAtcManager;
-
-class CAtcManagerHandler : public QObject
-{
- Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "org.vatsim.pilotClient.AtcManager")
- Q_PROPERTY( QStringList atcList READ atcList)
-
- QStringList atcList() const;
-
- BlackCore::CDBusServer *m_dbusserver;
- CAtcManager *m_parent;
-
- QString m_dbusPath;
-
-public:
- CAtcManagerHandler(QObject *parent = NULL);
- ~CAtcManagerHandler();
-
- void setDBusServer(BlackCore::CDBusServer *dbusServer);
-
-
-};
-
-#endif // ATCMANAGERHANDLER_H
diff --git a/samples/dbusserver/dbus/aircraftmanager.xml b/samples/dbusserver/dbus/aircraftmanager.xml
new file mode 100644
index 000000000..a70131d7f
--- /dev/null
+++ b/samples/dbusserver/dbus/aircraftmanager.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/samples/dbusserver/atcmanager.xml b/samples/dbusserver/dbus/atcmanager.xml
similarity index 100%
rename from samples/dbusserver/atcmanager.xml
rename to samples/dbusserver/dbus/atcmanager.xml
diff --git a/samples/dbusserver/fsdclient.xml b/samples/dbusserver/dbus/fsdclient.xml
similarity index 100%
rename from samples/dbusserver/fsdclient.xml
rename to samples/dbusserver/dbus/fsdclient.xml
diff --git a/samples/dbusserver/fsd_client.cpp b/samples/dbusserver/fsd_client.cpp
new file mode 100644
index 000000000..8b3ec69e9
--- /dev/null
+++ b/samples/dbusserver/fsd_client.cpp
@@ -0,0 +1,18 @@
+/* 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
new file mode 100644
index 000000000..9b98cf977
--- /dev/null
+++ b/samples/dbusserver/fsd_client.h
@@ -0,0 +1,42 @@
+/* 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
new file mode 100644
index 000000000..88085f8d0
--- /dev/null
+++ b/samples/dbusserver/fsd_client_handler.cpp
@@ -0,0 +1,29 @@
+/* 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
new file mode 100644
index 000000000..5eddca071
--- /dev/null
+++ b/samples/dbusserver/fsd_client_handler.h
@@ -0,0 +1,52 @@
+/* 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/fsdclient.cpp b/samples/dbusserver/fsdclient.cpp
deleted file mode 100644
index 640e2b101..000000000
--- a/samples/dbusserver/fsdclient.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#include
-
-#include "fsdclient.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/fsdclient.h b/samples/dbusserver/fsdclient.h
deleted file mode 100644
index 58c526a17..000000000
--- a/samples/dbusserver/fsdclient.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef FSDCLIENT_H
-#define FSDCLIENT_H
-
-#include
-
-class CFsdClient : public QObject
-{
- Q_OBJECT
-public:
- CFsdClient(QObject *parent = 0);
-
- void connectTo(const QString &host);
-
-signals:
-
-public slots:
-
-};
-
-#endif // FSDCLIENT_H
diff --git a/samples/dbusserver/fsdclienthandler.cpp b/samples/dbusserver/fsdclienthandler.cpp
deleted file mode 100644
index 5fd7729a8..000000000
--- a/samples/dbusserver/fsdclienthandler.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-
-#include "blackcore/dbusserver.h"
-#include "fsdclienthandler.h"
-#include "fsdclient.h"
-
-// It is really IMPORTANT to include this header.
-// Otherwise it won't be generated by qmake and the
-// project can't be build
-#include "fsdclient_adaptor.h"
-
-CFsdClientHandler::CFsdClientHandler(QObject *parent) :
- QObject(parent), m_dbusserver(0), m_parent(0)
-{
- m_dbusPath = "/FsdClient";
- m_parent = qobject_cast(parent);
-
- new FsdClientAdaptor(this);
-}
-
-void CFsdClientHandler::connectTo(const QString &host)
-{
- m_parent->connectTo(host);
- emit connectedTo(host);
-}
-
-void CFsdClientHandler::setDBusServer(BlackCore::CDBusServer *dbusServer)
-{
- m_dbusserver = dbusServer;
-
- if (m_dbusserver)
- m_dbusserver->addObject(m_dbusPath, this);
-}
diff --git a/samples/dbusserver/fsdclienthandler.h b/samples/dbusserver/fsdclienthandler.h
deleted file mode 100644
index 5ce1fe4bd..000000000
--- a/samples/dbusserver/fsdclienthandler.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef FSDCLIENTHANDLER_H
-#define FSDCLIENTHANDLER_H
-
-#include
-
-
-namespace BlackCore
-{
- class CDBusServer;
-}
-
-class CFsdClient;
-
-class CFsdClientHandler : public QObject
-{
- Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "org.vatsim.pilotClient.FsdClient")
-
- BlackCore::CDBusServer *m_dbusserver;
- CFsdClient *m_parent;
-
- QString m_dbusPath;
-
-public:
- CFsdClientHandler(QObject *parent = 0);
- ~CFsdClientHandler() {}
-
- Q_INVOKABLE void connectTo(const QString &host);
-
- void setDBusServer(BlackCore::CDBusServer *dbusServer);
-
-signals:
- void connectedTo( const QString &host);
-
-public slots:
-
-};
-
-#endif // FSDCLIENTHANDLER_H
diff --git a/samples/dbusserver/main.cpp b/samples/dbusserver/main.cpp
index 292c14b75..bc47cae6e 100644
--- a/samples/dbusserver/main.cpp
+++ b/samples/dbusserver/main.cpp
@@ -1,33 +1,46 @@
#include
#include
-#include "blackcore/dbusserver.h"
-#include "planemanagerhandler.h"
-#include "atcmanagerhandler.h"
-#include "atcmanager.h"
-#include "fsdclient.h"
-#include "fsdclienthandler.h"
+#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);
- BlackCore::CDBusServer server;
+ CRemoteAircraft::registerMetaType();
+
+ BlackCore::CDBusServer server("tcp:host=127.0.0.1,port=45000");
// Setting up our objects
- CPlaneManager planeManager;
+ 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
- CPlaneManagerHandler planeManagerHandler(&planeManager);
+ 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.
- planeManagerHandler.setDBusServer(&server);
+ aircraftManagerHandler.setDBusServer(&server);
atcManagerHandler.setDBusServer(&server);
fsdClientHandler.setDBusServer(&server);
diff --git a/samples/dbusserver/planemanager.cpp b/samples/dbusserver/planemanager.cpp
deleted file mode 100644
index b2edb0d31..000000000
--- a/samples/dbusserver/planemanager.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#include "planemanager.h"
-
-CPlaneManager::CPlaneManager(QObject *parent) :
- QObject(parent)
-{
- m_pilotsList << "DLH123" << "BER456" << "SWS789";
-}
-
-CPlaneManager::~CPlaneManager()
-{
-}
-
-QStringList CPlaneManager::pilotList() const
-{
- return m_pilotsList;
-}
diff --git a/samples/dbusserver/planemanager.h b/samples/dbusserver/planemanager.h
deleted file mode 100644
index 38fb6674a..000000000
--- a/samples/dbusserver/planemanager.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef PLANEMANAGER_H
-#define PLANEMANAGER_H
-
-#include
-#include
-
-class CPlaneManager : public QObject
-{
- Q_OBJECT
-
- QStringList m_pilotsList; //!< List of all pilots with their callsigns
-
-public:
- CPlaneManager(QObject *parent = 0);
- ~CPlaneManager();
-
- /*!
- * \brief Returns a list of all pilots with their callsigns
- * \return pilotList
- */
- QStringList pilotList() const;
-
-signals:
-
-public slots:
-};
-
-#endif // PLANEMANAGER_H
diff --git a/samples/dbusserver/planemanager.xml b/samples/dbusserver/planemanager.xml
deleted file mode 100644
index c7b38e162..000000000
--- a/samples/dbusserver/planemanager.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/samples/dbusserver/planemanagerhandler.cpp b/samples/dbusserver/planemanagerhandler.cpp
deleted file mode 100644
index b4add309d..000000000
--- a/samples/dbusserver/planemanagerhandler.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-#include
-#include "planemanagerhandler.h"
-
-// It is really IMPORTANT to include this header.
-// Otherwise it won't be generated by qmake and the
-// project can't be build
-#include "planemanager_adaptor.h"
-
-CPlaneManagerHandler::CPlaneManagerHandler(QObject *parent) :
- QObject(parent), m_dbusserver(0), m_parent(0)
-{
- m_dbusPath = "/PlaneManager";
- m_parent = qobject_cast(parent);
-
- new PlaneManagerAdaptor(this);
-
-}
-
-void CPlaneManagerHandler::setDBusServer(BlackCore::CDBusServer *dbusServer)
-{
- m_dbusserver = dbusServer;
-
- // We add ourselves to the DBus server. This is needed, because
- // DBus has to register all exposed objects for each new connection
- if (m_dbusserver)
- m_dbusserver->addObject(m_dbusPath, this);
-}
-
-QStringList CPlaneManagerHandler::pilotList() const
-{
- qDebug() << "Somebody requested the list of pilots. Here you go...";
- return m_parent->pilotList();
-}
diff --git a/samples/dbusserver/planemanagerhandler.h b/samples/dbusserver/planemanagerhandler.h
deleted file mode 100644
index ed2b29d3c..000000000
--- a/samples/dbusserver/planemanagerhandler.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef PLANEMANAGERHANDLER_H
-#define PLANEMANAGERHANDLER_H
-
-#include
-#include "planemanager.h"
-#include "blackcore/dbusserver.h"
-
-class CPlaneManagerHandler : public QObject
-{
- Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "org.vatsim.pilotClient.PlaneManager")
- Q_PROPERTY( QStringList pilotList READ pilotList)
-
-public:
- CPlaneManagerHandler(QObject *parent = NULL);
- ~CPlaneManagerHandler() {}
-
- void setDBusServer(BlackCore::CDBusServer *dbusServer);
-
-signals:
-
-public slots:
-
-private:
- QStringList pilotList() const;
-
- BlackCore::CDBusServer *m_dbusserver;
- CPlaneManager *m_parent;
-
- QString m_dbusPath;
-
-};
-
-#endif // PLANEMANAGERHANDLER_H
diff --git a/samples/dbusserver/remote_aircraft.cpp b/samples/dbusserver/remote_aircraft.cpp
new file mode 100644
index 000000000..f5dc090a0
--- /dev/null
+++ b/samples/dbusserver/remote_aircraft.cpp
@@ -0,0 +1,68 @@
+#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
new file mode 100644
index 000000000..72c8b52d1
--- /dev/null
+++ b/samples/dbusserver/remote_aircraft.h
@@ -0,0 +1,92 @@
+/* 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
index 725300350..9a6c39388 100644
--- a/samples/dbusserver/sample_dbusserver.pro
+++ b/samples/dbusserver/sample_dbusserver.pro
@@ -14,7 +14,7 @@ CONFIG -= app_bundle
TEMPLATE = app
-DBUS_ADAPTORS += planemanager.xml atcmanager.xml fsdclient.xml
+DBUS_ADAPTORS += dbus/aircraftmanager.xml dbus/atcmanager.xml dbus/fsdclient.xml
DEPENDPATH += . ../../src
INCLUDEPATH += . ../../src
@@ -22,6 +22,9 @@ 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 \
diff --git a/src/blackcore/dbusserver.cpp b/src/blackcore/dbus_server.cpp
similarity index 67%
rename from src/blackcore/dbusserver.cpp
rename to src/blackcore/dbus_server.cpp
index 02ccc24cf..e40a1d515 100644
--- a/src/blackcore/dbusserver.cpp
+++ b/src/blackcore/dbus_server.cpp
@@ -1,16 +1,16 @@
+/* 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 "dbusserver.h"
+#include "dbus_server.h"
-namespace BlackCore
-{
+namespace BlackCore {
-// TODO:
-// - Change constructor to use address from the config file
-// - Ammend debug message according to the final result in the forum discussion
-
- CDBusServer::CDBusServer(QObject *parent) :
- QObject(parent), m_busServer("tcp:host=127.0.0.1,port=6668", parent)
+ CDBusServer::CDBusServer(const QString &address, QObject *parent) :
+ QObject(parent), m_busServer(address, parent)
{
if (!m_busServer.isConnected())
{
@@ -18,7 +18,7 @@ namespace BlackCore
}
else
{
- qDebug() << "Server is running on" << m_busServer.address();
+ qDebug() << "Server listening on address: " << m_busServer.address();
}
connect(&m_busServer, &QDBusServer::newConnection, this, &CDBusServer::newConnection);
@@ -53,4 +53,3 @@ namespace BlackCore
} // namespace BlackCore
-
diff --git a/src/blackcore/dbus_server.h b/src/blackcore/dbus_server.h
new file mode 100644
index 000000000..95b15e030
--- /dev/null
+++ b/src/blackcore/dbus_server.h
@@ -0,0 +1,64 @@
+/* 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 DBUSSERVER_H
+#define DBUSSERVER_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace BlackCore {
+
+ /*!
+ * \brief Custom DBusServer
+ * \details This class implements a custom DBusServer for DBus peer connections
+ */
+
+ class CDBusServer : public QObject
+ {
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "org.vatsim.pilotClient")
+
+ private:
+ QDBusServer m_busServer; //!< QDBusServer implementation
+
+ QMap m_objects; //!< Mapping of all exposed objects
+
+ QMap m_DBusConnections; //!< Mapping of all DBusConnection objects
+
+ public:
+
+ /*!
+ * \brief Constructor
+ * \param parent
+ */
+ CDBusServer(const QString &address, QObject *parent = 0);
+
+ /*!
+ * \brief Adds a QObject to be exposed to DBus
+ * \param name
+ * \param object
+ */
+ void addObject(const QString &name, QObject *object);
+
+ void printError();
+
+ public slots:
+
+ /*!
+ * \brief Called when a new DBus client has connected
+ * \param connection
+ */
+ void newConnection(const QDBusConnection & connection);
+ signals:
+ };
+
+}
+
+#endif // DBUSSERVER_H
diff --git a/src/blackcore/dbusserver.h b/src/blackcore/dbusserver.h
deleted file mode 100644
index e65c473ae..000000000
--- a/src/blackcore/dbusserver.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef BLACKCORE_DBUSSERVER_H
-#define BLACKCORE_DBUSSERVER_H
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-namespace BlackCore
-{
-
- class CDBusServer : public QObject
- {
- Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "org.vatsim.pilotClient")
-
- private:
- QDBusServer m_busServer; //!< QDBusServer implementation
-
- QMap m_objects; //!< Mapping of all exposed objects
-
- QMap m_DBusConnections; //!< Mapping of all DBusConnection objects
-
- public:
-
- /*!
- * \brief Constructor
- * \param parent
- */
- CDBusServer(QObject *parent = 0);
-
- /*!
- * \brief Adds a QObject to be exposed to DBus
- * \param name
- * \param object
- */
- void addObject(const QString &name, QObject *object);
-
-
- void printError();
-
- public slots:
- void newConnection(const QDBusConnection & connection);
-
- };
-
-} // namespace BlackCore
-
-#endif // BLACKCORE_DBUSSERVER_H
diff --git a/src/blackmisc/dbus_handler.cpp b/src/blackmisc/dbus_handler.cpp
new file mode 100644
index 000000000..90f061028
--- /dev/null
+++ b/src/blackmisc/dbus_handler.cpp
@@ -0,0 +1,30 @@
+/* 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
new file mode 100644
index 000000000..7166ad467
--- /dev/null
+++ b/src/blackmisc/dbus_handler.h
@@ -0,0 +1,59 @@
+/* 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