VirtualBox

source: vbox/trunk/src/VBox/Main/src-client/AdditionsFacilityImpl.cpp@ 39890

Last change on this file since 39890 was 39890, checked in by vboxsync, 13 years ago

VMMDev,IGuest,IAdditionsFacility,VBoxGuest,iprt/types.h: VMMDev must track the guest facility reports so they can be saved and restored correctly. Also fixed a reset bug related to guestInfo2. Restrict who can report the status of which facilities. Recalc the runlevel based on which facilities are active. Restrict the number of facilities main tracks.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.7 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2011 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#include "AdditionsFacilityImpl.h"
19#include "Global.h"
20
21#include "AutoCaller.h"
22#include "Logging.h"
23
24/* static */
25const AdditionsFacility::FacilityInfo AdditionsFacility::s_aFacilityInfo[8] =
26{
27 /* NOTE: We assume that unknown is always the first entry! */
28 { "Unknown", AdditionsFacilityType_None, AdditionsFacilityClass_None },
29 { "VirtualBox Base Driver", AdditionsFacilityType_VBoxGuestDriver, AdditionsFacilityClass_Driver },
30 { "VirtualBox System Service", AdditionsFacilityType_VBoxService, AdditionsFacilityClass_Service },
31 { "VirtualBox Desktop Integration", AdditionsFacilityType_VBoxTrayClient, AdditionsFacilityClass_Program },
32 { "Seamless Mode", AdditionsFacilityType_Seamless, AdditionsFacilityClass_Feature },
33 { "Graphics Mode", AdditionsFacilityType_Graphics, AdditionsFacilityClass_Feature },
34};
35
36// constructor / destructor
37/////////////////////////////////////////////////////////////////////////////
38
39DEFINE_EMPTY_CTOR_DTOR(AdditionsFacility)
40
41HRESULT AdditionsFacility::FinalConstruct()
42{
43 LogFlowThisFunc(("\n"));
44 return BaseFinalConstruct();
45}
46
47void AdditionsFacility::FinalRelease()
48{
49 LogFlowThisFuncEnter();
50 uninit();
51 BaseFinalRelease();
52 LogFlowThisFuncLeave();
53}
54
55// public initializer/uninitializer for internal purposes only
56/////////////////////////////////////////////////////////////////////////////
57
58HRESULT AdditionsFacility::init(Guest *a_pParent, AdditionsFacilityType_T a_enmFacility, AdditionsFacilityStatus_T a_enmStatus,
59 uint32_t a_fFlags, PCRTTIMESPEC a_pTimeSpecTS)
60{
61 LogFlowThisFunc(("a_pParent=%p\n", a_pParent));
62
63 /* Enclose the state transition NotReady->InInit->Ready. */
64 AutoInitSpan autoInitSpan(this);
65 AssertReturn(autoInitSpan.isOk(), E_FAIL);
66
67 mData.mStatus = a_enmStatus;
68 mData.mType = a_enmFacility;
69 mData.mLastUpdated = *a_pTimeSpecTS;
70 /** @todo mClass is not initialized here. */
71 NOREF(a_fFlags);
72
73 /* Confirm a successful initialization when it's the case. */
74 autoInitSpan.setSucceeded();
75
76 return S_OK;
77}
78
79/**
80 * Uninitializes the instance.
81 * Called from FinalRelease().
82 */
83void AdditionsFacility::uninit()
84{
85 LogFlowThisFunc(("\n"));
86
87 /* Enclose the state transition Ready->InUninit->NotReady. */
88 AutoUninitSpan autoUninitSpan(this);
89 if (autoUninitSpan.uninitDone())
90 return;
91}
92
93STDMETHODIMP AdditionsFacility::COMGETTER(ClassType)(AdditionsFacilityClass_T *aClass)
94{
95 LogFlowThisFuncEnter();
96
97 CheckComArgOutPointerValid(aClass);
98
99 AutoCaller autoCaller(this);
100 if (FAILED(autoCaller.rc())) return autoCaller.rc();
101
102 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
103
104 *aClass = getClass();
105
106 return S_OK;
107}
108
109STDMETHODIMP AdditionsFacility::COMGETTER(Name)(BSTR *aName)
110{
111 LogFlowThisFuncEnter();
112
113 CheckComArgOutPointerValid(aName);
114
115 AutoCaller autoCaller(this);
116 if (FAILED(autoCaller.rc())) return autoCaller.rc();
117
118 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
119
120 Bstr(getName()).cloneTo(aName);
121
122 return S_OK;
123}
124
125STDMETHODIMP AdditionsFacility::COMGETTER(LastUpdated)(LONG64 *aTimestamp)
126{
127 LogFlowThisFuncEnter();
128
129 CheckComArgOutPointerValid(aTimestamp);
130
131 AutoCaller autoCaller(this);
132 if (FAILED(autoCaller.rc())) return autoCaller.rc();
133
134 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
135
136 *aTimestamp = getLastUpdated();
137
138 return S_OK;
139}
140
141STDMETHODIMP AdditionsFacility::COMGETTER(Status)(AdditionsFacilityStatus_T *aStatus)
142{
143 LogFlowThisFuncEnter();
144
145 CheckComArgOutPointerValid(aStatus);
146
147 AutoCaller autoCaller(this);
148 if (FAILED(autoCaller.rc())) return autoCaller.rc();
149
150 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
151
152 *aStatus = getStatus();
153
154 return S_OK;
155}
156
157STDMETHODIMP AdditionsFacility::COMGETTER(Type)(AdditionsFacilityType_T *aType)
158{
159 LogFlowThisFuncEnter();
160
161 CheckComArgOutPointerValid(aType);
162
163 AutoCaller autoCaller(this);
164 if (FAILED(autoCaller.rc())) return autoCaller.rc();
165
166 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
167
168 *aType = getType();
169
170 return S_OK;
171}
172
173const AdditionsFacility::FacilityInfo &AdditionsFacility::typeToInfo(AdditionsFacilityType_T aType)
174{
175 for (size_t i = 0; i < RT_ELEMENTS(s_aFacilityInfo); ++i)
176 {
177 if (s_aFacilityInfo[i].mType == aType)
178 return s_aFacilityInfo[i];
179 }
180 return s_aFacilityInfo[0]; /* Return unknown type. */
181}
182
183AdditionsFacilityClass_T AdditionsFacility::getClass() const
184{
185 return AdditionsFacility::typeToInfo(mData.mType).mClass;
186}
187
188Bstr AdditionsFacility::getName() const
189{
190 return AdditionsFacility::typeToInfo(mData.mType).mName;
191}
192
193LONG64 AdditionsFacility::getLastUpdated() const
194{
195 return RTTimeSpecGetMilli(&mData.mLastUpdated);
196}
197
198AdditionsFacilityStatus_T AdditionsFacility::getStatus() const
199{
200 return mData.mStatus;
201}
202
203AdditionsFacilityType_T AdditionsFacility::getType() const
204{
205 return mData.mType;
206}
207
208/**
209 * Method used by IGuest::facilityUpdate to make updates.
210 */
211void AdditionsFacility::update(AdditionsFacilityStatus_T a_enmStatus, uint32_t a_fFlags, PCRTTIMESPEC a_pTimeSpecTS)
212{
213 mData.mStatus = a_enmStatus;
214 mData.mLastUpdated = *a_pTimeSpecTS;
215 NOREF(a_fFlags);
216}
217
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