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