diff --git a/daemon/daemon.cpp b/daemon/daemon.cpp index d4052ea63..c2520f7df 100644 --- a/daemon/daemon.cpp +++ b/daemon/daemon.cpp @@ -160,6 +160,7 @@ void Daemon::onDeviceReachableStatusChanged() if (!device->reachable()) { if (!device->paired()) { + qDebug() << "Destroying device"; Q_EMIT deviceRemoved(id); mDevices.remove(id); device->deleteLater(); diff --git a/daemon/device.cpp b/daemon/device.cpp index e96cb95de..030c35b8e 100644 --- a/daemon/device.cpp +++ b/daemon/device.cpp @@ -18,6 +18,7 @@ Device::Device(const QString& id, const QString& name) { + m_deviceId = id; m_deviceName = name; m_paired = true; @@ -32,6 +33,7 @@ Device::Device(const QString& id, const QString& name) Device::Device(const QString& id, const QString& name, DeviceLink* link) { + m_deviceId = id; m_deviceName = name; m_paired = false; @@ -45,23 +47,11 @@ Device::Device(const QString& id, const QString& name, DeviceLink* link) QDBusConnection::sessionBus().registerObject("/modules/kdeconnect/devices/"+id, this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors); } -/* -Device::Device(const QString& id, const QString& name, DeviceLink* link) + +Device::~Device() { - m_deviceId = id; - m_deviceName = id; //Temporary name - m_paired = false; - m_knownIdentiy = false; - addLink(link); - - NetworkPackage identityRequest; - identityRequest.setType("IDENTITY_REQUEST"); - link->sendPackage(identityRequest); - - QDBusConnection::sessionBus().registerObject("/modules/kdeconnect/Devices/"+id, this); } -*/ bool Device::hasPlugin(const QString& name) { @@ -123,9 +113,11 @@ void Device::setPair(bool b) if (b) { qDebug() << name() << "paired"; config->group("devices").group("paired").group(id()).writeEntry("name",name()); + Q_EMIT reachableStatusChanged(); } else { qDebug() << name() << "unpaired"; config->group("devices").group("paired").deleteGroup(id()); + //Do not Q_EMIT reachableStatusChanged() because we do not want it to suddenly disappear from device list } reloadPlugins(); } diff --git a/daemon/device.h b/daemon/device.h index ad2ee6175..625ab0368 100644 --- a/daemon/device.h +++ b/daemon/device.h @@ -46,9 +46,7 @@ public: //Device known via an incoming connection sent to us via a devicelink, we know everything but we don't trust it yet Device(const QString& id, const QString& name, DeviceLink* dl); - //Device known via discovery, we know nothing and have to ask for a presentation package - //(not supported yet, do we need it or we can rely on the device presenging itself?) - //Device(const QString& id, DeviceLink* dl); + virtual ~Device(); QString id() const { return m_deviceId; } QString name() const { return m_deviceName; } diff --git a/daemon/plugins/notifications/notificationsplugin.cpp b/daemon/plugins/notifications/notificationsplugin.cpp index fdafeb7b6..2bcbe87fe 100644 --- a/daemon/plugins/notifications/notificationsplugin.cpp +++ b/daemon/plugins/notifications/notificationsplugin.cpp @@ -29,7 +29,7 @@ K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_notifications", "kdeconnect NotificationsPlugin::NotificationsPlugin(QObject* parent, const QVariantList& args) : KdeConnectPlugin(parent, args) { - trayIcon = new KStatusNotifierItem(parent); + trayIcon = new KStatusNotifierItem(this); trayIcon->setIconByName("smartphone"); trayIcon->setTitle(device()->name()); } diff --git a/daemon/plugins/notifications/notificationsplugin.h b/daemon/plugins/notifications/notificationsplugin.h index 55f2528e4..0512cb0e6 100644 --- a/daemon/plugins/notifications/notificationsplugin.h +++ b/daemon/plugins/notifications/notificationsplugin.h @@ -31,7 +31,6 @@ class NotificationsPlugin : public KdeConnectPlugin { Q_OBJECT - KStatusNotifierItem* trayIcon; public: explicit NotificationsPlugin(QObject *parent, const QVariantList &args); @@ -40,6 +39,9 @@ public: public Q_SLOTS: virtual bool receivePackage(const NetworkPackage& np); +private: + KStatusNotifierItem* trayIcon; + }; #endif diff --git a/daemon/plugins/ping/pingplugin.cpp b/daemon/plugins/ping/pingplugin.cpp index 8ffb317c7..4aec2327f 100644 --- a/daemon/plugins/ping/pingplugin.cpp +++ b/daemon/plugins/ping/pingplugin.cpp @@ -46,8 +46,8 @@ bool PingPlugin::receivePackage(const NetworkPackage& np) KNotification* notification = new KNotification("pingReceived"); //KNotification::Persistent notification->setPixmap(KIcon("dialog-ok").pixmap(48, 48)); notification->setComponentData(KComponentData("kdeconnect", "kdeconnect")); - notification->setTitle("Ping!"); - notification->setText(device()->name()); + notification->setTitle(device()->name()); + notification->setText("Ping!"); notification->sendEvent(); return true; diff --git a/daemon/plugins/telephony/telephonyplugin.cpp b/daemon/plugins/telephony/telephonyplugin.cpp index 48f63a7ab..71e0dbae9 100644 --- a/daemon/plugins/telephony/telephonyplugin.cpp +++ b/daemon/plugins/telephony/telephonyplugin.cpp @@ -60,7 +60,7 @@ KNotification* TelephonyPlugin::createNotification(const NetworkPackage& np) //TODO: return NULL if !debug type = "unknownEvent"; icon = "pda"; - content = "Unknown notification type: " + event; + content = "Unknown telephony event: " + event; } qDebug() << "Creating notification with type:" << type; diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp index ca82bfc17..1bdd657b6 100644 --- a/kcm/kcm.cpp +++ b/kcm/kcm.cpp @@ -120,9 +120,19 @@ void KdeConnectKcm::deviceSelected(const QModelIndex& current) void KdeConnectKcm::trustedStateChanged(bool b) { if (!currentDevice) return; - currentDevice->setPair(b); - devicesModel->deviceStatusChanged(currentDevice->id()); - + QDBusPendingReply pendingReply = currentDevice->setPair(b); + pendingReply.waitForFinished(); + if (pendingReply.isValid()) { + //If dbus was down, calling this would make kcm crash + devicesModel->deviceStatusChanged(currentDevice->id()); + } else { + //Revert checkbox + disconnect(kcmUi->trust_checkbox, SIGNAL(toggled(bool)), + this, SLOT(trustedStateChanged(bool))); + kcmUi->trust_checkbox->setCheckState(b? Qt::Unchecked : Qt::Checked); + connect(kcmUi->trust_checkbox, SIGNAL(toggled(bool)), + this, SLOT(trustedStateChanged(bool))); + } } void KdeConnectKcm::pluginsConfigChanged()