VirtualBox

Changeset 106808 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Oct 31, 2024 2:20:11 PM (3 months ago)
Author:
vboxsync
Message:

Additions: Linux/Wayland: Add customizable prefix to IPC server sock name to destinguish between clipboard and DnD IPC sockets, bugref:10796.

Location:
trunk/src/VBox/Additions/x11/VBoxClient
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/VBoxClient/vboxwl.cpp

    r106790 r106808  
    534534
    535535/**
     536 * Get IPC server socket name prefix depending on session type.
     537 *
     538 * @returns Prefix name or NULL if session type is unknown.
     539 */
     540static const char *vboxwl_ipc_srv_name_prefix(void)
     541{
     542    const char *pcszPrefix;
     543
     544    switch (g_enmSessionType)
     545    {
     546        case VBCL_WL_CLIPBOARD_SESSION_TYPE_COPY_TO_GUEST:
     547        case VBCL_WL_CLIPBOARD_SESSION_TYPE_ANNOUNCE_TO_HOST:
     548        case VBCL_WL_CLIPBOARD_SESSION_TYPE_COPY_TO_HOST:
     549        {
     550            pcszPrefix = VBOXWL_SRV_NAME_PREFIX_CLIP;
     551            break;
     552        }
     553
     554        default:
     555            pcszPrefix = NULL;
     556    }
     557
     558    return pcszPrefix;
     559}
     560
     561/**
    536562 * Connect to VBoxClient service.
    537563 *
     
    543569    int rc;
    544570    char szIpcServerName[128];
     571    const char *pcszPrefix = vboxwl_ipc_srv_name_prefix();
    545572
    546573    AssertPtrReturn(phIpcSession, VERR_INVALID_PARAMETER);
    547 
    548     rc = vbcl_wayland_hlp_gtk_ipc_srv_name(szIpcServerName, sizeof(szIpcServerName));
     574    AssertPtrReturn(pcszPrefix, VERR_INVALID_POINTER);
     575
     576    rc = vbcl_wayland_hlp_gtk_ipc_srv_name(pcszPrefix, szIpcServerName, sizeof(szIpcServerName));
    549577    if (RT_SUCCESS(rc))
    550578        rc = RTLocalIpcSessionConnect(phIpcSession, szIpcServerName, 0);
  • trunk/src/VBox/Additions/x11/VBoxClient/wayland-helper-gtk.cpp

    r106807 r106808  
    8383    /** Local IPC server object. */
    8484    RTLOCALIPCSERVER                        hIpcServer;
     85
     86    /** IPC server socket name prefix. */
     87    const char                              *pcszIpcSockPrefix;
    8588} vbox_wl_gtk_ctx_t;
    8689
     
    337340    char szIpcServerName[128];
    338341
     342    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     343    AssertPtrReturn(pCtx->pcszIpcSockPrefix, VERR_INVALID_POINTER);
     344
    339345    RTThreadUserSignal(hThreadSelf);
    340346
    341347    VBClLogVerbose(1, "starting IPC\n");
    342348
    343     rc = vbcl_wayland_hlp_gtk_ipc_srv_name(szIpcServerName, sizeof(szIpcServerName));
     349    rc = vbcl_wayland_hlp_gtk_ipc_srv_name(pCtx->pcszIpcSockPrefix, szIpcServerName, sizeof(szIpcServerName));
    344350
    345351    if (RT_SUCCESS(rc))
     
    429435
    430436    RT_ZERO(g_GtkClipCtx);
     437
     438    /* Set IPC server socket name prefix before server is started. */
     439    g_GtkClipCtx.pcszIpcSockPrefix = VBOXWL_SRV_NAME_PREFIX_CLIP;
    431440
    432441    return vbcl_wayland_thread_start(&g_GtkClipCtx.Thread, vbcl_wayland_hlp_gtk_worker, "wl-gtk-ipc", &g_GtkClipCtx);
  • trunk/src/VBox/Additions/x11/VBoxClient/wayland-helper-ipc.cpp

    r106790 r106808  
    4545#include "wayland-helper-ipc.h"
    4646
    47 RTDECL(int) vbcl_wayland_hlp_gtk_ipc_srv_name(char *szBuf, size_t cbBuf)
     47RTDECL(int) vbcl_wayland_hlp_gtk_ipc_srv_name(const char *szNamePrefix, char *szBuf, size_t cbBuf)
    4848{
    4949    int rc;
     
    5353    struct passwd *pwd;
    5454
    55     AssertReturn(RT_VALID_PTR(szBuf), VERR_INVALID_PARAMETER);
     55    AssertPtrReturn(szNamePrefix, VERR_INVALID_POINTER);
     56    AssertPtrReturn(szBuf, VERR_INVALID_POINTER);
    5657    AssertReturn(cbBuf > 0, VERR_INVALID_PARAMETER);
    5758
     
    6061
    6162    rc = RTStrCat(szBuf, cbBuf, "GtkHlpIpcServer-");
     63    if (RT_SUCCESS(rc))
     64        rc = RTStrCat(szBuf, cbBuf, szNamePrefix);
     65    if (RT_SUCCESS(rc))
     66        rc = RTStrCat(szBuf, cbBuf, "-");
    6267    if (RT_SUCCESS(rc))
    6368        rc = RTLinuxSysFsReadStrFile(pszActiveTTY, sizeof(pszActiveTTY) - 1 /* reserve last byte for string termination */,
  • trunk/src/VBox/Additions/x11/VBoxClient/wayland-helper-ipc.h

    r106790 r106808  
    6060/** Limit maximum log verbosity level for popup tool. */
    6161#define VBOXWL_VERBOSITY_MAX            (5)
     62
     63/** IPC server socket name prefixes. */
     64#define VBOXWL_SRV_NAME_PREFIX_CLIP     "clip"
    6265
    6366/** Arguments to vboxwl tool. */
     
    415418 * This function should be used by both IPC server and client code
    416419 * in order to connect one to another. Output string will be in
    417  * format: GtkHlpIpcServer-<active tty>-<user name>.
     420 * format: GtkHlpIpcServer-<prefix>--<active tty>-<user name>.
    418421 *
    419422 * @returns     IPRT status code.
    420  * @param       szBuf   Where to store generated name string.
    421  * @param       cbBuf   Size of buffer.
     423 * @param       szNamePrefix    Name prefix.
     424 * @param       szBuf           Where to store generated name string.
     425 * @param       cbBuf           Size of buffer.
    422426 */
    423 RTDECL(int) vbcl_wayland_hlp_gtk_ipc_srv_name(char *szBuf, size_t cbBuf);
     427RTDECL(int) vbcl_wayland_hlp_gtk_ipc_srv_name(const char *szNamePrefix, char *szBuf, size_t cbBuf);
    424428
    425429#endif /* !GA_INCLUDED_SRC_x11_VBoxClient_wayland_helper_ipc_h */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette