VirtualBox

source: vbox/trunk/include/VBox/HostServices/DragAndDropSvc.h@ 50265

Last change on this file since 50265 was 50265, checked in by vboxsync, 11 years ago

DnD: First working implementation for Windows guest->host support; still work in progress. As for now only pure text data can be dragged over.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.5 KB
Line 
1/** @file
2 * Drag and Drop service - Common header for host service and guest clients.
3 */
4
5/*
6 * Copyright (C) 2011-2014 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 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___VBox_HostService_DragAndDropSvc_h
27#define ___VBox_HostService_DragAndDropSvc_h
28
29#include <VBox/VMMDev.h>
30#include <VBox/VBoxGuest2.h>
31
32/*
33 * The mode of operations.
34 */
35#define VBOX_DRAG_AND_DROP_MODE_OFF 0
36#define VBOX_DRAG_AND_DROP_MODE_HOST_TO_GUEST 1
37#define VBOX_DRAG_AND_DROP_MODE_GUEST_TO_HOST 2
38#define VBOX_DRAG_AND_DROP_MODE_BIDIRECTIONAL 3
39
40#define DND_IGNORE_ACTION UINT32_C(0)
41#define DND_COPY_ACTION RT_BIT_32(0)
42#define DND_MOVE_ACTION RT_BIT_32(1)
43#define DND_LINK_ACTION RT_BIT_32(2)
44
45#define hasDnDCopyAction(a) ((a) && DND_COPY_ACTION)
46#define hasDnDMoveAction(a) ((a) && DND_MOVE_ACTION)
47#define hasDnDLinkAction(a) ((a) && DND_LINK_ACTION)
48
49#define isDnDIgnoreAction(a) ((a) == DND_IGNORE_ACTION)
50#define isDnDCopyAction(a) ((a) == DND_COPY_ACTION)
51#define isDnDMoveAction(a) ((a) == DND_MOVE_ACTION)
52#define isDnDLinkAction(a) ((a) == DND_LINK_ACTION)
53
54/* Everything defined in this file lives in this namespace. */
55namespace DragAndDropSvc {
56
57/******************************************************************************
58* Typedefs, constants and inlines *
59******************************************************************************/
60
61/**
62 * The service functions which are callable by host.
63 * Note: When adding new functions to this table, make sure that the actual ID
64 * does *not* overlap with the eGuestFn enumeration below!
65 */
66enum eHostFn
67{
68 HOST_DND_SET_MODE = 100,
69
70 /* H->G */
71 HOST_DND_HG_EVT_ENTER = 200,
72 HOST_DND_HG_EVT_MOVE,
73 HOST_DND_HG_EVT_LEAVE,
74 HOST_DND_HG_EVT_DROPPED,
75 HOST_DND_HG_EVT_CANCEL,
76 /** Gets the actual MIME data, based on
77 * the format(s) specified by HOST_DND_HG_EVT_ENTER. */
78 HOST_DND_HG_SND_DATA,
79 /** Sent when the actual buffer for HOST_DND_HG_SND_DATA
80 * was too small. */
81 HOST_DND_HG_SND_MORE_DATA,
82 HOST_DND_HG_SND_DIR,
83 HOST_DND_HG_SND_FILE,
84
85 /* G->H */
86 /** The host asks the guest whether a DnD operation
87 * is in progress when the mouse leaves the guest window. */
88 HOST_DND_GH_REQ_PENDING = 600,
89 /** The host informs the guest that a DnD drop operation
90 * has been started and that the host wants the data in
91 * a specific mime-type. */
92 HOST_DND_GH_EVT_DROPPED
93};
94
95/**
96 * The service functions which are called by guest.
97 * Note: When adding new functions to this table, make sure that the actual ID
98 * does *not* overlap with the eGuestFn enumeration above!
99 */
100enum eGuestFn
101{
102 /**
103 * Guest waits for a new message the host wants to process
104 * on the guest side. This can be a blocking call.
105 */
106 GUEST_DND_GET_NEXT_HOST_MSG = 300,
107
108 /* H->G */
109 GUEST_DND_HG_ACK_OP = 400,
110 GUEST_DND_HG_REQ_DATA,
111 GUEST_DND_HG_EVT_PROGRESS,
112
113 /* G->H */
114 /**
115 * The guests acknowledges that it currently has a drag'n drop
116 * operation in progress on the guest, which eventually could be
117 * dragged over to the host.
118 */
119 GUEST_DND_GH_ACK_PENDING = 500,
120 GUEST_DND_GH_SND_DATA,
121 GUEST_DND_GH_EVT_ERROR
122};
123
124/**
125 * The possible states for the progress operations.
126 */
127enum
128{
129 DND_PROGRESS_RUNNING = 1,
130 DND_PROGRESS_COMPLETE,
131 DND_PROGRESS_CANCELLED,
132 DND_PROGRESS_ERROR
133};
134
135#pragma pack (1)
136
137/*
138 * Host events
139 */
140
141typedef struct VBOXDNDHGACTIONMSG
142{
143 VBoxGuestHGCMCallInfo hdr;
144
145 /**
146 * HG Action event.
147 *
148 * Used by:
149 * HOST_DND_HG_EVT_ENTER
150 * HOST_DND_HG_EVT_MOVE
151 * HOST_DND_HG_EVT_DROPPED
152 */
153 HGCMFunctionParameter uScreenId; /* OUT uint32_t */
154 HGCMFunctionParameter uX; /* OUT uint32_t */
155 HGCMFunctionParameter uY; /* OUT uint32_t */
156 HGCMFunctionParameter uDefAction; /* OUT uint32_t */
157 HGCMFunctionParameter uAllActions; /* OUT uint32_t */
158 HGCMFunctionParameter pvFormats; /* OUT ptr */
159 HGCMFunctionParameter cFormats; /* OUT uint32_t */
160} VBOXDNDHGACTIONMSG;
161
162typedef struct VBOXDNDHGLEAVEMSG
163{
164 VBoxGuestHGCMCallInfo hdr;
165 /**
166 * HG Leave event.
167 *
168 * Used by:
169 * HOST_DND_HG_EVT_LEAVE
170 */
171} VBOXDNDHGLEAVEMSG;
172
173typedef struct VBOXDNDHGCANCELMSG
174{
175 VBoxGuestHGCMCallInfo hdr;
176
177 /**
178 * HG Cancel return event.
179 *
180 * Used by:
181 * HOST_DND_HG_EVT_CANCEL
182 */
183} VBOXDNDHGCANCELMSG;
184
185typedef struct VBOXDNDHGSENDDATAMSG
186{
187 VBoxGuestHGCMCallInfo hdr;
188
189 /**
190 * HG Send Data event.
191 *
192 * Used by:
193 * HOST_DND_HG_SND_DATA
194 */
195 HGCMFunctionParameter uScreenId; /* OUT uint32_t */
196 HGCMFunctionParameter pvFormat; /* OUT ptr */
197 HGCMFunctionParameter cFormat; /* OUT uint32_t */
198 HGCMFunctionParameter pvData; /* OUT ptr */
199 HGCMFunctionParameter cData; /* OUT uint32_t */
200} VBOXDNDHGSENDDATAMSG;
201
202typedef struct VBOXDNDHGSENDMOREDATAMSG
203{
204 VBoxGuestHGCMCallInfo hdr;
205
206 /**
207 * HG Send More Data event.
208 *
209 * Used by:
210 * HOST_DND_HG_SND_MORE_DATA
211 */
212 HGCMFunctionParameter pvData; /* OUT ptr */
213 HGCMFunctionParameter cData; /* OUT uint32_t */
214} VBOXDNDHGSENDMOREDATAMSG;
215
216typedef struct VBOXDNDHGSENDDIRMSG
217{
218 VBoxGuestHGCMCallInfo hdr;
219
220 /**
221 * HG Directory event.
222 *
223 * Used by:
224 * HOST_DND_HG_SND_DIR
225 */
226 HGCMFunctionParameter pvName; /* OUT ptr */
227 HGCMFunctionParameter cName; /* OUT uint32_t */
228 HGCMFunctionParameter fMode; /* OUT uint32_t */
229} VBOXDNDHGSENDDIRMSG;
230
231typedef struct VBOXDNDHGSENDFILEMSG
232{
233 VBoxGuestHGCMCallInfo hdr;
234
235 /**
236 * HG File event.
237 *
238 * Used by:
239 * HOST_DND_HG_SND_FILE
240 */
241 HGCMFunctionParameter pvName; /* OUT ptr */
242 HGCMFunctionParameter cName; /* OUT uint32_t */
243 HGCMFunctionParameter pvData; /* OUT ptr */
244 HGCMFunctionParameter cData; /* OUT uint32_t */
245 HGCMFunctionParameter fMode; /* OUT uint32_t */
246} VBOXDNDHGSENDFILEMSG;
247
248typedef struct VBOXDNDGHREQPENDINGMSG
249{
250 VBoxGuestHGCMCallInfo hdr;
251
252 /**
253 * GH Request Pending event.
254 *
255 * Used by:
256 * HOST_DND_GH_REQ_PENDING
257 */
258 HGCMFunctionParameter uScreenId; /* OUT uint32_t */
259} VBOXDNDGHREQPENDINGMSG;
260
261typedef struct VBOXDNDGHDROPPEDMSG
262{
263 VBoxGuestHGCMCallInfo hdr;
264
265 /**
266 * GH Dropped event.
267 *
268 * Used by:
269 * HOST_DND_GH_EVT_DROPPED
270 */
271 HGCMFunctionParameter pvFormat; /* OUT ptr */
272 HGCMFunctionParameter cFormat; /* OUT uint32_t */
273 HGCMFunctionParameter uAction; /* OUT uint32_t */
274} VBOXDNDGHDROPPEDMSG;
275
276/*
277 * Guest events
278 */
279
280typedef struct VBOXDNDNEXTMSGMSG
281{
282 VBoxGuestHGCMCallInfo hdr;
283
284 /**
285 * The returned command the host wants to
286 * run on the guest.
287 *
288 * Used by:
289 * GUEST_DND_GET_NEXT_HOST_MSG
290 */
291 HGCMFunctionParameter msg; /* OUT uint32_t */
292 /** Number of parameters the message needs. */
293 HGCMFunctionParameter num_parms; /* OUT uint32_t */
294 HGCMFunctionParameter block; /* OUT uint32_t */
295
296} VBOXDNDNEXTMSGMSG;
297
298typedef struct VBOXDNDHGACKOPMSG
299{
300 VBoxGuestHGCMCallInfo hdr;
301
302 /**
303 * HG Acknowledge Operation event.
304 *
305 * Used by:
306 * GUEST_DND_HG_ACK_OP
307 */
308 HGCMFunctionParameter uAction; /* OUT uint32_t */
309} VBOXDNDHGACKOPMSG;
310
311typedef struct VBOXDNDHGREQDATAMSG
312{
313 VBoxGuestHGCMCallInfo hdr;
314
315 /**
316 * HG request for data event.
317 *
318 * Used by:
319 * GUEST_DND_HG_REQ_DATA
320 */
321 HGCMFunctionParameter pFormat; /* OUT ptr */
322} VBOXDNDHGREQDATAMSG;
323
324typedef struct VBOXDNDGHACKPENDINGMSG
325{
326 VBoxGuestHGCMCallInfo hdr;
327
328 /**
329 * GH Acknowledge Pending event.
330 *
331 * Used by:
332 * GUEST_DND_GH_ACK_PENDING
333 */
334 HGCMFunctionParameter uDefAction; /* OUT uint32_t */
335 HGCMFunctionParameter uAllActions; /* OUT uint32_t */
336 HGCMFunctionParameter pFormat; /* OUT ptr */
337} VBOXDNDGHACKPENDINGMSG;
338
339typedef struct VBOXDNDGHSENDDATAMSG
340{
341 VBoxGuestHGCMCallInfo hdr;
342
343 /**
344 * GH Send Data event.
345 *
346 * Used by:
347 * GUEST_DND_GH_SND_DATA
348 */
349 HGCMFunctionParameter pData; /* OUT ptr */
350 HGCMFunctionParameter uSize; /* OUT uint32_t */
351} VBOXDNDGHSENDDATAMSG;
352
353typedef struct VBOXDNDGHEVTERRORMSG
354{
355 VBoxGuestHGCMCallInfo hdr;
356
357 /**
358 * GH Cancel Data event.
359 *
360 * Used by:
361 * GUEST_DND_GH_EVT_CANCEL
362 */
363 HGCMFunctionParameter uRC; /* OUT uint32_t */
364} VBOXDNDGHEVTERRORMSG;
365
366#pragma pack()
367
368/*
369 * Callback handler
370 */
371enum
372{
373 CB_MAGIC_DND_HG_ACK_OP = 0xe2100b93,
374 CB_MAGIC_DND_HG_REQ_DATA = 0x5cb3faf9,
375 CB_MAGIC_DND_HG_EVT_PROGRESS = 0x8c8a6956,
376 CB_MAGIC_DND_GH_ACK_PENDING = 0xbe975a14,
377 CB_MAGIC_DND_GH_SND_DATA = 0x4eb61bff,
378 CB_MAGIC_DND_GH_EVT_ERROR = 0x117a87c4
379};
380
381typedef struct VBOXDNDCBHEADERDATA
382{
383 /** Magic number to identify the structure. */
384 uint32_t u32Magic;
385 /** Context ID to identify callback data. */
386 uint32_t u32ContextID;
387} VBOXDNDCBHEADERDATA;
388typedef VBOXDNDCBHEADERDATA *PVBOXDNDCBHEADERDATA;
389
390typedef struct VBOXDNDCBHGACKOPDATA
391{
392 /** Callback data header. */
393 VBOXDNDCBHEADERDATA hdr;
394 uint32_t uAction;
395} VBOXDNDCBHGACKOPDATA;
396typedef VBOXDNDCBHGACKOPDATA *PVBOXDNDCBHGACKOPDATA;
397
398typedef struct VBOXDNDCBHGREQDATADATA
399{
400 /** Callback data header. */
401 VBOXDNDCBHEADERDATA hdr;
402 char *pszFormat;
403} VBOXDNDCBHGREQDATADATA;
404typedef VBOXDNDCBHGREQDATADATA *PVBOXDNDCBHGREQDATADATA;
405
406typedef struct VBOXDNDCBHGEVTPROGRESSDATA
407{
408 /** Callback data header. */
409 VBOXDNDCBHEADERDATA hdr;
410 uint32_t uPercentage;
411 uint32_t uState;
412 int rc;
413} VBOXDNDCBHGEVTPROGRESSDATA;
414typedef VBOXDNDCBHGEVTPROGRESSDATA *PVBOXDNDCBHGEVTPROGRESSDATA;
415
416typedef struct VBOXDNDCBGHACKPENDINGDATA
417{
418 /** Callback data header. */
419 VBOXDNDCBHEADERDATA hdr;
420 uint32_t uDefAction;
421 uint32_t uAllActions;
422 char *pszFormat;
423} VBOXDNDCBGHACKPENDINGDATA;
424typedef VBOXDNDCBGHACKPENDINGDATA *PVBOXDNDCBGHACKPENDINGDATA;
425
426typedef struct VBOXDNDCBSNDDATADATA
427{
428 /** Callback data header. */
429 VBOXDNDCBHEADERDATA hdr;
430 void *pvData;
431 uint32_t cbData;
432 uint32_t cbAllSize; /** @todo Why is this transmitted every time? */
433} VBOXDNDCBSNDDATADATA;
434typedef VBOXDNDCBSNDDATADATA *PVBOXDNDCBSNDDATADATA;
435
436typedef struct VBOXDNDCBEVTERRORDATA
437{
438 /** Callback data header. */
439 VBOXDNDCBHEADERDATA hdr;
440 int32_t rc;
441} VBOXDNDCBEVTERRORDATA;
442typedef VBOXDNDCBEVTERRORDATA *PVBOXDNDCBEVTERRORDATA;
443
444
445} /* namespace DragAndDropSvc */
446
447#endif /* !___VBox_HostService_DragAndDropSvc_h */
448
Note: See TracBrowser for help on using the repository browser.

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