VirtualBox

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

Last change on this file since 39336 was 36037, checked in by vboxsync, 14 years ago

uninitalized member?

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.5 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::sFacilityInfo[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 *aParent, AdditionsFacilityType_T enmFacility, AdditionsFacilityStatus_T enmStatus)
59{
60 LogFlowThisFunc(("aParent=%p\n", aParent));
61
62 /* Enclose the state transition NotReady->InInit->Ready. */
63 AutoInitSpan autoInitSpan(this);
64 AssertReturn(autoInitSpan.isOk(), E_FAIL);
65
66 RTTimeNow(&mData.mLastUpdated);
67 mData.mStatus = enmStatus;
68 mData.mType = enmFacility;
69 /** @todo mClass is not initialized here. */
70
71 /* Confirm a successful initialization when it's the case. */
72 autoInitSpan.setSucceeded();
73
74 return S_OK;
75}
76
77/**
78 * Uninitializes the instance.
79 * Called from FinalRelease().
80 */
81void AdditionsFacility::uninit()
82{
83 LogFlowThisFunc(("\n"));
84
85 /* Enclose the state transition Ready->InUninit->NotReady. */
86 AutoUninitSpan autoUninitSpan(this);
87 if (autoUninitSpan.uninitDone())
88 return;
89}
90
91STDMETHODIMP AdditionsFacility::COMGETTER(ClassType)(AdditionsFacilityClass_T *aClass)
92{
93 LogFlowThisFuncEnter();
94
95 CheckComArgOutPointerValid(aClass);
96
97 AutoCaller autoCaller(this);
98 if (FAILED(autoCaller.rc())) return autoCaller.rc();
99
100 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
101
102 *aClass = getClass();
103
104 return S_OK;
105}
106
107STDMETHODIMP AdditionsFacility::COMGETTER(Name)(BSTR *aName)
108{
109 LogFlowThisFuncEnter();
110
111 CheckComArgOutPointerValid(aName);
112
113 AutoCaller autoCaller(this);
114 if (FAILED(autoCaller.rc())) return autoCaller.rc();
115
116 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
117
118 Bstr(getName()).cloneTo(aName);
119
120 return S_OK;
121}
122
123STDMETHODIMP AdditionsFacility::COMGETTER(LastUpdated)(LONG64 *aTimestamp)
124{
125 LogFlowThisFuncEnter();
126
127 CheckComArgOutPointerValid(aTimestamp);
128
129 AutoCaller autoCaller(this);
130 if (FAILED(autoCaller.rc())) return autoCaller.rc();
131
132 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
133
134 *aTimestamp = getLastUpdated();
135
136 return S_OK;
137}
138
139STDMETHODIMP AdditionsFacility::COMGETTER(Status)(AdditionsFacilityStatus_T *aStatus)
140{
141 LogFlowThisFuncEnter();
142
143 CheckComArgOutPointerValid(aStatus);
144
145 AutoCaller autoCaller(this);
146 if (FAILED(autoCaller.rc())) return autoCaller.rc();
147
148 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
149
150 *aStatus = getStatus();
151
152 return S_OK;
153}
154
155STDMETHODIMP AdditionsFacility::COMGETTER(Type)(AdditionsFacilityType_T *aType)
156{
157 LogFlowThisFuncEnter();
158
159 CheckComArgOutPointerValid(aType);
160
161 AutoCaller autoCaller(this);
162 if (FAILED(autoCaller.rc())) return autoCaller.rc();
163
164 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
165
166 *aType = getType();
167
168 return S_OK;
169}
170
171const AdditionsFacility::FacilityInfo &AdditionsFacility::typeToInfo(AdditionsFacilityType_T aType)
172{
173 for (size_t i = 0; i < RT_ELEMENTS(sFacilityInfo); ++i)
174 {
175 if (sFacilityInfo[i].mType == aType)
176 return sFacilityInfo[i];
177 }
178 return sFacilityInfo[0]; /* Return unknown type. */
179}
180
181AdditionsFacilityClass_T AdditionsFacility::getClass() const
182{
183 return AdditionsFacility::typeToInfo(mData.mType).mClass;
184}
185
186Bstr AdditionsFacility::getName() const
187{
188 return AdditionsFacility::typeToInfo(mData.mType).mName;
189}
190
191LONG64 AdditionsFacility::getLastUpdated() const
192{
193 return RTTimeSpecGetMilli(&mData.mLastUpdated);
194}
195
196AdditionsFacilityStatus_T AdditionsFacility::getStatus() const
197{
198 return mData.mStatus;
199}
200
201AdditionsFacilityType_T AdditionsFacility::getType() const
202{
203 return mData.mType;
204}
205
206HRESULT AdditionsFacility::update(AdditionsFacilityStatus_T aStatus, RTTIMESPEC aTimestamp)
207{
208 mData.mStatus = aStatus;
209 mData.mLastUpdated = aTimestamp;
210
211 return S_OK;
212}
213
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