[51476] | 1 | /* $Id: GuestDnDSourceImpl.h 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
| 2 | /** @file
|
---|
| 3 | * VBox Console COM Class implementation - Guest drag'n drop source.
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[106061] | 7 | * Copyright (C) 2014-2024 Oracle and/or its affiliates.
|
---|
[51476] | 8 | *
|
---|
[96407] | 9 | * This file is part of VirtualBox base platform packages, as
|
---|
| 10 | * available from https://www.virtualbox.org.
|
---|
| 11 | *
|
---|
| 12 | * This program is free software; you can redistribute it and/or
|
---|
| 13 | * modify it under the terms of the GNU General Public License
|
---|
| 14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
| 15 | * License.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful, but
|
---|
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | * General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 24 | *
|
---|
| 25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
[51476] | 26 | */
|
---|
| 27 |
|
---|
[76562] | 28 | #ifndef MAIN_INCLUDED_GuestDnDSourceImpl_h
|
---|
| 29 | #define MAIN_INCLUDED_GuestDnDSourceImpl_h
|
---|
[76487] | 30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 31 | # pragma once
|
---|
| 32 | #endif
|
---|
[51476] | 33 |
|
---|
[58212] | 34 | #include <VBox/GuestHost/DragAndDrop.h>
|
---|
| 35 | #include <VBox/HostServices/DragAndDropSvc.h>
|
---|
| 36 |
|
---|
| 37 | using namespace DragAndDropSvc;
|
---|
| 38 |
|
---|
[51476] | 39 | #include "GuestDnDSourceWrap.h"
|
---|
| 40 | #include "GuestDnDPrivate.h"
|
---|
| 41 |
|
---|
[85020] | 42 | class GuestDnDRecvDataTask;
|
---|
[85018] | 43 | struct GuestDnDRecvCtx;
|
---|
[55422] | 44 |
|
---|
[51476] | 45 | class ATL_NO_VTABLE GuestDnDSource :
|
---|
[51556] | 46 | public GuestDnDSourceWrap,
|
---|
[55422] | 47 | public GuestDnDBase
|
---|
[51476] | 48 | {
|
---|
| 49 | public:
|
---|
[97780] | 50 | GuestDnDSource(void);
|
---|
| 51 | virtual ~GuestDnDSource(void);
|
---|
| 52 |
|
---|
[51476] | 53 | /** @name COM and internal init/term/mapping cruft.
|
---|
| 54 | * @{ */
|
---|
[97780] | 55 | DECLARE_TRANSLATE_METHODS(GuestDnDSource);
|
---|
[51476] | 56 |
|
---|
[85743] | 57 | HRESULT init(const ComObjPtr<Guest>& pGuest);
|
---|
[51476] | 58 | void uninit(void);
|
---|
| 59 |
|
---|
| 60 | HRESULT FinalConstruct(void);
|
---|
| 61 | void FinalRelease(void);
|
---|
| 62 | /** @} */
|
---|
| 63 |
|
---|
| 64 | private:
|
---|
| 65 |
|
---|
[51556] | 66 | /** Private wrapped @name IDnDBase methods.
|
---|
[51476] | 67 | * @{ */
|
---|
[51556] | 68 | HRESULT isFormatSupported(const com::Utf8Str &aFormat, BOOL *aSupported);
|
---|
[57221] | 69 | HRESULT getFormats(GuestDnDMIMEList &aFormats);
|
---|
| 70 | HRESULT addFormats(const GuestDnDMIMEList &aFormats);
|
---|
| 71 | HRESULT removeFormats(const GuestDnDMIMEList &aFormats);
|
---|
[51556] | 72 | /** @} */
|
---|
| 73 |
|
---|
| 74 | /** Private wrapped @name IDnDSource methods.
|
---|
| 75 | * @{ */
|
---|
[57221] | 76 | HRESULT dragIsPending(ULONG uScreenId, GuestDnDMIMEList &aFormats, std::vector<DnDAction_T> &aAllowedActions, DnDAction_T *aDefaultAction);
|
---|
[51476] | 77 | HRESULT drop(const com::Utf8Str &aFormat, DnDAction_T aAction, ComPtr<IProgress> &aProgress);
|
---|
| 78 | HRESULT receiveData(std::vector<BYTE> &aData);
|
---|
| 79 | /** @} */
|
---|
| 80 |
|
---|
| 81 | protected:
|
---|
| 82 |
|
---|
[97780] | 83 | /** @name Implemented virtual functions.
|
---|
| 84 | * @{ */
|
---|
[85537] | 85 | void i_reset(void);
|
---|
[97780] | 86 | /** @} */
|
---|
[85537] | 87 |
|
---|
[55422] | 88 | #ifdef VBOX_WITH_DRAG_AND_DROP_GH
|
---|
| 89 | /** @name Dispatch handlers for the HGCM callbacks.
|
---|
[51476] | 90 | * @{ */
|
---|
[85018] | 91 | int i_onReceiveDataHdr(GuestDnDRecvCtx *pCtx, PVBOXDNDSNDDATAHDR pDataHdr);
|
---|
| 92 | int i_onReceiveData(GuestDnDRecvCtx *pCtx, PVBOXDNDSNDDATA pSndData);
|
---|
| 93 | int i_onReceiveDir(GuestDnDRecvCtx *pCtx, const char *pszPath, uint32_t cbPath, uint32_t fMode);
|
---|
| 94 | int i_onReceiveFileHdr(GuestDnDRecvCtx *pCtx, const char *pszPath, uint32_t cbPath, uint64_t cbSize, uint32_t fMode, uint32_t fFlags);
|
---|
| 95 | int i_onReceiveFileData(GuestDnDRecvCtx *pCtx,const void *pvData, uint32_t cbData);
|
---|
[51476] | 96 | /** @} */
|
---|
[55422] | 97 | #endif
|
---|
| 98 |
|
---|
| 99 | protected:
|
---|
| 100 |
|
---|
[55963] | 101 | static Utf8Str i_guestErrorToString(int guestRc);
|
---|
| 102 | static Utf8Str i_hostErrorToString(int hostRc);
|
---|
| 103 |
|
---|
[55422] | 104 | /** @name Callbacks for dispatch handler.
|
---|
| 105 | * @{ */
|
---|
| 106 | static DECLCALLBACK(int) i_receiveRawDataCallback(uint32_t uMsg, void *pvParms, size_t cbParms, void *pvUser);
|
---|
[85402] | 107 | static DECLCALLBACK(int) i_receiveTransferDataCallback(uint32_t uMsg, void *pvParms, size_t cbParms, void *pvUser);
|
---|
[55422] | 108 | /** @} */
|
---|
| 109 |
|
---|
| 110 | protected:
|
---|
| 111 |
|
---|
[85018] | 112 | int i_receiveData(GuestDnDRecvCtx *pCtx, RTMSINTERVAL msTimeout);
|
---|
| 113 | int i_receiveRawData(GuestDnDRecvCtx *pCtx, RTMSINTERVAL msTimeout);
|
---|
[85371] | 114 | int i_receiveTransferData(GuestDnDRecvCtx *pCtx, RTMSINTERVAL msTimeout);
|
---|
[55512] | 115 |
|
---|
| 116 | protected:
|
---|
| 117 |
|
---|
[55520] | 118 | struct
|
---|
| 119 | {
|
---|
| 120 | /** Maximum data block size (in bytes) the source can handle. */
|
---|
| 121 | uint32_t mcbBlockSize;
|
---|
[58212] | 122 | /** The context for receiving data from the guest.
|
---|
| 123 | * At the moment only one transfer at a time is supported. */
|
---|
[85018] | 124 | GuestDnDRecvCtx mRecvCtx;
|
---|
[55520] | 125 | } mData;
|
---|
[58519] | 126 |
|
---|
[85020] | 127 | friend class GuestDnDRecvDataTask;
|
---|
[51476] | 128 | };
|
---|
| 129 |
|
---|
[76562] | 130 | #endif /* !MAIN_INCLUDED_GuestDnDSourceImpl_h */
|
---|
[51476] | 131 |
|
---|