[10798] | 1 | /* $Id: VBoxTray.h 99829 2023-05-17 13:51:57Z vboxsync $ */
|
---|
[9] | 2 | /** @file
|
---|
[21227] | 3 | * VBoxTray - Guest Additions Tray, Internal Header.
|
---|
[9] | 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
[9] | 8 | *
|
---|
[96407] | 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
|
---|
[9] | 26 | */
|
---|
| 27 |
|
---|
[76563] | 28 | #ifndef GA_INCLUDED_SRC_WINNT_VBoxTray_VBoxTray_h
|
---|
| 29 | #define GA_INCLUDED_SRC_WINNT_VBoxTray_VBoxTray_h
|
---|
[76540] | 30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 31 | # pragma once
|
---|
| 32 | #endif
|
---|
[10798] | 33 |
|
---|
[62679] | 34 | #include <iprt/win/windows.h>
|
---|
[42224] | 35 |
|
---|
[10777] | 36 | #include <iprt/initterm.h>
|
---|
| 37 | #include <iprt/string.h>
|
---|
[57741] | 38 | #include <iprt/thread.h>
|
---|
[10777] | 39 |
|
---|
| 40 | #include <VBox/version.h>
|
---|
[21229] | 41 | #include <VBox/VBoxGuestLib.h>
|
---|
[27955] | 42 | #include <VBoxDisplay.h>
|
---|
[9] | 43 |
|
---|
[31145] | 44 | #include "VBoxDispIf.h"
|
---|
| 45 |
|
---|
[95827] | 46 |
|
---|
| 47 | /*********************************************************************************************************************************
|
---|
| 48 | * Defined Constants And Macros *
|
---|
| 49 | *********************************************************************************************************************************/
|
---|
[95828] | 50 | /** Title of the program to show.
|
---|
[95827] | 51 | * Also shown as part of message boxes. */
|
---|
| 52 | #define VBOX_VBOXTRAY_TITLE "VBoxTray"
|
---|
| 53 |
|
---|
[33966] | 54 | /*
|
---|
| 55 | * Windows messsages.
|
---|
| 56 | */
|
---|
[4281] | 57 |
|
---|
[33966] | 58 | /**
|
---|
| 59 | * General VBoxTray messages.
|
---|
| 60 | */
|
---|
| 61 | #define WM_VBOXTRAY_TRAY_ICON WM_APP + 40
|
---|
| 62 |
|
---|
| 63 | /* The tray icon's ID. */
|
---|
[34025] | 64 | #define ID_TRAYICON 2000
|
---|
[4281] | 65 |
|
---|
[33966] | 66 | /*
|
---|
| 67 | * Timer IDs.
|
---|
| 68 | */
|
---|
| 69 | #define TIMERID_VBOXTRAY_CHECK_HOSTVERSION 1000
|
---|
[45760] | 70 | #define TIMERID_VBOXTRAY_CAPS_TIMER 1001
|
---|
[45802] | 71 | #define TIMERID_VBOXTRAY_DT_TIMER 1002
|
---|
[45837] | 72 | #define TIMERID_VBOXTRAY_ST_DELAYED_INIT_TIMER 1003
|
---|
[33966] | 73 |
|
---|
[95827] | 74 |
|
---|
| 75 | /*********************************************************************************************************************************
|
---|
| 76 | * Common structures *
|
---|
| 77 | *********************************************************************************************************************************/
|
---|
| 78 |
|
---|
[57741] | 79 | /**
|
---|
| 80 | * The environment information for services.
|
---|
| 81 | */
|
---|
[99828] | 82 | typedef struct VBOXSERVICEENV
|
---|
[9] | 83 | {
|
---|
[57741] | 84 | /** hInstance of VBoxTray. */
|
---|
[9] | 85 | HINSTANCE hInstance;
|
---|
[57741] | 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. */
|
---|
[27955] | 89 | VBOXDISPIF dispIf;
|
---|
[62191] | 90 | } VBOXSERVICEENV;
|
---|
| 91 | /** Pointer to a VBoxTray service env info structure. */
|
---|
| 92 | typedef VBOXSERVICEENV *PVBOXSERVICEENV;
|
---|
| 93 | /** Pointer to a const VBoxTray service env info structure. */
|
---|
| 94 | typedef VBOXSERVICEENV const *PCVBOXSERVICEENV;
|
---|
[9] | 95 |
|
---|
[57741] | 96 | /**
|
---|
| 97 | * A service descriptor.
|
---|
| 98 | */
|
---|
[99828] | 99 | typedef struct VBOXSERVICEDESC
|
---|
[57741] | 100 | {
|
---|
| 101 | /** The service's name. RTTHREAD_NAME_LEN maximum characters. */
|
---|
[99828] | 102 | const char *pszName;
|
---|
[57741] | 103 | /** The service description. */
|
---|
[99828] | 104 | const char *pszDesc;
|
---|
[57741] | 105 |
|
---|
| 106 | /** Callbacks. */
|
---|
| 107 |
|
---|
| 108 | /**
|
---|
| 109 | * Initializes a service.
|
---|
| 110 | * @returns VBox status code.
|
---|
[84720] | 111 | * VERR_NOT_SUPPORTED if the service is not supported on this guest system. Logged.
|
---|
| 112 | * VERR_HGCM_SERVICE_NOT_FOUND if the service is not available on the host system. Logged.
|
---|
| 113 | * Returning any other error will be considered as a fatal error.
|
---|
[57741] | 114 | * @param pEnv
|
---|
| 115 | * @param ppInstance Where to return the thread-specific instance data.
|
---|
[62191] | 116 | * @todo r=bird: The pEnv type is WRONG! Please check all your const pointers.
|
---|
[57741] | 117 | */
|
---|
[85121] | 118 | DECLCALLBACKMEMBER(int, pfnInit,(const PVBOXSERVICEENV pEnv, void **ppInstance));
|
---|
[57741] | 119 |
|
---|
| 120 | /** Called from the worker thread.
|
---|
| 121 | *
|
---|
| 122 | * @returns VBox status code.
|
---|
| 123 | * @retval VINF_SUCCESS if exitting because *pfShutdown was set.
|
---|
| 124 | * @param pInstance Pointer to thread-specific instance data.
|
---|
| 125 | * @param pfShutdown Pointer to a per service termination flag to check
|
---|
| 126 | * before and after blocking.
|
---|
| 127 | */
|
---|
[85121] | 128 | DECLCALLBACKMEMBER(int, pfnWorker,(void *pInstance, bool volatile *pfShutdown));
|
---|
[57741] | 129 |
|
---|
| 130 | /**
|
---|
| 131 | * Stops a service.
|
---|
| 132 | */
|
---|
[85121] | 133 | DECLCALLBACKMEMBER(int, pfnStop,(void *pInstance));
|
---|
[57741] | 134 |
|
---|
| 135 | /**
|
---|
| 136 | * Does termination cleanups.
|
---|
| 137 | *
|
---|
| 138 | * @remarks This may be called even if pfnInit hasn't been called!
|
---|
| 139 | */
|
---|
[85121] | 140 | DECLCALLBACKMEMBER(void, pfnDestroy,(void *pInstance));
|
---|
[57741] | 141 | } VBOXSERVICEDESC, *PVBOXSERVICEDESC;
|
---|
| 142 |
|
---|
| 143 |
|
---|
| 144 | /**
|
---|
| 145 | * The service initialization info and runtime variables.
|
---|
| 146 | */
|
---|
[99828] | 147 | typedef struct VBOXSERVICEINFO
|
---|
[9] | 148 | {
|
---|
[57741] | 149 | /** Pointer to the service descriptor. */
|
---|
| 150 | PVBOXSERVICEDESC pDesc;
|
---|
| 151 | /** Thread handle. */
|
---|
| 152 | RTTHREAD hThread;
|
---|
| 153 | /** Pointer to service-specific instance data.
|
---|
| 154 | * Must be free'd by the service itself. */
|
---|
| 155 | void *pInstance;
|
---|
| 156 | /** Whether Pre-init was called. */
|
---|
| 157 | bool fPreInited;
|
---|
| 158 | /** Shutdown indicator. */
|
---|
| 159 | bool volatile fShutdown;
|
---|
| 160 | /** Indicator set by the service thread exiting. */
|
---|
| 161 | bool volatile fStopped;
|
---|
| 162 | /** Whether the service was started or not. */
|
---|
| 163 | bool fStarted;
|
---|
| 164 | /** Whether the service is enabled or not. */
|
---|
| 165 | bool fEnabled;
|
---|
| 166 | } VBOXSERVICEINFO, *PVBOXSERVICEINFO;
|
---|
[9] | 167 |
|
---|
[99829] | 168 | /**
|
---|
[99828] | 169 | * Globally unique (system wide) message registration.
|
---|
| 170 | */
|
---|
| 171 | typedef struct VBOXGLOBALMESSAGE
|
---|
[34025] | 172 | {
|
---|
| 173 | /** Message name. */
|
---|
[99828] | 174 | const char *pszName;
|
---|
[34025] | 175 | /** Function pointer for handling the message. */
|
---|
[99828] | 176 | int (*pfnHandler)(WPARAM wParam, LPARAM lParam);
|
---|
[3811] | 177 |
|
---|
[34025] | 178 | /* Variables. */
|
---|
| 179 |
|
---|
| 180 | /** Message ID;
|
---|
| 181 | * to be filled in when registering the actual message. */
|
---|
| 182 | UINT uMsgID;
|
---|
| 183 | } VBOXGLOBALMESSAGE, *PVBOXGLOBALMESSAGE;
|
---|
| 184 |
|
---|
[95827] | 185 |
|
---|
| 186 | /*********************************************************************************************************************************
|
---|
| 187 | * Externals *
|
---|
| 188 | *********************************************************************************************************************************/
|
---|
| 189 | extern VBOXSERVICEDESC g_SvcDescDisplay;
|
---|
| 190 | #ifdef VBOX_WITH_SHARED_CLIPBOARD
|
---|
| 191 | extern VBOXSERVICEDESC g_SvcDescClipboard;
|
---|
| 192 | #endif
|
---|
| 193 | extern VBOXSERVICEDESC g_SvcDescSeamless;
|
---|
| 194 | extern VBOXSERVICEDESC g_SvcDescVRDP;
|
---|
| 195 | extern VBOXSERVICEDESC g_SvcDescIPC;
|
---|
| 196 | extern VBOXSERVICEDESC g_SvcDescLA;
|
---|
| 197 | #ifdef VBOX_WITH_DRAG_AND_DROP
|
---|
| 198 | extern VBOXSERVICEDESC g_SvcDescDnD;
|
---|
| 199 | #endif
|
---|
| 200 |
|
---|
| 201 | extern int g_cVerbosity;
|
---|
[78937] | 202 | extern HINSTANCE g_hInstance;
|
---|
[57741] | 203 | extern HWND g_hwndToolWindow;
|
---|
[62865] | 204 | extern uint32_t g_fGuestDisplaysChanged;
|
---|
[3811] | 205 |
|
---|
[76098] | 206 | RTEXITCODE VBoxTrayShowError(const char *pszFormat, ...);
|
---|
| 207 |
|
---|
[76563] | 208 | #endif /* !GA_INCLUDED_SRC_WINNT_VBoxTray_VBoxTray_h */
|
---|
[10798] | 209 |
|
---|