[51476] | 1 | /* $Id: GuestDnDTargetImpl.h 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
| 2 | /** @file
|
---|
| 3 | * VBox Console COM Class implementation - Guest drag'n drop target.
|
---|
| 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_GuestDnDTargetImpl_h
|
---|
| 29 | #define MAIN_INCLUDED_GuestDnDTargetImpl_h
|
---|
[76487] | 30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 31 | # pragma once
|
---|
| 32 | #endif
|
---|
[51476] | 33 |
|
---|
| 34 | #include "GuestDnDTargetWrap.h"
|
---|
| 35 | #include "GuestDnDPrivate.h"
|
---|
| 36 |
|
---|
[55422] | 37 | #include <VBox/GuestHost/DragAndDrop.h>
|
---|
| 38 | #include <VBox/HostServices/DragAndDropSvc.h>
|
---|
| 39 |
|
---|
[85018] | 40 | struct GuestDnDSendCtx;
|
---|
[85020] | 41 | class GuestDnDSendDataTask;
|
---|
[55422] | 42 |
|
---|
[51476] | 43 | class ATL_NO_VTABLE GuestDnDTarget :
|
---|
[51556] | 44 | public GuestDnDTargetWrap,
|
---|
[55422] | 45 | public GuestDnDBase
|
---|
[51476] | 46 | {
|
---|
| 47 | public:
|
---|
[97780] | 48 | GuestDnDTarget(void);
|
---|
| 49 | virtual ~GuestDnDTarget(void);
|
---|
| 50 |
|
---|
[51476] | 51 | /** @name COM and internal init/term/mapping cruft.
|
---|
| 52 | * @{ */
|
---|
[97780] | 53 | DECLARE_TRANSLATE_METHODS(GuestDnDTarget);
|
---|
[51476] | 54 |
|
---|
[85743] | 55 | HRESULT init(const ComObjPtr<Guest>& pGuest);
|
---|
[51476] | 56 | void uninit(void);
|
---|
| 57 |
|
---|
| 58 | HRESULT FinalConstruct(void);
|
---|
| 59 | void FinalRelease(void);
|
---|
| 60 | /** @} */
|
---|
| 61 |
|
---|
| 62 | private:
|
---|
| 63 |
|
---|
[51556] | 64 | /** Private wrapped @name IDnDBase methods.
|
---|
[51476] | 65 | * @{ */
|
---|
[51556] | 66 | HRESULT isFormatSupported(const com::Utf8Str &aFormat, BOOL *aSupported);
|
---|
[57221] | 67 | HRESULT getFormats(GuestDnDMIMEList &aFormats);
|
---|
| 68 | HRESULT addFormats(const GuestDnDMIMEList &aFormats);
|
---|
| 69 | HRESULT removeFormats(const GuestDnDMIMEList &aFormats);
|
---|
[51556] | 70 | /** @} */
|
---|
| 71 |
|
---|
| 72 | /** Private wrapped @name IDnDTarget methods.
|
---|
| 73 | * @{ */
|
---|
[57221] | 74 | HRESULT enter(ULONG aScreenId, ULONG ax, ULONG aY, DnDAction_T aDefaultAction, const std::vector<DnDAction_T> &aAllowedActions, const GuestDnDMIMEList &aFormats, DnDAction_T *aResultAction);
|
---|
| 75 | HRESULT move(ULONG aScreenId, ULONG aX, ULONG aY, DnDAction_T aDefaultAction, const std::vector<DnDAction_T> &aAllowedActions, const GuestDnDMIMEList &aFormats, DnDAction_T *aResultAction);
|
---|
[51476] | 76 | HRESULT leave(ULONG aScreenId);
|
---|
[57221] | 77 | HRESULT drop(ULONG aScreenId, ULONG aX, ULONG aY, DnDAction_T aDefaultAction, const std::vector<DnDAction_T> &aAllowedActions, const GuestDnDMIMEList &aFormats, com::Utf8Str &aFormat, DnDAction_T *aResultAction);
|
---|
[51476] | 78 | HRESULT sendData(ULONG aScreenId, const com::Utf8Str &aFormat, const std::vector<BYTE> &aData, ComPtr<IProgress> &aProgress);
|
---|
[55422] | 79 | HRESULT cancel(BOOL *aVeto);
|
---|
[51476] | 80 | /** @} */
|
---|
| 81 |
|
---|
| 82 | protected:
|
---|
| 83 |
|
---|
[55963] | 84 | static Utf8Str i_guestErrorToString(int guestRc);
|
---|
| 85 | static Utf8Str i_hostErrorToString(int hostRc);
|
---|
| 86 |
|
---|
| 87 | /** @name Callbacks for dispatch handler.
|
---|
| 88 | * @{ */
|
---|
[85402] | 89 | static DECLCALLBACK(int) i_sendTransferDataCallback(uint32_t uMsg, void *pvParms, size_t cbParms, void *pvUser);
|
---|
[55963] | 90 | /** @} */
|
---|
[55422] | 91 |
|
---|
| 92 | protected:
|
---|
| 93 |
|
---|
[97780] | 94 | /** @name Implemented virtual functions.
|
---|
| 95 | * @{ */
|
---|
[85537] | 96 | void i_reset(void);
|
---|
[97780] | 97 | /** @} */
|
---|
[85537] | 98 |
|
---|
[85018] | 99 | int i_sendData(GuestDnDSendCtx *pCtx, RTMSINTERVAL msTimeout);
|
---|
[85371] | 100 |
|
---|
| 101 | int i_sendMetaDataBody(GuestDnDSendCtx *pCtx);
|
---|
| 102 | int i_sendMetaDataHeader(GuestDnDSendCtx *pCtx);
|
---|
| 103 |
|
---|
| 104 | int i_sendTransferData(GuestDnDSendCtx *pCtx, RTMSINTERVAL msTimeout);
|
---|
[85423] | 105 | int i_sendTransferListObject(GuestDnDSendCtx *pCtx, PDNDTRANSFERLIST pList, GuestDnDMsg *pMsg);
|
---|
[85371] | 106 |
|
---|
| 107 | int i_sendDirectory(GuestDnDSendCtx *pCtx, PDNDTRANSFEROBJECT pObj, GuestDnDMsg *pMsg);
|
---|
| 108 | int i_sendFile(GuestDnDSendCtx *pCtx, PDNDTRANSFEROBJECT pObj, GuestDnDMsg *pMsg);
|
---|
| 109 | int i_sendFileData(GuestDnDSendCtx *pCtx, PDNDTRANSFEROBJECT pObj, GuestDnDMsg *pMsg);
|
---|
| 110 |
|
---|
[85018] | 111 | int i_sendRawData(GuestDnDSendCtx *pCtx, RTMSINTERVAL msTimeout);
|
---|
[55422] | 112 |
|
---|
| 113 | protected:
|
---|
| 114 |
|
---|
[55520] | 115 | struct
|
---|
| 116 | {
|
---|
| 117 | /** Maximum data block size (in bytes) the target can handle. */
|
---|
[85537] | 118 | uint32_t mcbBlockSize;
|
---|
| 119 | /** The context for sending data to the guest.
|
---|
| 120 | * At the moment only one transfer at a time is supported. */
|
---|
| 121 | GuestDnDSendCtx mSendCtx;
|
---|
[55520] | 122 | } mData;
|
---|
[58519] | 123 |
|
---|
[85020] | 124 | friend class GuestDnDSendDataTask;
|
---|
[51476] | 125 | };
|
---|
| 126 |
|
---|
[76562] | 127 | #endif /* !MAIN_INCLUDED_GuestDnDTargetImpl_h */
|
---|
[51476] | 128 |
|
---|