darwin-pasteboard.cpp revision 04582cbe4711c5c860680c6cb8d8df1800de2019
904ef975124106054684a976dfb30f70372372e1vboxsync/* $Id$ */
904ef975124106054684a976dfb30f70372372e1vboxsync/** @file
904ef975124106054684a976dfb30f70372372e1vboxsync * Shared Clipboard: Mac OS X host implementation.
904ef975124106054684a976dfb30f70372372e1vboxsync */
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync/*
c7814cf6e1240a519cbec0441e033d0e2470ed00vboxsync * Includes contributions from Fran�ois Revol
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * Copyright (C) 2008-2012 Oracle Corporation
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
904ef975124106054684a976dfb30f70372372e1vboxsync * available from http://www.virtualbox.org. This file is free software;
904ef975124106054684a976dfb30f70372372e1vboxsync * you can redistribute it and/or modify it under the terms of the GNU
904ef975124106054684a976dfb30f70372372e1vboxsync * General Public License (GPL) as published by the Free Software
904ef975124106054684a976dfb30f70372372e1vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
904ef975124106054684a976dfb30f70372372e1vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
904ef975124106054684a976dfb30f70372372e1vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
904ef975124106054684a976dfb30f70372372e1vboxsync */
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync#define LOG_GROUP LOG_GROUP_HGCM
904ef975124106054684a976dfb30f70372372e1vboxsync#include <Carbon/Carbon.h>
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync#include <iprt/mem.h>
904ef975124106054684a976dfb30f70372372e1vboxsync#include <iprt/assert.h>
904ef975124106054684a976dfb30f70372372e1vboxsync#include "iprt/err.h"
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync#include "VBox/log.h"
904ef975124106054684a976dfb30f70372372e1vboxsync#include "VBox/HostServices/VBoxClipboardSvc.h"
904ef975124106054684a976dfb30f70372372e1vboxsync#include "VBox/GuestHost/clipboard-helper.h"
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync/* For debugging */
904ef975124106054684a976dfb30f70372372e1vboxsync//#define SHOW_CLIPBOARD_CONTENT
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync/**
904ef975124106054684a976dfb30f70372372e1vboxsync * Initialize the global pasteboard and return a reference to it.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * @param pPasteboardRef Reference to the global pasteboard.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * @returns IPRT status code.
904ef975124106054684a976dfb30f70372372e1vboxsync */
904ef975124106054684a976dfb30f70372372e1vboxsyncint initPasteboard(PasteboardRef *pPasteboardRef)
904ef975124106054684a976dfb30f70372372e1vboxsync{
904ef975124106054684a976dfb30f70372372e1vboxsync int rc = VINF_SUCCESS;
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync if (PasteboardCreate(kPasteboardClipboard, pPasteboardRef))
904ef975124106054684a976dfb30f70372372e1vboxsync rc = VERR_NOT_SUPPORTED;
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync return rc;
904ef975124106054684a976dfb30f70372372e1vboxsync}
904ef975124106054684a976dfb30f70372372e1vboxsync
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync/**
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * Release the reference to the global pasteboard.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync *
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * @param pPasteboardRef Reference to the global pasteboard.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync */
d544fe535c163a24bf8cd831b39264da292b8adfvboxsyncvoid destroyPasteboard(PasteboardRef *pPasteboardRef)
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync{
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync CFRelease(*pPasteboardRef);
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync *pPasteboardRef = NULL;
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync}
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync/**
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * Inspect the global pasteboard for new content. Check if there is some type
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * that is supported by vbox and return it.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync *
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * @param pPasteboardRef Reference to the global pasteboard.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * @param pfFormats Pointer for the bit combination of the
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * supported types.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * @param pbChanged True if something has changed after the
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * last call.
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync *
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync * @returns IPRT status code. (Always VINF_SUCCESS atm.)
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync */
d544fe535c163a24bf8cd831b39264da292b8adfvboxsyncint queryNewPasteboardFormats(PasteboardRef pPasteboard, uint32_t *pfFormats, bool *pfChanged)
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync{
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync Log(("queryNewPasteboardFormats\n"));
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync
d544fe535c163a24bf8cd831b39264da292b8adfvboxsync OSStatus err = noErr;
904ef975124106054684a976dfb30f70372372e1vboxsync *pfChanged = true;
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync PasteboardSyncFlags syncFlags;
904ef975124106054684a976dfb30f70372372e1vboxsync /* Make sure all is in sync */
904ef975124106054684a976dfb30f70372372e1vboxsync syncFlags = PasteboardSynchronize(pPasteboard);
904ef975124106054684a976dfb30f70372372e1vboxsync /* If nothing changed return */
904ef975124106054684a976dfb30f70372372e1vboxsync if (!(syncFlags & kPasteboardModified))
904ef975124106054684a976dfb30f70372372e1vboxsync {
904ef975124106054684a976dfb30f70372372e1vboxsync *pfChanged = false;
904ef975124106054684a976dfb30f70372372e1vboxsync return VINF_SUCCESS;
904ef975124106054684a976dfb30f70372372e1vboxsync }
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync /* Are some items in the pasteboard? */
904ef975124106054684a976dfb30f70372372e1vboxsync ItemCount itemCount;
904ef975124106054684a976dfb30f70372372e1vboxsync err = PasteboardGetItemCount(pPasteboard, &itemCount);
904ef975124106054684a976dfb30f70372372e1vboxsync if (itemCount < 1)
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync return VINF_SUCCESS;
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync /* The id of the first element in the pasteboard */
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync int rc = VINF_SUCCESS;
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync PasteboardItemID itemID;
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync if (!(err = PasteboardGetItemIdentifier(pPasteboard, 1, &itemID)))
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync {
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync /* Retrieve all flavors in the pasteboard, maybe there
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * is something we can use. */
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync CFArrayRef flavorTypeArray;
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync if (!(err = PasteboardCopyItemFlavors(pPasteboard, itemID, &flavorTypeArray)))
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync {
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync CFIndex flavorCount;
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync flavorCount = CFArrayGetCount(flavorTypeArray);
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync for (CFIndex flavorIndex = 0; flavorIndex < flavorCount; flavorIndex++)
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync {
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync CFStringRef flavorType;
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync flavorType = static_cast <CFStringRef>(CFArrayGetValueAtIndex(flavorTypeArray,
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync flavorIndex));
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync /* Currently only unicode supported */
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync if (UTTypeConformsTo(flavorType, kUTTypeUTF8PlainText) ||
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync UTTypeConformsTo(flavorType, kUTTypeUTF16PlainText))
904ef975124106054684a976dfb30f70372372e1vboxsync {
904ef975124106054684a976dfb30f70372372e1vboxsync Log(("Unicode flavor detected.\n"));
904ef975124106054684a976dfb30f70372372e1vboxsync *pfFormats |= VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT;
904ef975124106054684a976dfb30f70372372e1vboxsync }
904ef975124106054684a976dfb30f70372372e1vboxsync else if (UTTypeConformsTo(flavorType, kUTTypeBMP))
904ef975124106054684a976dfb30f70372372e1vboxsync {
4fb518cb2eadd86a2bf117501cd38b05dde47745vboxsync Log(("BMP flavor detected.\n"));
4fb518cb2eadd86a2bf117501cd38b05dde47745vboxsync *pfFormats |= VBOX_SHARED_CLIPBOARD_FMT_BITMAP;
4fb518cb2eadd86a2bf117501cd38b05dde47745vboxsync }
4fb518cb2eadd86a2bf117501cd38b05dde47745vboxsync }
4fb518cb2eadd86a2bf117501cd38b05dde47745vboxsync CFRelease(flavorTypeArray);
4fb518cb2eadd86a2bf117501cd38b05dde47745vboxsync }
904ef975124106054684a976dfb30f70372372e1vboxsync }
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync Log(("queryNewPasteboardFormats: rc = %02X\n", rc));
904ef975124106054684a976dfb30f70372372e1vboxsync return rc;
904ef975124106054684a976dfb30f70372372e1vboxsync}
904ef975124106054684a976dfb30f70372372e1vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync/**
904ef975124106054684a976dfb30f70372372e1vboxsync * Read content from the host clipboard and write it to the internal clipboard
904ef975124106054684a976dfb30f70372372e1vboxsync * structure for further processing.
904ef975124106054684a976dfb30f70372372e1vboxsync *
904ef975124106054684a976dfb30f70372372e1vboxsync * @param pPasteboardRef Reference to the global pasteboard.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param fFormats The format type which should be read.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param pv The destination buffer.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param cb The size of the destination buffer.
904ef975124106054684a976dfb30f70372372e1vboxsync * @param pcbActual The size which is needed to transfer the content.
904ef975124106054684a976dfb30f70372372e1vboxsync *
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync * @returns IPRT status code.
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync */
97566036db1dc1dba46ed21be4e147c728fd1027vboxsyncint readFromPasteboard(PasteboardRef pPasteboard, uint32_t fFormat, void *pv, uint32_t cb, uint32_t *pcbActual)
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync{
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync Log(("readFromPasteboard: fFormat = %02X\n", fFormat));
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync OSStatus err = noErr;
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync /* Make sure all is in sync */
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync PasteboardSynchronize(pPasteboard);
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync /* Are some items in the pasteboard? */
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync ItemCount itemCount;
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync err = PasteboardGetItemCount(pPasteboard, &itemCount);
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync if (itemCount < 1)
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync return VINF_SUCCESS;
97566036db1dc1dba46ed21be4e147c728fd1027vboxsync
904ef975124106054684a976dfb30f70372372e1vboxsync /* The id of the first element in the pasteboard */
904ef975124106054684a976dfb30f70372372e1vboxsync int rc = VERR_NOT_SUPPORTED;
904ef975124106054684a976dfb30f70372372e1vboxsync PasteboardItemID itemID;
904ef975124106054684a976dfb30f70372372e1vboxsync if (!(err = PasteboardGetItemIdentifier(pPasteboard, 1, &itemID)))
904ef975124106054684a976dfb30f70372372e1vboxsync {
904ef975124106054684a976dfb30f70372372e1vboxsync /* The guest request unicode */
904ef975124106054684a976dfb30f70372372e1vboxsync if (fFormat & VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT)
904ef975124106054684a976dfb30f70372372e1vboxsync {
904ef975124106054684a976dfb30f70372372e1vboxsync CFDataRef outData;
904ef975124106054684a976dfb30f70372372e1vboxsync PRTUTF16 pwszTmp = NULL;
904ef975124106054684a976dfb30f70372372e1vboxsync /* Try utf-16 first */
904ef975124106054684a976dfb30f70372372e1vboxsync if (!(err = PasteboardCopyItemFlavorData(pPasteboard, itemID, kUTTypeUTF16PlainText, &outData)))
904ef975124106054684a976dfb30f70372372e1vboxsync {
904ef975124106054684a976dfb30f70372372e1vboxsync Log(("Clipboard content is utf-16\n"));
904ef975124106054684a976dfb30f70372372e1vboxsync
PRTUTF16 pwszString = (PRTUTF16)CFDataGetBytePtr(outData);
if (pwszString)
rc = RTUtf16DupEx(&pwszTmp, pwszString, 0);
else
rc = VERR_INVALID_PARAMETER;
}
/* Second try is utf-8 */
else
if (!(err = PasteboardCopyItemFlavorData(pPasteboard, itemID, kUTTypeUTF8PlainText, &outData)))
{
Log(("readFromPasteboard: clipboard content is utf-8\n"));
const char *pszString = (const char *)CFDataGetBytePtr(outData);
if (pszString)
rc = RTStrToUtf16(pszString, &pwszTmp);
else
rc = VERR_INVALID_PARAMETER;
}
if (pwszTmp)
{
/* Check how much longer will the converted text will be. */
size_t cwSrc = RTUtf16Len(pwszTmp);
size_t cwDest;
rc = vboxClipboardUtf16GetWinSize(pwszTmp, cwSrc, &cwDest);
if (RT_FAILURE(rc))
{
RTUtf16Free(pwszTmp);
Log(("readFromPasteboard: clipboard conversion failed. vboxClipboardUtf16GetWinSize returned %Rrc. Abandoning.\n", rc));
AssertRCReturn(rc, rc);
}
/* Set the actually needed data size */
*pcbActual = cwDest * 2;
/* Return success state */
rc = VINF_SUCCESS;
/* Do not copy data if the dst buffer is not big enough. */
if (*pcbActual <= cb)
{
rc = vboxClipboardUtf16LinToWin(pwszTmp, RTUtf16Len(pwszTmp), static_cast <PRTUTF16>(pv), cb / 2);
if (RT_FAILURE(rc))
{
RTUtf16Free(pwszTmp);
Log(("readFromPasteboard: clipboard conversion failed. vboxClipboardUtf16LinToWin() returned %Rrc. Abandoning.\n", rc));
AssertRCReturn(rc, rc);
}
#ifdef SHOW_CLIPBOARD_CONTENT
Log(("readFromPasteboard: clipboard content: %ls\n", static_cast <PRTUTF16>(pv)));
#endif
}
/* Free the temp string */
RTUtf16Free(pwszTmp);
}
}
/* The guest request BITMAP */
else if (fFormat & VBOX_SHARED_CLIPBOARD_FMT_BITMAP)
{
CFDataRef outData;
const void *pTmp = NULL;
size_t cbTmpSize;
/* Get the data from the pasteboard */
if (!(err = PasteboardCopyItemFlavorData(pPasteboard, itemID, kUTTypeBMP, &outData)))
{
Log(("Clipboard content is BMP\n"));
pTmp = CFDataGetBytePtr(outData);
cbTmpSize = CFDataGetLength(outData);
}
if (pTmp)
{
const void *pDib;
size_t cbDibSize;
rc = vboxClipboardBmpGetDib(pTmp, cbTmpSize, &pDib, &cbDibSize);
if (RT_FAILURE(rc))
{
rc = VERR_NOT_SUPPORTED;
Log(("readFromPasteboard: unknown bitmap format. vboxClipboardBmpGetDib returned %Rrc. Abandoning.\n", rc));
AssertRCReturn(rc, rc);
}
*pcbActual = cbDibSize;
/* Return success state */
rc = VINF_SUCCESS;
/* Do not copy data if the dst buffer is not big enough. */
if (*pcbActual <= cb)
{
memcpy(pv, pDib, cbDibSize);
#ifdef SHOW_CLIPBOARD_CONTENT
Log(("readFromPasteboard: clipboard content bitmap %d bytes\n", cbDibSize));
#endif
}
}
}
}
Log(("readFromPasteboard: rc = %02X\n", rc));
return rc;
}
/**
* Write clipboard content to the host clipboard from the internal clipboard
* structure.
*
* @param pPasteboardRef Reference to the global pasteboard.
* @param pv The source buffer.
* @param cb The size of the source buffer.
* @param fFormats The format type which should be written.
*
* @returns IPRT status code.
*/
int writeToPasteboard(PasteboardRef pPasteboard, void *pv, uint32_t cb, uint32_t fFormat)
{
Log(("writeToPasteboard: fFormat = %02X\n", fFormat));
/* Clear the pasteboard */
if (PasteboardClear(pPasteboard))
return VERR_NOT_SUPPORTED;
/* Make sure all is in sync */
PasteboardSynchronize(pPasteboard);
int rc = VERR_NOT_SUPPORTED;
/* Handle the unicode text */
if (fFormat & VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT)
{
PRTUTF16 pwszSrcText = static_cast <PRTUTF16>(pv);
size_t cwSrc = cb / 2;
size_t cwDest = 0;
/* How long will the converted text be? */
rc = vboxClipboardUtf16GetLinSize(pwszSrcText, cwSrc, &cwDest);
if (RT_FAILURE(rc))
{
Log(("writeToPasteboard: clipboard conversion failed. vboxClipboardUtf16GetLinSize returned %Rrc. Abandoning.\n", rc));
AssertRCReturn(rc, rc);
}
/* Empty clipboard? Not critical */
if (cwDest == 0)
{
Log(("writeToPasteboard: received empty clipboard data from the guest, returning false.\n"));
return VINF_SUCCESS;
}
/* Allocate the necessary memory */
PRTUTF16 pwszDestText = static_cast <PRTUTF16>(RTMemAlloc(cwDest * 2));
if (pwszDestText == NULL)
{
Log(("writeToPasteboard: failed to allocate %d bytes\n", cwDest * 2));
return VERR_NO_MEMORY;
}
/* Convert the EOL */
rc = vboxClipboardUtf16WinToLin(pwszSrcText, cwSrc, pwszDestText, cwDest);
if (RT_FAILURE(rc))
{
Log(("writeToPasteboard: clipboard conversion failed. vboxClipboardUtf16WinToLin() returned %Rrc. Abandoning.\n", rc));
RTMemFree(pwszDestText);
AssertRCReturn(rc, rc);
}
CFDataRef textData = NULL;
/* Item id is 1. Nothing special here. */
PasteboardItemID itemId = (PasteboardItemID)1;
/* Create a CData object which we could pass to the pasteboard */
if ((textData = CFDataCreate(kCFAllocatorDefault,
reinterpret_cast<UInt8*>(pwszDestText), cwDest * 2)))
{
/* Put the Utf-16 version to the pasteboard */
PasteboardPutItemFlavor(pPasteboard, itemId,
kUTTypeUTF16PlainText,
textData, 0);
}
/* Create a Utf-8 version */
char *pszDestText;
rc = RTUtf16ToUtf8(pwszDestText, &pszDestText);
if (RT_SUCCESS(rc))
{
/* Create a CData object which we could pass to the pasteboard */
if ((textData = CFDataCreate(kCFAllocatorDefault,
reinterpret_cast<UInt8*>(pszDestText), strlen(pszDestText))))
{
/* Put the Utf-8 version to the pasteboard */
PasteboardPutItemFlavor(pPasteboard, itemId,
kUTTypeUTF8PlainText,
textData, 0);
}
RTStrFree(pszDestText);
}
RTMemFree(pwszDestText);
rc = VINF_SUCCESS;
}
/* Handle the bitmap */
else if (fFormat & VBOX_SHARED_CLIPBOARD_FMT_BITMAP)
{
/* Create a full BMP from it */
void *pBmp;
size_t cbBmpSize;
CFDataRef bmpData = NULL;
/* Item id is 1. Nothing special here. */
PasteboardItemID itemId = (PasteboardItemID)1;
rc = vboxClipboardDibToBmp(pv, cb, &pBmp, &cbBmpSize);
if (RT_SUCCESS(rc))
{
/* Create a CData object which we could pass to the pasteboard */
if ((bmpData = CFDataCreate(kCFAllocatorDefault,
reinterpret_cast<UInt8*>(pBmp), cbBmpSize)))
{
/* Put the Utf-8 version to the pasteboard */
PasteboardPutItemFlavor(pPasteboard, itemId,
kUTTypeBMP,
bmpData, 0);
}
RTMemFree(pBmp);
}
rc = VINF_SUCCESS;
}
else
rc = VERR_NOT_IMPLEMENTED;
Log(("writeToPasteboard: rc = %02X\n", rc));
return rc;
}