swift
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 
15 using namespace swift::misc;
16 using namespace swift::misc::audio;
17 using namespace swift::misc::network;
18 using namespace swift::misc::aviation;
19 using namespace swift::core::afv::clients;
20 
21 namespace swift::core::context
22 {
23  CContextAudioProxy::CContextAudioProxy(const QString &serviceName, QDBusConnection &connection,
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 
32  Qt::QueuedConnection);
33  }
34 
35  void CContextAudioProxy::unitTestRelaySignals()
36  {
37  // connect signals, asserts when failures
38  QDBusConnection con = QDBusConnection::sessionBus();
40  Q_UNUSED(c)
41  }
42 
44  {
45  if (devices.isEmpty()) { return; }
46  m_dBusInterface->callDBus(QLatin1String("registerDevices"), devices);
47  }
48 
50  {
51  if (devices.isEmpty()) { return; }
52  m_dBusInterface->callDBus(QLatin1String("unRegisterDevices"), devices);
53  }
54 
56  {
57  m_dBusInterface->callDBus(QLatin1String("unRegisterDevicesFor"), identifier);
58  }
59 
60  void CContextAudioProxy::registerAudioCallsign(const CCallsign &callsign, const CIdentifier &identifier)
61  {
62  m_dBusInterface->callDBus(QLatin1String("registerAudioCallsign"), callsign, identifier);
63  }
64 
65  void CContextAudioProxy::unRegisterAudioCallsign(const CCallsign &callsign, const CIdentifier &identifier)
66  {
67  m_dBusInterface->callDBus(QLatin1String("unRegisterAudioCallsign"), callsign, identifier);
68  }
69 
71  {
72  return m_dBusInterface->callDBusRet<bool>(QLatin1String("hasRegisteredAudioCallsign"), callsign);
73  }
74 
76  {
78  QLatin1String("getRegisteredDevices"));
79  }
80 
81  void CContextAudioProxy::relaySignals(const QString &serviceName, QDBusConnection &connection)
82  {
83  bool s =
84  connection.connect(serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(),
85  "voiceClientFailure", this, SIGNAL(voiceClientFailure(swift::misc::CStatusMessage)));
86  Q_ASSERT(s);
87 
88  this->relayBaseClassSignals(serviceName, connection, IContextAudio::ObjectPath(),
90  }
91 
92 } // namespace swift::core::context
ContextMode
How to handle a given context.
@ Remote
context runs in a different process.
The class providing facades (the contexts) for all DBus relevant operations.
Definition: corefacade.h:57
void changedLocalAudioDevices(const swift::misc::audio::CAudioDeviceInfoList &devices)
Changed audio devices (e.g. device enabled/disable)
virtual 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)
virtual void unRegisterDevices(const swift::misc::audio::CAudioDeviceInfoList &devices)
Unregister devices.
virtual bool hasRegisteredAudioCallsign(const swift::misc::aviation::CCallsign &callsign) const
Un-register an audio callsign (used with AFV)
virtual void registerAudioCallsign(const swift::misc::aviation::CCallsign &callsign, const swift::misc::CIdentifier &identifier)
Register an audio callsign (used with AFV)
virtual swift::misc::audio::CAudioDeviceInfoList getRegisteredDevices() const
All registered devices.
virtual void unRegisterAudioCallsign(const swift::misc::aviation::CCallsign &callsign, const swift::misc::CIdentifier &identifier)
Un-register an audio callsign (used with AFV)
virtual 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:61
static const QString & coreServiceName()
Default service name.
Definition: dbusserver.cpp:98
Used for hand written interface based on virtual methods.
void callDBus(QLatin1String method, Args &&...args)
Call DBus, no return value.
Ret callDBusRet(QLatin1String method, Args &&...args)
Call DBus with synchronous return value.
const CIdentifier & identifier() const
Get identifier.
Definition: identifiable.h:27
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.