VirtualBox

source: vbox/trunk/src/VBox/Main/include/ClientTokenHolder.h

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.9 KB
Line 
1/* $Id: ClientTokenHolder.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2
3/** @file
4 *
5 * VirtualBox API client session token holder (in the client process)
6 */
7
8/*
9 * Copyright (C) 2013-2023 Oracle and/or its affiliates.
10 *
11 * This file is part of VirtualBox base platform packages, as
12 * available from https://www.virtualbox.org.
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation, in version 3 of the
17 * License.
18 *
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see <https://www.gnu.org/licenses>.
26 *
27 * SPDX-License-Identifier: GPL-3.0-only
28 */
29
30#ifndef MAIN_INCLUDED_ClientTokenHolder_h
31#define MAIN_INCLUDED_ClientTokenHolder_h
32#ifndef RT_WITHOUT_PRAGMA_ONCE
33# pragma once
34#endif
35
36#include "SessionImpl.h"
37
38#if defined(RT_OS_WINDOWS)
39# define CTHSEMARG NULL
40# define CTHSEMTYPE HANDLE
41/* this second semaphore is only used on Windows */
42# define CTHTHREADSEMARG NULL
43# define CTHTHREADSEMTYPE HANDLE
44#elif defined(RT_OS_OS2)
45# define CTHSEMARG NIL_RTSEMEVENT
46# define CTHSEMTYPE RTSEMEVENT
47#elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER)
48# define CTHSEMARG -1
49# define CTHSEMTYPE int
50#elif defined(VBOX_WITH_GENERIC_SESSION_WATCHER)
51/* the token object based implementation needs no semaphores */
52#else
53# error "Port me!"
54#endif
55
56
57/**
58 * Class which holds a client token.
59 */
60class Session::ClientTokenHolder
61{
62public:
63#ifndef VBOX_WITH_GENERIC_SESSION_WATCHER
64 /**
65 * Constructor which creates a usable instance
66 *
67 * @param strTokenId String with identifier of the token
68 */
69 ClientTokenHolder(const Utf8Str &strTokenId);
70#else /* VBOX_WITH_GENERIC_SESSION_WATCHER */
71 /**
72 * Constructor which creates a usable instance
73 *
74 * @param aToken Reference to token object
75 */
76 ClientTokenHolder(IToken *aToken);
77#endif /* VBOX_WITH_GENERIC_SESSION_WATCHER */
78
79 /**
80 * Default destructor. Cleans everything up.
81 */
82 ~ClientTokenHolder();
83
84 /**
85 * Check if object contains a usable token.
86 */
87 bool isReady();
88
89private:
90 /**
91 * Default constructor. Don't use, will not create a sensible instance.
92 */
93 ClientTokenHolder();
94
95#ifndef VBOX_WITH_GENERIC_SESSION_WATCHER
96 Utf8Str mClientTokenId;
97#else /* VBOX_WITH_GENERIC_SESSION_WATCHER */
98 ComPtr<IToken> mToken;
99#endif /* VBOX_WITH_GENERIC_SESSION_WATCHER */
100#ifdef CTHSEMTYPE
101 CTHSEMTYPE mSem;
102#endif
103#if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)
104 RTTHREAD mThread;
105#endif
106#ifdef RT_OS_WINDOWS
107 CTHTHREADSEMTYPE mThreadSem;
108#endif
109};
110
111#endif /* !MAIN_INCLUDED_ClientTokenHolder_h */
112/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use