VirtualBox

source: vbox/trunk/src/VBox/Main/GuestImpl.cpp@ 4044

Last change on this file since 4044 was 3911, checked in by vboxsync, 17 years ago

Main: IGuest::seamlessSupport => supportsSeamless.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.3 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
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 as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22#include "GuestImpl.h"
23#include "ConsoleImpl.h"
24#include "VMMDev.h"
25
26#include "Logging.h"
27
28#include <VBox/VBoxDev.h>
29#include <iprt/cpputils.h>
30
31// defines
32/////////////////////////////////////////////////////////////////////////////
33
34// constructor / destructor
35/////////////////////////////////////////////////////////////////////////////
36
37DEFINE_EMPTY_CTOR_DTOR (Guest)
38
39HRESULT Guest::FinalConstruct()
40{
41 return S_OK;
42}
43
44void Guest::FinalRelease()
45{
46 uninit ();
47}
48
49// public methods only for internal purposes
50/////////////////////////////////////////////////////////////////////////////
51
52/**
53 * Initializes the guest object.
54 */
55HRESULT Guest::init (Console *aParent)
56{
57 LogFlowThisFunc (("aParent=%p\n", aParent));
58
59 ComAssertRet (aParent, E_INVALIDARG);
60
61 /* Enclose the state transition NotReady->InInit->Ready */
62 AutoInitSpan autoInitSpan (this);
63 AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
64
65 unconst (mParent) = aParent;
66
67 /* mData.mAdditionsActive is FALSE */
68
69 /* Confirm a successful initialization when it's the case */
70 autoInitSpan.setSucceeded();
71
72 return S_OK;
73}
74
75/**
76 * Uninitializes the instance and sets the ready flag to FALSE.
77 * Called either from FinalRelease() or by the parent when it gets destroyed.
78 */
79void Guest::uninit()
80{
81 LogFlowThisFunc (("\n"));
82
83 /* Enclose the state transition Ready->InUninit->NotReady */
84 AutoUninitSpan autoUninitSpan (this);
85 if (autoUninitSpan.uninitDone())
86 return;
87
88 unconst (mParent).setNull();
89}
90
91// IGuest properties
92/////////////////////////////////////////////////////////////////////////////
93
94STDMETHODIMP Guest::COMGETTER(OSTypeId) (BSTR *aOSTypeId)
95{
96 if (!aOSTypeId)
97 return E_POINTER;
98
99 AutoCaller autoCaller (this);
100 CheckComRCReturnRC (autoCaller.rc());
101
102 AutoReaderLock alock (this);
103
104 // redirect the call to IMachine if no additions are installed
105 if (mData.mAdditionsVersion.isNull())
106 return mParent->machine()->COMGETTER(OSTypeId) (aOSTypeId);
107
108 mData.mOSTypeId.cloneTo (aOSTypeId);
109
110 return S_OK;
111}
112
113STDMETHODIMP Guest::COMGETTER(AdditionsActive) (BOOL *aAdditionsActive)
114{
115 if (!aAdditionsActive)
116 return E_POINTER;
117
118 AutoCaller autoCaller (this);
119 CheckComRCReturnRC (autoCaller.rc());
120
121 AutoReaderLock alock (this);
122
123 *aAdditionsActive = mData.mAdditionsActive;
124
125 return S_OK;
126}
127
128STDMETHODIMP Guest::COMGETTER(AdditionsVersion) (BSTR *aAdditionsVersion)
129{
130 if (!aAdditionsVersion)
131 return E_POINTER;
132
133 AutoCaller autoCaller (this);
134 CheckComRCReturnRC (autoCaller.rc());
135
136 AutoReaderLock alock (this);
137
138 mData.mAdditionsVersion.cloneTo (aAdditionsVersion);
139
140 return S_OK;
141}
142
143STDMETHODIMP Guest::COMGETTER(SupportsSeamless) (BOOL *aSupportsSeamless)
144{
145 if (!aSupportsSeamless)
146 return E_POINTER;
147
148 AutoCaller autoCaller (this);
149 CheckComRCReturnRC (autoCaller.rc());
150
151 AutoReaderLock alock (this);
152
153 *aSupportsSeamless = mData.mSupportsSeamless;
154
155 return S_OK;
156}
157
158STDMETHODIMP Guest::SetCredentials(INPTR BSTR aUserName, INPTR BSTR aPassword,
159 INPTR BSTR aDomain, BOOL aAllowInteractiveLogon)
160{
161 if (!aUserName || !aPassword || !aDomain)
162 return E_INVALIDARG;
163
164 AutoCaller autoCaller (this);
165 CheckComRCReturnRC (autoCaller.rc());
166
167 /* forward the information to the VMM device */
168 VMMDev *vmmDev = mParent->getVMMDev();
169 if (vmmDev)
170 {
171 uint32_t u32Flags = VMMDEV_SETCREDENTIALS_GUESTLOGON;
172 if (!aAllowInteractiveLogon)
173 u32Flags = VMMDEV_SETCREDENTIALS_NOLOCALLOGON;
174
175 vmmDev->getVMMDevPort()->pfnSetCredentials(vmmDev->getVMMDevPort(),
176 Utf8Str(aUserName).raw(), Utf8Str(aPassword).raw(),
177 Utf8Str(aDomain).raw(), u32Flags);
178 return S_OK;
179 }
180
181 return setError (E_FAIL,
182 tr ("VMM device is not available (is the VM running?)"));
183}
184
185
186// public methods only for internal purposes
187/////////////////////////////////////////////////////////////////////////////
188
189void Guest::setAdditionsVersion (Bstr aVersion)
190{
191 AssertReturnVoid (!aVersion.isEmpty());
192
193 AutoCaller autoCaller (this);
194 AssertComRCReturnVoid (autoCaller.rc());
195
196 AutoLock alock (this);
197
198 mData.mAdditionsVersion = aVersion;
199 /* this implies that Additions are active */
200 mData.mAdditionsActive = TRUE;
201}
202
203void Guest::setSupportsSeamless (BOOL aSupportsSeamless)
204{
205 AutoCaller autoCaller (this);
206 AssertComRCReturnVoid (autoCaller.rc());
207
208 AutoLock alock (this);
209
210 mData.mSupportsSeamless = aSupportsSeamless;
211}
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