1 | /* $Id: GuestDnDSourceImpl.h 55963 2015-05-20 11:18:14Z 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 "GuestDnDSourceWrap.h"
|
---|
22 | #include "GuestDnDPrivate.h"
|
---|
23 |
|
---|
24 | struct RECVDATACTX;
|
---|
25 | typedef struct RECVDATACTX *PRECVDATACTX;
|
---|
26 |
|
---|
27 | class ATL_NO_VTABLE GuestDnDSource :
|
---|
28 | public GuestDnDSourceWrap,
|
---|
29 | public GuestDnDBase
|
---|
30 | {
|
---|
31 | public:
|
---|
32 | /** @name COM and internal init/term/mapping cruft.
|
---|
33 | * @{ */
|
---|
34 | DECLARE_EMPTY_CTOR_DTOR(GuestDnDSource)
|
---|
35 |
|
---|
36 | int init(const ComObjPtr<Guest>& pGuest);
|
---|
37 | void uninit(void);
|
---|
38 |
|
---|
39 | HRESULT FinalConstruct(void);
|
---|
40 | void FinalRelease(void);
|
---|
41 | /** @} */
|
---|
42 |
|
---|
43 | private:
|
---|
44 |
|
---|
45 | /** Private wrapped @name IDnDBase methods.
|
---|
46 | * @{ */
|
---|
47 | HRESULT isFormatSupported(const com::Utf8Str &aFormat, BOOL *aSupported);
|
---|
48 | HRESULT getFormats(std::vector<com::Utf8Str> &aFormats);
|
---|
49 | HRESULT addFormats(const std::vector<com::Utf8Str> &aFormats);
|
---|
50 | HRESULT removeFormats(const std::vector<com::Utf8Str> &aFormats);
|
---|
51 |
|
---|
52 | HRESULT getProtocolVersion(ULONG *aProtocolVersion);
|
---|
53 | /** @} */
|
---|
54 |
|
---|
55 | /** Private wrapped @name IDnDSource methods.
|
---|
56 | * @{ */
|
---|
57 | HRESULT dragIsPending(ULONG uScreenId, std::vector<com::Utf8Str> &aFormats, std::vector<DnDAction_T> &aAllowedActions, DnDAction_T *aDefaultAction);
|
---|
58 | HRESULT drop(const com::Utf8Str &aFormat, DnDAction_T aAction, ComPtr<IProgress> &aProgress);
|
---|
59 | HRESULT receiveData(std::vector<BYTE> &aData);
|
---|
60 | /** @} */
|
---|
61 |
|
---|
62 | protected:
|
---|
63 |
|
---|
64 | #ifdef VBOX_WITH_DRAG_AND_DROP_GH
|
---|
65 | /** @name Dispatch handlers for the HGCM callbacks.
|
---|
66 | * @{ */
|
---|
67 | int i_onReceiveData(PRECVDATACTX pCtx, const void *pvData, uint32_t cbData, uint64_t cbTotalSize);
|
---|
68 | int i_onReceiveDir(PRECVDATACTX pCtx, const char *pszPath, uint32_t cbPath, uint32_t fMode);
|
---|
69 | int i_onReceiveFileHdr(PRECVDATACTX pCtx, const char *pszPath, uint32_t cbPath, uint64_t cbSize, uint32_t fMode, uint32_t fFlags);
|
---|
70 | int i_onReceiveFileData(PRECVDATACTX pCtx, const void *pvData, uint32_t cbData);
|
---|
71 | /** @} */
|
---|
72 | #endif
|
---|
73 |
|
---|
74 | protected:
|
---|
75 |
|
---|
76 | static Utf8Str i_guestErrorToString(int guestRc);
|
---|
77 | static Utf8Str i_hostErrorToString(int hostRc);
|
---|
78 |
|
---|
79 | /** @name Thread callbacks.
|
---|
80 | * @{ */
|
---|
81 | static DECLCALLBACK(int) i_receiveDataThread(RTTHREAD Thread, void *pvUser);
|
---|
82 | /** @} */
|
---|
83 |
|
---|
84 | /** @name Callbacks for dispatch handler.
|
---|
85 | * @{ */
|
---|
86 | static DECLCALLBACK(int) i_receiveRawDataCallback(uint32_t uMsg, void *pvParms, size_t cbParms, void *pvUser);
|
---|
87 | static DECLCALLBACK(int) i_receiveURIDataCallback(uint32_t uMsg, void *pvParms, size_t cbParms, void *pvUser);
|
---|
88 | /** @} */
|
---|
89 |
|
---|
90 | protected:
|
---|
91 |
|
---|
92 | int i_receiveData(PRECVDATACTX pCtx, RTMSINTERVAL msTimeout);
|
---|
93 | int i_receiveRawData(PRECVDATACTX pCtx, RTMSINTERVAL msTimeout);
|
---|
94 | int i_receiveURIData(PRECVDATACTX pCtx, RTMSINTERVAL msTimeout);
|
---|
95 | int i_updateProcess(PRECVDATACTX pCtx, uint32_t cbDataAdd);
|
---|
96 |
|
---|
97 | protected:
|
---|
98 |
|
---|
99 | struct
|
---|
100 | {
|
---|
101 | /** Maximum data block size (in bytes) the source can handle. */
|
---|
102 | uint32_t mcbBlockSize;
|
---|
103 | /** The context for receiving data from the guest. */
|
---|
104 | RECVDATACTX mRecvCtx;
|
---|
105 | } mData;
|
---|
106 | };
|
---|
107 |
|
---|
108 | #endif /* !____H_GUESTDNDSOURCEIMPL */
|
---|
109 |
|
---|