VirtualBox

source: vbox/trunk/src/VBox/Main/include/ClientToken.h@ 94368

Last change on this file since 94368 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1/* $Id: ClientToken.h 93115 2022-01-01 11:31:46Z vboxsync $ */
2
3/** @file
4 *
5 * VirtualBox API client session token abstraction
6 */
7
8/*
9 * Copyright (C) 2013-2022 Oracle Corporation
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 */
19
20#ifndef MAIN_INCLUDED_ClientToken_h
21#define MAIN_INCLUDED_ClientToken_h
22#ifndef RT_WITHOUT_PRAGMA_ONCE
23# pragma once
24#endif
25
26#include <VBox/com/ptr.h>
27#include <VBox/com/AutoLock.h>
28
29#include "MachineImpl.h"
30#ifdef VBOX_WITH_GENERIC_SESSION_WATCHER
31# include "TokenImpl.h"
32#endif /* VBOX_WITH_GENERIC_SESSION_WATCHER */
33
34#if defined(RT_OS_WINDOWS)
35# define CTTOKENARG NULL
36# define CTTOKENTYPE HANDLE
37#elif defined(RT_OS_OS2)
38# define CTTOKENARG NULLHANDLE
39# define CTTOKENTYPE HMTX
40#elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER)
41# define CTTOKENARG -1
42# define CTTOKENTYPE int
43#elif defined(VBOX_WITH_GENERIC_SESSION_WATCHER)
44# define CTTOKENARG NULL
45# define CTTOKENTYPE MachineToken *
46#else
47# error "Port me!"
48#endif
49
50/**
51 * Class which represents a token which can be used to check for client
52 * crashes and similar purposes.
53 */
54class Machine::ClientToken
55{
56public:
57 /**
58 * Constructor which creates a usable instance
59 *
60 * @param pMachine Reference to Machine object
61 * @param pSessionMachine Reference to corresponding SessionMachine object
62 */
63 ClientToken(const ComObjPtr<Machine> &pMachine, SessionMachine *pSessionMachine);
64
65 /**
66 * Default destructor. Cleans everything up.
67 */
68 ~ClientToken();
69
70 /**
71 * Check if object contains a usable token.
72 */
73 bool isReady();
74
75 /**
76 * Query token ID, which is a unique string value for this token. Do not
77 * assume any specific content/format, it is opaque information.
78 */
79 void getId(Utf8Str &strId);
80
81 /**
82 * Query token, which is platform dependent.
83 */
84 CTTOKENTYPE getToken();
85
86#ifndef VBOX_WITH_GENERIC_SESSION_WATCHER
87 /**
88 * Release token now. Returns information if the client has terminated.
89 */
90 bool release();
91#endif /* !VBOX_WITH_GENERIC_SESSION_WATCHER */
92
93private:
94 /**
95 * Default constructor. Don't use, will not create a sensible instance.
96 */
97 ClientToken();
98
99 Machine *mMachine;
100 CTTOKENTYPE mClientToken;
101 Utf8Str mClientTokenId;
102#ifdef VBOX_WITH_GENERIC_SESSION_WATCHER
103 bool mClientTokenPassed;
104#endif
105};
106
107#endif /* !MAIN_INCLUDED_ClientToken_h */
108/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette