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 as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * If you received this file as part of a commercial VirtualBox
|
---|
18 | * distribution, then only the terms of your commercial VirtualBox
|
---|
19 | * license agreement apply instead of the previous paragraph.
|
---|
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 | #if defined (RT_OS_WINDOWS)
|
---|
91 |
|
---|
92 | /**
|
---|
93 | * Initializes itself by fetching error information from the given error info
|
---|
94 | * object.
|
---|
95 | */
|
---|
96 | HRESULT VirtualBoxErrorInfo::init (IErrorInfo *aInfo)
|
---|
97 | {
|
---|
98 | AssertReturn (aInfo, E_FAIL);
|
---|
99 |
|
---|
100 | HRESULT rc = S_OK;
|
---|
101 |
|
---|
102 | /* We don't return a failure if talking to IErrorInfo fails below to
|
---|
103 | * protect ourselves from bad IErrorInfo implementations (the
|
---|
104 | * corresponding fields will simply remain null in this case). */
|
---|
105 |
|
---|
106 | mResultCode = S_OK;
|
---|
107 | rc = aInfo->GetGUID (mIID.asOutParam());
|
---|
108 | AssertComRC (rc);
|
---|
109 | rc = aInfo->GetSource (mComponent.asOutParam());
|
---|
110 | AssertComRC (rc);
|
---|
111 | rc = aInfo->GetDescription (mText.asOutParam());
|
---|
112 | AssertComRC (rc);
|
---|
113 |
|
---|
114 | return S_OK;
|
---|
115 | }
|
---|
116 |
|
---|
117 | // IErrorInfo methods
|
---|
118 | ////////////////////////////////////////////////////////////////////////////////
|
---|
119 |
|
---|
120 | STDMETHODIMP VirtualBoxErrorInfo::GetDescription (BSTR *description)
|
---|
121 | {
|
---|
122 | return COMGETTER(Text) (description);
|
---|
123 | }
|
---|
124 |
|
---|
125 | STDMETHODIMP VirtualBoxErrorInfo::GetGUID (GUID *guid)
|
---|
126 | {
|
---|
127 | return COMGETTER(InterfaceID) (guid);
|
---|
128 | }
|
---|
129 |
|
---|
130 | STDMETHODIMP VirtualBoxErrorInfo::GetHelpContext (DWORD *pdwHelpContext)
|
---|
131 | {
|
---|
132 | return E_NOTIMPL;
|
---|
133 | }
|
---|
134 |
|
---|
135 | STDMETHODIMP VirtualBoxErrorInfo::GetHelpFile (BSTR *pbstrHelpFile)
|
---|
136 | {
|
---|
137 | return E_NOTIMPL;
|
---|
138 | }
|
---|
139 |
|
---|
140 | STDMETHODIMP VirtualBoxErrorInfo::GetSource (BSTR *source)
|
---|
141 | {
|
---|
142 | return COMGETTER(Component) (source);
|
---|
143 | }
|
---|
144 |
|
---|
145 | #endif // defined (RT_OS_WINDOWS)
|
---|
146 | #else // !defined (VBOX_WITH_XPCOM)
|
---|
147 |
|
---|
148 | /**
|
---|
149 | * Initializes itself by fetching error information from the given error info
|
---|
150 | * object.
|
---|
151 | */
|
---|
152 | HRESULT VirtualBoxErrorInfo::init (nsIException *aInfo)
|
---|
153 | {
|
---|
154 | AssertReturn (aInfo, E_FAIL);
|
---|
155 |
|
---|
156 | HRESULT rc = S_OK;
|
---|
157 |
|
---|
158 | /* We don't return a failure if talking to nsIException fails below to
|
---|
159 | * protect ourselves from bad nsIException implementations (the
|
---|
160 | * corresponding fields will simply remain null in this case). */
|
---|
161 |
|
---|
162 | rc = aInfo->GetResult (&mResultCode);
|
---|
163 | AssertComRC (rc);
|
---|
164 | Utf8Str message;
|
---|
165 | rc = aInfo->GetMessage (message.asOutParam());
|
---|
166 | AssertComRC (rc);
|
---|
167 | mText = message;
|
---|
168 |
|
---|
169 | return S_OK;
|
---|
170 | }
|
---|
171 |
|
---|
172 | // nsIException methods
|
---|
173 | ////////////////////////////////////////////////////////////////////////////////
|
---|
174 |
|
---|
175 | /* readonly attribute string message; */
|
---|
176 | NS_IMETHODIMP VirtualBoxErrorInfo::GetMessage (char **aMessage)
|
---|
177 | {
|
---|
178 | if (!aMessage)
|
---|
179 | return NS_ERROR_INVALID_POINTER;
|
---|
180 |
|
---|
181 | Utf8Str (mText).cloneTo (aMessage);
|
---|
182 | return S_OK;
|
---|
183 | }
|
---|
184 |
|
---|
185 | /* readonly attribute nsresult result; */
|
---|
186 | NS_IMETHODIMP VirtualBoxErrorInfo::GetResult (nsresult *aResult)
|
---|
187 | {
|
---|
188 | return COMGETTER(ResultCode) (aResult);
|
---|
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 |
|
---|