mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
refs #42
- Added DBus handler interface - Added more complex flow to both samples - Added custom class to be transfered
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
64
src/blackcore/dbus_server.h
Normal file
64
src/blackcore/dbus_server.h
Normal 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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user