VirtualBox

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

Last change on this file since 30396 was 28800, checked in by vboxsync, 15 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.5 KB
Line 
1/** @file
2 *
3 * VirtualBoxErrorInfo COM classe implementation
4 */
5
6/*
7 * Copyright (C) 2006-2009 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 "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 CBSTR aComponent, CBSTR 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) (LONG *aResultCode)
41{
42 CheckComArgOutPointerValid(aResultCode);
43
44 *aResultCode = mResultCode;
45 return S_OK;
46}
47
48STDMETHODIMP VirtualBoxErrorInfo::COMGETTER(InterfaceID) (BSTR *aIID)
49{
50 CheckComArgOutPointerValid(aIID);
51
52 mIID.toUtf16().cloneTo(aIID);
53 return S_OK;
54}
55
56STDMETHODIMP VirtualBoxErrorInfo::COMGETTER(Component) (BSTR *aComponent)
57{
58 CheckComArgOutPointerValid(aComponent);
59
60 mComponent.cloneTo(aComponent);
61 return S_OK;
62}
63
64STDMETHODIMP VirtualBoxErrorInfo::COMGETTER(Text) (BSTR *aText)
65{
66 CheckComArgOutPointerValid(aText);
67
68 mText.cloneTo(aText);
69 return S_OK;
70}
71
72STDMETHODIMP VirtualBoxErrorInfo::COMGETTER(Next) (IVirtualBoxErrorInfo **aNext)
73{
74 CheckComArgOutPointerValid(aNext);
75
76 /* this will set aNext to NULL if mNext is null */
77 return mNext.queryInterfaceTo(aNext);
78}
79
80#if !defined(VBOX_WITH_XPCOM)
81
82/**
83 * Initializes itself by fetching error information from the given error info
84 * object.
85 */
86HRESULT VirtualBoxErrorInfo::init (IErrorInfo *aInfo)
87{
88 AssertReturn(aInfo, E_FAIL);
89
90 HRESULT rc = S_OK;
91
92 /* We don't return a failure if talking to IErrorInfo fails below to
93 * protect ourselves from bad IErrorInfo implementations (the
94 * corresponding fields will simply remain null in this case). */
95
96 mResultCode = S_OK;
97 rc = aInfo->GetGUID (mIID.asOutParam());
98 AssertComRC (rc);
99 rc = aInfo->GetSource (mComponent.asOutParam());
100 AssertComRC (rc);
101 rc = aInfo->GetDescription (mText.asOutParam());
102 AssertComRC (rc);
103
104 return S_OK;
105}
106
107// IErrorInfo methods
108////////////////////////////////////////////////////////////////////////////////
109
110STDMETHODIMP VirtualBoxErrorInfo::GetDescription (BSTR *description)
111{
112 return COMGETTER(Text) (description);
113}
114
115STDMETHODIMP VirtualBoxErrorInfo::GetGUID (GUID *guid)
116{
117 Bstr iid;
118 HRESULT rc = COMGETTER(InterfaceID) (iid.asOutParam());
119 if (SUCCEEDED(rc))
120 *guid = Guid(iid);
121 return rc;
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
158 char *pszMsg; /* No Utf8Str.asOutParam, different allocator! */
159 rc = aInfo->GetMessage(&pszMsg);
160 AssertComRC(rc);
161 if (NS_SUCCEEDED(rc))
162 {
163 mText = Bstr(pszMsg);
164 nsMemory::Free(pszMsg);
165 }
166 else
167 mText.setNull();
168
169 return S_OK;
170}
171
172// nsIException methods
173////////////////////////////////////////////////////////////////////////////////
174
175/* readonly attribute string message; */
176NS_IMETHODIMP VirtualBoxErrorInfo::GetMessage (char **aMessage)
177{
178 CheckComArgOutPointerValid(aMessage);
179
180 Utf8Str (mText).cloneTo(aMessage);
181 return S_OK;
182}
183
184/* readonly attribute nsresult result; */
185NS_IMETHODIMP VirtualBoxErrorInfo::GetResult (nsresult *aResult)
186{
187 if (!aResult)
188 return NS_ERROR_INVALID_POINTER;
189
190 PRInt32 lrc;
191 nsresult rc = COMGETTER(ResultCode) (&lrc);
192 if (SUCCEEDED(rc))
193 *aResult = lrc;
194 return rc;
195}
196
197/* readonly attribute string name; */
198NS_IMETHODIMP VirtualBoxErrorInfo::GetName (char ** /* aName */)
199{
200 return NS_ERROR_NOT_IMPLEMENTED;
201}
202
203/* readonly attribute string filename; */
204NS_IMETHODIMP VirtualBoxErrorInfo::GetFilename (char ** /* aFilename */)
205{
206 return NS_ERROR_NOT_IMPLEMENTED;
207}
208
209/* readonly attribute PRUint32 lineNumber; */
210NS_IMETHODIMP VirtualBoxErrorInfo::GetLineNumber (PRUint32 * /* aLineNumber */)
211{
212 return NS_ERROR_NOT_IMPLEMENTED;
213}
214
215/* readonly attribute PRUint32 columnNumber; */
216NS_IMETHODIMP VirtualBoxErrorInfo::GetColumnNumber (PRUint32 * /*aColumnNumber */)
217{
218 return NS_ERROR_NOT_IMPLEMENTED;
219}
220
221/* readonly attribute nsIStackFrame location; */
222NS_IMETHODIMP VirtualBoxErrorInfo::GetLocation (nsIStackFrame ** /* aLocation */)
223{
224 return NS_ERROR_NOT_IMPLEMENTED;
225}
226
227/* readonly attribute nsIException inner; */
228NS_IMETHODIMP VirtualBoxErrorInfo::GetInner (nsIException **aInner)
229{
230 ComPtr<IVirtualBoxErrorInfo> info;
231 nsresult rv = COMGETTER(Next) (info.asOutParam());
232 if (FAILED(rv)) return rv;
233 return info.queryInterfaceTo(aInner);
234}
235
236/* readonly attribute nsISupports data; */
237NS_IMETHODIMP VirtualBoxErrorInfo::GetData (nsISupports ** /* aData */)
238{
239 return NS_ERROR_NOT_IMPLEMENTED;
240}
241
242/* string toString (); */
243NS_IMETHODIMP VirtualBoxErrorInfo::ToString (char ** /* retval */)
244{
245 return NS_ERROR_NOT_IMPLEMENTED;
246}
247
248NS_IMPL_THREADSAFE_ISUPPORTS2 (VirtualBoxErrorInfo,
249 nsIException, IVirtualBoxErrorInfo)
250
251#endif // defined(VBOX_WITH_XPCOM)
252/* 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