Changeset View
Changeset View
Standalone View
Standalone View
core/daemon.cpp
Show All 21 Lines | |||||
22 | 22 | | |||
23 | #include <QDBusConnection> | 23 | #include <QDBusConnection> | ||
24 | #include <QNetworkAccessManager> | 24 | #include <QNetworkAccessManager> | ||
25 | #include <QDebug> | 25 | #include <QDebug> | ||
26 | #include <QPointer> | 26 | #include <QPointer> | ||
27 | 27 | | |||
28 | #include "core_debug.h" | 28 | #include "core_debug.h" | ||
29 | #include "kdeconnectconfig.h" | 29 | #include "kdeconnectconfig.h" | ||
30 | #include "networkpackage.h" | 30 | #include "networkpacket.h" | ||
31 | 31 | | |||
32 | #ifdef KDECONNECT_BLUETOOTH | 32 | #ifdef KDECONNECT_BLUETOOTH | ||
33 | #include "backends/bluetooth/bluetoothlinkprovider.h" | 33 | #include "backends/bluetooth/bluetoothlinkprovider.h" | ||
34 | #endif | 34 | #endif | ||
35 | 35 | | |||
36 | #include "backends/lan/lanlinkprovider.h" | 36 | #include "backends/lan/lanlinkprovider.h" | ||
37 | #include "backends/loopback/loopbacklinkprovider.h" | 37 | #include "backends/loopback/loopbacklinkprovider.h" | ||
38 | #include "device.h" | 38 | #include "device.h" | ||
▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Line(s) | 161 | { | |||
163 | for (Device* device : qAsConst(d->m_devices)) { | 163 | for (Device* device : qAsConst(d->m_devices)) { | ||
164 | if (onlyReachable && !device->isReachable()) continue; | 164 | if (onlyReachable && !device->isReachable()) continue; | ||
165 | if (onlyTrusted && !device->isTrusted()) continue; | 165 | if (onlyTrusted && !device->isTrusted()) continue; | ||
166 | ret.append(device->id()); | 166 | ret.append(device->id()); | ||
167 | } | 167 | } | ||
168 | return ret; | 168 | return ret; | ||
169 | } | 169 | } | ||
170 | 170 | | |||
171 | void Daemon::onNewDeviceLink(const NetworkPackage& identityPackage, DeviceLink* dl) | 171 | void Daemon::onNewDeviceLink(const NetworkPacket& identityPacket, DeviceLink* dl) | ||
172 | { | 172 | { | ||
173 | const QString& id = identityPackage.get<QString>(QStringLiteral("deviceId")); | 173 | const QString& id = identityPacket.get<QString>(QStringLiteral("deviceId")); | ||
174 | 174 | | |||
175 | //qCDebug(KDECONNECT_CORE) << "Device discovered" << id << "via" << dl->provider()->name(); | 175 | //qCDebug(KDECONNECT_CORE) << "Device discovered" << id << "via" << dl->provider()->name(); | ||
176 | 176 | | |||
177 | if (d->m_devices.contains(id)) { | 177 | if (d->m_devices.contains(id)) { | ||
178 | qCDebug(KDECONNECT_CORE) << "It is a known device" << identityPackage.get<QString>(QStringLiteral("deviceName")); | 178 | qCDebug(KDECONNECT_CORE) << "It is a known device" << identityPacket.get<QString>(QStringLiteral("deviceName")); | ||
179 | Device* device = d->m_devices[id]; | 179 | Device* device = d->m_devices[id]; | ||
180 | bool wasReachable = device->isReachable(); | 180 | bool wasReachable = device->isReachable(); | ||
181 | device->addLink(identityPackage, dl); | 181 | device->addLink(identityPacket, dl); | ||
182 | if (!wasReachable) { | 182 | if (!wasReachable) { | ||
183 | Q_EMIT deviceVisibilityChanged(id, true); | 183 | Q_EMIT deviceVisibilityChanged(id, true); | ||
184 | } | 184 | } | ||
185 | } else { | 185 | } else { | ||
186 | qCDebug(KDECONNECT_CORE) << "It is a new device" << identityPackage.get<QString>(QStringLiteral("deviceName")); | 186 | qCDebug(KDECONNECT_CORE) << "It is a new device" << identityPacket.get<QString>(QStringLiteral("deviceName")); | ||
187 | Device* device = new Device(this, identityPackage, dl); | 187 | Device* device = new Device(this, identityPacket, dl); | ||
188 | 188 | | |||
189 | //we discard the connections that we created but it's not paired. | 189 | //we discard the connections that we created but it's not paired. | ||
190 | if (!isDiscoveringDevices() && !device->isTrusted() && !dl->linkShouldBeKeptAlive()) { | 190 | if (!isDiscoveringDevices() && !device->isTrusted() && !dl->linkShouldBeKeptAlive()) { | ||
191 | device->deleteLater(); | 191 | device->deleteLater(); | ||
192 | } else { | 192 | } else { | ||
193 | addDevice(device); | 193 | addDevice(device); | ||
194 | } | 194 | } | ||
195 | } | 195 | } | ||
▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines |