Skip to content

fix: use GET_PRIVATE_LINK socket command for Wayland clipboard support#5

Open
DeepDiver1975 wants to merge 1 commit into
masterfrom
fix/wayland-clipboard-get-private-link
Open

fix: use GET_PRIVATE_LINK socket command for Wayland clipboard support#5
DeepDiver1975 wants to merge 1 commit into
masterfrom
fix/wayland-clipboard-get-private-link

Conversation

@DeepDiver1975

Copy link
Copy Markdown
Member

Problem

On native Wayland sessions the ownCloud daemon has no compositor surface, so
QClipboard::setText() is silently dropped. Copy private link to clipboard never
works on Wayland from the Dolphin context menu.

Solution

When the session is Wayland (WAYLAND_DISPLAY set or XDG_SESSION_TYPE=wayland), the
plugin replaces the COPY_PRIVATE_LINK action handler: it sends GET_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 via QApplication::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_LINK command.

Testing

  • KDE Plasma on Wayland with Dolphin: right-click synced file →
    "Copy private link to clipboard" → clipboard contains the URL ✓
  • X11 session: existing behaviour unchanged ✓
  • Old client (no GET_PRIVATE_LINK): event loop times out cleanly ✓

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>
@DeepDiver1975
DeepDiver1975 force-pushed the fix/wayland-clipboard-get-private-link branch from dd04074 to e79ddb8 Compare May 11, 2026 21:27

@dj4oC dj4oC left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants