fix: use GET_PRIVATE_LINK socket command for Wayland clipboard support#5
fix: use GET_PRIVATE_LINK socket command for Wayland clipboard support#5DeepDiver1975 wants to merge 1 commit into
Conversation
897c101 to
dd04074
Compare
On native Wayland sessions, the ownCloud client daemon has no Wayland surface and therefore cannot write to the clipboard. The new GET_PRIVATE_LINK socket command returns the resolved URL back to the caller instead, allowing the Dolphin plugin (which runs inside the Dolphin process that owns a live Wayland surface) to write to the clipboard itself. Changes: - OwncloudDolphinPluginHelper: add privateLinkReceived signal and handle PRIVATE_LINK responses in slotReadyRead(); add isWayland() helper - OwncloudDolphinActionPlugin: store command name in action data; on Wayland, replace COPY_PRIVATE_LINK handler with one that sends GET_PRIVATE_LINK and waits for PRIVATE_LINK response via QEventLoop Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
dd04074 to
e79ddb8
Compare
dj4oC
left a comment
There was a problem hiding this comment.
Adds a Wayland-specific "Copy private link to clipboard" path: on Wayland, intercepts the COPY_PRIVATE_LINK action, sends the new GET_PRIVATE_LINK socket command, waits for PRIVATE_LINK: and writes to the clipboard from within the Dolphin process (which has a valid Wayland surface).
Findings
Memory safety: No raw pointer arithmetic; the helper/files/parentWidget raw-pointer captures match the existing pattern already used a few lines above in the same function, so not a new risk. The &waitLoop reference capture is safe — it's used synchronously within the same stack frame and explicitly disconnected before the function returns.
Stability/UX concern: waitLoop.exec(QEventLoop::ExcludeUserInputEvents) blocks user input processing in Dolphin for up to 1000ms per "copy private link" click while waiting for the client's reply. That's a real, if bounded, UI freeze on every invocation (not just the old-client/timeout case) — worth reducing the timeout or making it async/non-modal if possible.
Cross-repo dependency risk (blocking): This depends on GET_PRIVATE_LINK, added in owncloud/client PR #12535, which this same automated review flagged with a stability: Block finding — the client-side handler captures a raw SocketListener* in an async completion lambda, risking a use-after-free if the socket disconnects before the reply arrives (exactly the kind of disconnect this 1-second wait window makes more likely to be hit in practice, e.g. if Dolphin/the plugin is torn down mid-wait). Recommend holding this PR until the client-side UAF is fixed, to avoid shipping a shell-integration feature that can crash the sync daemon.
Platform API / syscalls: QApplication::clipboard()/QClipboard usage is standard Qt, appropriate here. No new unsafe syscalls.
REUSE: Additive changes to existing licensed files; no new files.
Verdict
Changes requested (pending the upstream client-side fix)
🤖 Automated review by Claude Code (memory-safety · platform-API · REUSE)
Generated by Claude Code
Problem
On native Wayland sessions the ownCloud daemon has no compositor surface, so
QClipboard::setText()is silently dropped. Copy private link to clipboard neverworks on Wayland from the Dolphin context menu.
Solution
When the session is Wayland (
WAYLAND_DISPLAYset orXDG_SESSION_TYPE=wayland), theplugin replaces the
COPY_PRIVATE_LINKaction handler: it sendsGET_PRIVATE_LINK:<file>to the client (a new socket command in owncloud/client) and waits up to 1 s for
PRIVATE_LINK:<url>. The URL is then written viaQApplication::clipboard()->setText()from within the Dolphin process, which has a valid Wayland surface.
If no response arrives within the timeout (old client), the clipboard is left unchanged —
same as the current broken behaviour, with no crash or user-visible error.
Requires: owncloud/client PR for
GET_PRIVATE_LINKcommand.Testing
"Copy private link to clipboard" → clipboard contains the URL ✓