Changeset 55459 in vbox
- Timestamp:
- Apr 27, 2015 5:17:07 PM (9 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 3 edited
-
Additions/common/VBoxGuestLib/VBoxGuestR3LibDragAndDrop.cpp (modified) (6 diffs)
-
Additions/x11/VBoxClient/draganddrop.cpp (modified) (19 diffs)
-
Main/src-client/GuestDnDTargetImpl.cpp (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibDragAndDrop.cpp
r55422 r55459 223 223 224 224 static int vbglR3DnDHGProcessSendFileMessage(PVBGLR3GUESTDNDCMDCTX pCtx, 225 char *pszFilename,226 uint32_t cbFilename,227 uint32_t *pcbFilenameRecv,228 void *pvData,229 uint32_t cbData,230 uint32_t *pcbDataRecv,231 uint32_t *pfMode)225 char *pszFilename, 226 uint32_t cbFilename, 227 uint32_t *pcbFilenameRecv, 228 void *pvData, 229 uint32_t cbData, 230 uint32_t *pcbDataRecv, 231 uint32_t *pfMode) 232 232 { 233 233 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); … … 248 248 { 249 249 Msg.u.v1.pvName.SetPtr(pszFilename, cbFilename); 250 Msg.u.v1.cbName.SetUInt32( 0);250 Msg.u.v1.cbName.SetUInt32(cbFilename); 251 251 Msg.u.v1.pvData.SetPtr(pvData, cbData); 252 Msg.u.v1.cbData.SetUInt32( 0);252 Msg.u.v1.cbData.SetUInt32(cbData); 253 253 Msg.u.v1.fMode.SetUInt32(0); 254 254 … … 257 257 else 258 258 { 259 Msg.u.v2.uContext.SetUInt32(0); /** @todo Not used yet. */ 259 260 Msg.u.v2.pvData.SetPtr(pvData, cbData); 260 Msg.u.v2.cbData.SetUInt32( 0);261 262 Msg.hdr.cParms = 2;261 Msg.u.v2.cbData.SetUInt32(cbData); 262 263 Msg.hdr.cParms = 3; 263 264 } 264 265 … … 316 317 else 317 318 { 319 Msg.uContext.SetUInt32(0); /** @todo Not used yet. */ 318 320 Msg.pvName.SetPtr(pszFilename, cbFilename); 319 Msg.cbName.SetUInt32(0); 320 Msg.uContext.SetUInt32(0); /** @todo Not used yet. */ 321 Msg.cbName.SetUInt32(cbFilename); 321 322 Msg.uFlags.SetUInt32(0); 322 323 Msg.fMode.SetUInt32(0); … … 345 346 } 346 347 347 static int vbglR3DnDHGProcessURIMessages(PVBGLR3GUESTDNDCMDCTX pCtx,348 uint32_t *puScreenId,349 char *pszFormat,350 uint32_t cbFormat,351 uint32_t *pcbFormatRecv,352 void **ppvData,353 uint32_t cbData,354 size_t *pcbDataRecv)348 static int vbglR3DnDHGProcessURIMessages(PVBGLR3GUESTDNDCMDCTX pCtx, 349 uint32_t *puScreenId, 350 char *pszFormat, 351 uint32_t cbFormat, 352 uint32_t *pcbFormatRecv, 353 void **ppvData, 354 uint32_t cbData, 355 size_t *pcbDataRecv) 355 356 { 356 357 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); … … 475 476 &cbDataRecv, 476 477 &fMode); 477 LogFlowFunc(("HOST_DND_HG_SND_FILE pszPathName=%s, cbPathName=%RU32, pvData=0x%p, cbDataRecv=%RU32, fMode=0x%x, rc=%Rrc\n",478 LogFlowFunc(("HOST_DND_HG_SND_FILE_DATA pszPathName=%s, cbPathName=%RU32, pvData=0x%p, cbDataRecv=%RU32, fMode=0x%x, rc=%Rrc\n", 478 479 szPathName, cbPathName, pvTmpData, cbDataRecv, fMode, rc)); 479 480 -
trunk/src/VBox/Additions/x11/VBoxClient/draganddrop.cpp
r55422 r55459 335 335 ******************************************************************************/ 336 336 337 #ifdef DEBUG 338 # define VBOX_DND_FN_DECL_LOG(x) inline x 339 #else 340 # define VBOX_DND_FN_DECL_LOG(x) x 341 #endif 342 337 343 /* For now only one DragInstance will exits when the app is running. In the 338 344 * future the support for having more than one D&D operation supported at the … … 364 370 void uninit(void); 365 371 void reset(void); 372 373 /* Logging. */ 374 VBOX_DND_FN_DECL_LOG(void) logError(const char *pszFormat, ...); 366 375 367 376 /* X11 message processing. */ … … 628 637 if (!m_wndProxy) 629 638 { 639 LogRel(("DnD: Error creating proxy window\n")); 630 640 rc = VERR_GENERAL_FAILURE; 631 641 break; … … 654 664 LogFlowFuncLeaveRC(rc); 655 665 return rc; 666 } 667 668 VBOX_DND_FN_DECL_LOG(void) DragInstance::logError(const char *pszFormat, ...) 669 { 670 va_list args; 671 va_start(args, pszFormat); 672 char *psz = NULL; 673 RTStrAPrintfV(&psz, pszFormat, args); 674 va_end(args); 675 676 AssertPtr(psz); 677 LogFlowFunc(("%s", psz)); 678 LogRel2(("DnD: %s", psz)); 679 680 RTStrFree(psz); 656 681 } 657 682 … … 1089 1114 if ( m_mode != HG 1090 1115 || m_state != Dragging) 1116 { 1091 1117 return VERR_INVALID_STATE; 1118 } 1092 1119 1093 1120 int rc = VINF_SUCCESS; … … 1116 1143 1117 1144 if (RT_UNLIKELY(xrc != Success)) 1118 LogFlowThisFunc(("Error in getting the window property: %s\n", gX11->xErrorToString(xrc).c_str()));1145 logError("Error getting properties of cursor window=%#x: %s\n", wndCursor, gX11->xErrorToString(xrc).c_str()); 1119 1146 else 1120 1147 { 1121 1148 if (RT_UNLIKELY(pcData == NULL || fmt != 32 || cItems != 1)) 1122 LogFlowThisFunc(("Wrong properties pcData=%#x, iFmt=%u, cItems=%u\n", pcData, fmt, cItems));1149 LogFlowThisFunc(("Wrong properties: pcData=%#x, iFmt=%d, cItems=%ul\n", pcData, fmt, cItems)); 1123 1150 else 1124 1151 { 1125 1152 newVer = reinterpret_cast<long*>(pcData)[0]; 1126 LogFlowThisFunc(("wndCursor=%#x, XdndAware=% u\n", newVer));1153 LogFlowThisFunc(("wndCursor=%#x, XdndAware=%ld\n", wndCursor, newVer)); 1127 1154 } 1128 1155 … … 1135 1162 */ 1136 1163 if ( wndCursor != m_wndCur 1137 && m_curVer != -1)1164 && m_curVer != -1) 1138 1165 { 1139 1166 LogFlowThisFunc(("Leaving window=%#x\n", m_wndCur)); … … 1151 1178 xrc = XSendEvent(m_pDisplay, m_wndCur, False, NoEventMask, reinterpret_cast<XEvent*>(&m)); 1152 1179 if (RT_UNLIKELY(xrc == 0)) 1153 LogFlowThisFunc(("Error sending XA_XdndLeave to old window=%#x\n", m_wndCur));1180 logError("DnD: Error sending XA_XdndLeave to old window=%#x: %s\n", m_wndCur, gX11->xErrorToString(xrc).c_str()); 1154 1181 } 1155 1182 … … 1157 1184 * Do we have a new window which now is under the cursor? 1158 1185 */ 1159 if (wndCursor != m_wndCur && newVer != -1) 1186 if ( wndCursor != m_wndCur 1187 && newVer != -1) 1160 1188 { 1161 1189 LogFlowThisFunc(("Entering window=%#x\n", wndCursor)); … … 1182 1210 xrc = XSendEvent(m_pDisplay, wndCursor, False, NoEventMask, reinterpret_cast<XEvent*>(&m)); 1183 1211 if (RT_UNLIKELY(xrc == 0)) 1184 LogFlowThisFunc(("Error sending XA_XdndEnter to new window=%#x\n", wndCursor));1212 logError("Error sending XA_XdndEnter to new window=%#x: %s\n", wndCursor, gX11->xErrorToString(xrc).c_str()); 1185 1213 } 1186 1214 1187 1215 if (newVer != -1) 1188 1216 { 1189 LogFlowThisFunc(("Moving window=%#x, xPos=%RU32, yPos=%RU32\n", 1190 wndCursor, u32xPos, u32yPos)); 1217 LogFlowThisFunc(("Moving window=%#x, xPos=%RU32, yPos=%RU32\n", wndCursor, u32xPos, u32yPos)); 1191 1218 1192 1219 /* … … 1210 1237 xrc = XSendEvent(m_pDisplay, wndCursor, False, NoEventMask, reinterpret_cast<XEvent*>(&m)); 1211 1238 if (RT_UNLIKELY(xrc == 0)) 1212 LogFlowThisFunc(("Error sending XA_XdndPosition to window=%#x\n", wndCursor));1239 logError(("Error sending XA_XdndPosition to current window=%#x: %s\n", wndCursor, gX11->xErrorToString(xrc).c_str())); 1213 1240 } 1214 1241 … … 1251 1278 int xrc = XSendEvent(m_pDisplay, m_wndCur, False, NoEventMask, reinterpret_cast<XEvent*>(&m)); 1252 1279 if (RT_UNLIKELY(xrc == 0)) 1253 LogFlowThisFunc(("Error sending XA_XdndDrop to window=%#x\n", m_wndCur));1280 logError(("Error sending XA_XdndDrop to current window=%#x: %s\n", m_wndCur, gX11->xErrorToString(xrc).c_str())); 1254 1281 1255 1282 m_wndCur = None; … … 1310 1337 int xrc = XSendEvent(s.xselection.display, s.xselection.requestor, True, 0, &s); 1311 1338 if (RT_UNLIKELY(xrc == 0)) 1312 LogFlowThisFunc(("Error sending SelectionNotify event to wnd=%#x\n", s.xselection.requestor)); 1339 { 1340 logError(("Error sending SelectionNotify event to window=%#x: %s\n", 1341 s.xselection.requestor, gX11->xErrorToString(xrc).c_str())); 1342 } 1313 1343 1314 1344 return VINF_SUCCESS; … … 1418 1448 } 1419 1449 1420 /* Acknowledge the event by sending a Status msg back to the 1421 * window. */ 1450 /* 1451 * Acknowledge the event by sending a status message back to the window. 1452 */ 1422 1453 XClientMessageEvent m; 1423 1454 RT_ZERO(m); … … 1434 1465 False, 0, reinterpret_cast<XEvent*>(&m)); 1435 1466 if (RT_UNLIKELY(xRc == 0)) 1436 LogFlowThisFunc(("Error sending xEvent\n")); 1467 { 1468 logError(("Error sending enter XA_XdndStatus to current window=%#x: %s\n", 1469 m_wndCur, gX11->xErrorToString(xRc).c_str())); 1470 } 1437 1471 } 1438 1472 /* Did the source tell us where the cursor currently is? */ … … 1457 1491 False, 0, reinterpret_cast<XEvent*>(&m)); 1458 1492 if (RT_UNLIKELY(xRc == 0)) 1459 LogFlowThisFunc(("Error sending xEvent\n")); 1493 { 1494 logError(("Error sending position XA_XdndStatus to current window=%#x: %s\n", 1495 m_wndCur, gX11->xErrorToString(xRc).c_str())); 1496 } 1460 1497 } 1461 1498 else if (pEventClient->message_type == xAtom(XA_XdndLeave)) … … 1653 1690 int xrc = XSendEvent(m_pDisplay, wndSource, False, NoEventMask, reinterpret_cast<XEvent*>(&m)); 1654 1691 if (RT_UNLIKELY(xrc == 0)) 1655 LogFlowThisFunc(("Error sending cancel event\n")); 1692 { 1693 logError(("Error sending XA_XdndFinished to proxy window=%#x: %s\n", 1694 m_wndProxy, gX11->xErrorToString(xrc).c_str())); 1695 } 1656 1696 } 1657 1697 … … 1872 1912 } 1873 1913 1874 void DragInstance::setActionsWindowProperty(Window wndThis, 1875 const RTCList<Atom> &lstActions) const 1914 void DragInstance::setActionsWindowProperty(Window wndThis, const RTCList<Atom> &lstActions) const 1876 1915 { 1877 1916 if (lstActions.isEmpty()) … … 1890 1929 } 1891 1930 1892 void DragInstance::setFormatsWindowProperty(Window wndThis, 1893 Atom property) const 1931 void DragInstance::setFormatsWindowProperty(Window wndThis, Atom property) const 1894 1932 { 1895 1933 if (m_formats.isEmpty()) -
trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp
r55427 r55459 530 530 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 531 531 532 HRESULT hr ;532 HRESULT hr = S_OK; 533 533 int vrc; 534 534 … … 682 682 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 683 683 684 RTCString strPath = aFile.GetDestPath();685 if (strPath .isEmpty())684 RTCString strPathSrc = aFile.GetSourcePath(); 685 if (strPathSrc.isEmpty()) 686 686 return VERR_INVALID_PARAMETER; 687 687 … … 689 689 690 690 LogFlowFunc(("Sending \"%s\" (%RU32 bytes buffer) using protocol v%RU32 ...\n", 691 aFile.GetDestPath().c_str(), m_cbBlockSize, mData.mProtocolVersion)); 691 strPathSrc.c_str(), m_cbBlockSize, mData.mProtocolVersion)); 692 693 bool fOpen = aFile.IsOpen(); 694 if (!fOpen) 695 { 696 LogFlowFunc(("Opening \"%s\" ...\n", strPathSrc.c_str())); 697 rc = aFile.OpenEx(strPathSrc, DnDURIObject::File, DnDURIObject::Source, 698 RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE, 0 /* fFlags */); 699 } 692 700 693 701 bool fSendFileData = false; 694 if (mData.mProtocolVersion >= 2) 695 { 696 if (!aFile.IsOpen()) 697 { 698 rc = aFile.OpenEx(aFile.GetSourcePath(), DnDURIObject::File, DnDURIObject::Source, 699 RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE, 0 /* fFlags */); 700 if (RT_SUCCESS(rc)) 702 if (RT_SUCCESS(rc)) 703 { 704 if (mData.mProtocolVersion >= 2) 705 { 706 if (!fOpen) 701 707 { 702 708 /* … … 706 712 */ 707 713 pMsg->setType(DragAndDropSvc::HOST_DND_HG_SND_FILE_HDR); 708 pMsg->setNextUInt32(0); /* context ID */ 709 pMsg->setNextString(strPath.c_str()); /* pvName */ 710 pMsg->setNextUInt32((uint32_t)(strPath.length() + 1)); /* cbName */ 711 pMsg->setNextUInt32(0); /* uFlags */ 712 pMsg->setNextUInt32(aFile.GetMode()); /* fMode */ 713 pMsg->setNextUInt64(aFile.GetSize()); /* uSize */ 714 pMsg->setNextUInt32(0); /* context ID */ 715 rc = pMsg->setNextString(aFile.GetDestPath().c_str()); /* pvName */ 716 AssertRC(rc); 717 pMsg->setNextUInt32((uint32_t)(aFile.GetDestPath().length() + 1)); /* cbName */ 718 pMsg->setNextUInt32(0); /* uFlags */ 719 pMsg->setNextUInt32(aFile.GetMode()); /* fMode */ 720 pMsg->setNextUInt64(aFile.GetSize()); /* uSize */ 714 721 715 722 LogFlowFunc(("Sending file header ...\n")); 716 723 } 717 } 718 else 719 { 720 /* File header was sent, so only send the actual file data. */ 724 else 725 { 726 /* File header was sent, so only send the actual file data. */ 727 fSendFileData = true; 728 } 729 } 730 else /* Protocol v1. */ 731 { 732 /* Always send the file data, every time. */ 721 733 fSendFileData = true; 722 734 } 723 }724 else /* Protocol v1. */725 {726 /* Always send the file data, every time. */727 fSendFileData = true;728 735 } 729 736 … … 766 773 if (mData.mProtocolVersion <= 1) 767 774 { 768 pMsg->setNextUInt32(0); /* context ID */769 775 pMsg->setNextString(aFile.GetSourcePath().c_str()); /* pvName */ 770 776 pMsg->setNextUInt32((uint32_t)(aFile.GetSourcePath().length() + 1)); /* cbName */ 777 } 778 else 779 { 780 /* Protocol version 2 also sends the context ID. Currently unused. */ 781 pMsg->setNextUInt32(0); /* context ID */ 771 782 } 772 783 … … 869 880 AssertReturn(DragAndDropSvc::CB_MAGIC_DND_HG_GET_NEXT_HOST_MSG_DATA == pCBData->hdr.u32Magic, VERR_INVALID_PARAMETER); 870 881 882 LogFlowFunc(("pCBData->uMsg=%RU32, paParms=%p, cParms=%RU32\n", pCBData->uMsg, pCBData->paParms, pCBData->cParms)); 883 871 884 GuestDnDMsg *pMsg = pThis->nextMsg(); 872 885 if (pMsg) … … 884 897 if (RT_SUCCESS(rc)) 885 898 { 886 LogFlowFunc((" Sending uMsg=%RU32, cParms=%RU32 ...\n", uMsg, pCBData->cParms));899 LogFlowFunc(("Returning uMsg=%RU32\n", uMsg)); 887 900 rc = HGCM::Message::copyParms(pMsg->getCount(), pMsg->getParms(), pCBData->paParms); 888 901 if (RT_SUCCESS(rc)) … … 891 904 pThis->removeNext(); 892 905 } 906 else 907 LogFlowFunc(("Copying parameters failed with rc=%Rrc\n", rc)); 893 908 } 894 909 } … … 896 911 rc = VERR_NO_DATA; 897 912 898 LogFlowFunc((" Returning msg %RU32, rc=%Rrc\n", uMsg, rc));913 LogFlowFunc(("Processing next message ended with rc=%Rrc\n", rc)); 899 914 break; 900 915 } … … 992 1007 break; 993 1008 1009 pCtx->mURI.cbProcessed = 0; 1010 pCtx->mURI.cProcessed = 0; 1011 pCtx->mURI.cbToProcess = lstURI.TotalBytes(); 1012 994 1013 /* 995 1014 * The first message always is the meta info for the data. The meta … … 1044 1063 #undef UNREGISTER_CALLBACK 1045 1064 1065 /* Destroy temporary scratch buffer. */ 1046 1066 if (pvBuf) 1047 1067 RTMemFree(pvBuf); … … 1055 1075 int GuestDnDTarget::i_sendURIDataLoop(PSENDDATACTX pCtx, GuestDnDMsg *pMsg) 1056 1076 { 1057 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);1077 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 1058 1078 1059 1079 DnDURIList &lstURI = pCtx->mURI.lstURI; … … 1061 1081 int rc; 1062 1082 1063 uint64_t cbTotal = pCtx->mURI. lstURI.TotalBytes();1083 uint64_t cbTotal = pCtx->mURI.cbToProcess; 1064 1084 uint8_t uPercent = pCtx->mURI.cbProcessed * 100 / (cbTotal ? cbTotal : 1); 1065 Assert(uPercent <= 100);1066 1085 1067 1086 LogFlowFunc(("%RU64 / %RU64 -- %RU8%%\n", pCtx->mURI.cbProcessed, cbTotal, uPercent));
Note:
See TracChangeset
for help on using the changeset viewer.

