1 | /* $Id: GuestDnDSourceImpl.h 58519 2015-10-30 08:17:19Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Console COM Class implementation - Guest drag'n drop source.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2014-2015 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef ____H_GUESTDNDSOURCEIMPL
|
---|
19 | #define ____H_GUESTDNDSOURCEIMPL
|
---|
20 |
|
---|
21 | #include <VBox/GuestHost/DragAndDrop.h>
|
---|
22 | #include <VBox/HostServices/DragAndDropSvc.h>
|
---|
23 |
|
---|
24 | using namespace DragAndDropSvc;
|
---|
25 |
|
---|
26 | #include "GuestDnDSourceWrap.h"
|
---|
27 | #include "GuestDnDPrivate.h"
|
---|
28 |
|
---|
29 | struct RECVDATACTX;
|
---|
30 | typedef struct RECVDATACTX *PRECVDATACTX;
|
---|
31 |
|
---|
32 | class ATL_NO_VTABLE GuestDnDSource :
|
---|
33 | public GuestDnDSourceWrap,
|
---|
34 | public GuestDnDBase
|
---|
35 | {
|
---|
36 | public:
|
---|
37 | /** @name COM and internal init/term/mapping cruft.
|
---|
38 | * @{ */
|
---|
39 | DECLARE_EMPTY_CTOR_DTOR(GuestDnDSource)
|
---|
40 |
|
---|
41 | int init(const ComObjPtr<Guest>& pGuest);
|
---|
42 | void uninit(void);
|
---|
43 |
|
---|
44 | HRESULT FinalConstruct(void);
|
---|
45 | void FinalRelease(void);
|
---|
46 | /** @} */
|
---|
47 |
|
---|
48 | private:
|
---|
49 |
|
---|
50 | /** Private wrapped @name IDnDBase methods.
|
---|
51 | * @{ */
|
---|
52 | HRESULT isFormatSupported(const com::Utf8Str &aFormat, BOOL *aSupported);
|
---|
53 | HRESULT getFormats(GuestDnDMIMEList &aFormats);
|
---|
54 | HRESULT addFormats(const GuestDnDMIMEList &aFormats);
|
---|
55 | HRESULT removeFormats(const GuestDnDMIMEList &aFormats);
|
---|
56 |
|
---|
57 | HRESULT getProtocolVersion(ULONG *aProtocolVersion);
|
---|
58 | /** @} */
|
---|
59 |
|
---|
60 | /** Private wrapped @name IDnDSource methods.
|
---|
61 | * @{ */
|
---|
62 | HRESULT dragIsPending(ULONG uScreenId, GuestDnDMIMEList &aFormats, std::vector<DnDAction_T> &aAllowedActions, DnDAction_T *aDefaultAction);
|
---|
63 | HRESULT drop(const com::Utf8Str &aFormat, DnDAction_T aAction, ComPtr<IProgress> &aProgress);
|
---|
64 | HRESULT receiveData(std::vector<BYTE> &aData);
|
---|
65 | /** @} */
|
---|
66 |
|
---|
67 | protected:
|
---|
68 |
|
---|
69 | #ifdef VBOX_WITH_DRAG_AND_DROP_GH
|
---|
70 | /** @name Dispatch handlers for the HGCM callbacks.
|
---|
71 | * @{ */
|
---|
72 | int i_onReceiveDataHdr(PRECVDATACTX pCtx, PVBOXDNDSNDDATAHDR pDataHdr);
|
---|
73 | int i_onReceiveData(PRECVDATACTX pCtx, PVBOXDNDSNDDATA pSndData);
|
---|
74 | int i_onReceiveDir(PRECVDATACTX pCtx, const char *pszPath, uint32_t cbPath, uint32_t fMode);
|
---|
75 | int i_onReceiveFileHdr(PRECVDATACTX pCtx, const char *pszPath, uint32_t cbPath, uint64_t cbSize, uint32_t fMode, uint32_t fFlags);
|
---|
76 | int i_onReceiveFileData(PRECVDATACTX pCtx,const void *pvData, uint32_t cbData);
|
---|
77 | /** @} */
|
---|
78 | #endif
|
---|
79 |
|
---|
80 | protected:
|
---|
81 |
|
---|
82 | static Utf8Str i_guestErrorToString(int guestRc);
|
---|
83 | static Utf8Str i_hostErrorToString(int hostRc);
|
---|
84 |
|
---|
85 | /** @name Thread callbacks.
|
---|
86 | * @{ */
|
---|
87 | static DECLCALLBACK(int) i_receiveDataThread(RTTHREAD Thread, void *pvUser);
|
---|
88 | /** @} */
|
---|
89 |
|
---|
90 | /** @name Callbacks for dispatch handler.
|
---|
91 | * @{ */
|
---|
92 | static DECLCALLBACK(int) i_receiveRawDataCallback(uint32_t uMsg, void *pvParms, size_t cbParms, void *pvUser);
|
---|
93 | static DECLCALLBACK(int) i_receiveURIDataCallback(uint32_t uMsg, void *pvParms, size_t cbParms, void *pvUser);
|
---|
94 | /** @} */
|
---|
95 |
|
---|
96 | protected:
|
---|
97 |
|
---|
98 | int i_receiveData(PRECVDATACTX pCtx, RTMSINTERVAL msTimeout);
|
---|
99 | int i_receiveRawData(PRECVDATACTX pCtx, RTMSINTERVAL msTimeout);
|
---|
100 | int i_receiveURIData(PRECVDATACTX pCtx, RTMSINTERVAL msTimeout);
|
---|
101 |
|
---|
102 | protected:
|
---|
103 |
|
---|
104 | struct
|
---|
105 | {
|
---|
106 | /** Maximum data block size (in bytes) the source can handle. */
|
---|
107 | uint32_t mcbBlockSize;
|
---|
108 | /** The context for receiving data from the guest.
|
---|
109 | * At the moment only one transfer at a time is supported. */
|
---|
110 | RECVDATACTX mRecvCtx;
|
---|
111 | } mData;
|
---|
112 |
|
---|
113 | friend class RecvDataTask;
|
---|
114 | };
|
---|
115 |
|
---|
116 | #endif /* !____H_GUESTDNDSOURCEIMPL */
|
---|
117 |
|
---|