VirtualBox

source: vbox/trunk/src/VBox/Main/VirtualBoxErrorInfoImpl.cpp@ 20928

Last change on this file since 20928 was 20267, checked in by vboxsync, 15 years ago

Main: completed scriptable changes
Make VBox buildable on SMB share exported by Win box.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.4 KB
Line 
1/** @file
2 *
3 * VirtualBoxErrorInfo COM classe implementation
4 */
5
6/*
7 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#include "VirtualBoxErrorInfoImpl.h"
23#include "Logging.h"
24
25// public initializer/uninitializer for internal purposes only
26////////////////////////////////////////////////////////////////////////////////
27
28HRESULT VirtualBoxErrorInfo::init (HRESULT aResultCode, const GUID &aIID,
29 CBSTR aComponent, CBSTR aText,
30 IVirtualBoxErrorInfo *aNext)
31{
32 mResultCode = aResultCode;
33 mIID = aIID;
34 mComponent = aComponent;
35 mText = aText;
36 mNext = aNext;
37
38 return S_OK;
39}
40
41// IVirtualBoxErrorInfo properties
42////////////////////////////////////////////////////////////////////////////////
43
44STDMETHODIMP VirtualBoxErrorInfo::COMGETTER(ResultCode) (LONG *aResultCode)
45{
46 CheckComArgOutPointerValid(aResultCode);
47
48 *aResultCode = mResultCode;
49 return S_OK;
50}
51
52STDMETHODIMP VirtualBoxErrorInfo::COMGETTER(InterfaceID) (OUT_GUID aIID)
53{
54 CheckComArgOutPointerValid(aIID);
55
56 mIID.cloneTo (aIID);
57 return S_OK;
58}
59
60STDMETHODIMP VirtualBoxErrorInfo::COMGETTER(Component) (BSTR *aComponent)
61{
62 CheckComArgOutPointerValid(aComponent);
63
64 mComponent.cloneTo (aComponent);
65 return S_OK;
66}
67
68STDMETHODIMP VirtualBoxErrorInfo::COMGETTER(Text) (BSTR *aText)
69{
70 CheckComArgOutPointerValid(aText);
71
72 mText.cloneTo (aText);
73 return S_OK;
74}
75
76STDMETHODIMP VirtualBoxErrorInfo::COMGETTER(Next) (IVirtualBoxErrorInfo **aNext)
77{
78 CheckComArgOutPointerValid(aNext);
79
80 /* this will set aNext to NULL if mNext is null */
81 return mNext.queryInterfaceTo (aNext);
82}
83
84#if !defined (VBOX_WITH_XPCOM)
85
86/**
87 * Initializes itself by fetching error information from the given error info
88 * object.
89 */
90HRESULT VirtualBoxErrorInfo::init (IErrorInfo *aInfo)
91{
92 AssertReturn (aInfo, E_FAIL);
93
94 HRESULT rc = S_OK;
95
96 /* We don't return a failure if talking to IErrorInfo fails below to
97 * protect ourselves from bad IErrorInfo implementations (the
98 * corresponding fields will simply remain null in this case). */
99
100 mResultCode = S_OK;
101 rc = aInfo->GetGUID (mIID.asOutParam());
102 AssertComRC (rc);
103 rc = aInfo->GetSource (mComponent.asOutParam());
104 AssertComRC (rc);
105 rc = aInfo->GetDescription (mText.asOutParam());
106 AssertComRC (rc);
107
108 return S_OK;
109}
110
111// IErrorInfo methods
112////////////////////////////////////////////////////////////////////////////////
113
114STDMETHODIMP VirtualBoxErrorInfo::GetDescription (BSTR *description)
115{
116 return COMGETTER(Text) (description);
117}
118
119STDMETHODIMP VirtualBoxErrorInfo::GetGUID (GUID *guid)
120{
121 return COMGETTER(InterfaceID) (guid);
122}
123
124STDMETHODIMP VirtualBoxErrorInfo::GetHelpContext (DWORD *pdwHelpContext)
125{
126 return E_NOTIMPL;
127}
128
129STDMETHODIMP VirtualBoxErrorInfo::GetHelpFile (BSTR *pbstrHelpFile)
130{
131 return E_NOTIMPL;
132}
133
134STDMETHODIMP VirtualBoxErrorInfo::GetSource (BSTR *source)
135{
136 return COMGETTER(Component) (source);
137}
138
139#else // !defined (VBOX_WITH_XPCOM)
140
141/**
142 * Initializes itself by fetching error information from the given error info
143 * object.
144 */
145HRESULT VirtualBoxErrorInfo::init (nsIException *aInfo)
146{
147 AssertReturn (aInfo, E_FAIL);
148
149 HRESULT rc = S_OK;
150
151 /* We don't return a failure if talking to nsIException fails below to
152 * protect ourselves from bad nsIException implementations (the
153 * corresponding fields will simply remain null in this case). */
154
155 rc = aInfo->GetResult (&mResultCode);
156 AssertComRC (rc);
157 Utf8Str message;
158 rc = aInfo->GetMessage (message.asOutParam());
159 AssertComRC (rc);
160 mText = message;
161
162 return S_OK;
163}
164
165// nsIException methods
166////////////////////////////////////////////////////////////////////////////////
167
168/* readonly attribute string message; */
169NS_IMETHODIMP VirtualBoxErrorInfo::GetMessage (char **aMessage)
170{
171 CheckComArgOutPointerValid(aMessage);
172
173 Utf8Str (mText).cloneTo (aMessage);
174 return S_OK;
175}
176
177/* readonly attribute nsresult result; */
178NS_IMETHODIMP VirtualBoxErrorInfo::GetResult (nsresult *aResult)
179{
180 if (!aResult)
181 return NS_ERROR_INVALID_POINTER;
182
183 PRInt32 lrc;
184 nsresult rc = COMGETTER(ResultCode) (&lrc);
185 if (SUCCEEDED(rc))
186 *aResult = lrc;
187 return rc;
188}
189
190/* readonly attribute string name; */
191NS_IMETHODIMP VirtualBoxErrorInfo::GetName (char ** /* aName */)
192{
193 return NS_ERROR_NOT_IMPLEMENTED;
194}
195
196/* readonly attribute string filename; */
197NS_IMETHODIMP VirtualBoxErrorInfo::GetFilename (char ** /* aFilename */)
198{
199 return NS_ERROR_NOT_IMPLEMENTED;
200}
201
202/* readonly attribute PRUint32 lineNumber; */
203NS_IMETHODIMP VirtualBoxErrorInfo::GetLineNumber (PRUint32 * /* aLineNumber */)
204{
205 return NS_ERROR_NOT_IMPLEMENTED;
206}
207
208/* readonly attribute PRUint32 columnNumber; */
209NS_IMETHODIMP VirtualBoxErrorInfo::GetColumnNumber (PRUint32 * /*aColumnNumber */)
210{
211 return NS_ERROR_NOT_IMPLEMENTED;
212}
213
214/* readonly attribute nsIStackFrame location; */
215NS_IMETHODIMP VirtualBoxErrorInfo::GetLocation (nsIStackFrame ** /* aLocation */)
216{
217 return NS_ERROR_NOT_IMPLEMENTED;
218}
219
220/* readonly attribute nsIException inner; */
221NS_IMETHODIMP VirtualBoxErrorInfo::GetInner (nsIException **aInner)
222{
223 ComPtr <IVirtualBoxErrorInfo> info;
224 nsresult rv = COMGETTER(Next) (info.asOutParam());
225 CheckComRCReturnRC (rv);
226 return info.queryInterfaceTo (aInner);
227}
228
229/* readonly attribute nsISupports data; */
230NS_IMETHODIMP VirtualBoxErrorInfo::GetData (nsISupports ** /* aData */)
231{
232 return NS_ERROR_NOT_IMPLEMENTED;
233}
234
235/* string toString (); */
236NS_IMETHODIMP VirtualBoxErrorInfo::ToString (char ** /* retval */)
237{
238 return NS_ERROR_NOT_IMPLEMENTED;
239}
240
241NS_IMPL_THREADSAFE_ISUPPORTS2 (VirtualBoxErrorInfo,
242 nsIException, IVirtualBoxErrorInfo)
243
244#endif // !defined (VBOX_WITH_XPCOM)
245/* 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