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 |
|
---|
28 | HRESULT 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 |
|
---|
44 | STDMETHODIMP VirtualBoxErrorInfo::COMGETTER(ResultCode) (LONG *aResultCode)
|
---|
45 | {
|
---|
46 | CheckComArgOutPointerValid(aResultCode);
|
---|
47 |
|
---|
48 | *aResultCode = mResultCode;
|
---|
49 | return S_OK;
|
---|
50 | }
|
---|
51 |
|
---|
52 | STDMETHODIMP VirtualBoxErrorInfo::COMGETTER(InterfaceID) (OUT_GUID aIID)
|
---|
53 | {
|
---|
54 | CheckComArgOutPointerValid(aIID);
|
---|
55 |
|
---|
56 | mIID.cloneTo (aIID);
|
---|
57 | return S_OK;
|
---|
58 | }
|
---|
59 |
|
---|
60 | STDMETHODIMP VirtualBoxErrorInfo::COMGETTER(Component) (BSTR *aComponent)
|
---|
61 | {
|
---|
62 | CheckComArgOutPointerValid(aComponent);
|
---|
63 |
|
---|
64 | mComponent.cloneTo (aComponent);
|
---|
65 | return S_OK;
|
---|
66 | }
|
---|
67 |
|
---|
68 | STDMETHODIMP VirtualBoxErrorInfo::COMGETTER(Text) (BSTR *aText)
|
---|
69 | {
|
---|
70 | CheckComArgOutPointerValid(aText);
|
---|
71 |
|
---|
72 | mText.cloneTo (aText);
|
---|
73 | return S_OK;
|
---|
74 | }
|
---|
75 |
|
---|
76 | STDMETHODIMP 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 | */
|
---|
90 | HRESULT 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 |
|
---|
114 | STDMETHODIMP VirtualBoxErrorInfo::GetDescription (BSTR *description)
|
---|
115 | {
|
---|
116 | return COMGETTER(Text) (description);
|
---|
117 | }
|
---|
118 |
|
---|
119 | STDMETHODIMP VirtualBoxErrorInfo::GetGUID (GUID *guid)
|
---|
120 | {
|
---|
121 | return COMGETTER(InterfaceID) (guid);
|
---|
122 | }
|
---|
123 |
|
---|
124 | STDMETHODIMP VirtualBoxErrorInfo::GetHelpContext (DWORD *pdwHelpContext)
|
---|
125 | {
|
---|
126 | return E_NOTIMPL;
|
---|
127 | }
|
---|
128 |
|
---|
129 | STDMETHODIMP VirtualBoxErrorInfo::GetHelpFile (BSTR *pbstrHelpFile)
|
---|
130 | {
|
---|
131 | return E_NOTIMPL;
|
---|
132 | }
|
---|
133 |
|
---|
134 | STDMETHODIMP 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 | */
|
---|
145 | HRESULT 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 | message.jolt();
|
---|
160 | AssertComRC (rc);
|
---|
161 | mText = message;
|
---|
162 |
|
---|
163 | return S_OK;
|
---|
164 | }
|
---|
165 |
|
---|
166 | // nsIException methods
|
---|
167 | ////////////////////////////////////////////////////////////////////////////////
|
---|
168 |
|
---|
169 | /* readonly attribute string message; */
|
---|
170 | NS_IMETHODIMP VirtualBoxErrorInfo::GetMessage (char **aMessage)
|
---|
171 | {
|
---|
172 | CheckComArgOutPointerValid(aMessage);
|
---|
173 |
|
---|
174 | Utf8Str (mText).cloneTo (aMessage);
|
---|
175 | return S_OK;
|
---|
176 | }
|
---|
177 |
|
---|
178 | /* readonly attribute nsresult result; */
|
---|
179 | NS_IMETHODIMP VirtualBoxErrorInfo::GetResult (nsresult *aResult)
|
---|
180 | {
|
---|
181 | if (!aResult)
|
---|
182 | return NS_ERROR_INVALID_POINTER;
|
---|
183 |
|
---|
184 | PRInt32 lrc;
|
---|
185 | nsresult rc = COMGETTER(ResultCode) (&lrc);
|
---|
186 | if (SUCCEEDED(rc))
|
---|
187 | *aResult = lrc;
|
---|
188 | return rc;
|
---|
189 | }
|
---|
190 |
|
---|
191 | /* readonly attribute string name; */
|
---|
192 | NS_IMETHODIMP VirtualBoxErrorInfo::GetName (char ** /* aName */)
|
---|
193 | {
|
---|
194 | return NS_ERROR_NOT_IMPLEMENTED;
|
---|
195 | }
|
---|
196 |
|
---|
197 | /* readonly attribute string filename; */
|
---|
198 | NS_IMETHODIMP VirtualBoxErrorInfo::GetFilename (char ** /* aFilename */)
|
---|
199 | {
|
---|
200 | return NS_ERROR_NOT_IMPLEMENTED;
|
---|
201 | }
|
---|
202 |
|
---|
203 | /* readonly attribute PRUint32 lineNumber; */
|
---|
204 | NS_IMETHODIMP VirtualBoxErrorInfo::GetLineNumber (PRUint32 * /* aLineNumber */)
|
---|
205 | {
|
---|
206 | return NS_ERROR_NOT_IMPLEMENTED;
|
---|
207 | }
|
---|
208 |
|
---|
209 | /* readonly attribute PRUint32 columnNumber; */
|
---|
210 | NS_IMETHODIMP VirtualBoxErrorInfo::GetColumnNumber (PRUint32 * /*aColumnNumber */)
|
---|
211 | {
|
---|
212 | return NS_ERROR_NOT_IMPLEMENTED;
|
---|
213 | }
|
---|
214 |
|
---|
215 | /* readonly attribute nsIStackFrame location; */
|
---|
216 | NS_IMETHODIMP VirtualBoxErrorInfo::GetLocation (nsIStackFrame ** /* aLocation */)
|
---|
217 | {
|
---|
218 | return NS_ERROR_NOT_IMPLEMENTED;
|
---|
219 | }
|
---|
220 |
|
---|
221 | /* readonly attribute nsIException inner; */
|
---|
222 | NS_IMETHODIMP VirtualBoxErrorInfo::GetInner (nsIException **aInner)
|
---|
223 | {
|
---|
224 | ComPtr <IVirtualBoxErrorInfo> info;
|
---|
225 | nsresult rv = COMGETTER(Next) (info.asOutParam());
|
---|
226 | CheckComRCReturnRC (rv);
|
---|
227 | return info.queryInterfaceTo (aInner);
|
---|
228 | }
|
---|
229 |
|
---|
230 | /* readonly attribute nsISupports data; */
|
---|
231 | NS_IMETHODIMP VirtualBoxErrorInfo::GetData (nsISupports ** /* aData */)
|
---|
232 | {
|
---|
233 | return NS_ERROR_NOT_IMPLEMENTED;
|
---|
234 | }
|
---|
235 |
|
---|
236 | /* string toString (); */
|
---|
237 | NS_IMETHODIMP VirtualBoxErrorInfo::ToString (char ** /* retval */)
|
---|
238 | {
|
---|
239 | return NS_ERROR_NOT_IMPLEMENTED;
|
---|
240 | }
|
---|
241 |
|
---|
242 | NS_IMPL_THREADSAFE_ISUPPORTS2 (VirtualBoxErrorInfo,
|
---|
243 | nsIException, IVirtualBoxErrorInfo)
|
---|
244 |
|
---|
245 | #endif // !defined (VBOX_WITH_XPCOM)
|
---|
246 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|