From d8ec308a3b81f759333fbc158c2f69b9f35bcc57 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sun, 3 Nov 2019 01:20:42 +0100 Subject: [PATCH] [DBus] DBus related fixes * use INT in CAudioDeviceInfo (minimum trouble) * register metatype * removed getSimulatorStatusEnum from DBus slots --- src/blackcore/context/contextaudioproxy.cpp | 4 ++-- src/blackcore/context/contextsimulator.h | 8 ++++---- src/blackcore/registermetadata.cpp | 7 +++++-- src/blackcore/simulator.h | 2 ++ src/blackmisc/audio/audiodeviceinfo.cpp | 14 +++++++------- src/blackmisc/audio/audiodeviceinfo.h | 8 ++++---- 6 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/blackcore/context/contextaudioproxy.cpp b/src/blackcore/context/contextaudioproxy.cpp index c5af48d45..b57f8bc25 100644 --- a/src/blackcore/context/contextaudioproxy.cpp +++ b/src/blackcore/context/contextaudioproxy.cpp @@ -47,13 +47,13 @@ namespace BlackCore void CContextAudioProxy::registerDevices(const CAudioDeviceInfoList &devices) { if (devices.isEmpty()) { return; } - m_dBusInterface->callDBus(QLatin1String("registerDevices")); + m_dBusInterface->callDBus(QLatin1String("registerDevices"), devices); } void CContextAudioProxy::unRegisterDevices(const CAudioDeviceInfoList &devices) { if (devices.isEmpty()) { return; } - m_dBusInterface->callDBus(QLatin1String("unRegisterDevices")); + m_dBusInterface->callDBus(QLatin1String("unRegisterDevices"), devices); } void CContextAudioProxy::unRegisterDevicesFor(const CIdentifier &identifier) diff --git a/src/blackcore/context/contextsimulator.h b/src/blackcore/context/contextsimulator.h index a422b2cbc..0e89ac87c 100644 --- a/src/blackcore/context/contextsimulator.h +++ b/src/blackcore/context/contextsimulator.h @@ -87,6 +87,10 @@ namespace BlackCore //! Destructor virtual ~IContextSimulator() override {} + //! Get simulator status as enum + //! \fixme To be removed with Qt 5.5 when getSimualtorStatus directly provides the enum + BlackCore::ISimulator::SimulatorStatus getSimulatorStatusEnum() const; + signals: //! Simulator combined status //! \sa ISimulator::SimulatorStatus @@ -171,10 +175,6 @@ namespace BlackCore //! Simulator combined status virtual int getSimulatorStatus() const = 0; - //! Get simulator status as enum - //! \fixme To be removed with Qt 5.5 when getSimualtorStatus directly provides the enum - BlackCore::ISimulator::SimulatorStatus getSimulatorStatusEnum() const; - //! Simulator setup virtual BlackMisc::Simulation::CSimulatorInternals getSimulatorInternals() const = 0; diff --git a/src/blackcore/registermetadata.cpp b/src/blackcore/registermetadata.cpp index acce6f0b3..f338eda60 100644 --- a/src/blackcore/registermetadata.cpp +++ b/src/blackcore/registermetadata.cpp @@ -14,11 +14,12 @@ #include "blackcore/db/databasereader.h" #include "blackcore/vatsim/vatsimsettings.h" #include "blackcore/fsd/fsdclient.h" +#include "blackcore/afv/clients/afvclient.h" +#include "blackcore/simulator.h" #include "blackcore/webreaderflags.h" #include "blackcore/aircraftmatcher.h" -#include "blackcore/afv/clients/afvclient.h" -#include "blackmisc/dbus.h" #include "blackmisc/network/network.h" +#include "blackmisc/dbus.h" #include "blackmisc/valueobject.h" #include @@ -43,6 +44,8 @@ namespace BlackCore qDBusRegisterMetaType(); qDBusRegisterMetaType(); qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); qRegisterMetaTypeStreamOperators(); qRegisterMetaTypeStreamOperators(); diff --git a/src/blackcore/simulator.h b/src/blackcore/simulator.h index e72eb6262..8b51be103 100644 --- a/src/blackcore/simulator.h +++ b/src/blackcore/simulator.h @@ -736,6 +736,8 @@ namespace BlackCore }; } // namespace +Q_DECLARE_METATYPE(BlackCore::ISimulator::SimulatorStatusFlag) +Q_DECLARE_METATYPE(BlackCore::ISimulator::SimulatorStatus) Q_DECLARE_INTERFACE(BlackCore::ISimulator, "org.swift-project.blackcore.simulator") Q_DECLARE_INTERFACE(BlackCore::ISimulatorFactory, "org.swift-project.blackcore.simulatorfactory") Q_DECLARE_OPERATORS_FOR_FLAGS(BlackCore::ISimulator::SimulatorStatus) diff --git a/src/blackmisc/audio/audiodeviceinfo.cpp b/src/blackmisc/audio/audiodeviceinfo.cpp index 81174558e..58e9fa890 100644 --- a/src/blackmisc/audio/audiodeviceinfo.cpp +++ b/src/blackmisc/audio/audiodeviceinfo.cpp @@ -25,7 +25,7 @@ namespace BlackMisc { } CAudioDeviceInfo::CAudioDeviceInfo(DeviceType type, const QString &name) : - m_type(type), + m_type(static_cast(type)), m_deviceName(name) { } @@ -83,7 +83,7 @@ namespace BlackMisc case IndexDeviceType: return CVariant::fromValue(this->getType()); case IndexDeviceTypeAsString: return CVariant::fromValue(this->getTypeAsString()); case IndexName: return CVariant::fromValue(this->getName()); - case IndexIdentifier: return m_identifier.propertyByIndex(index.copyFrontRemoved()); + case IndexIdentifier: return m_identifier.propertyByIndex(index.copyFrontRemoved()); default: break; } return CValueObject::propertyByIndex(index); @@ -95,8 +95,8 @@ namespace BlackMisc const ColumnIndex i = index.frontCasted(); switch (i) { - case IndexDeviceType: m_type = static_cast(variant.toInt()); return; - case IndexName: m_deviceName = variant.toQString(); return; + case IndexDeviceType: m_type = static_cast(variant.toInt()); return; + case IndexName: m_deviceName = variant.toQString(); return; case IndexIdentifier: m_identifier.setPropertyByIndex(index.copyFrontRemoved(), variant); return; default: break; } @@ -110,8 +110,8 @@ namespace BlackMisc switch (i) { case IndexDeviceTypeAsString: - case IndexDeviceType: return Compare::compare(m_type, compareValue.m_type); - case IndexName: return m_deviceName.compare(compareValue.m_deviceName, Qt::CaseInsensitive); + case IndexDeviceType: return Compare::compare(m_type, compareValue.m_type); + case IndexName: return m_deviceName.compare(compareValue.m_deviceName, Qt::CaseInsensitive); case IndexIdentifier: return m_identifier.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getIdentifier()); default: break; } @@ -127,7 +127,7 @@ namespace BlackMisc switch (t) { - case InputDevice: return i; + case InputDevice: return i; case OutputDevice: return o; default: break; } diff --git a/src/blackmisc/audio/audiodeviceinfo.h b/src/blackmisc/audio/audiodeviceinfo.h index 125f1d830..3b3c82064 100644 --- a/src/blackmisc/audio/audiodeviceinfo.h +++ b/src/blackmisc/audio/audiodeviceinfo.h @@ -65,7 +65,7 @@ namespace BlackMisc const CIdentifier &getIdentifier() const { return m_identifier; } //! Type - DeviceType getType() const { return m_type; } + DeviceType getType() const { return static_cast(m_type); } //! Type as string const QString &getTypeAsString() const { return deviceTypeToString(this->getType()); } @@ -113,9 +113,9 @@ namespace BlackMisc static const QString &deviceTypeToString(DeviceType t); private: - DeviceType m_type = Unknown; //!< Device type, @see CAudioDeviceInfo::DeviceType - QString m_deviceName; //!< Device name - CIdentifier m_identifier; //!< We use a DBus based system. Hence an audio device can reside on a different computers, this here is its name + int m_type = static_cast(Unknown); //!< Device type, @see CAudioDeviceInfo::DeviceType + QString m_deviceName; //!< Device name + CIdentifier m_identifier; //!< We use a DBus based system. Hence an audio device can reside on a different computers, this here is its name BLACK_METACLASS( CAudioDeviceInfo,