[network/kdeconnect-kde] plugins/share: shareplugin: Set device origin name on notification

Kai Uwe Broulik <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 53820862ffc6b62a6b2aecabd84f78cc09759345 by Kai Uwe Broulik.
Committed on 26/07/2026 at 16:02.
Pushed by broulik into branch 'master'.

shareplugin: Set device origin name on notification

Makes it consistent with regular notifications synced from the phone.
While at it, also set the source device so the notification isn't
echoed back to the device.

M  +11   -1    plugins/share/shareplugin.cpp

https://invent.kde.org/network/kdeconnect-kde/-/commit/53820862ffc6b62a6b2aecabd84f78cc09759345

diff --git a/plugins/share/shareplugin.cpp b/plugins/share/shareplugin.cpp
index 8ce9af22a..b7416dfbb 100644
--- a/plugins/share/shareplugin.cpp
+++ b/plugins/share/shareplugin.cpp
@@ -27,6 +27,7 @@
 
 #include "core/daemon.h"
 #include "core/filetransferjob.h"
+#include "core/notificationserverinfo.h"
 #include "plugin_share_debug.h"
 
 K_PLUGIN_CLASS_WITH_JSON(SharePlugin, "kdeconnect_share.json")
@@ -164,7 +165,16 @@ void SharePlugin::receivePacket(const NetworkPacket &np)
         KNotification *notif = new KNotification(QStringLiteral("textShareReceived"));
         notif->setComponentName(QStringLiteral("kdeconnect"));
         notif->setText(text);
-        notif->setTitle(i18nc("@info Some piece of text was received from a connected device", "Shared text from %1 copied to clipboard", device()->name()));
+        if (NotificationServerInfo::instance().supportedHints().testFlag(NotificationServerInfo::X_KDE_ORIGIN_NAME)) {
+            notif->setTitle(i18nc("@info Some piece of text was received from a connected device", "Shared text copied to clipboard", device()->name()));
+            notif->setHint(QStringLiteral("x-kde-origin-name"), device()->name());
+        } else {
+            notif->setTitle(
+                i18nc("@info Some piece of text was received from a connected device", "Shared text from %1 copied to clipboard", device()->name()));
+        }
+
+        // Mark this notification so sendnotifications can filter it out and not echo it back to the device
+        notif->setHint(QStringLiteral("x-kdeconnect-source-device"), device()->name());
 
         auto openTextEditor = [this, text, notif] {
             KService::Ptr service = KApplicationTrader::preferredService(QStringLiteral("text/plain"));
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.