vbox的更動 59840 路徑 trunk/src/VBox/Additions
- 時間撮記:
- 2016-2-26 上午10:43:26 (9 年 以前)
- 位置:
- trunk/src/VBox/Additions/WINNT/VBoxTray
- 檔案:
-
- 修改 2 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnD.h
r58336 r59840 5 5 6 6 /* 7 * Copyright (C) 2013-201 5Oracle Corporation7 * Copyright (C) 2013-2016 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 112 112 protected: 113 113 114 /** Reference count of this object. */ 114 115 LONG mRefCount; 116 /** Pointer to parent proxy window. */ 115 117 VBoxDnDWnd *mpWndParent; 118 /** Current drag effect. */ 116 119 DWORD mdwCurEffect; 120 /** Current action to perform on the host. */ 117 121 uint32_t muCurAction; 118 122 }; … … 140 144 protected: 141 145 146 static void DumpFormats(IDataObject *pDataObject); 142 147 static DWORD GetDropEffect(DWORD grfKeyState, DWORD dwAllowedEffects); 143 148 void reset(void); … … 145 150 public: 146 151 147 void *DataMutableRaw(void) { return mpvData; }148 uint32_t DataSize(void){ return mcbData; }149 RTCString Formats(void) ;152 void *DataMutableRaw(void) const { return mpvData; } 153 size_t DataSize(void) const { return mcbData; } 154 RTCString Formats(void) const; 150 155 int WaitForDrop(RTMSINTERVAL msTimeout); 151 156 152 157 protected: 153 158 159 /** Reference count of this object. */ 154 160 LONG mRefCount; 161 /** Pointer to parent proxy window. */ 155 162 VBoxDnDWnd *mpWndParent; 163 /** Current drop effect. */ 156 164 DWORD mdwCurEffect; 157 /** Copy of the data object's FORMATETC struct.165 /** Copy of the data object's current FORMATETC struct. 158 166 * Note: We don't keep the pointer of the DVTARGETDEVICE here! */ 159 167 FORMATETC mFormatEtc; 160 RTCString mFormats; 168 /** Stringified data object's formats string. */ 169 RTCString mstrFormats; 170 /** Pointer to actual format data. */ 161 171 void *mpvData; 162 uint32_t mcbData; 172 /** Size (in bytes) of format data. */ 173 size_t mcbData; 174 /** Event for waiting on the "drop" event. */ 163 175 RTSEMEVENT hEventDrop; 176 /** Result of the drop event. */ 164 177 int mDroppedRc; 165 178 }; -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnDDropTarget.cpp
r58336 r59840 5 5 6 6 /* 7 * Copyright (C) 2014-201 5Oracle Corporation7 * Copyright (C) 2014-2016 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 93 93 } 94 94 95 /* static */ 96 void VBoxDnDDropTarget::DumpFormats(IDataObject *pDataObject) 97 { 98 AssertPtrReturnVoid(pDataObject); 99 100 /* Enumerate supported source formats. This shouldn't happen too often 101 * on day to day use, but still keep it in here. */ 102 IEnumFORMATETC *pEnumFormats; 103 HRESULT hr2 = pDataObject->EnumFormatEtc(DATADIR_GET, &pEnumFormats); 104 if (SUCCEEDED(hr2)) 105 { 106 LogRel(("DnD: The following formats were offered to us:\n")); 107 108 FORMATETC curFormatEtc; 109 while (pEnumFormats->Next(1, &curFormatEtc, 110 NULL /* pceltFetched */) == S_OK) 111 { 112 WCHAR wszCfName[128]; /* 128 chars should be enough, rest will be truncated. */ 113 hr2 = GetClipboardFormatNameW(curFormatEtc.cfFormat, wszCfName, 114 sizeof(wszCfName) / sizeof(WCHAR)); 115 LogRel(("\tcfFormat=%RI16 (%s), tyMed=%RI32, dwAspect=%RI32, strCustomName=%ls, hr=%Rhrc\n", 116 curFormatEtc.cfFormat, 117 VBoxDnDDataObject::ClipboardFormatToString(curFormatEtc.cfFormat), 118 curFormatEtc.tymed, 119 curFormatEtc.dwAspect, 120 wszCfName, hr2)); 121 } 122 123 pEnumFormats->Release(); 124 } 125 } 126 95 127 /* 96 128 * IDropTarget methods. … … 110 142 /** @todo At the moment we only support one DnD format at a time. */ 111 143 112 /* Try different formats. CF_HDROP is the most common one, so start 113 * with this. */ 144 #ifdef DEBUG 145 VBoxDnDDropTarget::DumpFormats(pDataObject); 146 #endif 147 148 /* Try different formats. 149 * CF_HDROP is the most common one, so start with this. */ 114 150 FORMATETC fmtEtc = { CF_HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; 115 151 HRESULT hr = pDataObject->QueryGetData(&fmtEtc); 116 152 if (hr == S_OK) 117 153 { 118 m Formats = "text/uri-list";154 mstrFormats = "text/uri-list"; 119 155 } 120 156 else … … 128 164 if (hr == S_OK) 129 165 { 130 m Formats = "text/plain;charset=utf-8";166 mstrFormats = "text/plain;charset=utf-8"; 131 167 } 132 168 else … … 138 174 if (hr == S_OK) 139 175 { 140 m Formats = "text/plain;charset=utf-8";176 mstrFormats = "text/plain;charset=utf-8"; 141 177 } 142 178 else 143 179 { 144 180 LogFlowFunc(("CF_TEXT not wanted, hr=%Rhrc\n", hr)); 145 fmtEtc.cfFormat = 0; /* Mark it to not supported. */ 181 fmtEtc.cfFormat = 0; /* Set it to non-supported. */ 182 183 /* Clean up. */ 184 reset(); 146 185 } 147 186 } … … 156 195 /* Make a copy of the FORMATETC structure so that we later can 157 196 * use this for comparrison and stuff. */ 158 /** Note:The DVTARGETDEVICE member only is a shallow copy for now! */197 /** @todo The DVTARGETDEVICE member only is a shallow copy for now! */ 159 198 memcpy(&mFormatEtc, &fmtEtc, sizeof(FORMATETC)); 160 199 … … 174 213 { 175 214 LogRel(("DnD: Drag and drop format is not supported by VBoxTray\n")); 176 177 /* Enumerate supported source formats. This shouldn't happen too often 178 * on day to day use, but still keep it in here. */ 179 IEnumFORMATETC *pEnumFormats; 180 HRESULT hr2 = pDataObject->EnumFormatEtc(DATADIR_GET, &pEnumFormats); 181 if (SUCCEEDED(hr2)) 182 { 183 LogRel(("DnD: The following formats were offered to us:\n")); 184 185 FORMATETC curFormatEtc; 186 while (pEnumFormats->Next(1, &curFormatEtc, 187 NULL /* pceltFetched */) == S_OK) 188 { 189 WCHAR wszCfName[128]; /* 128 chars should be enough, rest will be truncated. */ 190 hr2 = GetClipboardFormatNameW(curFormatEtc.cfFormat, wszCfName, 191 sizeof(wszCfName) / sizeof(WCHAR)); 192 LogRel(("\tcfFormat=%RI16 (%s), tyMed=%RI32, dwAspect=%RI32, strCustomName=%ls, hr=%Rhrc\n", 193 curFormatEtc.cfFormat, 194 VBoxDnDDataObject::ClipboardFormatToString(curFormatEtc.cfFormat), 195 curFormatEtc.tymed, 196 curFormatEtc.dwAspect, 197 wszCfName, hr2)); 198 } 199 200 pEnumFormats->Release(); 201 } 202 215 VBoxDnDDropTarget::DumpFormats(pDataObject); 203 216 break; 204 217 } … … 209 222 } 210 223 211 LogFlowFunc(("Returning cfFormat=%RI16, pdwEffect=%ld, hr=%Rhrc\n",212 fmtEtc.cfFormat, *pdwEffect, hr));224 LogFlowFunc(("Returning mstrFormats=%s, cfFormat=%RI16, pdwEffect=%ld, hr=%Rhrc\n", 225 mstrFormats.c_str(), fmtEtc.cfFormat, *pdwEffect, hr)); 213 226 return hr; 214 227 } … … 256 269 { 257 270 AssertPtrReturn(pDataObject, E_INVALIDARG); 258 AssertPtrReturn(pdwEffect, E_INVALIDARG); 259 260 #ifdef DEBUG 271 AssertPtrReturn(pdwEffect, E_INVALIDARG); 272 261 273 LogFlowFunc(("mFormatEtc.cfFormat=%RI16 (%s), pDataObject=0x%p, grfKeyState=0x%x, x=%ld, y=%ld\n", 262 274 mFormatEtc.cfFormat, VBoxDnDDataObject::ClipboardFormatToString(mFormatEtc.cfFormat), 263 275 pDataObject, grfKeyState, pt.x, pt.y)); 264 #endif 276 265 277 HRESULT hr = S_OK; 266 278 267 279 if (mFormatEtc.cfFormat) /* Did we get a supported format yet? */ 268 280 { 269 /* Make sure the data object's data format is still the same 270 * as we got it in DragEnter(). */ 281 /* Make sure the data object's data format is still valid. */ 271 282 hr = pDataObject->QueryGetData(&mFormatEtc); 272 283 AssertMsg(SUCCEEDED(hr), 273 ("Data format changed between DragEnter() and Drop(), cfFormat=%RI16 (%s), hr=%Rhrc\n", 274 mFormatEtc.cfFormat, VBoxDnDDataObject::ClipboardFormatToString(mFormatEtc.cfFormat), 275 hr)); 284 ("Data format changed to invalid between DragEnter() and Drop(), cfFormat=%RI16 (%s), hr=%Rhrc\n", 285 mFormatEtc.cfFormat, VBoxDnDDataObject::ClipboardFormatToString(mFormatEtc.cfFormat), hr)); 276 286 } 277 287 … … 313 323 if (RT_SUCCESS(rc)) 314 324 { 315 /* Second stage: Do the actual copying of the data object's data, 316 based on the storage medium type. */ 325 /* 326 * Second stage: Do the actual copying of the data object's data, 327 * based on the storage medium type. 328 */ 317 329 switch (mFormatEtc.cfFormat) 318 330 { 331 case CF_TEXT: 332 /* Fall through is intentional. */ 319 333 case CF_UNICODETEXT: 320 334 { 321 335 AssertPtr(pvData); 322 336 size_t cbSize = GlobalSize(pvData); 323 LogFlowFunc(("CF_ UNICODETEXT 0x%p got %zu bytes\n", pvData, cbSize));337 LogFlowFunc(("CF_TEXT/CF_UNICODETEXT 0x%p got %zu bytes\n", pvData, cbSize)); 324 338 if (cbSize) 325 339 { 326 340 char *pszText = NULL; 327 rc = RTUtf16ToUtf8((PCRTUTF16)pvData, &pszText); 341 342 rc = mFormatEtc.cfFormat == CF_TEXT 343 /* ANSI codepage -> UTF-8 */ 344 ? RTStrCurrentCPToUtf8(&pszText, (char *)pvData) 345 /* Unicode -> UTF-8 */ 346 : RTUtf16ToUtf8((PCRTUTF16)pvData, &pszText); 347 328 348 if (RT_SUCCESS(rc)) 329 349 { 330 mpvData = (void *)pszText; 331 mcbData = strlen(pszText) + 1; /* Include termination. */ 332 333 /* Note: Don't free data of pszText, mpvData now owns it. */ 334 } 335 } 336 337 break; 338 } 339 340 case CF_TEXT: 341 { 342 AssertPtr(pvData); 343 size_t cbSize = GlobalSize(pvData); 344 LogFlowFunc(("CF_TEXT 0x%p got %zu bytes\n", pvData, cbSize)); 345 if (cbSize) 346 { 347 char *pszText = NULL; 348 rc = RTStrCurrentCPToUtf8(&pszText, (char *)pvData); 349 if (RT_SUCCESS(rc)) 350 { 351 mpvData = (void *)pszText; 352 mcbData = strlen(pszText) + 1; /* Include termination. */ 353 354 /* Note: Don't free data of pszText, mpvData now owns it. */ 350 AssertPtr(pszText); 351 352 size_t cbText = strlen(pszText) + 1; /* Include termination. */ 353 354 mpvData = RTMemDup((void *)pszText, cbText); 355 mcbData = cbText; 356 357 RTStrFree(pszText); 358 pszText = NULL; 355 359 } 356 360 } … … 429 433 if (RT_SUCCESS(rc)) 430 434 { 431 LogFlowFunc(("\tFile: %s (cchFile=%RU32)\n", 432 pszFile, cchFile)); 433 435 LogFlowFunc(("\tFile: %s (cchFile=%RU32)\n", pszFile, cchFile)); 434 436 rc = RTStrAAppendExN(&pszFiles, 1 /* cPairs */, 435 437 pszFile, cchFile); … … 491 493 /* Note: Should not happen due to the checks done in DragEnter(). */ 492 494 AssertMsgFailed(("Format of type %RI16 (%s) not supported\n", 493 mFormatEtc.cfFormat, 494 VBoxDnDDataObject::ClipboardFormatToString(mFormatEtc.cfFormat))); 495 mFormatEtc.cfFormat, VBoxDnDDataObject::ClipboardFormatToString(mFormatEtc.cfFormat))); 495 496 hr = DV_E_CLIPFORMAT; /* Set special hr for OLE. */ 496 497 break; … … 580 581 581 582 mcbData = 0; 583 582 584 RT_ZERO(mFormatEtc); 583 m Formats = "";584 } 585 586 RTCString VBoxDnDDropTarget::Formats(void) 587 { 588 return m Formats;585 mstrFormats = ""; 586 } 587 588 RTCString VBoxDnDDropTarget::Formats(void) const 589 { 590 return mstrFormats; 589 591 } 590 592
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器