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