VirtualBox

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

Last change on this file since 50874 was 48431, checked in by vboxsync, 11 years ago

Main/Machine+Session: New generic client session watcher implementation based on token objects, works on all platforms and is used for now on XPCOM. Additionally a better error message when several API clients are racing for a lock, previously it could be quite confusing.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1/* $Id: ClientToken.h 48431 2013-09-11 14:08:36Z vboxsync $ */
2
3/** @file
4 *
5 * VirtualBox API client session token abstraction
6 */
7
8/*
9 * Copyright (C) 2013 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 ____H_CLIENTTOKEN
21#define ____H_CLIENTTOKEN
22
23#include <VBox/com/ptr.h>
24#include <VBox/com/AutoLock.h>
25
26#include "MachineImpl.h"
27#ifdef VBOX_WITH_GENERIC_SESSION_WATCHER
28# include "TokenImpl.h"
29#endif /* VBOX_WITH_GENERIC_SESSION_WATCHER */
30
31#if defined(RT_OS_WINDOWS)
32# define CTTOKENARG NULL
33# define CTTOKENTYPE HANDLE
34#elif defined(RT_OS_OS2)
35# define CTTOKENARG NULLHANDLE
36# define CTTOKENTYPE HMTX
37#elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER)
38# define CTTOKENARG -1
39# define CTTOKENTYPE int
40#elif defined(VBOX_WITH_GENERIC_SESSION_WATCHER)
41# define CTTOKENARG NULL
42# define CTTOKENTYPE MachineToken *
43#else
44# error "Port me!"
45#endif
46
47/**
48 * Class which represents a token which can be used to check for client
49 * crashes and similar purposes.
50 */
51class Machine::ClientToken
52{
53public:
54 /**
55 * Constructor which creates a usable instance
56 *
57 * @param pMachine Reference to Machine object
58 * @param pSessionMachine Reference to corresponding SessionMachine object
59 */
60 ClientToken(const ComObjPtr<Machine> &pMachine, SessionMachine *pSessionMachine);
61
62 /**
63 * Default destructor. Cleans everything up.
64 */
65 ~ClientToken();
66
67 /**
68 * Check if object contains a usable token.
69 */
70 bool isReady();
71
72 /**
73 * Query token ID, which is a unique string value for this token. Do not
74 * assume any specific content/format, it is opaque information.
75 */
76 void getId(Utf8Str &strId);
77
78 /**
79 * Query token, which is platform dependent.
80 */
81 CTTOKENTYPE getToken();
82
83#ifndef VBOX_WITH_GENERIC_SESSION_WATCHER
84 /**
85 * Release token now. Returns information if the client has terminated.
86 */
87 bool release();
88#endif /* !VBOX_WITH_GENERIC_SESSION_WATCHER */
89
90private:
91 /**
92 * Default constructor. Don't use, will not create a sensible instance.
93 */
94 ClientToken();
95
96 Machine *mMachine;
97 CTTOKENTYPE mClientToken;
98 Utf8Str mClientTokenId;
99#ifdef VBOX_WITH_GENERIC_SESSION_WATCHER
100 bool mClientTokenPassed;
101#endif
102};
103
104#endif /* !____H_CLIENTTOKEN */
105/* 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