Changeset 7241 in vbox for trunk/src/VBox/HostServices
- Timestamp:
- Mar 3, 2008 2:24:56 PM (17 years ago)
- Location:
- trunk/src/VBox/HostServices/SharedClipboard
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedClipboard/darwin-pasteboard.cpp
r7162 r7241 16 16 */ 17 17 18 /// @todo: same as defined in VBoxClipboardSvc.h19 /// @todo r-bird: why don't you include it?20 #define VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT 0x0121 #define VBOX_SHARED_CLIPBOARD_FMT_BITMAP 0x0222 #define VBOX_SHARED_CLIPBOARD_FMT_HTML 0x0423 24 18 #include <Carbon/Carbon.h> 25 19 … … 30 24 #define LOG_GROUP LOG_GROUP_HGCM 31 25 #include "VBox/log.h" 26 #include "VBox/HostServices/VBoxClipboardSvc.h" 32 27 #include "clipboard-helper.h" 33 28 29 /* For debugging */ 34 30 //#define SHOW_CLIPBOARD_CONTENT 35 31 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 */ 38 39 int initPasteboard (PasteboardRef *pPasteboardRef) 39 40 { … … 46 47 } 47 48 49 /** 50 * Release the reference to the global pasteboard. 51 * 52 * @param pPasteboardRef Reference to the global pasteboard. 53 */ 48 54 void destroyPasteboard (PasteboardRef *pPasteboardRef) 49 55 { … … 52 58 } 53 59 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 */ 70 int queryNewPasteboardFormats (PasteboardRef pPasteboard, uint32_t *pfFormats) 71 { 72 Log (("queryNewPasteboardFormats\n")); 57 73 58 74 OSStatus err = noErr; … … 71 87 return VINF_SUCCESS; 72 88 73 /* The id of the first element in the past board */89 /* The id of the first element in the pasteboard */ 74 90 int rc = VERR_NOT_SUPPORTED; 75 91 PasteboardItemID itemID; … … 101 117 } 102 118 103 Log (("query PasteboardFormats: rc = %02X\n", rc));119 Log (("queryNewPasteboardFormats: rc = %02X\n", rc)); 104 120 return rc; 105 121 } 106 122 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 */ 107 135 int readFromPasteboard (PasteboardRef pPasteboard, uint32_t fFormat, void *pv, uint32_t cb, uint32_t *pcbActual) 108 136 { 109 Log (("readFromPast board: fFormat = %02X\n", fFormat));137 Log (("readFromPasteboard: fFormat = %02X\n", fFormat)); 110 138 111 139 OSStatus err = noErr; … … 120 148 return VINF_SUCCESS; 121 149 122 /* The id of the first element in the past board */150 /* The id of the first element in the pasteboard */ 123 151 int rc = VERR_NOT_SUPPORTED; 124 152 PasteboardItemID itemID; … … 144 172 if (!(err = PasteboardCopyItemFlavorData (pPasteboard, itemID, CFSTR ("public.utf8-plain-text"), &outData))) 145 173 { 146 Log (("readFromPast board: clipboard content is utf-8\n"));174 Log (("readFromPasteboard: clipboard content is utf-8\n")); 147 175 rc = RTStrToUtf16 ((const char*)CFDataGetBytePtr (outData), &pwszTmp); 148 176 } … … 156 184 { 157 185 RTUtf16Free (pwszTmp); 158 Log (("readFromPast board: clipboard conversion failed. vboxClipboardUtf16GetWinSize returned %Vrc. Abandoning.\n", rc));186 Log (("readFromPasteboard: clipboard conversion failed. vboxClipboardUtf16GetWinSize returned %Vrc. Abandoning.\n", rc)); 159 187 AssertRCReturn (rc, rc); 160 188 } … … 170 198 { 171 199 RTUtf16Free (pwszTmp); 172 Log (("readFromPast board: clipboard conversion failed. vboxClipboardUtf16LinToWin() returned %Vrc. Abandoning.\n", rc));200 Log (("readFromPasteboard: clipboard conversion failed. vboxClipboardUtf16LinToWin() returned %Vrc. Abandoning.\n", rc)); 173 201 AssertRCReturn (rc, rc); 174 202 } 175 203 #ifdef SHOW_CLIPBOARD_CONTENT 176 Log (("readFromPast board: clipboard content: %ls\n", static_cast <PRTUTF16> (pv)));204 Log (("readFromPasteboard: clipboard content: %ls\n", static_cast <PRTUTF16> (pv))); 177 205 #endif 178 206 } … … 183 211 } 184 212 185 Log (("readFromPast board: rc = %02X\n", rc));213 Log (("readFromPasteboard: rc = %02X\n", rc)); 186 214 return rc; 187 215 } 188 216 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 */ 189 228 int writeToPasteboard (PasteboardRef pPasteboard, void *pv, uint32_t cb, uint32_t fFormat) 190 229 { 191 230 Log (("writeToPasteboard: fFormat = %02X\n", fFormat)); 192 231 193 /* Clear the past board */232 /* Clear the pasteboard */ 194 233 if (PasteboardClear (pPasteboard)) 195 234 return VERR_NOT_SUPPORTED; … … 253 292 /* Create a CData object which we could pass to the pasteboard */ 254 293 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)))) 256 295 { 257 296 /* Put the Utf-8 version to the pasteboard */ -
trunk/src/VBox/HostServices/SharedClipboard/darwin-pasteboard.h
r7117 r7241 25 25 void destroyPasteboard (PasteboardRef *pPasteboardRef); 26 26 27 int query PasteboardFormats (PasteboardRef pPasteboard, uint32_t *pfFormats);27 int queryNewPasteboardFormats (PasteboardRef pPasteboard, uint32_t *pfFormats); 28 28 int readFromPasteboard (PasteboardRef pPasteboard, uint32_t fFormat, void *pv, uint32_t cb, uint32_t *pcbActual); 29 29 int writeToPasteboard (PasteboardRef pPasteboard, void *pv, uint32_t cb, uint32_t fFormat); -
trunk/src/VBox/HostServices/SharedClipboard/darwin.cpp
r7163 r7241 23 23 24 24 #include "VBoxClipboard.h" 25 /* We do the work in a separate cpp file because26 * of the conflicting typedef "OSType". This is27 * defined in Carbon and in VBox/ostypes.h also. */28 25 #include "darwin-pasteboard.h" 29 26 … … 50 47 * @returns IPRT status code (ignored). 51 48 * @param pCtx The context. 52 *53 * @todo r=bird: This function does not check if something has _changed_ like indicated by54 * the name. It will instead notify the client every 200ms as long as something55 * is on the clipboard. When the clipboard is cleared it will do nothing.56 * I somehow cannot think that this intentional behavior...57 49 */ 58 50 static int vboxClipboardChanged (VBOXCLIPBOARDCONTEXT *pCtx) … … 63 55 uint32_t fFormats = 0; 64 56 /* Retrieve the formats currently in the clipboard and supported by vbox */ 65 int rc = query PasteboardFormats (pCtx->pasteboard, &fFormats);57 int rc = queryNewPasteboardFormats (pCtx->pasteboard, &fFormats); 66 58 67 59 if (fFormats > 0)
Note:
See TracChangeset
for help on using the changeset viewer.