- Added DBus handler interface
- Added more complex flow to both samples
- Added custom class to be transfered
This commit is contained in:
Roland Winklmeier
2013-08-07 01:32:13 +02:00
parent 40abcf4c19
commit efacac77eb
47 changed files with 1036 additions and 434 deletions

View File

@@ -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 <QDebug>
#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

View File

@@ -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 <QObject>
#include <QtDBus/QDBusServer>
#include <QtDBus/QDBusError>
#include <QtDBus/QDBusConnection>
#include <QStringList>
#include <QMap>
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<QString, QObject*> m_objects; //!< Mapping of all exposed objects
QMap<QString, QDBusConnection> 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

View File

@@ -1,51 +0,0 @@
#ifndef BLACKCORE_DBUSSERVER_H
#define BLACKCORE_DBUSSERVER_H
#include <QObject>
#include <QtDBus/QDBusServer>
#include <QtDBus/QDBusError>
#include <QtDBus/QDBusConnection>
#include <QStringList>
#include <QMap>
namespace BlackCore
{
class CDBusServer : public QObject
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.vatsim.pilotClient")
private:
QDBusServer m_busServer; //!< QDBusServer implementation
QMap<QString, QObject*> m_objects; //!< Mapping of all exposed objects
QMap<QString, QDBusConnection> 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