VirtualBox

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

Last change on this file since 15828 was 15051, checked in by vboxsync, 16 years ago

Main: Cleaned up the long standing const BSTR = const (OLECHAR *) on WIn32 vs (const PRunichar) * on XPCOM clash. Cleaned up BSTR/GUID macros (IN_BSTR replaces INPTR BSTR, IN_GUID replaces INPTR GUIDPARAM, OUT_GUID replaces GUIDPARAMOUT).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.2 KB
Line 
1/** @file
2 *
3 * VirtualBoxErrorInfo COM classe implementation
4 */
5
6/*
7 * Copyright (C) 2006-2007 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) (HRESULT *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 return COMGETTER(ResultCode) (aResult);
181}
182
183/* readonly attribute string name; */
184NS_IMETHODIMP VirtualBoxErrorInfo::GetName (char **aName)
185{
186 return NS_ERROR_NOT_IMPLEMENTED;
187}
188
189/* readonly attribute string filename; */
190NS_IMETHODIMP VirtualBoxErrorInfo::GetFilename (char **aFilename)
191{
192 return NS_ERROR_NOT_IMPLEMENTED;
193}
194
195/* readonly attribute PRUint32 lineNumber; */
196NS_IMETHODIMP VirtualBoxErrorInfo::GetLineNumber (PRUint32 *aLineNumber)
197{
198 return NS_ERROR_NOT_IMPLEMENTED;
199}
200
201/* readonly attribute PRUint32 columnNumber; */
202NS_IMETHODIMP VirtualBoxErrorInfo::GetColumnNumber (PRUint32 *aColumnNumber)
203{
204 return NS_ERROR_NOT_IMPLEMENTED;
205}
206
207/* readonly attribute nsIStackFrame location; */
208NS_IMETHODIMP VirtualBoxErrorInfo::GetLocation (nsIStackFrame **aLocation)
209{
210 return NS_ERROR_NOT_IMPLEMENTED;
211}
212
213/* readonly attribute nsIException inner; */
214NS_IMETHODIMP VirtualBoxErrorInfo::GetInner (nsIException **aInner)
215{
216 ComPtr <IVirtualBoxErrorInfo> info;
217 nsresult rv = COMGETTER(Next) (info.asOutParam());
218 CheckComRCReturnRC (rv);
219 return info.queryInterfaceTo (aInner);
220}
221
222/* readonly attribute nsISupports data; */
223NS_IMETHODIMP VirtualBoxErrorInfo::GetData (nsISupports **aData)
224{
225 return NS_ERROR_NOT_IMPLEMENTED;
226}
227
228/* string toString (); */
229NS_IMETHODIMP VirtualBoxErrorInfo::ToString (char **_retval)
230{
231 return NS_ERROR_NOT_IMPLEMENTED;
232}
233
234NS_IMPL_THREADSAFE_ISUPPORTS2 (VirtualBoxErrorInfo,
235 nsIException, IVirtualBoxErrorInfo)
236
237#endif // !defined (VBOX_WITH_XPCOM)
238/* 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