Changeset 49891 in vbox for trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibDragAndDrop.cpp
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/VBox-4.1 merged: 85944-85947,85949-85950,85953,86701,86728,87009 /branches/andy/draganddrop (added) merged: 90781-91268
- Property svn:mergeinfo changed
-
trunk/src/VBox
- Property svn:mergeinfo changed
/branches/andy/draganddrop/src/VBox (added) merged: 90781-91268
- Property svn:mergeinfo changed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibDragAndDrop.cpp
r42261 r49891 5 5 6 6 /* 7 * Copyright (C) 2011-201 2Oracle Corporation7 * Copyright (C) 2011-2013 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 41 41 #include "VBox/HostServices/DragAndDropSvc.h" 42 42 43 #define VERBOSE 144 45 #if defined(VERBOSE) && defined(DEBUG_poetzsch)46 # include <iprt/stream.h>47 # define DO(s) RTPrintf s48 #else49 # define DO(s) do {} while(0)50 //# define DO(s) Log s51 #endif52 53 43 /* Here all the communication with the host over HGCM is handled platform 54 44 * neutral. Also the receiving of URIs content (directory trees and files) is … … 61 51 */ 62 52 63 /* Not really used at the moment (only one client is possible): */64 uint32_t g_clientId = 0;65 66 53 /****************************************************************************** 67 54 * Private internal functions * … … 70 57 static int vbglR3DnDCreateDropDir(char* pszDropDir, size_t cbSize) 71 58 { 72 /* Validate input */73 59 AssertPtrReturn(pszDropDir, VERR_INVALID_POINTER); 74 60 AssertReturn(cbSize, VERR_INVALID_PARAMETER); 75 61 76 /* Get the users document directory (usually $HOME/Documents). */ 77 int rc = RTPathUserDocuments(pszDropDir, cbSize); 62 /** @todo On Windows we also could use the registry to override 63 * this path, on Posix a dotfile and/or a guest property 64 * can be used. */ 65 66 /* Get the users temp directory. Don't use the user's root directory (or 67 * something inside it) because we don't know for how long/if the data will 68 * be kept after the guest OS used it. */ 69 int rc = RTPathTemp(pszDropDir, cbSize); 78 70 if (RT_FAILURE(rc)) 79 71 return rc; 72 80 73 /* Append our base drop directory. */ 81 74 rc = RTPathAppend(pszDropDir, cbSize, "VirtualBox Dropped Files"); 82 75 if (RT_FAILURE(rc)) 83 76 return rc; 77 84 78 /* Create it when necessary. */ 85 79 if (!RTDirExists(pszDropDir)) … … 89 83 return rc; 90 84 } 85 91 86 /* The actually drop directory consist of the current time stamp and a 92 87 * unique number when necessary. */ … … 95 90 if (!RTTimeSpecToString(RTTimeNow(&time), pszTime, sizeof(pszTime))) 96 91 return VERR_BUFFER_OVERFLOW; 92 #ifdef RT_OS_WINDOWS 93 /* Filter out characters not allowed on Windows platforms, put in by 94 RTTimeSpecToString(). */ 95 /** @todo Use something like RTPathSanitize() when available. Later. */ 96 RTUNICP aCpSet[] = 97 { ' ', ' ', '(', ')', '-', '.', '0', '9', 'A', 'Z', 'a', 'z', '_', '_', 98 0xa0, 0xd7af, '\0' }; 99 RTStrPurgeComplementSet(pszTime, aCpSet, '_' /* Replacement */); 100 #endif 101 97 102 rc = RTPathAppend(pszDropDir, cbSize, pszTime); 98 103 if (RT_FAILURE(rc)) … … 105 110 static int vbglR3DnDQueryNextHostMessageType(uint32_t uClientId, uint32_t *puMsg, uint32_t *pcParms, bool fWait) 106 111 { 107 /* Validate input */108 112 AssertPtrReturn(puMsg, VERR_INVALID_POINTER); 109 113 AssertPtrReturn(pcParms, VERR_INVALID_POINTER); 110 114 111 /* Initialize header */112 115 DragAndDropSvc::VBOXDNDNEXTMSGMSG Msg; 113 116 RT_ZERO(Msg); … … 116 119 Msg.hdr.u32Function = DragAndDropSvc::GUEST_DND_GET_NEXT_HOST_MSG; 117 120 Msg.hdr.cParms = 3; 118 /* Initialize parameter */ 121 119 122 Msg.msg.SetUInt32(0); 120 123 Msg.num_parms.SetUInt32(0); 121 124 Msg.block.SetUInt32(fWait); 122 /* Do request */ 125 123 126 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 124 127 if (RT_SUCCESS(rc)) … … 132 135 } 133 136 } 137 134 138 return rc; 135 139 } … … 146 150 uint32_t *pcbFormatsRecv) 147 151 { 148 /* Validate input */149 152 AssertPtrReturn(puScreenId, VERR_INVALID_POINTER); 150 153 AssertPtrReturn(puX, VERR_INVALID_POINTER); … … 156 159 AssertPtrReturn(pcbFormatsRecv, VERR_INVALID_POINTER); 157 160 158 /* Initialize header */159 161 DragAndDropSvc::VBOXDNDHGACTIONMSG Msg; 160 162 RT_ZERO(Msg); … … 162 164 Msg.hdr.u32Function = uMsg; 163 165 Msg.hdr.cParms = 7; 164 /* Initialize parameter */ 166 165 167 Msg.uScreenId.SetUInt32(0); 166 168 Msg.uX.SetUInt32(0); … … 170 172 Msg.pvFormats.SetPtr(pszFormats, cbFormats); 171 173 Msg.cFormats.SetUInt32(0); 172 /* Do request */ 174 173 175 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 174 176 if (RT_SUCCESS(rc)) … … 188 190 } 189 191 } 192 190 193 return rc; 191 194 } … … 193 196 static int vbglR3DnDHGProcessLeaveMessage(uint32_t uClientId) 194 197 { 195 /* Initialize header */196 198 DragAndDropSvc::VBOXDNDHGLEAVEMSG Msg; 197 199 RT_ZERO(Msg); … … 199 201 Msg.hdr.u32Function = DragAndDropSvc::HOST_DND_HG_EVT_LEAVE; 200 202 Msg.hdr.cParms = 0; 201 /* Do request */ 202 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 203 if (RT_SUCCESS(rc)) 204 rc = Msg.hdr.result; 203 204 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 205 if (RT_SUCCESS(rc)) 206 rc = Msg.hdr.result; 207 205 208 return rc; 206 209 } … … 208 211 static int vbglR3DnDHGProcessCancelMessage(uint32_t uClientId) 209 212 { 210 /* Initialize header */211 213 DragAndDropSvc::VBOXDNDHGCANCELMSG Msg; 212 214 RT_ZERO(Msg); … … 214 216 Msg.hdr.u32Function = DragAndDropSvc::HOST_DND_HG_EVT_CANCEL; 215 217 Msg.hdr.cParms = 0; 216 /* Do request */ 217 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 218 if (RT_SUCCESS(rc)) 219 rc = Msg.hdr.result; 218 219 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 220 if (RT_SUCCESS(rc)) 221 rc = Msg.hdr.result; 222 220 223 return rc; 221 224 } … … 227 230 uint32_t *pfMode) 228 231 { 229 /* Validate input */230 232 AssertPtrReturn(pszDirname, VERR_INVALID_POINTER); 231 233 AssertReturn(cbDirname, VERR_INVALID_PARAMETER); … … 233 235 AssertPtrReturn(pfMode, VERR_INVALID_POINTER); 234 236 235 /* Initialize header */236 237 DragAndDropSvc::VBOXDNDHGSENDDIRMSG Msg; 237 238 RT_ZERO(Msg); … … 239 240 Msg.hdr.u32Function = DragAndDropSvc::HOST_DND_HG_SND_DIR; 240 241 Msg.hdr.cParms = 3; 241 /* Initialize parameter */ 242 242 243 Msg.pvName.SetPtr(pszDirname, cbDirname); 243 244 Msg.cName.SetUInt32(0); 244 245 Msg.fMode.SetUInt32(0); 245 /* Do request */ 246 246 247 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 247 248 if (RT_SUCCESS(rc)) … … 257 258 } 258 259 } 260 259 261 return rc; 260 262 } … … 269 271 uint32_t *pfMode) 270 272 { 271 /* Validate input */272 273 AssertPtrReturn(pszFilename, VERR_INVALID_POINTER); 273 274 AssertReturn(cbFilename, VERR_INVALID_PARAMETER); … … 278 279 AssertPtrReturn(pfMode, VERR_INVALID_POINTER); 279 280 280 /* Initialize header */281 281 DragAndDropSvc::VBOXDNDHGSENDFILEMSG Msg; 282 282 RT_ZERO(Msg); … … 284 284 Msg.hdr.u32Function = DragAndDropSvc::HOST_DND_HG_SND_FILE; 285 285 Msg.hdr.cParms = 5; 286 /* Initialize parameter */ 286 287 287 Msg.pvName.SetPtr(pszFilename, cbFilename); 288 288 Msg.cName.SetUInt32(0); … … 290 290 Msg.cData.SetUInt32(0); 291 291 Msg.fMode.SetUInt32(0); 292 /* Do request */ 292 293 293 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 294 294 if (RT_SUCCESS(rc)) … … 306 306 } 307 307 } 308 308 309 return rc; 309 310 } … … 376 377 uint32_t uNextMsg; 377 378 uint32_t cNextParms; 378 rc = vbglR3DnDQueryNextHostMessageType(uClientId, &uNextMsg, &cNextParms, false); 379 DO(("%Rrc - %d\n", rc , uNextMsg)); 379 rc = vbglR3DnDQueryNextHostMessageType(uClientId, &uNextMsg, &cNextParms, false /* fWait */); 380 380 if (RT_SUCCESS(rc)) 381 381 { … … 392 392 if (RT_SUCCESS(rc)) 393 393 { 394 DO(("Got drop dir: %s - %o - %Rrc\n", pszPathname, fMode, rc));395 394 char *pszNewDir = RTPathJoinA(pszDropDir, pszPathname); 396 395 rc = RTDirCreate(pszNewDir, (fMode & RTFS_UNIX_MASK) | RTFS_UNIX_IRWXU, 0); … … 415 414 { 416 415 char *pszNewFile = RTPathJoinA(pszDropDir, pszPathname); 417 DO(("Got drop file: %s - %d - %o - %Rrc\n", pszPathname, cbDataRecv, fMode, rc));418 416 RTFILE hFile; 417 /** @todo r=andy Keep the file open and locked during the actual file transfer. Otherwise this will 418 * create all sorts of funny races because we don't know if the guest has 419 * modified the file in between the file data send calls. */ 419 420 rc = RTFileOpen(&hFile, pszNewFile, RTFILE_O_WRITE | RTFILE_O_APPEND | RTFILE_O_DENY_ALL | RTFILE_O_OPEN_CREATE); 420 421 if (RT_SUCCESS(rc)) … … 443 444 /* Break out of the loop. */ 444 445 } 445 default: fLoop = false; break; 446 default: 447 fLoop = false; 448 break; 446 449 } 447 } else 450 } 451 else 448 452 { 449 453 if (rc == VERR_NO_DATA) … … 451 455 break; 452 456 } 453 }while(fLoop); 457 458 } while (fLoop); 454 459 455 460 RTMemFree(pvTmpData); 461 456 462 /* Cleanup on failure or if the user has canceled. */ 457 463 if (RT_FAILURE(rc)) … … 477 483 uint32_t *pcbDataRecv) 478 484 { 479 /* Validate input */480 485 AssertPtrReturn(puScreenId, VERR_INVALID_POINTER); 481 486 AssertPtrReturn(pszFormat, VERR_INVALID_POINTER); … … 486 491 AssertPtrReturn(pcbDataRecv, VERR_INVALID_POINTER); 487 492 488 /* Initialize header */489 493 DragAndDropSvc::VBOXDNDHGSENDDATAMSG Msg; 490 494 RT_ZERO(Msg); … … 492 496 Msg.hdr.u32Function = DragAndDropSvc::HOST_DND_HG_SND_DATA; 493 497 Msg.hdr.cParms = 5; 494 /* Initialize parameter */ 498 495 499 Msg.uScreenId.SetUInt32(0); 496 500 Msg.pvFormat.SetPtr(pszFormat, cbFormat); … … 498 502 Msg.pvData.SetPtr(pvData, cbData); 499 503 Msg.cData.SetUInt32(0); 500 /* Do request */ 504 501 505 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 502 506 if (RT_SUCCESS(rc)) … … 515 519 } 516 520 } 521 517 522 return rc; 518 523 } … … 523 528 uint32_t *pcbDataRecv) 524 529 { 525 /* Validate input */526 530 AssertPtrReturn(pvData, VERR_INVALID_POINTER); 527 531 AssertReturn(cbData, VERR_INVALID_PARAMETER); 528 532 AssertPtrReturn(pcbDataRecv, VERR_INVALID_POINTER); 529 533 530 /* Initialize header */531 534 DragAndDropSvc::VBOXDNDHGSENDMOREDATAMSG Msg; 532 535 RT_ZERO(Msg); 533 Msg.hdr.u32ClientID = g_clientId;536 Msg.hdr.u32ClientID = uClientId; 534 537 Msg.hdr.u32Function = DragAndDropSvc::HOST_DND_HG_SND_MORE_DATA; 535 538 Msg.hdr.cParms = 2; 536 /* Initialize parameter */ 539 537 540 Msg.pvData.SetPtr(pvData, cbData); 538 541 Msg.cData.SetUInt32(0); 539 /* Do request */ 542 540 543 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 541 544 if (RT_SUCCESS(rc)) … … 554 557 } 555 558 556 static int vbglR3DnDHGProcessSendDataMessage s(uint32_t uClientId,557 uint32_t *puScreenId,558 char *pszFormat,559 uint32_t cbFormat,560 uint32_t *pcbFormatRecv,561 void **ppvData,562 uint32_t cbData,563 size_t *pcbDataRecv)559 static int vbglR3DnDHGProcessSendDataMessageLoop(uint32_t uClientId, 560 uint32_t *puScreenId, 561 char *pszFormat, 562 uint32_t cbFormat, 563 uint32_t *pcbFormatRecv, 564 void **ppvData, 565 uint32_t cbData, 566 size_t *pcbDataRecv) 564 567 { 565 568 uint32_t cbDataRecv = 0; … … 572 575 cbData, 573 576 &cbDataRecv); 574 575 size_t cbAllDataRecv = cbDataRecv; 577 uint32_t cbAllDataRecv = cbDataRecv; 576 578 while (rc == VERR_BUFFER_OVERFLOW) 577 579 { … … 624 626 size_t *pcbDataRecv) 625 627 { 626 int rc = vbglR3DnDHGProcessSendDataMessages(uClientId, 627 puScreenId, 628 pszFormat, 629 cbFormat, 630 pcbFormatRecv, 631 ppvData, 632 cbData, 633 pcbDataRecv); 634 if (RT_SUCCESS(rc)) 635 { 636 /* Check if this is a uri-event */ 628 int rc = vbglR3DnDHGProcessSendDataMessageLoop(uClientId, 629 puScreenId, 630 pszFormat, 631 cbFormat, 632 pcbFormatRecv, 633 ppvData, 634 cbData, 635 pcbDataRecv); 636 if (RT_SUCCESS(rc)) 637 { 638 /* Check if this is a uri-event. If so, let VbglR3 do all the actual 639 * data transfer + file /directory creation internally without letting 640 * the caller know. */ 637 641 if (RTStrNICmp(pszFormat, "text/uri-list", *pcbFormatRecv) == 0) 638 642 rc = vbglR3DnDHGProcessURIMessages(uClientId, … … 645 649 pcbDataRecv); 646 650 } 651 647 652 return rc; 648 653 } … … 651 656 uint32_t *puScreenId) 652 657 { 653 /* Validate input */654 658 AssertPtrReturn(puScreenId, VERR_INVALID_POINTER); 655 659 656 /* Initialize header */657 660 DragAndDropSvc::VBOXDNDGHREQPENDINGMSG Msg; 658 661 RT_ZERO(Msg); … … 660 663 Msg.hdr.u32Function = DragAndDropSvc::HOST_DND_GH_REQ_PENDING; 661 664 Msg.hdr.cParms = 1; 662 /* Initialize parameter */ 665 663 666 Msg.uScreenId.SetUInt32(0); 664 /* Do request */ 667 665 668 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 666 669 if (RT_SUCCESS(rc)) … … 673 676 } 674 677 } 678 675 679 return rc; 676 680 } … … 682 686 uint32_t *puAction) 683 687 { 684 /* Validate input */685 688 AssertPtrReturn(pszFormat, VERR_INVALID_POINTER); 686 689 AssertReturn(cbFormat, VERR_INVALID_PARAMETER); … … 688 691 AssertPtrReturn(puAction, VERR_INVALID_POINTER); 689 692 690 /* Initialize header */691 693 DragAndDropSvc::VBOXDNDGHDROPPEDMSG Msg; 692 694 RT_ZERO(Msg); … … 694 696 Msg.hdr.u32Function = DragAndDropSvc::HOST_DND_GH_EVT_DROPPED; 695 697 Msg.hdr.cParms = 3; 696 /* Initialize parameter */ 698 697 699 Msg.pvFormat.SetPtr(pszFormat, cbFormat); 698 700 Msg.cFormat.SetUInt32(0); 699 701 Msg.uAction.SetUInt32(0); 700 /* Do request */ 702 701 703 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 702 704 if (RT_SUCCESS(rc)) … … 712 714 } 713 715 } 716 714 717 return rc; 715 718 } … … 719 722 ******************************************************************************/ 720 723 721 /**722 * Initialize Drag & Drop.723 *724 * This will enable the Drag & Drop events.725 *726 * @returns VBox status code.727 */728 VBGLR3DECL(int) VbglR3DnDInit(void)729 {730 return VbglR3DnDConnect(&g_clientId);731 }732 733 /**734 * Terminate Drag and Drop.735 *736 * This will Drag and Drop events.737 *738 * @returns VBox status.739 */740 VBGLR3DECL(int) VbglR3DnDTerm(void)741 {742 return VbglR3DnDDisconnect(g_clientId);743 }744 745 724 VBGLR3DECL(int) VbglR3DnDConnect(uint32_t *pu32ClientId) 746 725 { 747 /* Validate input */748 726 AssertPtrReturn(pu32ClientId, VERR_INVALID_POINTER); 749 727 … … 770 748 VBGLR3DECL(int) VbglR3DnDDisconnect(uint32_t u32ClientId) 771 749 { 772 /* Initialize header */773 750 VBoxGuestHGCMDisconnectInfo Info; 774 751 Info.result = VERR_WRONG_ORDER; 775 752 Info.u32ClientID = u32ClientId; 753 776 754 /* Do request */ 777 755 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_DISCONNECT, &Info, sizeof(Info)); 778 756 if (RT_SUCCESS(rc)) 779 757 rc = Info.result; 780 return rc; 781 } 782 783 VBGLR3DECL(int) VbglR3DnDProcessNextMessage(CPVBGLR3DNDHGCMEVENT pEvent) 784 { 785 /* Validate input */ 758 759 return rc; 760 } 761 762 VBGLR3DECL(int) VbglR3DnDProcessNextMessage(uint32_t u32ClientId, CPVBGLR3DNDHGCMEVENT pEvent) 763 { 786 764 AssertPtrReturn(pEvent, VERR_INVALID_POINTER); 787 765 … … 789 767 uint32_t uNumParms = 0; 790 768 const uint32_t ccbFormats = _64K; 791 const uint32_t ccbData = _ 1M;792 int rc = vbglR3DnDQueryNextHostMessageType( g_clientId, &uMsg, &uNumParms, true);793 if (RT_SUCCESS(rc))794 {795 DO(("Got message %d\n", uMsg));769 const uint32_t ccbData = _64K; 770 int rc = vbglR3DnDQueryNextHostMessageType(u32ClientId, &uMsg, &uNumParms, 771 true /* fWait */); 772 if (RT_SUCCESS(rc)) 773 { 796 774 switch(uMsg) 797 775 { … … 803 781 pEvent->pszFormats = static_cast<char*>(RTMemAlloc(ccbFormats)); 804 782 if (!pEvent->pszFormats) 805 return VERR_NO_MEMORY; 806 rc = vbglR3DnDHGProcessActionMessage(g_clientId, 807 uMsg, 808 &pEvent->uScreenId, 809 &pEvent->u.a.uXpos, 810 &pEvent->u.a.uYpos, 811 &pEvent->u.a.uDefAction, 812 &pEvent->u.a.uAllActions, 813 pEvent->pszFormats, 814 ccbFormats, 815 &pEvent->cbFormats); 783 rc = VERR_NO_MEMORY; 784 785 if (RT_SUCCESS(rc)) 786 rc = vbglR3DnDHGProcessActionMessage(u32ClientId, 787 uMsg, 788 &pEvent->uScreenId, 789 &pEvent->u.a.uXpos, 790 &pEvent->u.a.uYpos, 791 &pEvent->u.a.uDefAction, 792 &pEvent->u.a.uAllActions, 793 pEvent->pszFormats, 794 ccbFormats, 795 &pEvent->cbFormats); 816 796 break; 817 797 } … … 819 799 { 820 800 pEvent->uType = uMsg; 821 rc = vbglR3DnDHGProcessLeaveMessage( g_clientId);801 rc = vbglR3DnDHGProcessLeaveMessage(u32ClientId); 822 802 break; 823 803 } … … 827 807 pEvent->pszFormats = static_cast<char*>(RTMemAlloc(ccbFormats)); 828 808 if (!pEvent->pszFormats) 829 r eturnVERR_NO_MEMORY;830 pEvent->u.b.pvData = RTMemAlloc(ccbData); 831 if ( !pEvent->u.b.pvData)809 rc = VERR_NO_MEMORY; 810 811 if (RT_SUCCESS(rc)) 832 812 { 833 RTMemFree(pEvent->pszFormats); 834 pEvent->pszFormats = NULL; 835 return VERR_NO_MEMORY; 813 pEvent->u.b.pvData = RTMemAlloc(ccbData); 814 if (!pEvent->u.b.pvData) 815 { 816 RTMemFree(pEvent->pszFormats); 817 pEvent->pszFormats = NULL; 818 rc = VERR_NO_MEMORY; 819 } 836 820 } 837 rc = vbglR3DnDHGProcessSendDataMessage(g_clientId, 838 &pEvent->uScreenId, 839 pEvent->pszFormats, 840 ccbFormats, 841 &pEvent->cbFormats, 842 &pEvent->u.b.pvData, 843 ccbData, 844 &pEvent->u.b.cbData); 821 822 if (RT_SUCCESS(rc)) 823 rc = vbglR3DnDHGProcessSendDataMessage(u32ClientId, 824 &pEvent->uScreenId, 825 pEvent->pszFormats, 826 ccbFormats, 827 &pEvent->cbFormats, 828 &pEvent->u.b.pvData, 829 ccbData, 830 &pEvent->u.b.cbData); 831 break; 832 } 833 case DragAndDropSvc::HOST_DND_HG_EVT_CANCEL: 834 { 835 pEvent->uType = uMsg; 836 rc = vbglR3DnDHGProcessCancelMessage(u32ClientId); 845 837 break; 846 838 } … … 849 841 { 850 842 pEvent->uType = uMsg; 851 rc = vbglR3DnDGHProcessRequestPendingMessage( g_clientId,843 rc = vbglR3DnDGHProcessRequestPendingMessage(u32ClientId, 852 844 &pEvent->uScreenId); 853 845 break; … … 858 850 pEvent->pszFormats = static_cast<char*>(RTMemAlloc(ccbFormats)); 859 851 if (!pEvent->pszFormats) 860 return VERR_NO_MEMORY; 861 rc = vbglR3DnDGHProcessDroppedMessage(g_clientId, 862 pEvent->pszFormats, 863 ccbFormats, 864 &pEvent->cbFormats, 865 &pEvent->u.a.uDefAction); 852 rc = VERR_NO_MEMORY; 853 854 if (RT_SUCCESS(rc)) 855 rc = vbglR3DnDGHProcessDroppedMessage(u32ClientId, 856 pEvent->pszFormats, 857 ccbFormats, 858 &pEvent->cbFormats, 859 &pEvent->u.a.uDefAction); 866 860 break; 867 861 } 868 862 #endif /* VBOX_WITH_DRAG_AND_DROP_GH */ 869 case DragAndDropSvc::HOST_DND_HG_EVT_CANCEL: 870 { 871 pEvent->uType = uMsg; 872 rc = vbglR3DnDHGProcessCancelMessage(g_clientId); 873 if (RT_SUCCESS(rc)) 874 rc = VERR_CANCELLED; 863 default: 864 AssertMsgFailedReturn(("Message %u isn't expected in this context", uMsg), 865 VERR_INVALID_PARAMETER); 875 866 break; 876 } 877 default: AssertMsgFailedReturn(("Message %u isn't expected in this context", uMsg), VERR_INVALID_PARAMETER); break; 878 } 879 } 880 return rc; 881 } 882 883 VBGLR3DECL(int) VbglR3DnDHGAcknowledgeOperation(uint32_t uAction) 884 { 885 DO(("ACK: %u\n", uAction)); 886 /* Initialize header */ 867 } 868 } 869 870 return rc; 871 } 872 873 VBGLR3DECL(int) VbglR3DnDHGAcknowledgeOperation(uint32_t u32ClientId, uint32_t uAction) 874 { 887 875 DragAndDropSvc::VBOXDNDHGACKOPMSG Msg; 888 876 RT_ZERO(Msg); 889 877 Msg.hdr.result = VERR_WRONG_ORDER; 890 Msg.hdr.u32ClientID = g_clientId;878 Msg.hdr.u32ClientID = u32ClientId; 891 879 Msg.hdr.u32Function = DragAndDropSvc::GUEST_DND_HG_ACK_OP; 892 880 Msg.hdr.cParms = 1; … … 897 885 if (RT_SUCCESS(rc)) 898 886 rc = Msg.hdr.result; 899 return rc; 900 } 901 902 VBGLR3DECL(int) VbglR3DnDHGRequestData(const char* pcszFormat) 903 { 904 DO(("DATA_REQ: '%s'\n", pcszFormat)); 905 /* Validate input */ 887 888 return rc; 889 } 890 891 VBGLR3DECL(int) VbglR3DnDHGRequestData(uint32_t u32ClientId, const char* pcszFormat) 892 { 906 893 AssertPtrReturn(pcszFormat, VERR_INVALID_PARAMETER); 907 894 908 /* Initialize header */909 895 DragAndDropSvc::VBOXDNDHGREQDATAMSG Msg; 910 896 RT_ZERO(Msg); 911 897 Msg.hdr.result = VERR_WRONG_ORDER; 912 Msg.hdr.u32ClientID = g_clientId;898 Msg.hdr.u32ClientID = u32ClientId; 913 899 Msg.hdr.u32Function = DragAndDropSvc::GUEST_DND_HG_REQ_DATA; 914 900 Msg.hdr.cParms = 1; … … 918 904 if (RT_SUCCESS(rc)) 919 905 rc = Msg.hdr.result; 920 return rc; 921 } 922 923 VBGLR3DECL(int) VbglR3DnDGHAcknowledgePending(uint32_t uDefAction, uint32_t uAllActions, const char* pcszFormat) 924 { 925 DO(("PEND: %u: %u (%s)\n", uDefAction, uAllActions, pcszFormat)); 926 /* Validate input */ 906 907 return rc; 908 } 909 910 VBGLR3DECL(int) VbglR3DnDGHAcknowledgePending(uint32_t u32ClientId, 911 uint32_t uDefAction, uint32_t uAllActions, 912 const char* pcszFormat) 913 { 927 914 AssertPtrReturn(pcszFormat, VERR_INVALID_POINTER); 928 915 929 /* Initialize header */930 916 DragAndDropSvc::VBOXDNDGHACKPENDINGMSG Msg; 931 917 RT_ZERO(Msg); 932 918 Msg.hdr.result = VERR_WRONG_ORDER; 933 Msg.hdr.u32ClientID = g_clientId;919 Msg.hdr.u32ClientID = u32ClientId; 934 920 Msg.hdr.u32Function = DragAndDropSvc::GUEST_DND_GH_ACK_PENDING; 935 921 Msg.hdr.cParms = 3; … … 942 928 if (RT_SUCCESS(rc)) 943 929 rc = Msg.hdr.result; 944 return rc; 945 } 946 947 VBGLR3DECL(int) VbglR3DnDGHSendData(void *pvData, uint32_t cbData) 948 { 949 DO(("DATA: %x (%u)\n", pvData, cbData)); 950 /* Validate input */ 930 931 return rc; 932 } 933 934 VBGLR3DECL(int) VbglR3DnDGHSendData(uint32_t u32ClientId, void *pvData, uint32_t cbData) 935 { 951 936 AssertPtrReturn(pvData, VERR_INVALID_POINTER); 952 937 AssertReturn(cbData, VERR_INVALID_PARAMETER); … … 962 947 */ 963 948 964 /* Initialize header */965 949 DragAndDropSvc::VBOXDNDGHSENDDATAMSG Msg; 966 950 RT_ZERO(Msg); 967 951 Msg.hdr.result = VERR_WRONG_ORDER; 968 Msg.hdr.u32ClientID = g_clientId;952 Msg.hdr.u32ClientID = u32ClientId; 969 953 Msg.hdr.u32Function = DragAndDropSvc::GUEST_DND_GH_SND_DATA; 970 954 Msg.hdr.cParms = 2; … … 992 976 // RTThreadSleep(500); 993 977 } 994 return rc; 995 } 996 997 VBGLR3DECL(int) VbglR3DnDGHErrorEvent(int rcOp) 998 { 999 DO(("GH_ERROR\n")); 1000 1001 /* Initialize header */ 978 979 return rc; 980 } 981 982 VBGLR3DECL(int) VbglR3DnDGHErrorEvent(uint32_t u32ClientId, int rcOp) 983 { 1002 984 DragAndDropSvc::VBOXDNDGHEVTERRORMSG Msg; 1003 985 RT_ZERO(Msg); 1004 986 Msg.hdr.result = VERR_WRONG_ORDER; 1005 Msg.hdr.u32ClientID = g_clientId;987 Msg.hdr.u32ClientID = u32ClientId; 1006 988 Msg.hdr.u32Function = DragAndDropSvc::GUEST_DND_GH_EVT_ERROR; 1007 989 Msg.hdr.cParms = 1; … … 1012 994 if (RT_SUCCESS(rc)) 1013 995 rc = Msg.hdr.result; 1014 return rc; 1015 } 996 997 return rc; 998 }
Note:
See TracChangeset
for help on using the changeset viewer.