VBoxClientClipboardGuestToHost.cpp revision 2e79616cdb94a9f801a368bc0b31a6a7dc7f20dd
/** $Id$ */
/** @file
* VBoxClient - Shared Clipboard Guest -> Host copying, 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 <signal.h>
#include <stdlib.h>
#include <iprt/initterm.h>
#include <VBox/VBoxGuestLib.h>
#include "VBoxClientInternal.h"
/**
* Walk through pasteboard items and report currently available item types.
*
* @param pPasteboard Reference to guest Pasteboard.
* @returns Available formats bit field.
*/
{
{ \
CFRelease(flavorData); \
}
{
{
{
{
{
VBoxClientVerbose(3, "Found: %s, size: %d\n", (char *)CFStringGetCStringPtr(flavorType, kCFStringEncodingMacRoman), (int)CFDataGetLength(flavorData1));
}
}
}
#endif /* CLIPBOARD_DUMP_CONTENT_FORMATS */
}
}
return fFormats;
}
/**
* Search for content of specified type in guest clipboard buffer and put
* it into newly allocated buffer.
*
* @param pPasteboard Guest PasteBoard reference.
* @param fFormat Data formats we are looking for.
* @param ppvData Where to return pointer to the received data. M
* @param pcbData Where to return the size of the data.
* @param pcbAlloc Where to return the size of the memory block
* *ppvData pointes to. (Usually greater than *cbData
* because the allocation is page aligned.)
* @returns IPRT status code.
*/
static int vbclClipboardReadGuestData(PasteboardRef pPasteboard, CFStringRef sFormat, void **ppvData, uint32_t *pcbData,
{
/* Walk through all the items in PasteBoard in order to find
that one that correcponds to requested data format. */
{
/* Now, get the item's flavors that corresponds to requested type. */
{
if (flavorDataPtr && cbData > 0)
{
if (pvData)
}
/* Found first matching item, no more search. */
break;
}
}
/* Found match */
if (pvData)
{
return VINF_SUCCESS;
}
return VERR_INVALID_PARAMETER;
}
/**
* Release resources occupied by vbclClipboardReadGuestData().
*/
{
}
/**
* Pass data to host.
*/
static int vbclClipboardHostPasteData(uint32_t u32ClientId, uint32_t u32Format, const void *pvData, uint32_t cbData)
{
/* Allow empty buffers */
if (cbData == 0)
return VbglR3ClipboardWriteData(u32ClientId, u32Format, (void *)pvData, cbData); /** @todo r=bird: Why on earth does a write function like VbglR3ClipboardWriteData take a non-const parameter? */
}
/**
* Paste text data into host clipboard.
*
* @param u32ClientId Host clipboard connection.
* @param pwszData UTF-16 encoded string.
* @param cbData The length of the string, in bytes, probably
* including a terminating zero.
*/
{
if (RT_SUCCESS(rc))
return rc;
}
/**
* Paste a bitmap onto the host clipboard.
*
* @param u32ClientId Host clipboard connection.
* @param pvData The bitmap data.
* @param cbData The size of the bitmap.
*/
{
const void *pvDib;
return rc;
}
/**
* Read guest's clipboard buffer and forward its content to host.
*
* @param u32ClientId Host clipboard connection.
* @param pPasteboard Guest PasteBoard reference.
* @param fFormats List of data formats (bit field) received from host.
*
* @returns IPRT status code.
*/
{
int rc = VINF_SUCCESS;
/* Walk across all item(s) formats */
while (fFormatsLeft)
{
{
/* First, try to get UTF16 encoded buffer */
if (RT_SUCCESS(rc))
{
if (RT_FAILURE(rc))
}
else /* Failed to get UTF16 buffer */
{
/* Then, try to get UTF8 encoded buffer */
if (RT_SUCCESS(rc))
{
if (RT_FAILURE(rc))
}
}
/* Finally, we got UTF16 encoded buffer */
if (RT_SUCCESS(rc))
{
if (pUtf16Str)
{
}
}
else
{
/* No data found or error occurred: send empty buffer */
}
}
else if (fFormatsLeft & VBOX_SHARED_CLIPBOARD_FMT_BITMAP)
{
if (RT_SUCCESS(rc))
{
}
else
{
/* No data found or error occurred: send empty buffer */
}
}
else if (fFormatsLeft & VBOX_SHARED_CLIPBOARD_FMT_HTML)
{
if (RT_SUCCESS(rc))
{
}
else
{
/* No data found or error occurred: send empty buffer */
}
}
else
{
break;
}
}
return rc; /** @todo r=bird: If there are multiple formats available, which rc is returned here? Does it matter? */
}