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. */
|
---|
55 | namespace 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 | */
|
---|
66 | enum eHostFn
|
---|
67 | {
|
---|
68 | HOST_DND_SET_MODE = 100,
|
---|
69 |
|
---|
70 | /*
|
---|
71 | * Host -> Guest messages
|
---|
72 | */
|
---|
73 |
|
---|
74 | HOST_DND_HG_EVT_ENTER = 200,
|
---|
75 | HOST_DND_HG_EVT_MOVE,
|
---|
76 | HOST_DND_HG_EVT_LEAVE,
|
---|
77 | HOST_DND_HG_EVT_DROPPED,
|
---|
78 | HOST_DND_HG_EVT_CANCEL,
|
---|
79 | /** Gets the actual MIME data, based on
|
---|
80 | * the format(s) specified by HOST_DND_HG_EVT_ENTER. */
|
---|
81 | HOST_DND_HG_SND_DATA,
|
---|
82 | /** Sent when the actual buffer for HOST_DND_HG_SND_DATA
|
---|
83 | * was too small, issued by the DnD host service. */
|
---|
84 | HOST_DND_HG_SND_MORE_DATA,
|
---|
85 | /** Directory entry to be handled on the guest. */
|
---|
86 | HOST_DND_HG_SND_DIR,
|
---|
87 | /** File entry to be handled on the guest. */
|
---|
88 | HOST_DND_HG_SND_FILE,
|
---|
89 |
|
---|
90 | /*
|
---|
91 | * Guest -> Host messages
|
---|
92 | */
|
---|
93 |
|
---|
94 | /** The host asks the guest whether a DnD operation
|
---|
95 | * is in progress when the mouse leaves the guest window. */
|
---|
96 | HOST_DND_GH_REQ_PENDING = 600,
|
---|
97 | /** The host informs the guest that a DnD drop operation
|
---|
98 | * has been started and that the host wants the data in
|
---|
99 | * a specific mime-type. */
|
---|
100 | HOST_DND_GH_EVT_DROPPED,
|
---|
101 |
|
---|
102 | HOST_DND_GH_RECV_DIR = 650,
|
---|
103 | HOST_DND_GH_RECV_FILE
|
---|
104 | };
|
---|
105 |
|
---|
106 | /**
|
---|
107 | * The service functions which are called by guest.
|
---|
108 | * Note: When adding new functions to this table, make sure that the actual ID
|
---|
109 | * does *not* overlap with the eGuestFn enumeration above!
|
---|
110 | */
|
---|
111 | enum eGuestFn
|
---|
112 | {
|
---|
113 | /**
|
---|
114 | * Guest waits for a new message the host wants to process
|
---|
115 | * on the guest side. This can be a blocking call.
|
---|
116 | */
|
---|
117 | GUEST_DND_GET_NEXT_HOST_MSG = 300,
|
---|
118 |
|
---|
119 | /* H->G */
|
---|
120 | /** The guest acknowledges that the pending DnD data from
|
---|
121 | * the host can be dropped on the currently selected source
|
---|
122 | * on the guest. */
|
---|
123 | GUEST_DND_HG_ACK_OP = 400,
|
---|
124 | /** The guest requests the actual DnD data to be sent
|
---|
125 | * from the host. */
|
---|
126 | GUEST_DND_HG_REQ_DATA,
|
---|
127 | GUEST_DND_HG_EVT_PROGRESS,
|
---|
128 |
|
---|
129 | /* G->H */
|
---|
130 | /**
|
---|
131 | * The guests acknowledges that it currently has a drag'n drop
|
---|
132 | * operation in progress on the guest, which eventually could be
|
---|
133 | * dragged over to the host.
|
---|
134 | */
|
---|
135 | GUEST_DND_GH_ACK_PENDING = 500,
|
---|
136 | GUEST_DND_GH_SND_DATA,
|
---|
137 | GUEST_DND_GH_EVT_ERROR,
|
---|
138 |
|
---|
139 | GUEST_DND_GH_SND_DIR = 700,
|
---|
140 | GUEST_DND_GH_SND_FILE
|
---|
141 | };
|
---|
142 |
|
---|
143 | /**
|
---|
144 | * The possible states for the progress operations.
|
---|
145 | */
|
---|
146 | enum
|
---|
147 | {
|
---|
148 | DND_PROGRESS_RUNNING = 1,
|
---|
149 | DND_PROGRESS_COMPLETE,
|
---|
150 | DND_PROGRESS_CANCELLED,
|
---|
151 | DND_PROGRESS_ERROR
|
---|
152 | };
|
---|
153 |
|
---|
154 | #pragma pack (1)
|
---|
155 |
|
---|
156 | /*
|
---|
157 | * Host events
|
---|
158 | */
|
---|
159 |
|
---|
160 | typedef struct VBOXDNDHGACTIONMSG
|
---|
161 | {
|
---|
162 | VBoxGuestHGCMCallInfo hdr;
|
---|
163 |
|
---|
164 | /**
|
---|
165 | * HG Action event.
|
---|
166 | *
|
---|
167 | * Used by:
|
---|
168 | * HOST_DND_HG_EVT_ENTER
|
---|
169 | * HOST_DND_HG_EVT_MOVE
|
---|
170 | * HOST_DND_HG_EVT_DROPPED
|
---|
171 | */
|
---|
172 | HGCMFunctionParameter uScreenId; /* OUT uint32_t */
|
---|
173 | HGCMFunctionParameter uX; /* OUT uint32_t */
|
---|
174 | HGCMFunctionParameter uY; /* OUT uint32_t */
|
---|
175 | HGCMFunctionParameter uDefAction; /* OUT uint32_t */
|
---|
176 | HGCMFunctionParameter uAllActions; /* OUT uint32_t */
|
---|
177 | HGCMFunctionParameter pvFormats; /* OUT ptr */
|
---|
178 | HGCMFunctionParameter cFormats; /* OUT uint32_t */
|
---|
179 | } VBOXDNDHGACTIONMSG;
|
---|
180 |
|
---|
181 | typedef struct VBOXDNDHGLEAVEMSG
|
---|
182 | {
|
---|
183 | VBoxGuestHGCMCallInfo hdr;
|
---|
184 | /**
|
---|
185 | * HG Leave event.
|
---|
186 | *
|
---|
187 | * Used by:
|
---|
188 | * HOST_DND_HG_EVT_LEAVE
|
---|
189 | */
|
---|
190 | } VBOXDNDHGLEAVEMSG;
|
---|
191 |
|
---|
192 | typedef struct VBOXDNDHGCANCELMSG
|
---|
193 | {
|
---|
194 | VBoxGuestHGCMCallInfo hdr;
|
---|
195 |
|
---|
196 | /**
|
---|
197 | * HG Cancel return event.
|
---|
198 | *
|
---|
199 | * Used by:
|
---|
200 | * HOST_DND_HG_EVT_CANCEL
|
---|
201 | */
|
---|
202 | } VBOXDNDHGCANCELMSG;
|
---|
203 |
|
---|
204 | typedef struct VBOXDNDHGSENDDATAMSG
|
---|
205 | {
|
---|
206 | VBoxGuestHGCMCallInfo hdr;
|
---|
207 |
|
---|
208 | /**
|
---|
209 | * HG Send Data event.
|
---|
210 | *
|
---|
211 | * Used by:
|
---|
212 | * HOST_DND_HG_SND_DATA
|
---|
213 | */
|
---|
214 | HGCMFunctionParameter uScreenId; /* OUT uint32_t */
|
---|
215 | HGCMFunctionParameter pvFormat; /* OUT ptr */
|
---|
216 | HGCMFunctionParameter cFormat; /* OUT uint32_t */
|
---|
217 | HGCMFunctionParameter pvData; /* OUT ptr */
|
---|
218 | HGCMFunctionParameter cData; /* OUT uint32_t */
|
---|
219 | } VBOXDNDHGSENDDATAMSG;
|
---|
220 |
|
---|
221 | typedef struct VBOXDNDHGSENDMOREDATAMSG
|
---|
222 | {
|
---|
223 | VBoxGuestHGCMCallInfo hdr;
|
---|
224 |
|
---|
225 | /**
|
---|
226 | * HG Send More Data event.
|
---|
227 | *
|
---|
228 | * Used by:
|
---|
229 | * HOST_DND_HG_SND_MORE_DATA
|
---|
230 | */
|
---|
231 | HGCMFunctionParameter pvData; /* OUT ptr */
|
---|
232 | HGCMFunctionParameter cData; /* OUT uint32_t */
|
---|
233 | } VBOXDNDHGSENDMOREDATAMSG;
|
---|
234 |
|
---|
235 | typedef struct VBOXDNDHGSENDDIRMSG
|
---|
236 | {
|
---|
237 | VBoxGuestHGCMCallInfo hdr;
|
---|
238 |
|
---|
239 | /**
|
---|
240 | * HG Directory event.
|
---|
241 | *
|
---|
242 | * Used by:
|
---|
243 | * HOST_DND_HG_SND_DIR
|
---|
244 | */
|
---|
245 | HGCMFunctionParameter pvName; /* OUT ptr */
|
---|
246 | HGCMFunctionParameter cName; /* OUT uint32_t */
|
---|
247 | HGCMFunctionParameter fMode; /* OUT uint32_t */
|
---|
248 | } VBOXDNDHGSENDDIRMSG;
|
---|
249 |
|
---|
250 | typedef struct VBOXDNDHGSENDFILEMSG
|
---|
251 | {
|
---|
252 | VBoxGuestHGCMCallInfo hdr;
|
---|
253 |
|
---|
254 | /**
|
---|
255 | * HG File event.
|
---|
256 | *
|
---|
257 | * Used by:
|
---|
258 | * HOST_DND_HG_SND_FILE
|
---|
259 | */
|
---|
260 | HGCMFunctionParameter pvName; /* OUT ptr */
|
---|
261 | HGCMFunctionParameter cName; /* OUT uint32_t */
|
---|
262 | HGCMFunctionParameter pvData; /* OUT ptr */
|
---|
263 | HGCMFunctionParameter cData; /* OUT uint32_t */
|
---|
264 | HGCMFunctionParameter fMode; /* OUT uint32_t */
|
---|
265 | } VBOXDNDHGSENDFILEMSG;
|
---|
266 |
|
---|
267 | typedef struct VBOXDNDGHREQPENDINGMSG
|
---|
268 | {
|
---|
269 | VBoxGuestHGCMCallInfo hdr;
|
---|
270 |
|
---|
271 | /**
|
---|
272 | * GH Request Pending event.
|
---|
273 | *
|
---|
274 | * Used by:
|
---|
275 | * HOST_DND_GH_REQ_PENDING
|
---|
276 | */
|
---|
277 | HGCMFunctionParameter uScreenId; /* OUT uint32_t */
|
---|
278 | } VBOXDNDGHREQPENDINGMSG;
|
---|
279 |
|
---|
280 | typedef struct VBOXDNDGHDROPPEDMSG
|
---|
281 | {
|
---|
282 | VBoxGuestHGCMCallInfo hdr;
|
---|
283 |
|
---|
284 | /**
|
---|
285 | * GH Dropped event.
|
---|
286 | *
|
---|
287 | * Used by:
|
---|
288 | * HOST_DND_GH_EVT_DROPPED
|
---|
289 | */
|
---|
290 | HGCMFunctionParameter pvFormat; /* OUT ptr */
|
---|
291 | HGCMFunctionParameter cFormat; /* OUT uint32_t */
|
---|
292 | HGCMFunctionParameter uAction; /* OUT uint32_t */
|
---|
293 | } VBOXDNDGHDROPPEDMSG;
|
---|
294 |
|
---|
295 | /*
|
---|
296 | * Guest events
|
---|
297 | */
|
---|
298 |
|
---|
299 | typedef struct VBOXDNDNEXTMSGMSG
|
---|
300 | {
|
---|
301 | VBoxGuestHGCMCallInfo hdr;
|
---|
302 |
|
---|
303 | /**
|
---|
304 | * The returned command the host wants to
|
---|
305 | * run on the guest.
|
---|
306 | *
|
---|
307 | * Used by:
|
---|
308 | * GUEST_DND_GET_NEXT_HOST_MSG
|
---|
309 | */
|
---|
310 | HGCMFunctionParameter msg; /* OUT uint32_t */
|
---|
311 | /** Number of parameters the message needs. */
|
---|
312 | HGCMFunctionParameter num_parms; /* OUT uint32_t */
|
---|
313 | HGCMFunctionParameter block; /* OUT uint32_t */
|
---|
314 |
|
---|
315 | } VBOXDNDNEXTMSGMSG;
|
---|
316 |
|
---|
317 | typedef struct VBOXDNDHGACKOPMSG
|
---|
318 | {
|
---|
319 | VBoxGuestHGCMCallInfo hdr;
|
---|
320 |
|
---|
321 | /**
|
---|
322 | * HG Acknowledge Operation event.
|
---|
323 | *
|
---|
324 | * Used by:
|
---|
325 | * GUEST_DND_HG_ACK_OP
|
---|
326 | */
|
---|
327 | HGCMFunctionParameter uAction; /* OUT uint32_t */
|
---|
328 | } VBOXDNDHGACKOPMSG;
|
---|
329 |
|
---|
330 | typedef struct VBOXDNDHGREQDATAMSG
|
---|
331 | {
|
---|
332 | VBoxGuestHGCMCallInfo hdr;
|
---|
333 |
|
---|
334 | /**
|
---|
335 | * HG request for data event.
|
---|
336 | *
|
---|
337 | * Used by:
|
---|
338 | * GUEST_DND_HG_REQ_DATA
|
---|
339 | */
|
---|
340 | HGCMFunctionParameter pFormat; /* OUT ptr */
|
---|
341 | } VBOXDNDHGREQDATAMSG;
|
---|
342 |
|
---|
343 | typedef struct VBOXDNDGHACKPENDINGMSG
|
---|
344 | {
|
---|
345 | VBoxGuestHGCMCallInfo hdr;
|
---|
346 |
|
---|
347 | /**
|
---|
348 | * GH Acknowledge Pending event.
|
---|
349 | *
|
---|
350 | * Used by:
|
---|
351 | * GUEST_DND_GH_ACK_PENDING
|
---|
352 | */
|
---|
353 | HGCMFunctionParameter uDefAction; /* OUT uint32_t */
|
---|
354 | HGCMFunctionParameter uAllActions; /* OUT uint32_t */
|
---|
355 | HGCMFunctionParameter pFormat; /* OUT ptr */
|
---|
356 | } VBOXDNDGHACKPENDINGMSG;
|
---|
357 |
|
---|
358 | typedef struct VBOXDNDGHSENDDATAMSG
|
---|
359 | {
|
---|
360 | VBoxGuestHGCMCallInfo hdr;
|
---|
361 |
|
---|
362 | /**
|
---|
363 | * GH Send Data event.
|
---|
364 | *
|
---|
365 | * Used by:
|
---|
366 | * GUEST_DND_GH_SND_DATA
|
---|
367 | */
|
---|
368 | HGCMFunctionParameter pData; /* OUT ptr */
|
---|
369 | HGCMFunctionParameter uSize; /* OUT uint32_t */
|
---|
370 | } VBOXDNDGHSENDDATAMSG;
|
---|
371 |
|
---|
372 | typedef struct VBOXDNDGHEVTERRORMSG
|
---|
373 | {
|
---|
374 | VBoxGuestHGCMCallInfo hdr;
|
---|
375 |
|
---|
376 | /**
|
---|
377 | * GH Cancel Data event.
|
---|
378 | *
|
---|
379 | * Used by:
|
---|
380 | * GUEST_DND_GH_EVT_CANCEL
|
---|
381 | */
|
---|
382 | HGCMFunctionParameter uRC; /* OUT uint32_t */
|
---|
383 | } VBOXDNDGHEVTERRORMSG;
|
---|
384 |
|
---|
385 | #pragma pack()
|
---|
386 |
|
---|
387 | /*
|
---|
388 | * Callback handler
|
---|
389 | */
|
---|
390 | enum
|
---|
391 | {
|
---|
392 | CB_MAGIC_DND_HG_ACK_OP = 0xe2100b93,
|
---|
393 | CB_MAGIC_DND_HG_REQ_DATA = 0x5cb3faf9,
|
---|
394 | CB_MAGIC_DND_HG_EVT_PROGRESS = 0x8c8a6956,
|
---|
395 | CB_MAGIC_DND_GH_ACK_PENDING = 0xbe975a14,
|
---|
396 | CB_MAGIC_DND_GH_SND_DATA = 0x4eb61bff,
|
---|
397 | CB_MAGIC_DND_GH_EVT_ERROR = 0x117a87c4
|
---|
398 | };
|
---|
399 |
|
---|
400 | typedef struct VBOXDNDCBHEADERDATA
|
---|
401 | {
|
---|
402 | /** Magic number to identify the structure. */
|
---|
403 | uint32_t u32Magic;
|
---|
404 | /** Context ID to identify callback data. */
|
---|
405 | uint32_t u32ContextID;
|
---|
406 | } VBOXDNDCBHEADERDATA;
|
---|
407 | typedef VBOXDNDCBHEADERDATA *PVBOXDNDCBHEADERDATA;
|
---|
408 |
|
---|
409 | typedef struct VBOXDNDCBHGACKOPDATA
|
---|
410 | {
|
---|
411 | /** Callback data header. */
|
---|
412 | VBOXDNDCBHEADERDATA hdr;
|
---|
413 | uint32_t uAction;
|
---|
414 | } VBOXDNDCBHGACKOPDATA;
|
---|
415 | typedef VBOXDNDCBHGACKOPDATA *PVBOXDNDCBHGACKOPDATA;
|
---|
416 |
|
---|
417 | typedef struct VBOXDNDCBHGREQDATADATA
|
---|
418 | {
|
---|
419 | /** Callback data header. */
|
---|
420 | VBOXDNDCBHEADERDATA hdr;
|
---|
421 | char *pszFormat;
|
---|
422 | } VBOXDNDCBHGREQDATADATA;
|
---|
423 | typedef VBOXDNDCBHGREQDATADATA *PVBOXDNDCBHGREQDATADATA;
|
---|
424 |
|
---|
425 | typedef struct VBOXDNDCBHGEVTPROGRESSDATA
|
---|
426 | {
|
---|
427 | /** Callback data header. */
|
---|
428 | VBOXDNDCBHEADERDATA hdr;
|
---|
429 | uint32_t uPercentage;
|
---|
430 | uint32_t uState;
|
---|
431 | int rc;
|
---|
432 | } VBOXDNDCBHGEVTPROGRESSDATA;
|
---|
433 | typedef VBOXDNDCBHGEVTPROGRESSDATA *PVBOXDNDCBHGEVTPROGRESSDATA;
|
---|
434 |
|
---|
435 | typedef struct VBOXDNDCBGHACKPENDINGDATA
|
---|
436 | {
|
---|
437 | /** Callback data header. */
|
---|
438 | VBOXDNDCBHEADERDATA hdr;
|
---|
439 | uint32_t uDefAction;
|
---|
440 | uint32_t uAllActions;
|
---|
441 | char *pszFormat;
|
---|
442 | } VBOXDNDCBGHACKPENDINGDATA;
|
---|
443 | typedef VBOXDNDCBGHACKPENDINGDATA *PVBOXDNDCBGHACKPENDINGDATA;
|
---|
444 |
|
---|
445 | typedef struct VBOXDNDCBSNDDATADATA
|
---|
446 | {
|
---|
447 | /** Callback data header. */
|
---|
448 | VBOXDNDCBHEADERDATA hdr;
|
---|
449 | void *pvData;
|
---|
450 | uint32_t cbData;
|
---|
451 | uint32_t cbAllSize; /** @todo Why is this transmitted every time? */
|
---|
452 | } VBOXDNDCBSNDDATADATA;
|
---|
453 | typedef VBOXDNDCBSNDDATADATA *PVBOXDNDCBSNDDATADATA;
|
---|
454 |
|
---|
455 | typedef struct VBOXDNDCBEVTERRORDATA
|
---|
456 | {
|
---|
457 | /** Callback data header. */
|
---|
458 | VBOXDNDCBHEADERDATA hdr;
|
---|
459 | int32_t rc;
|
---|
460 | } VBOXDNDCBEVTERRORDATA;
|
---|
461 | typedef VBOXDNDCBEVTERRORDATA *PVBOXDNDCBEVTERRORDATA;
|
---|
462 |
|
---|
463 |
|
---|
464 | } /* namespace DragAndDropSvc */
|
---|
465 |
|
---|
466 | #endif /* !___VBox_HostService_DragAndDropSvc_h */
|
---|
467 |
|
---|