1 | /* $Id: VBoxClient.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | *
|
---|
4 | * VirtualBox additions user session daemon.
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox base platform packages, as
|
---|
11 | * available from https://www.virtualbox.org.
|
---|
12 | *
|
---|
13 | * This program is free software; you can redistribute it and/or
|
---|
14 | * modify it under the terms of the GNU General Public License
|
---|
15 | * as published by the Free Software Foundation, in version 3 of the
|
---|
16 | * License.
|
---|
17 | *
|
---|
18 | * This program is distributed in the hope that it will be useful, but
|
---|
19 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
21 | * General Public License for more details.
|
---|
22 | *
|
---|
23 | * You should have received a copy of the GNU General Public License
|
---|
24 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
25 | *
|
---|
26 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
27 | */
|
---|
28 |
|
---|
29 | #ifndef GA_INCLUDED_SRC_x11_VBoxClient_VBoxClient_h
|
---|
30 | #define GA_INCLUDED_SRC_x11_VBoxClient_VBoxClient_h
|
---|
31 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
32 | # pragma once
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | #include <VBox/log.h>
|
---|
36 | #include <iprt/cpp/utils.h>
|
---|
37 | #include <iprt/string.h>
|
---|
38 |
|
---|
39 | /** Environment variable which is exported when in Wayland Desktop Environment. */
|
---|
40 | #define VBCL_ENV_WAYLAND_DISPLAY "WAYLAND_DISPLAY"
|
---|
41 | /** Environment variable which contains information about currently running Desktop Environment. */
|
---|
42 | #define VBCL_ENV_XDG_CURRENT_DESKTOP "XDG_CURRENT_DESKTOP"
|
---|
43 | /** Environment variable which contains information about currently running session (X11, Wayland, etc). */
|
---|
44 | #define VBCL_ENV_XDG_SESSION_TYPE "XDG_SESSION_TYPE"
|
---|
45 |
|
---|
46 | int VBClShowNotify(const char *pszHeader, const char *pszBody);
|
---|
47 |
|
---|
48 | void VBClLogInfo(const char *pszFormat, ...);
|
---|
49 | void VBClLogError(const char *pszFormat, ...);
|
---|
50 | void VBClLogFatalError(const char *pszFormat, ...);
|
---|
51 | void VBClLogVerbose(unsigned iLevel, const char *pszFormat, ...);
|
---|
52 |
|
---|
53 | int VBClLogCreate(const char *pszLogFile);
|
---|
54 | void VBClLogSetLogPrefix(const char *pszPrefix);
|
---|
55 | void VBClLogDestroy(void);
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * Detect if user is running on Wayland by checking corresponding environment variable.
|
---|
59 | *
|
---|
60 | * @returns True if Wayland has been detected, False otherwise.
|
---|
61 | */
|
---|
62 | extern bool VBClHasWayland(void);
|
---|
63 |
|
---|
64 | /** Call clean-up for the current service and exit. */
|
---|
65 | extern void VBClShutdown(bool fExit = true);
|
---|
66 |
|
---|
67 | /**
|
---|
68 | * A service descriptor.
|
---|
69 | */
|
---|
70 | typedef struct
|
---|
71 | {
|
---|
72 | /** The short service name. 16 chars maximum (RTTHREAD_NAME_LEN). */
|
---|
73 | const char *pszName;
|
---|
74 | /** The longer service name. */
|
---|
75 | const char *pszDesc;
|
---|
76 | /** Get the services default path to pidfile, relative to $HOME */
|
---|
77 | /** @todo Should this also have a component relative to the X server number?
|
---|
78 | */
|
---|
79 | const char *pszPidFilePath;
|
---|
80 | /** The usage options stuff for the --help screen. */
|
---|
81 | const char *pszUsage;
|
---|
82 | /** The option descriptions for the --help screen. */
|
---|
83 | const char *pszOptions;
|
---|
84 |
|
---|
85 | /**
|
---|
86 | * Tries to parse the given command line option.
|
---|
87 | *
|
---|
88 | * @returns 0 if we parsed, -1 if it didn't and anything else means exit.
|
---|
89 | * @param ppszShort If not NULL it points to the short option iterator. a short argument.
|
---|
90 | * If NULL examine argv[*pi].
|
---|
91 | * @param argc The argument count.
|
---|
92 | * @param argv The argument vector.
|
---|
93 | * @param pi The argument vector index. Update if any value(s) are eaten.
|
---|
94 | */
|
---|
95 | DECLCALLBACKMEMBER(int, pfnOption,(const char **ppszShort, int argc, char **argv, int *pi));
|
---|
96 |
|
---|
97 | /**
|
---|
98 | * Called before parsing arguments.
|
---|
99 | * @returns VBox status code, or
|
---|
100 | * VERR_NOT_AVAILABLE if service is supported on this platform in general but not available at the moment.
|
---|
101 | * VERR_NOT_SUPPORTED if service is not supported on this platform. */
|
---|
102 | DECLCALLBACKMEMBER(int, pfnInit,(void));
|
---|
103 |
|
---|
104 | /** Called from the worker thread.
|
---|
105 | *
|
---|
106 | * @returns VBox status code.
|
---|
107 | * @retval VINF_SUCCESS if exitting because *pfShutdown was set.
|
---|
108 | * @param pfShutdown Pointer to a per service termination flag to check
|
---|
109 | * before and after blocking.
|
---|
110 | */
|
---|
111 | DECLCALLBACKMEMBER(int, pfnWorker,(bool volatile *pfShutdown));
|
---|
112 |
|
---|
113 | /**
|
---|
114 | * Asks the service to stop.
|
---|
115 | *
|
---|
116 | * @remarks Will be called from the signal handler.
|
---|
117 | */
|
---|
118 | DECLCALLBACKMEMBER(void, pfnStop,(void));
|
---|
119 |
|
---|
120 | /**
|
---|
121 | * Does termination cleanups.
|
---|
122 | *
|
---|
123 | * @remarks This will be called even if pfnInit hasn't been called or pfnStop failed!
|
---|
124 | */
|
---|
125 | DECLCALLBACKMEMBER(int, pfnTerm,(void));
|
---|
126 | } VBCLSERVICE;
|
---|
127 | /** Pointer to a VBCLSERVICE. */
|
---|
128 | typedef VBCLSERVICE *PVBCLSERVICE;
|
---|
129 | /** Pointer to a const VBCLSERVICE. */
|
---|
130 | typedef VBCLSERVICE const *PCVBCLSERVICE;
|
---|
131 |
|
---|
132 | RT_C_DECLS_BEGIN
|
---|
133 | extern VBCLSERVICE g_SvcClipboard;
|
---|
134 | extern VBCLSERVICE g_SvcDisplayDRM;
|
---|
135 | extern VBCLSERVICE g_SvcDisplaySVGA;
|
---|
136 | extern VBCLSERVICE g_SvcDisplayLegacy;
|
---|
137 | # ifdef RT_OS_LINUX
|
---|
138 | extern VBCLSERVICE g_SvcDisplaySVGASession;
|
---|
139 | # endif
|
---|
140 | extern VBCLSERVICE g_SvcDragAndDrop;
|
---|
141 | extern VBCLSERVICE g_SvcHostVersion;
|
---|
142 | extern VBCLSERVICE g_SvcSeamless;
|
---|
143 |
|
---|
144 | extern unsigned g_cVerbosity;
|
---|
145 | extern bool g_fDaemonized;
|
---|
146 | RT_C_DECLS_END
|
---|
147 |
|
---|
148 | #endif /* !GA_INCLUDED_SRC_x11_VBoxClient_VBoxClient_h */
|
---|