diff --git a/plugins/kdeconnect.notifyrc b/plugins/kdeconnect.notifyrc index 46300f498..24e36183d 100644 --- a/plugins/kdeconnect.notifyrc +++ b/plugins/kdeconnect.notifyrc @@ -648,3 +648,13 @@ Comment[zh_CN]=收到通知 Comment[zh_TW]=收到通知 Action=Popup ShowInHistory=false + +[Event/remoteLockSuccess] +Name=Remote Lock Successful +Comment=Remote lock successful +Action=Popup + +[Event/remoteLockFailure] +Name=Remote Lock Failure +Comment=Remote lock failed +Action=Popup diff --git a/plugins/lockdevice/lockdeviceplugin.cpp b/plugins/lockdevice/lockdeviceplugin.cpp index d24a9e390..681160686 100644 --- a/plugins/lockdevice/lockdeviceplugin.cpp +++ b/plugins/lockdevice/lockdeviceplugin.cpp @@ -12,6 +12,7 @@ #include #include "plugin_lock_debug.h" +#include #include #include @@ -82,12 +83,27 @@ bool LockDevicePlugin::receivePacket(const NetworkPacket & np) sendState(); } + // Receiving result of setLocked + if (np.has(QStringLiteral("lockResult"))) { + bool lockSuccess = np.get(QStringLiteral("lockResult")); + if (lockSuccess) { + Daemon::instance()->sendSimpleNotification(QStringLiteral("remoteLockSuccess"), device()->name(), i18n("Remote lock successful"), QStringLiteral("lock")); + } else { + Daemon::instance()->sendSimpleNotification(QStringLiteral("remoteLockFailure"), device()->name(), i18n("Remote lock failed"), QStringLiteral("error")); + Daemon::instance()->reportError(device()->name(), i18n("Remote lock failed")); + } + } + if (np.has(QStringLiteral("setLocked"))) { const bool lock = np.get(QStringLiteral("setLocked")); - + bool success = false; if (lock) { m_login1Interface.Lock(); - } else { + success = m_login1Interface.lockedHint(); + NetworkPacket np(PACKET_TYPE_LOCK, {{QStringLiteral("lockResult"), success}}); + sendPacket(np); + } + else { m_login1Interface.Unlock(); }