VirtualBox

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

Last change on this file since 6290 was 5999, checked in by vboxsync, 17 years ago

The Giant CDDL Dual-License Header Change.

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