VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/globals/UIGlobalSession.h

Last change on this file was 103982, checked in by vboxsync, 2 months ago

FE/Qt: bugref:10624. Replacing override and final keywords with RT_OVERRIDE and RT_FINAL defines.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.1 KB
Line 
1/* $Id: UIGlobalSession.h 103982 2024-03-21 11:43:53Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIGlobalSession class declaration.
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 FEQT_INCLUDED_SRC_globals_UIGlobalSession_h
29#define FEQT_INCLUDED_SRC_globals_UIGlobalSession_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QObject>
36#include <QReadWriteLock>
37
38/* COM includes: */
39#include "CHost.h"
40#include "CVirtualBox.h"
41#include "CVirtualBoxClient.h"
42
43/* Forward declarations: */
44class UIGuestOSTypeManager;
45
46/** QObject subclass wrapping global COM session functionality. */
47class SHARED_LIBRARY_STUFF UIGlobalSession : public QObject
48{
49 Q_OBJECT;
50
51signals:
52
53 /** @name General COM stuff.
54 * @{ */
55 /** Notifies listeners about the VBoxSVC availability change. */
56 void sigVBoxSVCAvailabilityChange(bool fAvailable);
57 /** @} */
58
59public:
60
61 /** Returns static UIGlobalSession instance. */
62 static UIGlobalSession *instance() { return s_pInstance; }
63 /** Creates static UIGlobalSession instance. */
64 static void create();
65 /** Destroys static UIGlobalSession instance. */
66 static void destroy();
67
68 /** Prepares all. */
69 bool prepare();
70 /** Cleanups all. */
71 void cleanup();
72
73 /** @name General COM stuff.
74 * @{ */
75 /** Try to acquire COM cleanup protection token for reading. */
76 bool comTokenTryLockForRead() { return m_comCleanupProtectionToken.tryLockForRead(); }
77 /** Unlock previously acquired COM cleanup protection token. */
78 void comTokenUnlock() { return m_comCleanupProtectionToken.unlock(); }
79
80 /** Returns the copy of VirtualBox client wrapper. */
81 CVirtualBoxClient virtualBoxClient() const { return m_comVBoxClient; }
82 /** Returns the copy of VirtualBox object wrapper. */
83 CVirtualBox virtualBox() const { return m_comVBox; }
84 /** Returns the copy of VirtualBox host-object wrapper. */
85 CHost host() const { return m_comHost; }
86 /** Returns the symbolic VirtualBox home-folder representation. */
87 QString homeFolder() const { return m_strHomeFolder; }
88
89 /** Returns the VBoxSVC availability value. */
90 bool isVBoxSVCAvailable() const { return m_fVBoxSVCAvailable; }
91 /** @} */
92
93 /** @name Guest OS type stuff.
94 * @{ */
95 const UIGuestOSTypeManager &guestOSTypeManager();
96 /** @} */
97
98protected slots:
99
100 /** @name General COM stuff.
101 * @{ */
102 /** Handles the VBoxSVC availability change. */
103 void sltHandleVBoxSVCAvailabilityChange(bool fAvailable);
104 /** @} */
105
106private:
107
108 /** Construcs global COM session object. */
109 UIGlobalSession();
110 /** Destrucs global COM session object. */
111 virtual ~UIGlobalSession() RT_OVERRIDE RT_FINAL;
112
113 /** @name General COM stuff.
114 * @{ */
115 /** Re-initializes COM wrappers and containers. */
116 bool comWrappersReinit();
117 /** @} */
118
119 /** Holds the singleton UIGlobalSession instance. */
120 static UIGlobalSession *s_pInstance;
121
122 /** @name General COM stuff.
123 * @{ */
124 /** Holds the COM cleanup protection token. */
125 QReadWriteLock m_comCleanupProtectionToken;
126
127 /** Holds the instance of VirtualBox client wrapper. */
128 CVirtualBoxClient m_comVBoxClient;
129 /** Holds the copy of VirtualBox object wrapper. */
130 CVirtualBox m_comVBox;
131 /** Holds the copy of VirtualBox host-object wrapper. */
132 CHost m_comHost;
133 /** Holds the symbolic VirtualBox home-folder representation. */
134 QString m_strHomeFolder;
135
136 /** Holds whether acquired COM wrappers are currently valid. */
137 bool m_fWrappersValid;
138 /** Holds whether VBoxSVC is currently available. */
139 bool m_fVBoxSVCAvailable;
140 /** @} */
141
142 /** @name Guest OS type stuff.
143 * @{ */
144 /** Holds the guest OS type manager instance. */
145 UIGuestOSTypeManager *m_pGuestOSTypeManager;
146 /** @} */
147
148#ifdef VBOX_WS_WIN
149 /** @name ATL stuff.
150 * @{ */
151 /** Holds the ATL module instance (for use with UIGlobalSession shared library only).
152 * @note Required internally by ATL (constructor records instance in global variable). */
153 ATL::CComModule _Module;
154 /** @} */
155#endif
156};
157
158#define gpGlobalSession UIGlobalSession::instance()
159
160#endif /* !FEQT_INCLUDED_SRC_globals_UIGlobalSession_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use