1 | /* $Id: VBoxTray.h 106411 2024-10-17 07:44:43Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxTray - Guest Additions Tray, Internal Header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2024 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
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
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef GA_INCLUDED_SRC_WINNT_VBoxTray_VBoxTray_h
|
---|
29 | #define GA_INCLUDED_SRC_WINNT_VBoxTray_VBoxTray_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | #include <iprt/win/windows.h>
|
---|
35 |
|
---|
36 | #include <iprt/initterm.h>
|
---|
37 | #include <iprt/string.h>
|
---|
38 | #include <iprt/thread.h>
|
---|
39 |
|
---|
40 | #include <VBox/version.h>
|
---|
41 | #include <VBox/VBoxGuestLib.h>
|
---|
42 | #include <VBoxDisplay.h>
|
---|
43 |
|
---|
44 | #include "VBoxDispIf.h"
|
---|
45 |
|
---|
46 |
|
---|
47 | /*********************************************************************************************************************************
|
---|
48 | * Defined Constants And Macros *
|
---|
49 | *********************************************************************************************************************************/
|
---|
50 | /** Title of the program to show.
|
---|
51 | * Also shown as part of message boxes. */
|
---|
52 | #define VBOX_VBOXTRAY_TITLE "VBoxTray"
|
---|
53 |
|
---|
54 | /*
|
---|
55 | * Windows messsages.
|
---|
56 | */
|
---|
57 |
|
---|
58 | /**
|
---|
59 | * General VBoxTray messages.
|
---|
60 | */
|
---|
61 | #define WM_VBOXTRAY_TRAY_ICON WM_APP + 40
|
---|
62 |
|
---|
63 | /* The tray icon's ID. */
|
---|
64 | #define ID_TRAYICON 2000
|
---|
65 |
|
---|
66 | /*
|
---|
67 | * Timer IDs.
|
---|
68 | */
|
---|
69 | #define TIMERID_VBOXTRAY_CHECK_HOSTVERSION 1000
|
---|
70 | #define TIMERID_VBOXTRAY_CAPS_TIMER 1001
|
---|
71 | #define TIMERID_VBOXTRAY_DT_TIMER 1002
|
---|
72 | #define TIMERID_VBOXTRAY_ST_DELAYED_INIT_TIMER 1003
|
---|
73 |
|
---|
74 |
|
---|
75 | /*********************************************************************************************************************************
|
---|
76 | * Common structures *
|
---|
77 | *********************************************************************************************************************************/
|
---|
78 |
|
---|
79 | /**
|
---|
80 | * The environment information for a single VBoxTray service.
|
---|
81 | */
|
---|
82 | typedef struct VBOXTRAYSVCENV
|
---|
83 | {
|
---|
84 | /** hInstance of VBoxTray. */
|
---|
85 | HINSTANCE hInstance;
|
---|
86 | /* Display driver interface, XPDM - WDDM abstraction see VBOXDISPIF** definitions above */
|
---|
87 | /** @todo r=andy Argh. Needed by the "display" + "seamless" services (which in turn get called
|
---|
88 | * by the VBoxCaps facility. See #8037. */
|
---|
89 | VBOXDISPIF dispIf;
|
---|
90 | } VBOXTRAYSVCENV;
|
---|
91 | /** Pointer to a VBoxTray service env info structure. */
|
---|
92 | typedef VBOXTRAYSVCENV *PVBOXTRAYSVCENV;
|
---|
93 | /** Pointer to a const VBoxTray service env info structure. */
|
---|
94 | typedef VBOXTRAYSVCENV const *PCVBOXTRAYSVCENV;
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * A VBoxTray service descriptor.
|
---|
98 | */
|
---|
99 | typedef struct VBOXTRAYSVCDESC
|
---|
100 | {
|
---|
101 | /** The service's name. RTTHREAD_NAME_LEN maximum characters. */
|
---|
102 | const char *pszName;
|
---|
103 | /** The service description. */
|
---|
104 | const char *pszDesc;
|
---|
105 | /** The usage options stuff for the --help screen. */
|
---|
106 | const char *pszUsage;
|
---|
107 | /** The option descriptions for the --help screen. */
|
---|
108 | const char *pszOptions;
|
---|
109 |
|
---|
110 | /** Callbacks. */
|
---|
111 |
|
---|
112 | /**
|
---|
113 | * Called before parsing arguments.
|
---|
114 | * @returns VBox status code.
|
---|
115 | */
|
---|
116 | DECLCALLBACKMEMBER(int, pfnPreInit,(void));
|
---|
117 |
|
---|
118 | /**
|
---|
119 | * Tries to parse the given command line option.
|
---|
120 | *
|
---|
121 | * @returns 0 if we parsed, -1 if it didn't and anything else means exit.
|
---|
122 | * @param ppszShort If not NULL it points to the short option iterator. a short argument.
|
---|
123 | * If NULL examine argv[*pi].
|
---|
124 | * @param argc The argument count.
|
---|
125 | * @param argv The argument vector.
|
---|
126 | * @param pi The argument vector index. Update if any value(s) are eaten.
|
---|
127 | */
|
---|
128 | DECLCALLBACKMEMBER(int, pfnOption,(const char **ppszShort, int argc, char **argv, int *pi));
|
---|
129 |
|
---|
130 | /**
|
---|
131 | * Initializes a service.
|
---|
132 | * @returns VBox status code.
|
---|
133 | * VERR_NOT_SUPPORTED if the service is not supported on this guest system. Logged.
|
---|
134 | * VERR_HGCM_SERVICE_NOT_FOUND if the service is not available on the host system. Logged.
|
---|
135 | * Returning any other error will be considered as a fatal error.
|
---|
136 | * @param pEnv
|
---|
137 | * @param ppInstance Where to return the thread-specific instance data.
|
---|
138 | * @todo r=bird: The pEnv type is WRONG! Please check all your const pointers.
|
---|
139 | */
|
---|
140 | DECLCALLBACKMEMBER(int, pfnInit,(const PVBOXTRAYSVCENV pEnv, void **ppInstance));
|
---|
141 |
|
---|
142 | /** Called from the worker thread.
|
---|
143 | *
|
---|
144 | * @returns VBox status code.
|
---|
145 | * @retval VINF_SUCCESS if exitting because *pfShutdown was set.
|
---|
146 | * @param pInstance Pointer to thread-specific instance data.
|
---|
147 | * @param pfShutdown Pointer to a per service termination flag to check
|
---|
148 | * before and after blocking.
|
---|
149 | */
|
---|
150 | DECLCALLBACKMEMBER(int, pfnWorker,(void *pInstance, bool volatile *pfShutdown));
|
---|
151 |
|
---|
152 | /**
|
---|
153 | * Stops a service.
|
---|
154 | */
|
---|
155 | DECLCALLBACKMEMBER(int, pfnStop,(void *pInstance));
|
---|
156 |
|
---|
157 | /**
|
---|
158 | * Does termination cleanups.
|
---|
159 | *
|
---|
160 | * @remarks This may be called even if pfnInit hasn't been called!
|
---|
161 | */
|
---|
162 | DECLCALLBACKMEMBER(void, pfnDestroy,(void *pInstance));
|
---|
163 | } VBOXTRAYSVCDESC;
|
---|
164 | /** Pointer to a VBoxTray service descriptor. */
|
---|
165 | typedef VBOXTRAYSVCDESC *PVBOXTRAYSVCDESC;
|
---|
166 |
|
---|
167 | /**
|
---|
168 | * VBoxTray service initialization info and runtime variables.
|
---|
169 | */
|
---|
170 | typedef struct VBOXTRAYSVCINFO
|
---|
171 | {
|
---|
172 | /** Pointer to the service descriptor. */
|
---|
173 | PVBOXTRAYSVCDESC pDesc;
|
---|
174 | /** Thread handle. */
|
---|
175 | RTTHREAD hThread;
|
---|
176 | /** Pointer to service-specific instance data.
|
---|
177 | * Must be free'd by the service itself. */
|
---|
178 | void *pInstance;
|
---|
179 | /** Whether Pre-init was called. */
|
---|
180 | bool fPreInited;
|
---|
181 | /** Shutdown indicator. */
|
---|
182 | bool volatile fShutdown;
|
---|
183 | /** Indicator set by the service thread exiting. */
|
---|
184 | bool volatile fStopped;
|
---|
185 | /** Whether the service was started or not. */
|
---|
186 | bool fStarted;
|
---|
187 | /** Whether the service is enabled or not. */
|
---|
188 | bool fEnabled;
|
---|
189 | } VBOXTRAYSVCINFO;
|
---|
190 | /** Pointer to a VBoxTray service' initialization and runtime variables. */
|
---|
191 | typedef VBOXTRAYSVCINFO *PVBOXTRAYSVCINFO;
|
---|
192 |
|
---|
193 | /**
|
---|
194 | * Structure for keeping a globally registered Windows message.
|
---|
195 | */
|
---|
196 | typedef struct VBOXTRAYGLOBALMSG
|
---|
197 | {
|
---|
198 | /** Message name. */
|
---|
199 | const char *pszName;
|
---|
200 | /** Function pointer for handling the message. */
|
---|
201 | int (*pfnHandler)(WPARAM wParam, LPARAM lParam);
|
---|
202 |
|
---|
203 | /* Variables. */
|
---|
204 |
|
---|
205 | /** Message ID;
|
---|
206 | * to be filled in when registering the actual message. */
|
---|
207 | UINT uMsgID;
|
---|
208 | } VBOXTRAYGLOBALMSG;
|
---|
209 | /** Pointer to a globally registered Windows message. */
|
---|
210 | typedef VBOXTRAYGLOBALMSG *PVBOXTRAYGLOBALMSG;
|
---|
211 |
|
---|
212 | /*********************************************************************************************************************************
|
---|
213 | * Externals *
|
---|
214 | *********************************************************************************************************************************/
|
---|
215 | extern VBOXTRAYSVCDESC g_SvcDescDisplay;
|
---|
216 | #ifdef VBOX_WITH_SHARED_CLIPBOARD
|
---|
217 | extern VBOXTRAYSVCDESC g_SvcDescClipboard;
|
---|
218 | #endif
|
---|
219 | extern VBOXTRAYSVCDESC g_SvcDescSeamless;
|
---|
220 | extern VBOXTRAYSVCDESC g_SvcDescVRDP;
|
---|
221 | extern VBOXTRAYSVCDESC g_SvcDescIPC;
|
---|
222 | extern VBOXTRAYSVCDESC g_SvcDescLA;
|
---|
223 | #ifdef VBOX_WITH_DRAG_AND_DROP
|
---|
224 | extern VBOXTRAYSVCDESC g_SvcDescDnD;
|
---|
225 | #endif
|
---|
226 |
|
---|
227 | extern bool g_fHasConsole;
|
---|
228 | extern unsigned g_cVerbosity;
|
---|
229 | extern HINSTANCE g_hInstance;
|
---|
230 | extern HWND g_hwndToolWindow;
|
---|
231 | extern uint32_t g_fGuestDisplaysChanged;
|
---|
232 |
|
---|
233 | #endif /* !GA_INCLUDED_SRC_WINNT_VBoxTray_VBoxTray_h */
|
---|
234 |
|
---|