Changeset View
Changeset View
Standalone View
Standalone View
src/device_p.cpp
Show All 17 Lines | |||||
18 | * | 18 | * | ||
19 | * You should have received a copy of the GNU Lesser General Public | 19 | * You should have received a copy of the GNU Lesser General Public | ||
20 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | 20 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
21 | */ | 21 | */ | ||
22 | 22 | | |||
23 | #include "device_p.h" | 23 | #include "device_p.h" | ||
24 | #include "device.h" | 24 | #include "device.h" | ||
25 | #include "adapter.h" | 25 | #include "adapter.h" | ||
26 | #include "battery.h" | ||||
27 | #include "battery_p.h" | ||||
26 | #include "input.h" | 28 | #include "input.h" | ||
27 | #include "input_p.h" | 29 | #include "input_p.h" | ||
28 | #include "mediaplayer.h" | 30 | #include "mediaplayer.h" | ||
29 | #include "mediaplayer_p.h" | 31 | #include "mediaplayer_p.h" | ||
30 | #include "mediatransport.h" | 32 | #include "mediatransport.h" | ||
31 | #include "mediatransport_p.h" | 33 | #include "mediatransport_p.h" | ||
32 | #include "utils.h" | 34 | #include "utils.h" | ||
33 | #include "macros.h" | 35 | #include "macros.h" | ||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | |||||
82 | } | 84 | } | ||
83 | 85 | | |||
84 | void DevicePrivate::interfacesAdded(const QString &path, const QVariantMapMap &interfaces) | 86 | void DevicePrivate::interfacesAdded(const QString &path, const QVariantMapMap &interfaces) | ||
85 | { | 87 | { | ||
86 | bool changed = false; | 88 | bool changed = false; | ||
87 | QVariantMapMap::const_iterator it; | 89 | QVariantMapMap::const_iterator it; | ||
88 | 90 | | |||
89 | for (it = interfaces.constBegin(); it != interfaces.constEnd(); ++it) { | 91 | for (it = interfaces.constBegin(); it != interfaces.constEnd(); ++it) { | ||
90 | if (it.key() == Strings::orgBluezInput1()) { | 92 | if (it.key() == Strings::orgBluezBattery1()) { | ||
93 | m_battery = BatteryPtr(new Battery(path, it.value())); | ||||
94 | m_battery->d->q = m_battery.toWeakRef(); | ||||
95 | Q_EMIT q.lock()->batteryChanged(m_battery); | ||||
96 | changed = true; | ||||
97 | } else if (it.key() == Strings::orgBluezInput1()) { | ||||
91 | m_input = InputPtr(new Input(path, it.value())); | 98 | m_input = InputPtr(new Input(path, it.value())); | ||
92 | m_input->d->q = m_input.toWeakRef(); | 99 | m_input->d->q = m_input.toWeakRef(); | ||
93 | Q_EMIT q.lock()->inputChanged(m_input); | 100 | Q_EMIT q.lock()->inputChanged(m_input); | ||
94 | changed = true; | 101 | changed = true; | ||
95 | } else if (it.key() == Strings::orgBluezMediaPlayer1()) { | 102 | } else if (it.key() == Strings::orgBluezMediaPlayer1()) { | ||
96 | m_mediaPlayer = MediaPlayerPtr(new MediaPlayer(path, it.value())); | 103 | m_mediaPlayer = MediaPlayerPtr(new MediaPlayer(path, it.value())); | ||
97 | m_mediaPlayer->d->q = m_mediaPlayer.toWeakRef(); | 104 | m_mediaPlayer->d->q = m_mediaPlayer.toWeakRef(); | ||
98 | Q_EMIT q.lock()->mediaPlayerChanged(m_mediaPlayer); | 105 | Q_EMIT q.lock()->mediaPlayerChanged(m_mediaPlayer); | ||
Show All 11 Lines | |||||
110 | } | 117 | } | ||
111 | } | 118 | } | ||
112 | 119 | | |||
113 | void DevicePrivate::interfacesRemoved(const QString &path, const QStringList &interfaces) | 120 | void DevicePrivate::interfacesRemoved(const QString &path, const QStringList &interfaces) | ||
114 | { | 121 | { | ||
115 | bool changed = false; | 122 | bool changed = false; | ||
116 | 123 | | |||
117 | for (const QString &interface : interfaces) { | 124 | for (const QString &interface : interfaces) { | ||
118 | if (interface == Strings::orgBluezInput1() && m_input && m_input->d->m_path == path) { | 125 | if (interface == Strings::orgBluezBattery1() && m_battery && m_battery->d->m_path == path) { | ||
126 | m_battery.clear(); | ||||
127 | Q_EMIT q.lock()->batteryChanged(m_battery); | ||||
128 | changed = true; | ||||
129 | } else if (interface == Strings::orgBluezInput1() && m_input && m_input->d->m_path == path) { | ||||
119 | m_input.clear(); | 130 | m_input.clear(); | ||
120 | Q_EMIT q.lock()->inputChanged(m_input); | 131 | Q_EMIT q.lock()->inputChanged(m_input); | ||
121 | changed = true; | 132 | changed = true; | ||
122 | } else if (interface == Strings::orgBluezMediaPlayer1() && m_mediaPlayer && m_mediaPlayer->d->m_path == path) { | 133 | } else if (interface == Strings::orgBluezMediaPlayer1() && m_mediaPlayer && m_mediaPlayer->d->m_path == path) { | ||
123 | m_mediaPlayer.clear(); | 134 | m_mediaPlayer.clear(); | ||
124 | Q_EMIT q.lock()->mediaPlayerChanged(m_mediaPlayer); | 135 | Q_EMIT q.lock()->mediaPlayerChanged(m_mediaPlayer); | ||
125 | changed = true; | 136 | changed = true; | ||
126 | } else if (interface == Strings::orgBluezMediaTransport1() && m_mediaTransport && m_mediaTransport->d->m_path == path) { | 137 | } else if (interface == Strings::orgBluezMediaTransport1() && m_mediaTransport && m_mediaTransport->d->m_path == path) { | ||
Show All 10 Lines | |||||
137 | 148 | | |||
138 | QDBusPendingReply<> DevicePrivate::setDBusProperty(const QString &name, const QVariant &value) | 149 | QDBusPendingReply<> DevicePrivate::setDBusProperty(const QString &name, const QVariant &value) | ||
139 | { | 150 | { | ||
140 | return m_dbusProperties->Set(Strings::orgBluezDevice1(), name, QDBusVariant(value)); | 151 | return m_dbusProperties->Set(Strings::orgBluezDevice1(), name, QDBusVariant(value)); | ||
141 | } | 152 | } | ||
142 | 153 | | |||
143 | void DevicePrivate::propertiesChanged(const QString &interface, const QVariantMap &changed, const QStringList &invalidated) | 154 | void DevicePrivate::propertiesChanged(const QString &interface, const QVariantMap &changed, const QStringList &invalidated) | ||
144 | { | 155 | { | ||
145 | if (interface == Strings::orgBluezInput1() && m_input) { | 156 | if (interface == Strings::orgBluezBattery1() && m_battery) { | ||
157 | m_battery->d->propertiesChanged(interface, changed, invalidated); | ||||
158 | } else if (interface == Strings::orgBluezInput1() && m_input) { | ||||
146 | m_input->d->propertiesChanged(interface, changed, invalidated); | 159 | m_input->d->propertiesChanged(interface, changed, invalidated); | ||
147 | } else if (interface == Strings::orgBluezMediaPlayer1() && m_mediaPlayer) { | 160 | } else if (interface == Strings::orgBluezMediaPlayer1() && m_mediaPlayer) { | ||
148 | m_mediaPlayer->d->propertiesChanged(interface, changed, invalidated); | 161 | m_mediaPlayer->d->propertiesChanged(interface, changed, invalidated); | ||
149 | } else if (interface != Strings::orgBluezDevice1()) { | 162 | } else if (interface != Strings::orgBluezDevice1()) { | ||
150 | return; | 163 | return; | ||
151 | } | 164 | } | ||
152 | 165 | | |||
153 | QVariantMap::const_iterator i; | 166 | QVariantMap::const_iterator i; | ||
▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines |