VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/VBoxClient/VBoxClient.h@ 97744

Last change on this file since 97744 was 97732, checked in by vboxsync, 2 years ago

Additions/VBoxClient: Cleaned up / unified the "notify to desktop" handling; there we had two different functions, whereas the D-BUS / freedesktop.org version only was available in the host notifier code. Both facilities now are available as common code, also using invoking "notify-send" as a fallback in case D-BUS is not available.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.0 KB
Line 
1/* $Id: VBoxClient.h 97732 2022-12-02 16:19:55Z vboxsync $ */
2/** @file
3 *
4 * VirtualBox additions user session daemon.
5 */
6
7/*
8 * Copyright (C) 2006-2022 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
46int VBClShowNotify(const char *pszHeader, const char *pszBody);
47
48void VBClLogInfo(const char *pszFormat, ...);
49void VBClLogError(const char *pszFormat, ...);
50void VBClLogFatalError(const char *pszFormat, ...);
51void VBClLogVerbose(unsigned iLevel, const char *pszFormat, ...);
52
53int VBClLogCreate(const char *pszLogFile);
54void VBClLogSetLogPrefix(const char *pszPrefix);
55void 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 */
62extern bool VBClHasWayland(void);
63
64/** Call clean-up for the current service and exit. */
65extern void VBClShutdown(bool fExit = true);
66
67/**
68 * A service descriptor.
69 */
70typedef 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. */
128typedef VBCLSERVICE *PVBCLSERVICE;
129/** Pointer to a const VBCLSERVICE. */
130typedef VBCLSERVICE const *PCVBCLSERVICE;
131
132RT_C_DECLS_BEGIN
133extern VBCLSERVICE g_SvcClipboard;
134extern VBCLSERVICE g_SvcDisplayDRM;
135extern VBCLSERVICE g_SvcDisplaySVGA;
136extern VBCLSERVICE g_SvcDisplayLegacy;
137# ifdef RT_OS_LINUX
138extern VBCLSERVICE g_SvcDisplaySVGASession;
139# endif
140extern VBCLSERVICE g_SvcDragAndDrop;
141extern VBCLSERVICE g_SvcHostVersion;
142extern VBCLSERVICE g_SvcSeamless;
143
144extern unsigned g_cVerbosity;
145extern bool g_fDaemonized;
146RT_C_DECLS_END
147
148#endif /* !GA_INCLUDED_SRC_x11_VBoxClient_VBoxClient_h */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette