1 | /* $Id: VBoxClient.h 76563 2019-01-01 03:53:56Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | *
|
---|
4 | * VirtualBox additions user session daemon.
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2019 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 | /** Exit with a fatal error. */
|
---|
30 | #define VBClFatalError(format) \
|
---|
31 | do { \
|
---|
32 | char *pszMessage = RTStrAPrintf2 format; \
|
---|
33 | LogRel(format); \
|
---|
34 | vbclFatalError(pszMessage); \
|
---|
35 | } while(0)
|
---|
36 |
|
---|
37 | /** Exit with a fatal error. */
|
---|
38 | extern DECLNORETURN(void) vbclFatalError(char *pszMessage);
|
---|
39 |
|
---|
40 | /** Call clean-up for the current service and exit. */
|
---|
41 | extern void VBClCleanUp(bool fExit = true);
|
---|
42 |
|
---|
43 | /** A simple interface describing a service. VBoxClient will run exactly one
|
---|
44 | * service per invocation. */
|
---|
45 | struct VBCLSERVICE
|
---|
46 | {
|
---|
47 | /** Get the services default path to pidfile, relative to $HOME */
|
---|
48 | /** @todo Should this also have a component relative to the X server number?
|
---|
49 | */
|
---|
50 | const char *(*getPidFilePath)(void);
|
---|
51 | /** Special initialisation, if needed. @a pause and @a resume are
|
---|
52 | * guaranteed not to be called until after this returns. */
|
---|
53 | int (*init)(struct VBCLSERVICE **ppInterface);
|
---|
54 | /** Run the service main loop */
|
---|
55 | int (*run)(struct VBCLSERVICE **ppInterface, bool fDaemonised);
|
---|
56 | /** Clean up any global resources before we shut down hard. The last calls
|
---|
57 | * to @a pause and @a resume are guaranteed to finish before this is called.
|
---|
58 | */
|
---|
59 | void (*cleanup)(struct VBCLSERVICE **ppInterface);
|
---|
60 | };
|
---|
61 |
|
---|
62 | /** Default handler for various struct VBCLSERVICE member functions. */
|
---|
63 | DECLINLINE(int) VBClServiceDefaultHandler(struct VBCLSERVICE **pSelf)
|
---|
64 | {
|
---|
65 | RT_NOREF1(pSelf);
|
---|
66 | return VINF_SUCCESS;
|
---|
67 | }
|
---|
68 |
|
---|
69 | /** Default handler for the struct VBCLSERVICE clean-up member function.
|
---|
70 | * Usually used because the service is cleaned up automatically when the user
|
---|
71 | * process/X11 exits. */
|
---|
72 | DECLINLINE(void) VBClServiceDefaultCleanup(struct VBCLSERVICE **ppInterface)
|
---|
73 | {
|
---|
74 | NOREF(ppInterface);
|
---|
75 | }
|
---|
76 |
|
---|
77 | extern struct VBCLSERVICE **VBClGetClipboardService();
|
---|
78 | extern struct VBCLSERVICE **VBClGetSeamlessService();
|
---|
79 | extern struct VBCLSERVICE **VBClGetDisplayService();
|
---|
80 | extern struct VBCLSERVICE **VBClGetHostVersionService();
|
---|
81 | #ifdef VBOX_WITH_DRAG_AND_DROP
|
---|
82 | extern struct VBCLSERVICE **VBClGetDragAndDropService();
|
---|
83 | #endif /* VBOX_WITH_DRAG_AND_DROP */
|
---|
84 | extern struct VBCLSERVICE **VBClCheck3DService();
|
---|
85 | extern struct VBCLSERVICE **VBClDisplaySVGAService();
|
---|
86 | extern struct VBCLSERVICE **VBClDisplaySVGAX11Service();
|
---|
87 |
|
---|
88 | #endif /* !GA_INCLUDED_SRC_x11_VBoxClient_VBoxClient_h */
|
---|