mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-05 01:35:45 +08:00
@@ -14,7 +14,7 @@
|
|||||||
#include "guimodeenums.h"
|
#include "guimodeenums.h"
|
||||||
#include "blackcore/context_audio.h"
|
#include "blackcore/context_audio.h"
|
||||||
#include "blackcore/context_network.h"
|
#include "blackcore/context_network.h"
|
||||||
#include "blackcore/context_settings_interface.h"
|
#include "blackcore/context_settings.h"
|
||||||
#include "blackcore/context_application.h"
|
#include "blackcore/context_application.h"
|
||||||
#include "blackcore/context_simulator.h"
|
#include "blackcore/context_simulator.h"
|
||||||
#include "blackcore/coreruntime.h"
|
#include "blackcore/coreruntime.h"
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
#include "blackcore/context_simulator_proxy.h"
|
#include "blackcore/context_simulator_proxy.h"
|
||||||
#include "blackcore/context_application_impl.h"
|
#include "blackcore/context_application_impl.h"
|
||||||
#include "blackcore/context_application_proxy.h"
|
#include "blackcore/context_application_proxy.h"
|
||||||
|
#include "blackcore/context_settings_impl.h"
|
||||||
|
#include "blackcore/context_settings_proxy.h"
|
||||||
#include "blackcore/context_audio_impl.h"
|
#include "blackcore/context_audio_impl.h"
|
||||||
#include "blackcore/context_audio_proxy.h"
|
#include "blackcore/context_audio_proxy.h"
|
||||||
#include "blackcore/coreruntime.h"
|
#include "blackcore/coreruntime.h"
|
||||||
@@ -170,8 +172,8 @@ void MainWindow::init(GuiModes::CoreMode coreMode)
|
|||||||
{
|
{
|
||||||
this->m_dBusConnection = QDBusConnection::sessionBus();
|
this->m_dBusConnection = QDBusConnection::sessionBus();
|
||||||
this->m_contextNetwork = new BlackCore::CContextNetworkProxy(BlackCore::CDBusServer::ServiceName, this->m_dBusConnection, this);
|
this->m_contextNetwork = new BlackCore::CContextNetworkProxy(BlackCore::CDBusServer::ServiceName, this->m_dBusConnection, this);
|
||||||
this->m_contextSettings = new BlackCore::IContextSettings(BlackCore::CDBusServer::ServiceName, this->m_dBusConnection, this);
|
|
||||||
this->m_contextAudio = new BlackCore::CContextAudioProxy(BlackCore::CDBusServer::ServiceName, this->m_dBusConnection, this);
|
this->m_contextAudio = new BlackCore::CContextAudioProxy(BlackCore::CDBusServer::ServiceName, this->m_dBusConnection, this);
|
||||||
|
this->m_contextSettings = new BlackCore::CContextSettingsProxy(BlackCore::CDBusServer::ServiceName, this->m_dBusConnection, this);
|
||||||
this->m_contextApplication = new BlackCore::CContextApplicationProxy(BlackCore::CDBusServer::ServiceName, this->m_dBusConnection, this);
|
this->m_contextApplication = new BlackCore::CContextApplicationProxy(BlackCore::CDBusServer::ServiceName, this->m_dBusConnection, this);
|
||||||
this->m_contextSimulator = new BlackCore::CContextSimulatorProxy(BlackCore::CDBusServer::ServiceName, this->m_dBusConnection, this);
|
this->m_contextSimulator = new BlackCore::CContextSimulatorProxy(BlackCore::CDBusServer::ServiceName, this->m_dBusConnection, this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,60 +6,115 @@
|
|||||||
#ifndef BLACKCORE_CONTEXTSETTINGS_H
|
#ifndef BLACKCORE_CONTEXTSETTINGS_H
|
||||||
#define BLACKCORE_CONTEXTSETTINGS_H
|
#define BLACKCORE_CONTEXTSETTINGS_H
|
||||||
|
|
||||||
#include "blackcore/coreruntime.h"
|
|
||||||
#include "blackcore/dbus_server.h"
|
|
||||||
#include "blackcore/context_settings_interface.h"
|
|
||||||
#include "blackmisc/statusmessagelist.h"
|
#include "blackmisc/statusmessagelist.h"
|
||||||
|
#include "blackmisc/settingutilities.h"
|
||||||
|
#include "blackmisc/setnetwork.h"
|
||||||
#include "blackmisc/hwkeyboardkeylist.h"
|
#include "blackmisc/hwkeyboardkeylist.h"
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
#define BLACKCORE_CONTEXTSETTINGS_INTERFACENAME "blackcore.contextsettings"
|
#include <QObject>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
|
#define BLACKCORE_CONTEXTSETTINGS_INTERFACENAME "net.vatsim.PilotClient.BlackCore.ContextSettings"
|
||||||
|
#define BLACKCORE_CONTEXTSETTINGS_OBJECTPATH "/Settings"
|
||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
{
|
{
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Network context
|
* \brief Context settings interface
|
||||||
*/
|
*/
|
||||||
class CContextSettings : public IContextSettings
|
class IContextSettings : public QObject
|
||||||
{
|
{
|
||||||
// Register by same name, make signals sender independent
|
|
||||||
// http://dbus.freedesktop.org/doc/dbus-faq.html#idp48032144
|
|
||||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTSETTINGS_INTERFACENAME)
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTSETTINGS_INTERFACENAME)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! \brief Constructor
|
/*!
|
||||||
CContextSettings(CCoreRuntime *runtime);
|
* \brief Service name
|
||||||
|
*/
|
||||||
//! Destructor
|
static const QString &InterfaceName()
|
||||||
virtual ~CContextSettings() {}
|
|
||||||
|
|
||||||
//! \brief Register myself in DBus
|
|
||||||
void registerWithDBus(CDBusServer *server)
|
|
||||||
{
|
{
|
||||||
server->addObject(IContextSettings::ServicePath(), this);
|
static QString s(BLACKCORE_CONTEXTSETTINGS_INTERFACENAME);
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Runtime
|
/*!
|
||||||
const CCoreRuntime *getRuntime() const
|
* \brief Service path
|
||||||
|
*/
|
||||||
|
static const QString &ObjectPath()
|
||||||
{
|
{
|
||||||
return static_cast<CCoreRuntime *>(this->parent());
|
static QString s(BLACKCORE_CONTEXTSETTINGS_OBJECTPATH);
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \copydoc IContextSettings::value()
|
/*!
|
||||||
virtual BlackMisc::CStatusMessageList value(const QString &path, const QString &command, const QVariant &value);
|
* \brief Path for network settings
|
||||||
|
* \remarks no to be confused with DBus paths
|
||||||
|
*/
|
||||||
|
static const QString &PathNetworkSettings()
|
||||||
|
{
|
||||||
|
static QString s("network");
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Path for network settings
|
||||||
|
* \remarks no to be confused with DBus paths
|
||||||
|
*/
|
||||||
|
static const QString &PathRoot()
|
||||||
|
{
|
||||||
|
static QString s("root");
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Path for hotkeys
|
||||||
|
* \remarks no to be confused with DBus paths
|
||||||
|
*/
|
||||||
|
static const QString &PathHotkeys()
|
||||||
|
{
|
||||||
|
static QString s("hotkeys");
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief DBus version constructor
|
||||||
|
*/
|
||||||
|
IContextSettings(QObject *parent = nullptr) : QObject(parent) {}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destructor
|
||||||
|
*/
|
||||||
|
virtual ~IContextSettings() {}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Handle value
|
||||||
|
* \param path where value belongs to
|
||||||
|
* \param command what to do with value
|
||||||
|
* \param value
|
||||||
|
* \return messages generated during handling
|
||||||
|
* \remarks Do not make this a slot, no DBus XML signature shall be created. The QVariant
|
||||||
|
* will be send a tailored value method using QDBusVariant
|
||||||
|
* @see value(const QString &, const QString &, QDBusVariant, int)
|
||||||
|
*/
|
||||||
|
virtual BlackMisc::CStatusMessageList value(const QString &path, const QString &command, const QVariant &value) = 0;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
//! \brief Settings have been changed
|
||||||
|
void changedSettings();
|
||||||
|
|
||||||
|
//! \brief Network settings have been changed
|
||||||
|
void changedNetworkSettings();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! \copydoc IContextSettings::getNetworkSettings()
|
|
||||||
virtual BlackMisc::Settings::CSettingsNetwork getNetworkSettings() const;
|
|
||||||
|
|
||||||
//! \copydoc IContextSettings::getHotkeys()
|
//! \brief Network settings
|
||||||
virtual BlackMisc::Hardware::CKeyboardKeyList getHotkeys() const;
|
virtual BlackMisc::Settings::CSettingsNetwork getNetworkSettings() const = 0;
|
||||||
|
|
||||||
private:
|
//! \brief Hotkeys
|
||||||
BlackMisc::Settings::CSettingsNetwork m_settingsNetwork;
|
virtual BlackMisc::Hardware::CKeyboardKeyList getHotkeys() const = 0;
|
||||||
BlackMisc::Hardware::CKeyboardKeyList m_hotkeys;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,9 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#include "context_settings.h"
|
#include "context_settings_impl.h"
|
||||||
#include "coreruntime.h"
|
#include "coreruntime.h"
|
||||||
|
|
||||||
#include "blackmisc/settingutilities.h"
|
#include "blackmisc/settingutilities.h"
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
@@ -18,7 +19,7 @@ namespace BlackCore
|
|||||||
/*
|
/*
|
||||||
* Init this context
|
* Init this context
|
||||||
*/
|
*/
|
||||||
CContextSettings::CContextSettings(CCoreRuntime *runtime) : IContextSettings(runtime)
|
CContextSettings::CContextSettings(QObject *parent) : IContextSettings(parent)
|
||||||
{
|
{
|
||||||
// create some dummy settings
|
// create some dummy settings
|
||||||
// this would actually be reading the settings from disk ..
|
// this would actually be reading the settings from disk ..
|
||||||
@@ -37,7 +38,7 @@ namespace BlackCore
|
|||||||
/*
|
/*
|
||||||
* Hotkeys
|
* Hotkeys
|
||||||
*/
|
*/
|
||||||
Hardware::CKeyboardKeyList CContextSettings::getHotkeys() const
|
CKeyboardKeyList CContextSettings::getHotkeys() const
|
||||||
{
|
{
|
||||||
return this->m_hotkeys;
|
return this->m_hotkeys;
|
||||||
}
|
}
|
||||||
@@ -45,7 +46,7 @@ namespace BlackCore
|
|||||||
/*
|
/*
|
||||||
* Network settings
|
* Network settings
|
||||||
*/
|
*/
|
||||||
BlackMisc::Settings::CSettingsNetwork CContextSettings::getNetworkSettings() const
|
CSettingsNetwork CContextSettings::getNetworkSettings() const
|
||||||
{
|
{
|
||||||
return this->m_settingsNetwork;
|
return this->m_settingsNetwork;
|
||||||
}
|
}
|
||||||
70
src/blackcore/context_settings_impl.h
Normal file
70
src/blackcore/context_settings_impl.h
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/* 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/. */
|
||||||
|
|
||||||
|
#ifndef BLACKCORE_CONTEXTSETTINGS_IMPL_H
|
||||||
|
#define BLACKCORE_CONTEXTSETTINGS_IMPL_H
|
||||||
|
|
||||||
|
#include "context_settings.h"
|
||||||
|
#include "dbus_server.h"
|
||||||
|
#include "coreruntime.h"
|
||||||
|
|
||||||
|
#include "blackmisc/setnetwork.h"
|
||||||
|
#include "blackmisc/statusmessagelist.h"
|
||||||
|
#include "blackmisc/hwkeyboardkeylist.h"
|
||||||
|
|
||||||
|
namespace BlackCore
|
||||||
|
{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Settings context implementation
|
||||||
|
*/
|
||||||
|
class CContextSettings : public IContextSettings
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTSETTINGS_INTERFACENAME)
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//! \brief Constructor
|
||||||
|
CContextSettings(QObject *runtime = nullptr);
|
||||||
|
|
||||||
|
//! Destructor
|
||||||
|
virtual ~CContextSettings() {}
|
||||||
|
|
||||||
|
//! \brief Register myself in DBus
|
||||||
|
void registerWithDBus(CDBusServer *server)
|
||||||
|
{
|
||||||
|
server->addObject(IContextSettings::ObjectPath(), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! \brief Runtime
|
||||||
|
CCoreRuntime *getRuntime()
|
||||||
|
{
|
||||||
|
return static_cast<CCoreRuntime *>(this->parent());
|
||||||
|
}
|
||||||
|
|
||||||
|
//! \brief Runtime
|
||||||
|
const CCoreRuntime *getRuntime() const
|
||||||
|
{
|
||||||
|
return static_cast<CCoreRuntime *>(this->parent());
|
||||||
|
}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
//! \copydoc IContextSettings::getNetworkSettings()
|
||||||
|
virtual BlackMisc::Settings::CSettingsNetwork getNetworkSettings() const override;
|
||||||
|
|
||||||
|
//! \copydoc IContextSettings::getHotkeys()
|
||||||
|
virtual BlackMisc::Hardware::CKeyboardKeyList getHotkeys() const override;
|
||||||
|
|
||||||
|
//! \copydoc IContextSettings::value()
|
||||||
|
virtual BlackMisc::CStatusMessageList value(const QString &path, const QString &command, const QVariant &value) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
BlackMisc::Settings::CSettingsNetwork m_settingsNetwork;
|
||||||
|
BlackMisc::Hardware::CKeyboardKeyList m_hotkeys;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
@@ -1,150 +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/. */
|
|
||||||
|
|
||||||
#ifndef BLACKCORE_CONTEXTSETTINGS_INTERFACE_H
|
|
||||||
#define BLACKCORE_CONTEXTSETTINGS_INTERFACE_H
|
|
||||||
|
|
||||||
#include "blackmisc/statusmessagelist.h"
|
|
||||||
#include "blackmisc/genericdbusinterface.h"
|
|
||||||
#include "blackmisc/settingutilities.h"
|
|
||||||
#include "blackmisc/setnetwork.h"
|
|
||||||
#include "blackmisc/hwkeyboardkeylist.h"
|
|
||||||
#include <QObject>
|
|
||||||
#include <QVariant>
|
|
||||||
#include <QDBusAbstractInterface>
|
|
||||||
|
|
||||||
#define BLACKCORE_CONTEXTSETTINGS_INTERFACENAME "blackcore.contextsettings"
|
|
||||||
#define BLACKCORE_CONTEXTSETTINGS_SERVICEPATH "/settings"
|
|
||||||
|
|
||||||
// SERVICENAME must contain at least one ".", otherwise generation fails
|
|
||||||
// as this is interpreted in the way comain.somename
|
|
||||||
|
|
||||||
namespace BlackCore
|
|
||||||
{
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief The interface context settings
|
|
||||||
*/
|
|
||||||
class IContextSettings : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTSETTINGS_INTERFACENAME)
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Service name
|
|
||||||
*/
|
|
||||||
static const QString &InterfaceName()
|
|
||||||
{
|
|
||||||
static QString s(BLACKCORE_CONTEXTSETTINGS_INTERFACENAME);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Service path
|
|
||||||
*/
|
|
||||||
static const QString &ServicePath()
|
|
||||||
{
|
|
||||||
static QString s(BLACKCORE_CONTEXTSETTINGS_SERVICEPATH);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Path for network settings
|
|
||||||
* \remarks no to be confused with DBus paths
|
|
||||||
*/
|
|
||||||
static const QString &PathNetworkSettings()
|
|
||||||
{
|
|
||||||
static QString s("network");
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Path for network settings
|
|
||||||
* \remarks no to be confused with DBus paths
|
|
||||||
*/
|
|
||||||
static const QString &PathRoot()
|
|
||||||
{
|
|
||||||
static QString s("root");
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Path for hotkeys
|
|
||||||
* \remarks no to be confused with DBus paths
|
|
||||||
*/
|
|
||||||
static const QString &PathHotkeys()
|
|
||||||
{
|
|
||||||
static QString s("hotkeys");
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief DBus version constructor
|
|
||||||
*/
|
|
||||||
IContextSettings(const QString &serviceName, QDBusConnection &connection, QObject *parent = nullptr);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Destructor
|
|
||||||
*/
|
|
||||||
~IContextSettings() {}
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Handle value
|
|
||||||
* \param path where value belongs to
|
|
||||||
* \param command what to do with value
|
|
||||||
* \param value
|
|
||||||
* \return messages generated during handling
|
|
||||||
* \remarks Do not make this a slot, no DBus XML signature shall be created. The QVariant
|
|
||||||
* will be send a tailored value method using QDBusVariant
|
|
||||||
* @see value(const QString &, const QString &, QDBusVariant, int)
|
|
||||||
*/
|
|
||||||
virtual BlackMisc::CStatusMessageList value(const QString &path, const QString &command, const QVariant &value);
|
|
||||||
|
|
||||||
private:
|
|
||||||
BlackMisc::CGenericDBusInterface *m_dBusInterface;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Relay connection signals to local signals
|
|
||||||
* No idea why this has to be wired and is not done automatically
|
|
||||||
* \param connection
|
|
||||||
*/
|
|
||||||
void relaySignals(const QString &serviceName, QDBusConnection &connection);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
/*!
|
|
||||||
* \brief IContextSettings
|
|
||||||
* \param parent
|
|
||||||
*/
|
|
||||||
IContextSettings(QObject *parent = nullptr) : QObject(parent), m_dBusInterface(nullptr) {}
|
|
||||||
|
|
||||||
signals:
|
|
||||||
//! \brief Settings have been changed
|
|
||||||
void changedSettings();
|
|
||||||
|
|
||||||
//! \brief Network settings have been changed
|
|
||||||
void changedNetworkSettings();
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
|
|
||||||
//! \brief Network settings
|
|
||||||
virtual BlackMisc::Settings::CSettingsNetwork getNetworkSettings() const;
|
|
||||||
|
|
||||||
//! \brief Hotkeys
|
|
||||||
virtual BlackMisc::Hardware::CKeyboardKeyList getHotkeys() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief DBus version of value method.
|
|
||||||
* \remarks Basically an unwanted signature as this is different from the "local" signature and
|
|
||||||
* contains explicit DBus types (a: QDbusArgument, b: type for conversion).
|
|
||||||
* If this can be removed, fine.
|
|
||||||
*/
|
|
||||||
virtual BlackMisc::CStatusMessageList value(const QString &path, const QString &command, QDBusVariant value, int unifiedBlackMetaType);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // guard
|
|
||||||
@@ -3,22 +3,29 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#include "blackcore/context_settings_interface.h"
|
#include "context_settings_proxy.h"
|
||||||
|
|
||||||
#include "blackmisc/blackmiscfreefunctions.h"
|
#include "blackmisc/blackmiscfreefunctions.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
|
|
||||||
|
using namespace BlackMisc;
|
||||||
|
using namespace BlackMisc::Settings;
|
||||||
|
using namespace BlackMisc::Network;
|
||||||
|
using namespace BlackMisc::Hardware;
|
||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Constructor for DBus
|
* Constructor for DBus
|
||||||
*/
|
*/
|
||||||
IContextSettings::IContextSettings(const QString &serviceName, QDBusConnection &connection, QObject *parent) : QObject(parent), m_dBusInterface(0)
|
CContextSettingsProxy::CContextSettingsProxy(const QString &serviceName, QDBusConnection &connection, QObject *parent) : IContextSettings(parent), m_dBusInterface(nullptr)
|
||||||
{
|
{
|
||||||
this->m_dBusInterface = new BlackMisc::CGenericDBusInterface(
|
this->m_dBusInterface = new BlackMisc::CGenericDBusInterface(
|
||||||
serviceName , IContextSettings::ServicePath(), IContextSettings::InterfaceName(),
|
serviceName , IContextSettings::ObjectPath(), IContextSettings::InterfaceName(),
|
||||||
connection, this);
|
connection, this);
|
||||||
this->relaySignals(serviceName, connection);
|
this->relaySignals(serviceName, connection);
|
||||||
}
|
}
|
||||||
@@ -26,32 +33,32 @@ namespace BlackCore
|
|||||||
/*
|
/*
|
||||||
* Workaround for signals
|
* Workaround for signals
|
||||||
*/
|
*/
|
||||||
void IContextSettings::relaySignals(const QString &serviceName, QDBusConnection &connection)
|
void CContextSettingsProxy::relaySignals(const QString &serviceName, QDBusConnection &connection)
|
||||||
{
|
{
|
||||||
connection.connect(serviceName, IContextSettings::ServicePath(), IContextSettings::InterfaceName(),
|
connection.connect(serviceName, IContextSettings::ObjectPath(), IContextSettings::InterfaceName(),
|
||||||
"changedNetworkSettings", this, SIGNAL(changedNetworkSettings()));
|
"changedNetworkSettings", this, SIGNAL(changedNetworkSettings()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Relay to DBus
|
* Relay to DBus
|
||||||
*/
|
*/
|
||||||
BlackMisc::Settings::CSettingsNetwork IContextSettings::getNetworkSettings() const
|
CSettingsNetwork CContextSettingsProxy::getNetworkSettings() const
|
||||||
{
|
{
|
||||||
return this->m_dBusInterface->callDBusRet<BlackMisc::Settings::CSettingsNetwork>(QLatin1Literal("getNetworkSettings"));
|
return this->m_dBusInterface->callDBusRet<CSettingsNetwork>(QLatin1Literal("getNetworkSettings"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Relay tp DBus
|
* Relay tp DBus
|
||||||
*/
|
*/
|
||||||
BlackMisc::Hardware::CKeyboardKeyList IContextSettings::getHotkeys() const
|
CKeyboardKeyList CContextSettingsProxy::getHotkeys() const
|
||||||
{
|
{
|
||||||
return this->m_dBusInterface->callDBusRet<BlackMisc::Hardware::CKeyboardKeyList>(QLatin1Literal("getHotkeys"));
|
return this->m_dBusInterface->callDBusRet<CKeyboardKeyList>(QLatin1Literal("getHotkeys"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Relay to DBus, but make this no slot
|
* Relay to DBus, but make this no slot
|
||||||
*/
|
*/
|
||||||
BlackMisc::CStatusMessageList IContextSettings::value(const QString &path, const QString &command, const QVariant &value)
|
BlackMisc::CStatusMessageList CContextSettingsProxy::value(const QString &path, const QString &command, const QVariant &value)
|
||||||
{
|
{
|
||||||
int type = value.userType() - BlackMisc::firstBlackMetaType();
|
int type = value.userType() - BlackMisc::firstBlackMetaType();
|
||||||
return this->m_dBusInterface->callDBusRet<BlackMisc::CStatusMessageList>(QLatin1Literal("value"), path, command, QDBusVariant(value), type);
|
return this->m_dBusInterface->callDBusRet<BlackMisc::CStatusMessageList>(QLatin1Literal("value"), path, command, QDBusVariant(value), type);
|
||||||
@@ -60,7 +67,7 @@ namespace BlackCore
|
|||||||
/*
|
/*
|
||||||
* DBus version of value
|
* DBus version of value
|
||||||
*/
|
*/
|
||||||
BlackMisc::CStatusMessageList IContextSettings::value(const QString &path, const QString &command, QDBusVariant value, int unifiedBlackMetaType)
|
BlackMisc::CStatusMessageList CContextSettingsProxy::value(const QString &path, const QString &command, QDBusVariant value, int unifiedBlackMetaType)
|
||||||
{
|
{
|
||||||
QVariant qv = value.variant();
|
QVariant qv = value.variant();
|
||||||
if (qv.canConvert<QDBusArgument>())
|
if (qv.canConvert<QDBusArgument>())
|
||||||
89
src/blackcore/context_settings_proxy.h
Normal file
89
src/blackcore/context_settings_proxy.h
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
/* 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/. */
|
||||||
|
|
||||||
|
#ifndef BLACKCORE_CONTEXTSETTINGS_PROXY_H
|
||||||
|
#define BLACKCORE_CONTEXTSETTINGS_PROXY_H
|
||||||
|
|
||||||
|
#include "context_settings.h"
|
||||||
|
|
||||||
|
#include "blackmisc/statusmessagelist.h"
|
||||||
|
#include "blackmisc/genericdbusinterface.h"
|
||||||
|
#include "blackmisc/settingutilities.h"
|
||||||
|
#include "blackmisc/setnetwork.h"
|
||||||
|
#include "blackmisc/hwkeyboardkeylist.h"
|
||||||
|
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
|
namespace BlackCore
|
||||||
|
{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Settings context proxy
|
||||||
|
*/
|
||||||
|
class CContextSettingsProxy : public IContextSettings
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief DBus version constructor
|
||||||
|
*/
|
||||||
|
CContextSettingsProxy(const QString &serviceName, QDBusConnection &connection, QObject *parent = nullptr);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Destructor
|
||||||
|
*/
|
||||||
|
virtual ~CContextSettingsProxy() {}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Handle value
|
||||||
|
* \param path where value belongs to
|
||||||
|
* \param command what to do with value
|
||||||
|
* \param value
|
||||||
|
* \return messages generated during handling
|
||||||
|
* \remarks Do not make this a slot, no DBus XML signature shall be created. The QVariant
|
||||||
|
* will be send a tailored value method using QDBusVariant
|
||||||
|
* @see value(const QString &, const QString &, QDBusVariant, int)
|
||||||
|
*/
|
||||||
|
virtual BlackMisc::CStatusMessageList value(const QString &path, const QString &command, const QVariant &value) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
BlackMisc::CGenericDBusInterface *m_dBusInterface;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Relay connection signals to local signals
|
||||||
|
* No idea why this has to be wired and is not done automatically
|
||||||
|
* \param connection
|
||||||
|
*/
|
||||||
|
void relaySignals(const QString &serviceName, QDBusConnection &connection);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/*!
|
||||||
|
* \brief IContextSettings
|
||||||
|
* \param parent
|
||||||
|
*/
|
||||||
|
CContextSettingsProxy(QObject *parent = nullptr) : IContextSettings(parent), m_dBusInterface(nullptr) {}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
//! \copydoc IContextSettings::getNetworkSettings()
|
||||||
|
virtual BlackMisc::Settings::CSettingsNetwork getNetworkSettings() const override;
|
||||||
|
|
||||||
|
//! \copydoc IContextSettings::getHotkeys()
|
||||||
|
virtual BlackMisc::Hardware::CKeyboardKeyList getHotkeys() const override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief DBus version of value method.
|
||||||
|
* \remarks Basically an unwanted signature as this is different from the "local" signature and
|
||||||
|
* contains explicit DBus types (a: QDbusArgument, b: type for conversion).
|
||||||
|
* If this can be removed, fine.
|
||||||
|
*/
|
||||||
|
BlackMisc::CStatusMessageList value(const QString &path, const QString &command, QDBusVariant value, int unifiedBlackMetaType);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
#include "blackmisc/nwserver.h"
|
#include "blackmisc/nwserver.h"
|
||||||
#include "blackcore/context_application_impl.h"
|
#include "blackcore/context_application_impl.h"
|
||||||
#include "blackcore/context_network_impl.h"
|
#include "blackcore/context_network_impl.h"
|
||||||
#include "blackcore/context_settings.h"
|
#include "blackcore/context_settings_impl.h"
|
||||||
#include "blackcore/context_audio_impl.h"
|
#include "blackcore/context_audio_impl.h"
|
||||||
#include "blackcore/context_simulator_impl.h"
|
#include "blackcore/context_simulator_impl.h"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user