1 | /* $Id: draganddrop.cpp 100063 2023-06-03 17:42:36Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Guest Additions - Common drag'n drop wrapper service.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
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
|
---|
26 | */
|
---|
27 |
|
---|
28 | #include <iprt/mem.h>
|
---|
29 |
|
---|
30 | #include "VBox/HostServices/DragAndDropSvc.h"
|
---|
31 | #include "VBoxClient.h"
|
---|
32 | #include "draganddrop.h"
|
---|
33 |
|
---|
34 |
|
---|
35 | /** Pointer to the DnD interface class. */
|
---|
36 | static VBClDnDSvc *g_pSvc = NULL;
|
---|
37 |
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * @interface_method_impl{VBCLSERVICE,pfnInit}
|
---|
41 | */
|
---|
42 | static DECLCALLBACK(int) vbclDnDInit(void)
|
---|
43 | {
|
---|
44 | switch (VBClGetDisplayServerType())
|
---|
45 | {
|
---|
46 | case VBGHDISPLAYSERVERTYPE_X11:
|
---|
47 | g_pSvc = new VBClX11DnDSvc();
|
---|
48 | break;
|
---|
49 |
|
---|
50 | case VBGHDISPLAYSERVERTYPE_PURE_WAYLAND:
|
---|
51 | RT_FALL_THROUGH();
|
---|
52 | default:
|
---|
53 | return VERR_NOT_SUPPORTED;
|
---|
54 | }
|
---|
55 |
|
---|
56 | if (!g_pSvc)
|
---|
57 | return VERR_NO_MEMORY;
|
---|
58 |
|
---|
59 | return g_pSvc->init();
|
---|
60 | }
|
---|
61 |
|
---|
62 | /**
|
---|
63 | * @interface_method_impl{VBCLSERVICE,pfnWorker}
|
---|
64 | */
|
---|
65 | static DECLCALLBACK(int) vbclDnDWorker(bool volatile *pfShutdown)
|
---|
66 | {
|
---|
67 | AssertPtrReturn(g_pSvc, VERR_NOT_IMPLEMENTED);
|
---|
68 | return g_pSvc->worker(pfShutdown);
|
---|
69 | }
|
---|
70 |
|
---|
71 | /**
|
---|
72 | * @interface_method_impl{VBCLSERVICE,pfnStop}
|
---|
73 | */
|
---|
74 | static DECLCALLBACK(void) vbclDnDStop(void)
|
---|
75 | {
|
---|
76 | if (g_pSvc)
|
---|
77 | g_pSvc->stop();
|
---|
78 | }
|
---|
79 |
|
---|
80 | /**
|
---|
81 | * @interface_method_impl{VBCLSERVICE,pfnTerm}
|
---|
82 | */
|
---|
83 | static DECLCALLBACK(int) vbclDnDTerm(void)
|
---|
84 | {
|
---|
85 | int rc = VINF_SUCCESS;
|
---|
86 |
|
---|
87 | if (g_pSvc)
|
---|
88 | {
|
---|
89 | rc = g_pSvc->term();
|
---|
90 |
|
---|
91 | delete g_pSvc;
|
---|
92 | g_pSvc = NULL;
|
---|
93 | }
|
---|
94 |
|
---|
95 | return rc;
|
---|
96 | }
|
---|
97 |
|
---|
98 | VBCLSERVICE g_SvcDragAndDrop =
|
---|
99 | {
|
---|
100 | "dnd", /* szName */
|
---|
101 | "Drag'n'Drop", /* pszDescription */
|
---|
102 | ".vboxclient-draganddrop", /* pszPidFilePathTemplate */
|
---|
103 | NULL, /* pszUsage */
|
---|
104 | NULL, /* pszOptions */
|
---|
105 | NULL, /* pfnOption */
|
---|
106 | vbclDnDInit, /* pfnInit */
|
---|
107 | vbclDnDWorker, /* pfnWorker */
|
---|
108 | vbclDnDStop, /* pfnStop*/
|
---|
109 | vbclDnDTerm /* pfnTerm */
|
---|
110 | };
|
---|
111 |
|
---|