VirtualBox

source: vbox/trunk/src/VBox/Main/include/VirtualBoxSDSImpl.h@ 67885

Last change on this file since 67885 was 66926, checked in by vboxsync, 8 years ago

Main: spaces

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1/* $Id: VirtualBoxSDSImpl.h 66926 2017-05-17 09:07:37Z vboxsync $ */
2/** @file
3 * VBox Global COM Class definition
4 */
5
6/*
7 * Copyright (C) 2015-2015 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ____H_VIRTUALBOXSDSIMPL
19#define ____H_VIRTUALBOXSDSIMPL
20
21#include "VirtualBoxSDSWrap.h"
22#include "TokenWrap.h"
23
24#ifdef RT_OS_WINDOWS
25# include "win/resource.h"
26#endif
27
28 /**
29 * The MediumLockToken class automates cleanup of a Medium lock.
30 */
31class ATL_NO_VTABLE VirtualBoxToken :
32 public TokenWrap
33{
34public:
35
36 DECLARE_EMPTY_CTOR_DTOR(VirtualBoxToken)
37
38 HRESULT FinalConstruct();
39 void FinalRelease();
40
41 // public initializer/uninitializer for internal purposes only
42 HRESULT init(const std::wstring& wstrUserName);
43 void uninit();
44
45 /**
46 * Fabrique method to create and initialize COM token object.
47 *
48 * @param aToken Pointer to result Token COM object.
49 * @param wstrUserName User name of client for that we create the token
50 */
51 static HRESULT CreateToken(ComPtr<IToken>& aToken, const std::wstring& wstrUserName);
52
53 // Trace COM reference counting in debug mode
54#ifdef RT_STRICT
55 virtual ULONG InternalAddRef();
56 virtual ULONG InternalRelease();
57#endif
58
59private:
60
61 // wrapped IToken methods
62 HRESULT abandon(AutoCaller &aAutoCaller);
63 HRESULT dummy();
64
65 // data
66 struct Data
67 {
68 std::wstring wstrUserName;
69 };
70
71 Data m;
72};
73
74class ATL_NO_VTABLE VirtualBoxSDS :
75 public VirtualBoxSDSWrap
76#ifdef RT_OS_WINDOWS
77 , public ATL::CComCoClass<VirtualBoxSDS, &CLSID_VirtualBoxSDS>
78#endif
79{
80public:
81
82 DECLARE_CLASSFACTORY_SINGLETON(VirtualBoxSDS)
83
84 //DECLARE_REGISTRY_RESOURCEID(IDR_VIRTUALBOX)
85
86 // Kind of redundant (VirtualBoxSDSWrap declares itself not aggregatable
87 // and CComCoClass<VirtualBoxSDS, &CLSID_VirtualBoxSDS> as aggregatable,
88 // the former is the first inheritance), but the C multiple inheritance
89 // rules and the class factory in VBoxSDS.cpp needs this to disambiguate.
90 DECLARE_NOT_AGGREGATABLE(VirtualBoxSDS)
91
92 DECLARE_EMPTY_CTOR_DTOR(VirtualBoxSDS)
93
94 HRESULT FinalConstruct();
95 void FinalRelease();
96
97 // public initializers/uninitializers for internal purposes only
98 HRESULT init();
99 void uninit();
100
101private:
102
103 // Wrapped IVirtualBoxSDS properties
104
105 /**
106 * Returns the instance of VirtualBox for client.
107 * It impersonates client and returns his VirtualBox instance
108 * either from cahce or makes new one.
109 */
110 HRESULT getVirtualBox(ComPtr<IVirtualBox> &aVirtualBox, ComPtr<IToken> &aToken);
111
112 // Wrapped IVirtualBoxSDS methods
113
114 // Inner methods
115
116 /**
117 * Gets the current user name of current thread
118 */
119 int GetCurrentUserName(std::wstring& wstrUserName);
120
121 /**
122 * Prints current user name of this thread to the log
123 * @param prefix string fragment that will be inserted at the beginning
124 * of the logging line
125 */
126 void LogUserName(char *prefix);
127
128 /**
129 * Thread that periodically checks items in cache and cleans obsolete items
130 */
131 static DWORD WINAPI CheckCacheThread(LPVOID);
132
133 // data fields
134 class VirtualBoxCache;
135 static VirtualBoxCache m_cache;
136 friend VirtualBoxToken;
137};
138
139
140#endif // !____H_VIRTUALBOXSDSIMPL
141/* 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