VirtualBox

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

Last change on this file since 74024 was 73939, checked in by vboxsync, 6 years ago

DnD/HostService: Renaming, docs.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 KB
Line 
1/** @file
2 * Drag and Drop manager.
3 */
4
5/*
6 * Copyright (C) 2011-2017 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 */
16
17#ifndef ___VBox_HostService_DnD_dndmanager_h
18#define ___VBox_HostService_DnD_dndmanager_h
19
20#include <VBox/GuestHost/DragAndDrop.h>
21#include <VBox/HostServices/Service.h>
22#include <VBox/HostServices/DragAndDropSvc.h>
23
24#include <iprt/cpp/ministring.h>
25#include <iprt/cpp/list.h>
26
27typedef DECLCALLBACK(int) FNDNDPROGRESS(uint32_t uState, uint32_t uPercentage, int rc, void *pvUser);
28typedef FNDNDPROGRESS *PFNDNDPROGRESS;
29
30/**
31 * DnD message class. This class forms the base of all other more specialized
32 * message classes.
33 */
34class DnDMessage
35{
36public:
37
38 DnDMessage(void)
39 : m_pNextMsg(NULL)
40 {
41 }
42
43 virtual ~DnDMessage(void)
44 {
45 clearNextMsg();
46 }
47
48 virtual HGCM::Message* nextHGCMMessage(void)
49 {
50 return m_pNextMsg;
51 }
52
53 virtual int currentMessageInfo(uint32_t *puMsg, uint32_t *pcParms)
54 {
55 AssertPtrReturn(puMsg, VERR_INVALID_POINTER);
56 AssertPtrReturn(pcParms, VERR_INVALID_POINTER);
57
58 if (!m_pNextMsg)
59 return VERR_NO_DATA;
60
61 *puMsg = m_pNextMsg->GetType();
62 *pcParms = m_pNextMsg->GetParamCount();
63
64 return VINF_SUCCESS;
65 }
66
67 virtual int currentMessage(uint32_t uMsg, uint32_t cParms,
68 VBOXHGCMSVCPARM paParms[])
69 {
70 if (!m_pNextMsg)
71 return VERR_NO_DATA;
72 int rc = m_pNextMsg->GetData(uMsg, cParms, paParms);
73
74 clearNextMsg();
75
76 return rc;
77 }
78
79 virtual void clearNextMsg(void)
80 {
81 if (m_pNextMsg)
82 {
83 delete m_pNextMsg;
84 m_pNextMsg = NULL;
85 }
86 }
87
88 virtual bool isMessageWaiting(void) const { return m_pNextMsg != NULL; }
89
90protected:
91
92 HGCM::Message *m_pNextMsg;
93};
94
95/**
96 * DnD message class for generic messages which didn't need any special
97 * handling.
98 */
99class DnDGenericMessage: public DnDMessage
100{
101public:
102 DnDGenericMessage(uint32_t uMsg, uint32_t cParms, VBOXHGCMSVCPARM paParms[])
103 {
104 m_pNextMsg = new HGCM::Message(uMsg, cParms, paParms);
105 }
106};
107
108/**
109 * DnD message class for informing the guest to cancel any current (and pending) activities.
110 */
111class DnDHGCancelMessage: public DnDMessage
112{
113public:
114
115 DnDHGCancelMessage(void)
116 {
117 m_pNextMsg
118 = new HGCM::Message(DragAndDropSvc::HOST_DND_HG_EVT_CANCEL,
119 0 /* cParms */, 0 /* aParms */);
120 }
121};
122
123/**
124 * DnD manager. Manage creation and queuing of messages for the various DnD
125 * messages types.
126 */
127class DnDManager
128{
129public:
130
131 DnDManager(PFNDNDPROGRESS pfnProgressCallback, void *pvProgressUser)
132 : m_pCurMsg(NULL)
133 , m_pfnProgressCallback(pfnProgressCallback)
134 , m_pvProgressUser(pvProgressUser)
135 {}
136
137 virtual ~DnDManager(void)
138 {
139 clear();
140 }
141
142 int addMessage(uint32_t uMsg, uint32_t cParms, VBOXHGCMSVCPARM paParms[], bool fAppend = true);
143
144 HGCM::Message *nextHGCMMessage(void);
145 int nextMessageInfo(uint32_t *puMsg, uint32_t *pcParms);
146 int nextMessage(uint32_t uMsg, uint32_t cParms, VBOXHGCMSVCPARM paParms[]);
147
148 void clear(void);
149 int doReschedule(void);
150
151private:
152 DnDMessage *m_pCurMsg;
153 RTCList<DnDMessage*> m_dndMessageQueue;
154
155 /* Progress stuff */
156 PFNDNDPROGRESS m_pfnProgressCallback;
157 void *m_pvProgressUser;
158};
159#endif /* ___VBox_HostService_DnD_dndmanager_h */
160
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