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