VirtualBox

source: vbox/trunk/src/VBox/HostServices/DragAndDrop/dndmanager.h@ 103068

Last change on this file since 103068 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1/** @file
2 * Drag and Drop manager.
3 */
4
5/*
6 * Copyright (C) 2011-2023 Oracle and/or its affiliates.
7 *
8 * This file is part of VirtualBox base platform packages, as
9 * available from https://www.virtualbox.org.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation, in version 3 of the
14 * License.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <https://www.gnu.org/licenses>.
23 *
24 * SPDX-License-Identifier: GPL-3.0-only
25 */
26
27#ifndef VBOX_INCLUDED_SRC_DragAndDrop_dndmanager_h
28#define VBOX_INCLUDED_SRC_DragAndDrop_dndmanager_h
29#ifndef RT_WITHOUT_PRAGMA_ONCE
30# pragma once
31#endif
32
33#include <VBox/GuestHost/DragAndDrop.h>
34#include <VBox/HostServices/Service.h>
35#include <VBox/HostServices/DragAndDropSvc.h>
36
37#include <iprt/cpp/ministring.h>
38#include <iprt/cpp/list.h>
39
40typedef DECLCALLBACKTYPE(int, FNDNDPROGRESS,(uint32_t uState, uint32_t uPercentage, int rc, void *pvUser));
41typedef FNDNDPROGRESS *PFNDNDPROGRESS;
42
43/**
44 * DnD message class. This class forms the base of all other more specialized
45 * message classes.
46 */
47class DnDMessage : public HGCM::Message
48{
49public:
50
51 DnDMessage(void)
52 : m_cRefs(0) { }
53
54 DnDMessage(uint32_t uMsg, uint32_t cParms, VBOXHGCMSVCPARM aParms[])
55 : Message(uMsg, cParms, aParms)
56 , m_cRefs(0) { }
57
58 virtual ~DnDMessage(void) { }
59
60 uint32_t AddRef(void) { Assert(m_cRefs < 32); return ++m_cRefs; }
61 uint32_t Release(void) { if (m_cRefs) return --m_cRefs; return m_cRefs; }
62 uint32_t RefCount(void) const { return m_cRefs; }
63
64protected:
65
66 /** The message's current reference count. */
67 uint32_t m_cRefs;
68};
69
70/**
71 * DnD message class for generic messages which didn't need any special
72 * handling.
73 */
74class DnDGenericMessage: public DnDMessage
75{
76public:
77 DnDGenericMessage(uint32_t uMsg, uint32_t cParms, VBOXHGCMSVCPARM paParms[])
78 : DnDMessage(uMsg, cParms, paParms) { }
79};
80
81/**
82 * DnD message class for informing the guest to cancel any current (and pending) activities.
83 */
84class DnDHGCancelMessage: public DnDMessage
85{
86public:
87
88 DnDHGCancelMessage(void)
89 {
90 int rc2 = initData(DragAndDropSvc::HOST_DND_FN_CANCEL,
91 0 /* cParms */, 0 /* aParms */);
92 AssertRC(rc2);
93 }
94};
95
96/**
97 * DnD manager. Manage creation and queuing of messages for the various DnD
98 * messages types.
99 */
100class DnDManager
101{
102public:
103
104 DnDManager(PFNDNDPROGRESS pfnProgressCallback, void *pvProgressUser)
105 : m_pfnProgressCallback(pfnProgressCallback)
106 , m_pvProgressUser(pvProgressUser)
107 {}
108
109 virtual ~DnDManager(void)
110 {
111 Reset(true /* fForce */);
112 }
113
114 int AddMsg(DnDMessage *pMessage, bool fAppend = true);
115 int AddMsg(uint32_t uMsg, uint32_t cParms, VBOXHGCMSVCPARM paParms[], bool fAppend = true);
116
117#ifdef DEBUG
118 void DumpQueue();
119#endif
120
121 int GetNextMsgInfo(bool fAddRef, uint32_t *puType, uint32_t *pcParms);
122 int GetNextMsg(uint32_t uMsg, uint32_t cParms, VBOXHGCMSVCPARM paParms[]);
123
124 void Reset(bool fForce);
125
126protected:
127
128 /** DnD message queue (FIFO). */
129 RTCList<DnDMessage *> m_queueMsg;
130 /** Pointer to host progress callback. Optional, can be NULL. */
131 PFNDNDPROGRESS m_pfnProgressCallback;
132 /** Pointer to progress callback user context. Can be NULL if not used. */
133 void *m_pvProgressUser;
134};
135#endif /* !VBOX_INCLUDED_SRC_DragAndDrop_dndmanager_h */
136
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette