swift
Loading...
Searching...
No Matches
contextaudioproxy.cpp
1// SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#include <QDBusConnection>
7#include <QLatin1String>
8#include <QtGlobal>
9
11#include "misc/dbus.h"
12#include "misc/dbusserver.h"
14
15using namespace swift::misc;
16using namespace swift::misc::audio;
17using namespace swift::misc::network;
18using namespace swift::misc::aviation;
19using namespace swift::core::afv::clients;
20
21namespace swift::core::context
22{
24 CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime)
25 : CContextAudioBase(mode, runtime), m_dBusInterface(nullptr)
26 {
27 m_dBusInterface = new CGenericDBusInterface(serviceName, IContextAudio::ObjectPath(),
28 IContextAudio::InterfaceName(), connection, this);
29 this->relaySignals(serviceName, connection);
30
33 }
34
35 void CContextAudioProxy::unitTestRelaySignals()
36 {
37 // connect signals, asserts when failures
40 Q_UNUSED(c)
41 }
42
44 {
45 if (devices.isEmpty())
46 {
47 return;
48 }
49 m_dBusInterface->callDBus(QLatin1String("registerDevices"), devices);
50 }
51
53 {
54 if (devices.isEmpty())
55 {
56 return;
57 }
58 m_dBusInterface->callDBus(QLatin1String("unRegisterDevices"), devices);
59 }
60
62 {
63 m_dBusInterface->callDBus(QLatin1String("unRegisterDevicesFor"), identifier);
64 }
65
67 {
68 m_dBusInterface->callDBus(QLatin1String("registerAudioCallsign"), callsign, identifier);
69 }
70
72 {
73 m_dBusInterface->callDBus(QLatin1String("unRegisterAudioCallsign"), callsign, identifier);
74 }
75
77 {
78 return m_dBusInterface->callDBusRet<bool>(QLatin1String("hasRegisteredAudioCallsign"), callsign);
79 }
80
82 {
83 return m_dBusInterface->callDBusRet<swift::misc::audio::CAudioDeviceInfoList>(
84 QLatin1String("getRegisteredDevices"));
85 }
86
87 void CContextAudioProxy::relaySignals(const QString &serviceName, QDBusConnection &connection)
88 {
89 bool s =
90 connection.connect(serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(),
91 "voiceClientFailure", this, SIGNAL(voiceClientFailure(swift::misc::CStatusMessage)));
92 Q_ASSERT(s);
93
94 this->relayBaseClassSignals(serviceName, connection, IContextAudio::ObjectPath(),
96 }
97
98} // namespace swift::core::context
ContextMode
How to handle a given context.
@ Remote
context runs in a different process.
void changedLocalAudioDevices(const swift::misc::audio::CAudioDeviceInfoList &devices)
Changed audio devices (e.g. device enabled/disable).
CContextAudioBase(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime)
Constructor.
void registerDevices(const swift::misc::audio::CAudioDeviceInfoList &devices)
Register a device on a machine (for core/GUI it will return all known devices on all machines).
void unRegisterDevices(const swift::misc::audio::CAudioDeviceInfoList &devices)
Unregister devices.
bool hasRegisteredAudioCallsign(const swift::misc::aviation::CCallsign &callsign) const
Un-register an audio callsign (used with AFV).
CContextAudioProxy(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime)
Contructor.
void registerAudioCallsign(const swift::misc::aviation::CCallsign &callsign, const swift::misc::CIdentifier &identifier)
Register an audio callsign (used with AFV).
swift::misc::audio::CAudioDeviceInfoList getRegisteredDevices() const
All registered devices.
void unRegisterAudioCallsign(const swift::misc::aviation::CCallsign &callsign, const swift::misc::CIdentifier &identifier)
Un-register an audio callsign (used with AFV).
void unRegisterDevicesFor(const swift::misc::CIdentifier &identifier)
Remove all devices for identifier (i.e. "a machine").
void onChangedLocalDevices(const swift::misc::audio::CAudioDeviceInfoList &devices)
Devices have been changed.
static const QString & InterfaceName()
Interface name.
static const QString & ObjectPath()
Object path.
void voiceClientFailure(const swift::misc::CStatusMessage &msg)
Authentication failed, ....
void relayBaseClassSignals(const QString &serviceName, QDBusConnection &connection, const QString &objectPath, const QString &interfaceName)
Relay signals from this class.
Definition context.cpp:64
static const QString & coreServiceName()
Default service name.
Used for hand written interface based on virtual methods.
const CIdentifier & identifier() const
Get identifier.
Value object encapsulating information identifying a component of a modular distributed swift process...
Definition identifier.h:29
bool isEmpty() const
Synonym for empty.
Definition sequence.h:285
Streamable status message, e.g.
Value object encapsulating a list of audio devices.
Value object encapsulating information of a callsign.
Definition callsign.h:30
Free functions in swift::misc.
QDBusConnection sessionBus()
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QueuedConnection