BluezQt

input.cpp
1 /*
2  * BluezQt - Asynchronous Bluez wrapper library
3  *
4  * SPDX-FileCopyrightText: 2015 David Rosca <[email protected]>
5  *
6  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7  */
8 
9 #include "input.h"
10 #include "input_p.h"
11 #include "macros.h"
12 #include "utils.h"
13 
14 #include <QVariantMap>
15 
16 namespace BluezQt
17 {
18 static Input::ReconnectMode stringToReconnectMode(const QString &mode)
19 {
20  if (mode == QLatin1String("none")) {
21  return Input::NoReconnect;
22  } else if (mode == QLatin1String("host")) {
23  return Input::HostReconnect;
24  } else if (mode == QLatin1String("device")) {
26  }
27  return Input::AnyReconnect;
28 }
29 
30 InputPrivate::InputPrivate(const QString &path, const QVariantMap &properties)
31  : QObject()
32  , m_path(path)
33 {
34  // Init properties
35  m_reconnectMode = stringToReconnectMode(properties.value(QStringLiteral("ReconnectMode")).toString());
36 }
37 
38 void InputPrivate::propertiesChanged(const QString &interface, const QVariantMap &changed, const QStringList &invalidated)
39 {
40  Q_UNUSED(invalidated)
41 
42  if (interface != Strings::orgBluezInput1()) {
43  return;
44  }
45 
46  QVariantMap::const_iterator i;
47  for (i = changed.constBegin(); i != changed.constEnd(); ++i) {
48  const QVariant &value = i.value();
49  const QString &property = i.key();
50 
51  if (property == QLatin1String("ReconnectMode")) {
52  PROPERTY_CHANGED2(m_reconnectMode, stringToReconnectMode(value.toString()), reconnectModeChanged);
53  }
54  }
55 }
56 
57 Input::Input(const QString &path, const QVariantMap &properties)
58  : d(new InputPrivate(path, properties))
59 {
60 }
61 
63 {
64  delete d;
65 }
66 
68 {
69  return d->q.toStrongRef();
70 }
71 
72 Input::ReconnectMode Input::reconnectMode() const
73 {
74  return d->m_reconnectMode;
75 }
76 
77 } // namespace BluezQt
T value() const const
KGuiItem properties()
ReconnectMode
Reconnect mode.
Definition: input.h:33
@ AnyReconnect
Device shall attempt to restore the lost connection, but host may also restore the connection.
Definition: input.h:41
char * toString(const T &value)
@ NoReconnect
Device and host are not required to automatically restore the connection.
Definition: input.h:35
@ HostReconnect
Host restores the connection.
Definition: input.h:37
InputPtr toSharedPtr() const
Returns a shared pointer from this.
Definition: input.cpp:67
@ DeviceReconnect
Device restores the connection.
Definition: input.h:39
~Input() override
Destroys an Input object.
Definition: input.cpp:62
QString toString() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Sep 25 2022 04:19:10 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.