Changeset View
Changeset View
Standalone View
Standalone View
core/device.cpp
Context not available. | |||||
21 | #include "device.h" | 21 | #include "device.h" | ||
---|---|---|---|---|---|
22 | 22 | | |||
23 | #include <QDBusConnection> | 23 | #include <QDBusConnection> | ||
24 | #include <QVector> | ||||
25 | #include <QSet> | ||||
24 | #include <QSslCertificate> | 26 | #include <QSslCertificate> | ||
25 | 27 | | |||
26 | #include <KSharedConfig> | 28 | #include <KSharedConfig> | ||
Context not available. | |||||
37 | #include "kdeconnectconfig.h" | 39 | #include "kdeconnectconfig.h" | ||
38 | #include "daemon.h" | 40 | #include "daemon.h" | ||
39 | 41 | | |||
42 | class Device::DevicePrivate | ||||
43 | { | ||||
44 | public: | ||||
45 | DevicePrivate(const QString &id) | ||||
46 | : m_deviceId(id) | ||||
47 | { | ||||
48 | | ||||
49 | } | ||||
50 | | ||||
51 | ~DevicePrivate() | ||||
52 | { | ||||
53 | qDeleteAll(m_deviceLinks); | ||||
54 | m_deviceLinks.clear(); | ||||
55 | } | ||||
56 | | ||||
57 | const QString m_deviceId; | ||||
58 | QString m_deviceName; | ||||
59 | DeviceType m_deviceType; | ||||
60 | int m_protocolVersion; | ||||
61 | | ||||
62 | QVector<DeviceLink *> m_deviceLinks; | ||||
63 | QHash<QString, KdeConnectPlugin *> m_plugins; | ||||
64 | | ||||
65 | QMultiMap<QString, KdeConnectPlugin *> m_pluginsByIncomingCapability; | ||||
66 | QSet<QString> m_supportedPlugins; | ||||
67 | QSet<PairingHandler *> m_pairRequests; | ||||
68 | }; | ||||
69 | | ||||
40 | static void warn(const QString& info) | 70 | static void warn(const QString& info) | ||
41 | { | 71 | { | ||
42 | qWarning() << "Device pairing error" << info; | 72 | qWarning() << "Device pairing error" << info; | ||
Context not available. | |||||
44 | 74 | | |||
45 | Device::Device(QObject* parent, const QString& id) | 75 | Device::Device(QObject* parent, const QString& id) | ||
46 | : QObject(parent) | 76 | : QObject(parent) | ||
47 | , m_deviceId(id) | 77 | , d(new Device::DevicePrivate(id)) | ||
48 | , m_protocolVersion(NetworkPacket::s_protocolVersion) //We don't know it yet | | |||
49 | { | 78 | { | ||
50 | KdeConnectConfig::DeviceInfo info = KdeConnectConfig::instance()->getTrustedDevice(id); | 79 | d->m_protocolVersion = NetworkPacket::s_protocolVersion; | ||
80 | KdeConnectConfig::DeviceInfo info = KdeConnectConfig::instance()->getTrustedDevice(d->m_deviceId); | ||||
51 | 81 | | |||
52 | m_deviceName = info.deviceName; | 82 | d->m_deviceName = info.deviceName; | ||
53 | m_deviceType = str2type(info.deviceType); | 83 | d->m_deviceType = str2type(info.deviceType); | ||
54 | 84 | | |||
55 | //Register in bus | 85 | //Register in bus | ||
56 | QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors); | 86 | QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors); | ||
57 | 87 | | |||
58 | //Assume every plugin is supported until addLink is called and we can get the actual list | 88 | //Assume every plugin is supported until addLink is called and we can get the actual list | ||
59 | m_supportedPlugins = PluginLoader::instance()->getPluginList().toSet(); | 89 | d->m_supportedPlugins = PluginLoader::instance()->getPluginList().toSet(); | ||
60 | 90 | | |||
61 | connect(this, &Device::pairingError, this, &warn); | 91 | connect(this, &Device::pairingError, this, &warn); | ||
62 | } | 92 | } | ||
63 | 93 | | |||
64 | Device::Device(QObject* parent, const NetworkPacket& identityPacket, DeviceLink* dl) | 94 | Device::Device(QObject* parent, const NetworkPacket& identityPacket, DeviceLink* dl) | ||
65 | : QObject(parent) | 95 | : QObject(parent) | ||
66 | , m_deviceId(identityPacket.get<QString>(QStringLiteral("deviceId"))) | 96 | , d(new Device::DevicePrivate(identityPacket.get<QString>(QStringLiteral("deviceId")))) | ||
67 | , m_deviceName(identityPacket.get<QString>(QStringLiteral("deviceName"))) | | |||
68 | { | 97 | { | ||
98 | d->m_deviceName = identityPacket.get<QString>(QStringLiteral("deviceName")); | ||||
69 | addLink(identityPacket, dl); | 99 | addLink(identityPacket, dl); | ||
70 | 100 | | |||
71 | //Register in bus | 101 | //Register in bus | ||
Context not available. | |||||
76 | 106 | | |||
77 | Device::~Device() | 107 | Device::~Device() | ||
78 | { | 108 | { | ||
79 | qDeleteAll(m_deviceLinks); | 109 | delete d; | ||
80 | m_deviceLinks.clear(); | 110 | } | ||
111 | | ||||
112 | QString Device::id() const | ||||
113 | { | ||||
114 | return d->m_deviceId; | ||||
115 | } | ||||
116 | | ||||
117 | QString Device::name() const | ||||
118 | { | ||||
119 | return d->m_deviceName; | ||||
120 | } | ||||
121 | | ||||
122 | QString Device::type() const | ||||
123 | { | ||||
124 | return type2str(d->m_deviceType); | ||||
125 | } | ||||
126 | | ||||
127 | bool Device::isReachable() const | ||||
128 | { | ||||
129 | return !d->m_deviceLinks.isEmpty(); | ||||
130 | } | ||||
131 | | ||||
132 | int Device::protocolVersion() | ||||
133 | { | ||||
134 | return d->m_protocolVersion; | ||||
135 | } | ||||
136 | | ||||
137 | QStringList Device::supportedPlugins() const | ||||
138 | { | ||||
139 | return d->m_supportedPlugins.toList(); | ||||
81 | } | 140 | } | ||
82 | 141 | | |||
83 | bool Device::hasPlugin(const QString& name) const | 142 | bool Device::hasPlugin(const QString& name) const | ||
84 | { | 143 | { | ||
85 | return m_plugins.contains(name); | 144 | return d->m_plugins.contains(name); | ||
86 | } | 145 | } | ||
87 | 146 | | |||
88 | QStringList Device::loadedPlugins() const | 147 | QStringList Device::loadedPlugins() const | ||
89 | { | 148 | { | ||
90 | return m_plugins.keys(); | 149 | return d->m_plugins.keys(); | ||
91 | } | 150 | } | ||
92 | 151 | | |||
93 | void Device::reloadPlugins() | 152 | void Device::reloadPlugins() | ||
94 | { | 153 | { | ||
95 | QHash<QString, KdeConnectPlugin*> newPluginMap, oldPluginMap = m_plugins; | 154 | QHash<QString, KdeConnectPlugin*> newPluginMap, oldPluginMap = d->m_plugins; | ||
96 | QMultiMap<QString, KdeConnectPlugin*> newPluginsByIncomingCapability; | 155 | QMultiMap<QString, KdeConnectPlugin*> newPluginsByIncomingCapability; | ||
97 | 156 | | |||
98 | if (isTrusted() && isReachable()) { //Do not load any plugin for unpaired devices, nor useless loading them for unreachable devices | 157 | if (isTrusted() && isReachable()) { //Do not load any plugin for unpaired devices, nor useless loading them for unreachable devices | ||
99 | 158 | | |||
100 | PluginLoader* loader = PluginLoader::instance(); | 159 | PluginLoader* loader = PluginLoader::instance(); | ||
101 | 160 | | |||
102 | for (const QString& pluginName : qAsConst(m_supportedPlugins)) { | 161 | for (const QString& pluginName : qAsConst(d->m_supportedPlugins)) { | ||
103 | const KPluginMetaData service = loader->getPluginInfo(pluginName); | 162 | const KPluginMetaData service = loader->getPluginInfo(pluginName); | ||
104 | 163 | | |||
105 | const bool pluginEnabled = isPluginEnabled(pluginName); | 164 | const bool pluginEnabled = isPluginEnabled(pluginName); | ||
106 | const QSet<QString> incomingCapabilities = KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-SupportedPacketType")).toSet(); | 165 | const QSet<QString> incomingCapabilities = KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-SupportedPacketType")).toSet(); | ||
107 | 166 | | |||
108 | if (pluginEnabled) { | 167 | if (pluginEnabled) { | ||
109 | KdeConnectPlugin* plugin = m_plugins.take(pluginName); | 168 | KdeConnectPlugin* plugin = d->m_plugins.take(pluginName); | ||
110 | 169 | | |||
111 | if (!plugin) { | 170 | if (!plugin) { | ||
112 | plugin = loader->instantiatePluginForDevice(pluginName, this); | 171 | plugin = loader->instantiatePluginForDevice(pluginName, this); | ||
Context not available. | |||||
126 | 185 | | |||
127 | //Erase all left plugins in the original map (meaning that we don't want | 186 | //Erase all left plugins in the original map (meaning that we don't want | ||
128 | //them anymore, otherwise they would have been moved to the newPluginMap) | 187 | //them anymore, otherwise they would have been moved to the newPluginMap) | ||
129 | qDeleteAll(m_plugins); | 188 | qDeleteAll(d->m_plugins); | ||
130 | m_plugins = newPluginMap; | 189 | d->m_plugins = newPluginMap; | ||
131 | m_pluginsByIncomingCapability = newPluginsByIncomingCapability; | 190 | d->m_pluginsByIncomingCapability = newPluginsByIncomingCapability; | ||
132 | 191 | | |||
133 | QDBusConnection bus = QDBusConnection::sessionBus(); | 192 | QDBusConnection bus = QDBusConnection::sessionBus(); | ||
134 | for (KdeConnectPlugin* plugin : qAsConst(m_plugins)) { | 193 | for (KdeConnectPlugin* plugin : qAsConst(d->m_plugins)) { | ||
135 | //TODO: see how it works in Android (only done once, when created) | 194 | //TODO: see how it works in Android (only done once, when created) | ||
136 | plugin->connected(); | 195 | plugin->connected(); | ||
137 | 196 | | |||
Context not available. | |||||
162 | return; | 221 | return; | ||
163 | } | 222 | } | ||
164 | 223 | | |||
165 | for (DeviceLink* dl : qAsConst(m_deviceLinks)) { | 224 | for (DeviceLink* dl : qAsConst(d->m_deviceLinks)) { | ||
166 | dl->userRequestsPair(); | 225 | dl->userRequestsPair(); | ||
167 | } | 226 | } | ||
168 | } | 227 | } | ||
169 | 228 | | |||
170 | void Device::unpair() | 229 | void Device::unpair() | ||
171 | { | 230 | { | ||
172 | for (DeviceLink* dl : qAsConst(m_deviceLinks)) { | 231 | for (DeviceLink* dl : qAsConst(d->m_deviceLinks)) { | ||
173 | dl->userRequestsUnpair(); | 232 | dl->userRequestsUnpair(); | ||
174 | } | 233 | } | ||
175 | KdeConnectConfig::instance()->removeTrustedDevice(id()); | 234 | KdeConnectConfig::instance()->removeTrustedDevice(id()); | ||
Context not available. | |||||
181 | if (status == DeviceLink::NotPaired) { | 240 | if (status == DeviceLink::NotPaired) { | ||
182 | KdeConnectConfig::instance()->removeTrustedDevice(id()); | 241 | KdeConnectConfig::instance()->removeTrustedDevice(id()); | ||
183 | 242 | | |||
184 | for (DeviceLink* dl : qAsConst(m_deviceLinks)) { | 243 | for (DeviceLink* dl : qAsConst(d->m_deviceLinks)) { | ||
185 | if (dl != sender()) { | 244 | if (dl != sender()) { | ||
186 | dl->setPairStatus(DeviceLink::NotPaired); | 245 | dl->setPairStatus(DeviceLink::NotPaired); | ||
187 | } | 246 | } | ||
Context not available. | |||||
207 | //qCDebug(KDECONNECT_CORE) << "Adding link to" << id() << "via" << link->provider(); | 266 | //qCDebug(KDECONNECT_CORE) << "Adding link to" << id() << "via" << link->provider(); | ||
208 | 267 | | |||
209 | setName(identityPacket.get<QString>(QStringLiteral("deviceName"))); | 268 | setName(identityPacket.get<QString>(QStringLiteral("deviceName"))); | ||
210 | m_deviceType = str2type(identityPacket.get<QString>(QStringLiteral("deviceType"))); | 269 | d->m_deviceType = str2type(identityPacket.get<QString>(QStringLiteral("deviceType"))); | ||
211 | 270 | | |||
212 | if (m_deviceLinks.contains(link)) | 271 | if (d->m_deviceLinks.contains(link)) | ||
213 | return; | 272 | return; | ||
214 | 273 | | |||
215 | m_protocolVersion = identityPacket.get<int>(QStringLiteral("protocolVersion"), -1); | 274 | d->m_protocolVersion = identityPacket.get<int>(QStringLiteral("protocolVersion"), -1); | ||
216 | if (m_protocolVersion != NetworkPacket::s_protocolVersion) { | 275 | if (d->m_protocolVersion != NetworkPacket::s_protocolVersion) { | ||
217 | qCWarning(KDECONNECT_CORE) << m_deviceName << "- warning, device uses a different protocol version" << m_protocolVersion << "expected" << NetworkPacket::s_protocolVersion; | 276 | qCWarning(KDECONNECT_CORE) << d->m_deviceName << "- warning, device uses a different protocol version" << d->m_protocolVersion << "expected" << NetworkPacket::s_protocolVersion; | ||
218 | } | 277 | } | ||
219 | 278 | | |||
220 | connect(link, &QObject::destroyed, | 279 | connect(link, &QObject::destroyed, | ||
221 | this, &Device::linkDestroyed); | 280 | this, &Device::linkDestroyed); | ||
222 | 281 | | |||
223 | m_deviceLinks.append(link); | 282 | d->m_deviceLinks.append(link); | ||
224 | 283 | | |||
225 | //Theoretically we will never add two links from the same provider (the provider should destroy | 284 | //Theoretically we will never add two links from the same provider (the provider should destroy | ||
226 | //the old one before this is called), so we do not have to worry about destroying old links. | 285 | //the old one before this is called), so we do not have to worry about destroying old links. | ||
Context not available. | |||||
229 | connect(link, &DeviceLink::receivedPacket, | 288 | connect(link, &DeviceLink::receivedPacket, | ||
230 | this, &Device::privateReceivedPacket); | 289 | this, &Device::privateReceivedPacket); | ||
231 | 290 | | |||
232 | std::sort(m_deviceLinks.begin(), m_deviceLinks.end(), lessThan); | 291 | std::sort(d->m_deviceLinks.begin(), d->m_deviceLinks.end(), lessThan); | ||
233 | 292 | | |||
234 | const bool capabilitiesSupported = identityPacket.has(QStringLiteral("incomingCapabilities")) || identityPacket.has(QStringLiteral("outgoingCapabilities")); | 293 | const bool capabilitiesSupported = identityPacket.has(QStringLiteral("incomingCapabilities")) || identityPacket.has(QStringLiteral("outgoingCapabilities")); | ||
235 | if (capabilitiesSupported) { | 294 | if (capabilitiesSupported) { | ||
236 | const QSet<QString> outgoingCapabilities = identityPacket.get<QStringList>(QStringLiteral("outgoingCapabilities")).toSet() | 295 | const QSet<QString> outgoingCapabilities = identityPacket.get<QStringList>(QStringLiteral("outgoingCapabilities")).toSet() | ||
237 | , incomingCapabilities = identityPacket.get<QStringList>(QStringLiteral("incomingCapabilities")).toSet(); | 296 | , incomingCapabilities = identityPacket.get<QStringList>(QStringLiteral("incomingCapabilities")).toSet(); | ||
238 | 297 | | |||
239 | m_supportedPlugins = PluginLoader::instance()->pluginsForCapabilities(incomingCapabilities, outgoingCapabilities); | 298 | d->m_supportedPlugins = PluginLoader::instance()->pluginsForCapabilities(incomingCapabilities, outgoingCapabilities); | ||
240 | //qDebug() << "new plugins for" << m_deviceName << m_supportedPlugins << incomingCapabilities << outgoingCapabilities; | 299 | //qDebug() << "new plugins for" << m_deviceName << m_supportedPlugins << incomingCapabilities << outgoingCapabilities; | ||
241 | } else { | 300 | } else { | ||
242 | m_supportedPlugins = PluginLoader::instance()->getPluginList().toSet(); | 301 | d->m_supportedPlugins = PluginLoader::instance()->getPluginList().toSet(); | ||
243 | } | 302 | } | ||
244 | 303 | | |||
245 | reloadPlugins(); | 304 | reloadPlugins(); | ||
246 | 305 | | |||
247 | if (m_deviceLinks.size() == 1) { | 306 | if (d->m_deviceLinks.size() == 1) { | ||
248 | Q_EMIT reachableChanged(true); | 307 | Q_EMIT reachableChanged(true); | ||
249 | } | 308 | } | ||
250 | 309 | | |||
Context not available. | |||||
256 | 315 | | |||
257 | void Device::addPairingRequest(PairingHandler* handler) | 316 | void Device::addPairingRequest(PairingHandler* handler) | ||
258 | { | 317 | { | ||
259 | const bool wasEmpty = m_pairRequests.isEmpty(); | 318 | const bool wasEmpty = d->m_pairRequests.isEmpty(); | ||
260 | m_pairRequests.insert(handler); | 319 | d->m_pairRequests.insert(handler); | ||
261 | 320 | | |||
262 | if (wasEmpty != m_pairRequests.isEmpty()) | 321 | if (wasEmpty != d->m_pairRequests.isEmpty()) | ||
263 | Q_EMIT hasPairingRequestsChanged(!m_pairRequests.isEmpty()); | 322 | Q_EMIT hasPairingRequestsChanged(!d->m_pairRequests.isEmpty()); | ||
264 | } | 323 | } | ||
265 | 324 | | |||
266 | void Device::removePairingRequest(PairingHandler* handler) | 325 | void Device::removePairingRequest(PairingHandler* handler) | ||
267 | { | 326 | { | ||
268 | const bool wasEmpty = m_pairRequests.isEmpty(); | 327 | const bool wasEmpty = d->m_pairRequests.isEmpty(); | ||
269 | m_pairRequests.remove(handler); | 328 | d->m_pairRequests.remove(handler); | ||
270 | 329 | | |||
271 | if (wasEmpty != m_pairRequests.isEmpty()) | 330 | if (wasEmpty != d->m_pairRequests.isEmpty()) | ||
272 | Q_EMIT hasPairingRequestsChanged(!m_pairRequests.isEmpty()); | 331 | Q_EMIT hasPairingRequestsChanged(!d->m_pairRequests.isEmpty()); | ||
273 | } | 332 | } | ||
274 | 333 | | |||
275 | bool Device::hasPairingRequests() const | 334 | bool Device::hasPairingRequests() const | ||
276 | { | 335 | { | ||
277 | return !m_pairRequests.isEmpty(); | 336 | return !d->m_pairRequests.isEmpty(); | ||
278 | } | 337 | } | ||
279 | 338 | | |||
280 | void Device::acceptPairing() | 339 | void Device::acceptPairing() | ||
281 | { | 340 | { | ||
282 | if (m_pairRequests.isEmpty()) | 341 | if (d->m_pairRequests.isEmpty()) | ||
283 | qWarning() << "no pair requests to accept!"; | 342 | qWarning() << "no pair requests to accept!"; | ||
284 | 343 | | |||
285 | //copying because the pairing handler will be removed upon accept | 344 | //copying because the pairing handler will be removed upon accept | ||
286 | const auto prCopy = m_pairRequests; | 345 | const auto prCopy = d->m_pairRequests; | ||
287 | for (auto ph: prCopy) | 346 | for (auto ph: prCopy) | ||
288 | ph->acceptPairing(); | 347 | ph->acceptPairing(); | ||
289 | } | 348 | } | ||
290 | 349 | | |||
291 | void Device::rejectPairing() | 350 | void Device::rejectPairing() | ||
292 | { | 351 | { | ||
293 | if (m_pairRequests.isEmpty()) | 352 | if (d->m_pairRequests.isEmpty()) | ||
294 | qWarning() << "no pair requests to reject!"; | 353 | qWarning() << "no pair requests to reject!"; | ||
295 | 354 | | |||
296 | //copying because the pairing handler will be removed upon reject | 355 | //copying because the pairing handler will be removed upon reject | ||
297 | const auto prCopy = m_pairRequests; | 356 | const auto prCopy = d->m_pairRequests; | ||
298 | for (auto ph: prCopy) | 357 | for (auto ph: prCopy) | ||
299 | ph->rejectPairing(); | 358 | ph->rejectPairing(); | ||
300 | } | 359 | } | ||
Context not available. | |||||
306 | 365 | | |||
307 | void Device::removeLink(DeviceLink* link) | 366 | void Device::removeLink(DeviceLink* link) | ||
308 | { | 367 | { | ||
309 | m_deviceLinks.removeAll(link); | 368 | d->m_deviceLinks.removeAll(link); | ||
310 | 369 | | |||
311 | //qCDebug(KDECONNECT_CORE) << "RemoveLink" << m_deviceLinks.size() << "links remaining"; | 370 | //qCDebug(KDECONNECT_CORE) << "RemoveLink" << m_deviceLinks.size() << "links remaining"; | ||
312 | 371 | | |||
313 | if (m_deviceLinks.isEmpty()) { | 372 | if (d->m_deviceLinks.isEmpty()) { | ||
314 | reloadPlugins(); | 373 | reloadPlugins(); | ||
315 | Q_EMIT reachableChanged(false); | 374 | Q_EMIT reachableChanged(false); | ||
316 | } | 375 | } | ||
Context not available. | |||||
322 | Q_ASSERT(isTrusted()); | 381 | Q_ASSERT(isTrusted()); | ||
323 | 382 | | |||
324 | //Maybe we could block here any packet that is not an identity or a pairing packet to prevent sending non encrypted data | 383 | //Maybe we could block here any packet that is not an identity or a pairing packet to prevent sending non encrypted data | ||
325 | for (DeviceLink* dl : qAsConst(m_deviceLinks)) { | 384 | for (DeviceLink* dl : qAsConst(d->m_deviceLinks)) { | ||
326 | if (dl->sendPacket(np)) return true; | 385 | if (dl->sendPacket(np)) return true; | ||
327 | } | 386 | } | ||
328 | 387 | | |||
Context not available. | |||||
333 | { | 392 | { | ||
334 | Q_ASSERT(np.type() != PACKET_TYPE_PAIR); | 393 | Q_ASSERT(np.type() != PACKET_TYPE_PAIR); | ||
335 | if (isTrusted()) { | 394 | if (isTrusted()) { | ||
336 | const QList<KdeConnectPlugin*> plugins = m_pluginsByIncomingCapability.values(np.type()); | 395 | const QList<KdeConnectPlugin*> plugins = d->m_pluginsByIncomingCapability.values(np.type()); | ||
337 | if (plugins.isEmpty()) { | 396 | if (plugins.isEmpty()) { | ||
338 | qWarning() << "discarding unsupported packet" << np.type() << "for" << name(); | 397 | qWarning() << "discarding unsupported packet" << np.type() << "for" << name(); | ||
339 | } | 398 | } | ||
Context not available. | |||||
355 | QStringList Device::availableLinks() const | 414 | QStringList Device::availableLinks() const | ||
356 | { | 415 | { | ||
357 | QStringList sl; | 416 | QStringList sl; | ||
358 | sl.reserve(m_deviceLinks.size()); | 417 | sl.reserve(d->m_deviceLinks.size()); | ||
359 | for (DeviceLink* dl : qAsConst(m_deviceLinks)) { | 418 | for (DeviceLink* dl : qAsConst(d->m_deviceLinks)) { | ||
360 | sl.append(dl->provider()->name()); | 419 | sl.append(dl->provider()->name()); | ||
361 | } | 420 | } | ||
362 | return sl; | 421 | return sl; | ||
Context not available. | |||||
366 | if (isTrusted()) { | 425 | if (isTrusted()) { | ||
367 | return; | 426 | return; | ||
368 | } | 427 | } | ||
369 | for(int i = 0; i < m_deviceLinks.size(); ) { | 428 | for(int i = 0; i < d->m_deviceLinks.size(); ) { | ||
370 | DeviceLink* dl = m_deviceLinks[i]; | 429 | DeviceLink* dl = d->m_deviceLinks[i]; | ||
371 | if (!dl->linkShouldBeKeptAlive()) { | 430 | if (!dl->linkShouldBeKeptAlive()) { | ||
372 | dl->deleteLater(); | 431 | dl->deleteLater(); | ||
373 | m_deviceLinks.remove(i); | 432 | d->m_deviceLinks.remove(i); | ||
374 | } else { | 433 | } else { | ||
375 | i++; | 434 | i++; | ||
376 | } | 435 | } | ||
Context not available. | |||||
379 | 438 | | |||
380 | QHostAddress Device::getLocalIpAddress() const | 439 | QHostAddress Device::getLocalIpAddress() const | ||
381 | { | 440 | { | ||
382 | for (DeviceLink* dl : m_deviceLinks) { | 441 | for (DeviceLink* dl : d->m_deviceLinks) { | ||
383 | LanDeviceLink* ldl = dynamic_cast<LanDeviceLink*>(dl); | 442 | LanDeviceLink* ldl = dynamic_cast<LanDeviceLink*>(dl); | ||
384 | if (ldl) { | 443 | if (ldl) { | ||
385 | return ldl->hostAddress(); | 444 | return ldl->hostAddress(); | ||
Context not available. | |||||
419 | 478 | | |||
420 | QString Device::iconForStatus(bool reachable, bool trusted) const | 479 | QString Device::iconForStatus(bool reachable, bool trusted) const | ||
421 | { | 480 | { | ||
422 | Device::DeviceType deviceType = m_deviceType; | 481 | Device::DeviceType deviceType = d->m_deviceType; | ||
423 | if (deviceType == Device::Unknown) { | 482 | if (deviceType == Device::Unknown) { | ||
424 | deviceType = Device::Phone; //Assume phone if we don't know the type | 483 | deviceType = Device::Phone; //Assume phone if we don't know the type | ||
425 | } else if (deviceType == Device::Desktop) { | 484 | } else if (deviceType == Device::Desktop) { | ||
Context not available. | |||||
434 | 493 | | |||
435 | void Device::setName(const QString& name) | 494 | void Device::setName(const QString& name) | ||
436 | { | 495 | { | ||
437 | if (m_deviceName != name) { | 496 | if (d->m_deviceName != name) { | ||
438 | m_deviceName = name; | 497 | d->m_deviceName = name; | ||
439 | Q_EMIT nameChanged(name); | 498 | Q_EMIT nameChanged(name); | ||
440 | } | 499 | } | ||
441 | } | 500 | } | ||
442 | 501 | | |||
443 | KdeConnectPlugin* Device::plugin(const QString& pluginName) const | 502 | KdeConnectPlugin* Device::plugin(const QString& pluginName) const | ||
444 | { | 503 | { | ||
445 | return m_plugins[pluginName]; | 504 | return d->m_plugins[pluginName]; | ||
446 | } | 505 | } | ||
447 | 506 | | |||
448 | void Device::setPluginEnabled(const QString& pluginName, bool enabled) | 507 | void Device::setPluginEnabled(const QString& pluginName, bool enabled) | ||
Context not available. |