VBoxClientClipboard.cpp revision 2e79616cdb94a9f801a368bc0b31a6a7dc7f20dd
/** $Id$ */
/** @file
* VBoxClient - Shared Slipboard Dispatcher, Darwin.
*/
/*
* Copyright (C) 2007-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <iprt/critsect.h>
#include <VBox/VBoxGuestLib.h>
#include "VBoxClientInternal.h"
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/** Host clipboard connection client ID */
static uint32_t g_u32ClientId;
/* Guest clipboard reference */
static PasteboardRef g_PasteboardRef;
/* Dispatcher tharead handle */
/* Pasteboard polling tharead handle */
/* Flag that indicates whether or not dispatcher and Pasteboard polling threada should stop */
static bool volatile g_fShouldStop;
/* Barrier for Pasteboard */
static RTCRITSECT g_critsect;
/*******************************************************************************
* Local Macros *
*******************************************************************************/
#define VBOXCLIENT_SERVICE_NAME "clipboard"
/*******************************************************************************
* Local Function Prototypes *
*******************************************************************************/
static int vbclClipboardStop(void);
/**
* Clipboard dispatcher function.
*
* Forwards cliproard content between host and guest.
*
* @param ThreadSelf Unused parameter.
* @param pvUser Unused parameter.
*
* @return IPRT status code.
*/
{
bool fQuit = false;
/*
* Block all signals for this thread. Only the main thread will handle signals.
*/
{
int rc;
if (RT_SUCCESS(rc))
{
switch (Msg)
{
/* The host is terminating */
fQuit = true;
break;
/* The host needs data in the specified format */
break;
/* The host has announced available clipboard formats */
break;
default:
RTThreadSleep(1000);
}
}
else
{
RTThreadSleep(1000);
}
}
return VINF_SUCCESS;
}
/**
* Clipboard dispatcher function.
*
* Forwards cliproard content between host and guest.
*
* @param ThreadSelf Unused parameter.
* @param pvUser Unused parameter.
*
* @return IPRT status code.
*/
{
/*
* Block all signals for this thread. Only the main thread will handle signals.
*/
while (!ASMAtomicReadBool(&g_fShouldStop))
{
int rc;
if (fSyncFlags & kPasteboardModified)
{
if (RT_FAILURE(rc))
{
}
else
{
}
}
/* Check pasteboard every 200 ms */
RTThreadSleep(200);
}
return VINF_SUCCESS;
}
/**
* Initialize host and guest clipboards, start clipboard dispatcher loop.
*
* @return IPRT status code.
*/
static int vbclClipboardStart(void)
{
int rc;
if (RT_FAILURE(rc))
return VERR_GENERAL_FAILURE;
if (RT_SUCCESS(rc))
{
{
/* Start dispatcher loop */
ASMAtomicWriteBool(&g_fShouldStop, false);
(void *)NULL,
0,
if (RT_SUCCESS(rc))
{
/* Start dispatcher loop */
ASMAtomicWriteBool(&g_fShouldStop, false);
(void *)NULL,
0,
if (RT_SUCCESS(rc))
return VINF_SUCCESS;
/* Stop dispatcher thread */
ASMAtomicWriteBool(&g_fShouldStop, true);
}
}
else
{
}
}
else
{
}
return rc;
}
/**
* Release host and guest clipboards, stop clipboard dispatcher loop.
*
* @return IPRT status code.
*/
static int vbclClipboardStop(void)
{
int rc;
if (RT_SUCCESS(rc))
g_u32ClientId = 0;
else
if (g_PasteboardRef)
{
}
/* Stop dispatcher thread */
ASMAtomicWriteBool(&g_fShouldStop, true);
if (RT_FAILURE(rc))
/* Stop Pasteboard polling thread */
if (RT_FAILURE(rc))
return rc;
}
/* Clipboard service struct */
{
/* pszName */
/* pfnStart */
/* pfnStop */
};