VirtualBox

Changeset 7241 in vbox for trunk/src/VBox/HostServices


Ignore:
Timestamp:
Mar 3, 2008 2:24:56 PM (17 years ago)
Author:
vboxsync
Message:

Mac OS X: Added some documentation to the pasteboard methods. Removed the outstanding todo issues.

Location:
trunk/src/VBox/HostServices/SharedClipboard
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedClipboard/darwin-pasteboard.cpp

    r7162 r7241  
    1616 */
    1717
    18 /// @todo: same as defined in VBoxClipboardSvc.h
    19 /// @todo r-bird: why don't you include it?
    20 #define VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT 0x01
    21 #define VBOX_SHARED_CLIPBOARD_FMT_BITMAP      0x02
    22 #define VBOX_SHARED_CLIPBOARD_FMT_HTML        0x04
    23 
    2418#include <Carbon/Carbon.h>
    2519
     
    3024#define LOG_GROUP LOG_GROUP_HGCM
    3125#include "VBox/log.h"
     26#include "VBox/HostServices/VBoxClipboardSvc.h"
    3227#include "clipboard-helper.h"
    3328
     29/* For debugging */
    3430//#define SHOW_CLIPBOARD_CONTENT
    3531
    36 /** @todo r=bird: document these functions */
    37 
     32/**
     33 * Initialize the global pasteboard and return a reference to it.
     34 *
     35 * @param pPasteboardRef Reference to the global pasteboard.
     36 *
     37 * @returns IPRT status code.
     38 */
    3839int initPasteboard (PasteboardRef *pPasteboardRef)
    3940{
     
    4647}
    4748
     49/**
     50 * Release the reference to the global pasteboard.
     51 *
     52 * @param pPasteboardRef Reference to the global pasteboard.
     53 */
    4854void destroyPasteboard (PasteboardRef *pPasteboardRef)
    4955{
     
    5258}
    5359
    54 int queryPasteboardFormats (PasteboardRef pPasteboard, uint32_t *pfFormats)
    55 {
    56     Log (("queryPasteboardFormats\n"));
     60/**
     61 * Inspect the global pasteboard for new content. Check if there is some type
     62 * that is supported by vbox and return it.
     63 *
     64 * @param   pPasteboardRef Reference to the global pasteboard.
     65 * @param   pfFormats      Pointer for the bit combination of the
     66 *                         supported types.
     67 *
     68 * @returns IPRT status code.
     69 */
     70int queryNewPasteboardFormats (PasteboardRef pPasteboard, uint32_t *pfFormats)
     71{
     72    Log (("queryNewPasteboardFormats\n"));
    5773
    5874    OSStatus err = noErr;
     
    7187        return VINF_SUCCESS;
    7288
    73     /* The id of the first element in the pastboard */
     89    /* The id of the first element in the pasteboard */
    7490    int rc = VERR_NOT_SUPPORTED;
    7591    PasteboardItemID itemID;
     
    101117    }
    102118
    103     Log (("queryPasteboardFormats: rc = %02X\n", rc));
     119    Log (("queryNewPasteboardFormats: rc = %02X\n", rc));
    104120    return rc;
    105121}
    106122
     123/**
     124 * Read content from the host clipboard and write it to the internal clipboard
     125 * structure for further processing.
     126 *
     127 * @param   pPasteboardRef Reference to the global pasteboard.
     128 * @param   fFormats       The format type which should be read.
     129 * @param   pv             The destination buffer.
     130 * @param   cb             The size of the destination buffer.
     131 * @param   pcbActual      The size which is needed to transfer the content.
     132 *
     133 * @returns IPRT status code.
     134 */
    107135int readFromPasteboard (PasteboardRef pPasteboard, uint32_t fFormat, void *pv, uint32_t cb, uint32_t *pcbActual)
    108136{
    109     Log (("readFromPastboard: fFormat = %02X\n", fFormat));
     137    Log (("readFromPasteboard: fFormat = %02X\n", fFormat));
    110138
    111139    OSStatus err = noErr;
     
    120148        return VINF_SUCCESS;
    121149
    122     /* The id of the first element in the pastboard */
     150    /* The id of the first element in the pasteboard */
    123151    int rc = VERR_NOT_SUPPORTED;
    124152    PasteboardItemID itemID;
     
    144172                if (!(err = PasteboardCopyItemFlavorData (pPasteboard, itemID, CFSTR ("public.utf8-plain-text"), &outData)))
    145173                {
    146                     Log (("readFromPastboard: clipboard content is utf-8\n"));
     174                    Log (("readFromPasteboard: clipboard content is utf-8\n"));
    147175                    rc = RTStrToUtf16 ((const char*)CFDataGetBytePtr (outData), &pwszTmp);
    148176                }
     
    156184                {
    157185                    RTUtf16Free (pwszTmp);
    158                     Log (("readFromPastboard: clipboard conversion failed.  vboxClipboardUtf16GetWinSize returned %Vrc.  Abandoning.\n", rc));
     186                    Log (("readFromPasteboard: clipboard conversion failed.  vboxClipboardUtf16GetWinSize returned %Vrc.  Abandoning.\n", rc));
    159187                    AssertRCReturn (rc, rc);
    160188                }
     
    170198                    {
    171199                        RTUtf16Free (pwszTmp);
    172                         Log (("readFromPastboard: clipboard conversion failed.  vboxClipboardUtf16LinToWin() returned %Vrc.  Abandoning.\n", rc));
     200                        Log (("readFromPasteboard: clipboard conversion failed.  vboxClipboardUtf16LinToWin() returned %Vrc.  Abandoning.\n", rc));
    173201                        AssertRCReturn (rc, rc);
    174202                    }
    175203#ifdef SHOW_CLIPBOARD_CONTENT
    176                     Log (("readFromPastboard: clipboard content: %ls\n", static_cast <PRTUTF16> (pv)));
     204                    Log (("readFromPasteboard: clipboard content: %ls\n", static_cast <PRTUTF16> (pv)));
    177205#endif
    178206                }
     
    183211    }
    184212
    185     Log (("readFromPastboard: rc = %02X\n", rc));
     213    Log (("readFromPasteboard: rc = %02X\n", rc));
    186214    return rc;
    187215}
    188216
     217/**
     218 * Write clipboard content to the host clipboard from the internal clipboard
     219 * structure.
     220 *
     221 * @param   pPasteboardRef Reference to the global pasteboard.
     222 * @param   pv             The source buffer.
     223 * @param   cb             The size of the source buffer.
     224 * @param   fFormats       The format type which should be written.
     225 *
     226 * @returns IPRT status code.
     227 */
    189228int writeToPasteboard (PasteboardRef pPasteboard, void *pv, uint32_t cb, uint32_t fFormat)
    190229{
    191230    Log (("writeToPasteboard: fFormat = %02X\n", fFormat));
    192231
    193     /* Clear the pastboard */
     232    /* Clear the pasteboard */
    194233    if (PasteboardClear (pPasteboard))
    195234        return VERR_NOT_SUPPORTED;
     
    253292            /* Create a CData object which we could pass to the pasteboard */
    254293            if ((textData = CFDataCreate (kCFAllocatorDefault,
    255                                           reinterpret_cast<UInt8*> (pszDestText), RTUtf16CalcUtf8Len (pwszDestText)))) /** @todo r=bird: why not strlen(pszDestText)? */
     294                                          reinterpret_cast<UInt8*> (pszDestText), strlen(pszDestText))))
    256295            {
    257296                /* Put the Utf-8 version to the pasteboard */
  • trunk/src/VBox/HostServices/SharedClipboard/darwin-pasteboard.h

    r7117 r7241  
    2525void destroyPasteboard (PasteboardRef *pPasteboardRef);
    2626
    27 int queryPasteboardFormats (PasteboardRef pPasteboard, uint32_t *pfFormats);
     27int queryNewPasteboardFormats (PasteboardRef pPasteboard, uint32_t *pfFormats);
    2828int readFromPasteboard (PasteboardRef pPasteboard, uint32_t fFormat, void *pv, uint32_t cb, uint32_t *pcbActual);
    2929int writeToPasteboard (PasteboardRef pPasteboard, void *pv, uint32_t cb, uint32_t fFormat);
  • trunk/src/VBox/HostServices/SharedClipboard/darwin.cpp

    r7163 r7241  
    2323
    2424#include "VBoxClipboard.h"
    25 /* We do the work in a separate cpp file because
    26  * of the conflicting typedef "OSType". This is
    27  * defined in Carbon and in VBox/ostypes.h also. */
    2825#include "darwin-pasteboard.h"
    2926
     
    5047 * @returns IPRT status code (ignored).
    5148 * @param   pCtx    The context.
    52  *
    53  * @todo r=bird: This function does not check if something has _changed_ like indicated by
    54  *               the name. It will instead notify the client every 200ms as long as something
    55  *               is on the clipboard. When the clipboard is cleared it will do nothing.
    56  *               I somehow cannot think that this intentional behavior...
    5749 */
    5850static int vboxClipboardChanged (VBOXCLIPBOARDCONTEXT *pCtx)
     
    6355    uint32_t fFormats = 0;
    6456    /* Retrieve the formats currently in the clipboard and supported by vbox */
    65     int rc = queryPasteboardFormats (pCtx->pasteboard, &fFormats);
     57    int rc = queryNewPasteboardFormats (pCtx->pasteboard, &fFormats);
    6658
    6759    if (fFormats > 0)
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