VirtualBox

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

Last change on this file since 69783 was 69782, checked in by vboxsync, 7 years ago

VBoxSDS: Plan B it is.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 KB
Line 
1/* $Id: VirtualBoxSDSImpl.h 69782 2017-11-20 18:53:29Z vboxsync $ */
2/** @file
3 * VBox Global COM Class definition
4 */
5
6/*
7 * Copyright (C) 2015-2017 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/**
30 * Per user data.
31 */
32class VBoxSDSPerUserData
33{
34public:
35 /** The SID (secure identifier) for the user. This is the key. */
36 com::Utf8Str m_strUserSid;
37 /** The user name (if we could get it). */
38 com::Utf8Str m_strUsername;
39 /** The VBoxSVC chosen to instantiate CLSID_VirtualBox.
40 * This is NULL if not set. */
41 ComPtr<IVBoxSVCRegistration> m_ptrTheChosenOne;
42 /** Critical section protecting everything here. */
43 RTCRITSECT m_Lock;
44
45
46public:
47 VBoxSDSPerUserData(com::Utf8Str const &a_rStrUserSid, com::Utf8Str const &a_rStrUsername)
48 : m_strUserSid(a_rStrUserSid), m_strUsername(a_rStrUsername)
49 {
50 RTCritSectInit(&m_Lock);
51 }
52
53 ~VBoxSDSPerUserData()
54 {
55 RTCritSectDelete(&m_Lock);
56 }
57
58 void i_lock()
59 {
60 RTCritSectEnter(&m_Lock);
61 }
62
63 void i_unlock()
64 {
65 RTCritSectLeave(&m_Lock);
66 }
67};
68
69
70class ATL_NO_VTABLE VirtualBoxSDS :
71 public VirtualBoxSDSWrap
72#ifdef RT_OS_WINDOWS
73 , public ATL::CComCoClass<VirtualBoxSDS, &CLSID_VirtualBoxSDS>
74#endif
75{
76private:
77 typedef std::map<com::Utf8Str, VBoxSDSPerUserData *> UserDataMap_T;
78 /** Per user data map (key is SID string). */
79 UserDataMap_T m_UserDataMap;
80 /** Lock protecting m_UserDataMap.*/
81 RTCRITSECTRW m_MapCritSect;
82
83public:
84
85 DECLARE_CLASSFACTORY_SINGLETON(VirtualBoxSDS)
86
87 //DECLARE_REGISTRY_RESOURCEID(IDR_VIRTUALBOX)
88
89 // Kind of redundant (VirtualBoxSDSWrap declares itself not aggregatable
90 // and CComCoClass<VirtualBoxSDS, &CLSID_VirtualBoxSDS> as aggregatable,
91 // the former is the first inheritance), but the C multiple inheritance
92 // rules and the class factory in VBoxSDS.cpp needs this to disambiguate.
93 DECLARE_NOT_AGGREGATABLE(VirtualBoxSDS)
94
95 DECLARE_EMPTY_CTOR_DTOR(VirtualBoxSDS)
96
97 HRESULT FinalConstruct();
98 void FinalRelease();
99
100 // public initializers/uninitializers for internal purposes only
101 HRESULT init();
102 void uninit();
103
104private:
105
106 // Wrapped IVirtualBoxSDS methods
107 HRESULT registerVBoxSVC(const ComPtr<IVBoxSVCRegistration> &aVBoxSVC, LONG aPid, ComPtr<IUnknown> &aExistingVirtualBox);
108 HRESULT deregisterVBoxSVC(const ComPtr<IVBoxSVCRegistration> &aVBoxSVC, LONG aPid);
109
110
111 // Private methods
112
113 /**
114 * Gets the client user SID of the
115 */
116 static bool i_getClientUserSid(com::Utf8Str *a_pStrSid, com::Utf8Str *a_pStrUsername);
117
118 /**
119 * Looks up the given user.
120 *
121 * @returns Pointer to the LOCKED per user data. NULL if not found.
122 * @param a_rStrUserSid The user SID.
123 */
124 VBoxSDSPerUserData *i_lookupPerUserData(com::Utf8Str const &a_rUserSid);
125
126 /**
127 * Looks up the given user, creating it if not found
128 *
129 * @returns Pointer to the LOCKED per user data. NULL on allocation error.
130 * @param a_rStrUserSid The user SID.
131 * @param a_rStrUsername The user name if available.
132 */
133 VBoxSDSPerUserData *i_lookupOrCreatePerUserData(com::Utf8Str const &a_rStrUserSid, com::Utf8Str const &a_rStrUsername);
134};
135
136
137#endif // !____H_VIRTUALBOXSDSIMPL
138/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

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