VirtualBox

Ignore:
Timestamp:
Nov 29, 2019 4:08:08 PM (5 years ago)
Author:
vboxsync
Message:

Shared Clipboard/VBoxClient: Initial commit for experimental FUSE support.

File:
1 edited

Legend:

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

    r82266 r82286  
    2323#include <iprt/asm.h>
    2424#include <iprt/assert.h>
     25#ifdef VBOX_WITH_SHARED_CLIPBOARD_FUSE
     26# include <iprt/dir.h>
     27#endif
    2528#include <iprt/initterm.h>
    2629#include <iprt/mem.h>
     
    3740#include "VBoxClient.h"
    3841
     42#ifdef VBOX_WITH_SHARED_CLIPBOARD_FUSE
     43# include "clipboard-fuse.h"
     44#endif
    3945
    4046/*********************************************************************************************************************************
    4147*   Global Variables                                                                                                             *
    4248*********************************************************************************************************************************/
     49
     50#ifdef VBOX_WITH_SHARED_CLIPBOARD_FUSE
     51typedef struct _SHCLCTXFUSE
     52{
     53    RTTHREAD Thread;
     54} SHCLCTXFUSE;
     55#endif /* VBOX_WITH_SHARED_CLIPBOARD_FUSE */
    4356
    4457/**
     
    5265    /** Associated transfer data. */
    5366    SHCLTRANSFERCTX  TransferCtx;
     67# ifdef VBOX_WITH_SHARED_CLIPBOARD_FUSE
     68    SHCLCTXFUSE      FUSE;
     69# endif
    5470#endif
    5571    /** X11 clipboard context. */
     
    430446}
    431447
     448#ifdef VBOX_WITH_SHARED_CLIPBOARD_FUSE
     449static DECLCALLBACK(int) vboxClipoardFUSEThread(RTTHREAD hThreadSelf, void *pvUser)
     450{
     451    RT_NOREF(hThreadSelf, pvUser);
     452
     453    VbglR3Init();
     454
     455    LogFlowFuncEnter();
     456
     457    RTThreadUserSignal(hThreadSelf);
     458
     459    char szExecPath[RTPATH_MAX];
     460    RTProcGetExecutablePath(szExecPath, sizeof(szExecPath));
     461
     462    char szTempDir[RTPATH_MAX];
     463    RTStrPrintf(szTempDir, sizeof(szTempDir), "VBoxSharedClipboard-XXXXXXXX");
     464
     465    int rc = RTDirCreateTemp(szTempDir, 0700);
     466    if (RT_SUCCESS(rc))
     467    {
     468        char *paArgs[2];
     469        paArgs[0] = szExecPath;
     470        paArgs[1] = szTempDir;
     471
     472        rc = ShClFuseMain(2 /* argc */, paArgs);
     473    }
     474
     475    LogFlowFuncLeaveRC(rc);
     476    return rc;
     477}
     478
     479static int vboxClipboardFUSEStart()
     480{
     481    LogFlowFuncEnter();
     482
     483    PSHCLCONTEXT pCtx = &g_Ctx;
     484
     485    int rc = RTThreadCreate(&pCtx->FUSE.Thread, vboxClipoardFUSEThread, &pCtx->FUSE, 0,
     486                            RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE, "SHCLFUSE");
     487    if (RT_SUCCESS(rc))
     488        rc = RTThreadUserWait(pCtx->FUSE.Thread, 30 * 1000);
     489
     490    LogFlowFuncLeaveRC(rc);
     491    return rc;
     492}
     493
     494static int vboxClipboardFUSEStop()
     495{
     496    LogFlowFuncEnter();
     497
     498    PSHCLCONTEXT pCtx = &g_Ctx;
     499
     500    int rcThread;
     501    int rc = RTThreadWait(pCtx->FUSE.Thread, 1000, &rcThread);
     502
     503    LogFlowFuncLeaveRC(rc);
     504    return rc;
     505}
     506#endif /* VBOX_WITH_SHARED_CLIPBOARD_FUSE */
     507
    432508static const char *getName()
    433509{
     
    448524    if (RT_SUCCESS(rc))
    449525    {
    450         rc = vboxClipboardMain();
     526#ifdef VBOX_WITH_SHARED_CLIPBOARD_FUSE
     527        rc = vboxClipboardFUSEStart();
     528        if (RT_SUCCESS(rc))
     529        {
     530#endif
     531            rc = vboxClipboardMain();
     532
     533#ifdef VBOX_WITH_SHARED_CLIPBOARD_FUSE
     534            int rc2 = vboxClipboardFUSEStop();
     535            if (RT_SUCCESS(rc))
     536                rc = rc2;
     537        }
     538#endif
    451539    }
    452540
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