[1] | 1 | /** @file
|
---|
| 2 | *
|
---|
| 3 | * VirtualBoxErrorInfo COM classe implementation
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[17911] | 7 | * Copyright (C) 2006-2009 Sun Microsystems, Inc.
|
---|
[1] | 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
|
---|
[5999] | 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.
|
---|
[8155] | 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.
|
---|
[1] | 20 | */
|
---|
| 21 |
|
---|
| 22 | #include "VirtualBoxErrorInfoImpl.h"
|
---|
| 23 | #include "Logging.h"
|
---|
| 24 |
|
---|
| 25 | // public initializer/uninitializer for internal purposes only
|
---|
| 26 | ////////////////////////////////////////////////////////////////////////////////
|
---|
| 27 |
|
---|
[2672] | 28 | HRESULT VirtualBoxErrorInfo::init (HRESULT aResultCode, const GUID &aIID,
|
---|
[15051] | 29 | CBSTR aComponent, CBSTR aText,
|
---|
[2672] | 30 | IVirtualBoxErrorInfo *aNext)
|
---|
[1] | 31 | {
|
---|
[2463] | 32 | mResultCode = aResultCode;
|
---|
| 33 | mIID = aIID;
|
---|
| 34 | mComponent = aComponent;
|
---|
| 35 | mText = aText;
|
---|
| 36 | mNext = aNext;
|
---|
[2672] | 37 |
|
---|
| 38 | return S_OK;
|
---|
[1] | 39 | }
|
---|
| 40 |
|
---|
| 41 | // IVirtualBoxErrorInfo properties
|
---|
| 42 | ////////////////////////////////////////////////////////////////////////////////
|
---|
| 43 |
|
---|
[20267] | 44 | STDMETHODIMP VirtualBoxErrorInfo::COMGETTER(ResultCode) (LONG *aResultCode)
|
---|
[1] | 45 | {
|
---|
[14972] | 46 | CheckComArgOutPointerValid(aResultCode);
|
---|
[1] | 47 |
|
---|
[2463] | 48 | *aResultCode = mResultCode;
|
---|
[1] | 49 | return S_OK;
|
---|
| 50 | }
|
---|
| 51 |
|
---|
[21783] | 52 | STDMETHODIMP VirtualBoxErrorInfo::COMGETTER(InterfaceID) (BSTR *aIID)
|
---|
[1] | 53 | {
|
---|
[14972] | 54 | CheckComArgOutPointerValid(aIID);
|
---|
[1] | 55 |
|
---|
[21878] | 56 | mIID.toUtf16().cloneTo(aIID);
|
---|
[1] | 57 | return S_OK;
|
---|
| 58 | }
|
---|
| 59 |
|
---|
[2463] | 60 | STDMETHODIMP VirtualBoxErrorInfo::COMGETTER(Component) (BSTR *aComponent)
|
---|
[1] | 61 | {
|
---|
[14972] | 62 | CheckComArgOutPointerValid(aComponent);
|
---|
[1] | 63 |
|
---|
[21878] | 64 | mComponent.cloneTo(aComponent);
|
---|
[1] | 65 | return S_OK;
|
---|
| 66 | }
|
---|
| 67 |
|
---|
[2463] | 68 | STDMETHODIMP VirtualBoxErrorInfo::COMGETTER(Text) (BSTR *aText)
|
---|
[1] | 69 | {
|
---|
[14972] | 70 | CheckComArgOutPointerValid(aText);
|
---|
[1] | 71 |
|
---|
[21878] | 72 | mText.cloneTo(aText);
|
---|
[1] | 73 | return S_OK;
|
---|
| 74 | }
|
---|
| 75 |
|
---|
[2463] | 76 | STDMETHODIMP VirtualBoxErrorInfo::COMGETTER(Next) (IVirtualBoxErrorInfo **aNext)
|
---|
| 77 | {
|
---|
[14972] | 78 | CheckComArgOutPointerValid(aNext);
|
---|
[2463] | 79 |
|
---|
| 80 | /* this will set aNext to NULL if mNext is null */
|
---|
[21878] | 81 | return mNext.queryInterfaceTo(aNext);
|
---|
[2463] | 82 | }
|
---|
| 83 |
|
---|
[3191] | 84 | #if !defined (VBOX_WITH_XPCOM)
|
---|
[1] | 85 |
|
---|
[2672] | 86 | /**
|
---|
| 87 | * Initializes itself by fetching error information from the given error info
|
---|
| 88 | * object.
|
---|
| 89 | */
|
---|
| 90 | HRESULT VirtualBoxErrorInfo::init (IErrorInfo *aInfo)
|
---|
| 91 | {
|
---|
[21878] | 92 | AssertReturn(aInfo, E_FAIL);
|
---|
[2672] | 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);
|
---|
[14950] | 107 |
|
---|
[2672] | 108 | return S_OK;
|
---|
| 109 | }
|
---|
| 110 |
|
---|
[1] | 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 | {
|
---|
[21786] | 121 | Bstr iid;
|
---|
| 122 | HRESULT rc = COMGETTER(InterfaceID) (iid.asOutParam());
|
---|
| 123 | if (SUCCEEDED(rc))
|
---|
| 124 | *guid = Guid(iid);
|
---|
| 125 | return rc;
|
---|
[1] | 126 | }
|
---|
| 127 |
|
---|
| 128 | STDMETHODIMP VirtualBoxErrorInfo::GetHelpContext (DWORD *pdwHelpContext)
|
---|
| 129 | {
|
---|
[14718] | 130 | return E_NOTIMPL;
|
---|
[1] | 131 | }
|
---|
| 132 |
|
---|
| 133 | STDMETHODIMP VirtualBoxErrorInfo::GetHelpFile (BSTR *pbstrHelpFile)
|
---|
| 134 | {
|
---|
[14718] | 135 | return E_NOTIMPL;
|
---|
[1] | 136 | }
|
---|
| 137 |
|
---|
| 138 | STDMETHODIMP VirtualBoxErrorInfo::GetSource (BSTR *source)
|
---|
| 139 | {
|
---|
| 140 | return COMGETTER(Component) (source);
|
---|
| 141 | }
|
---|
| 142 |
|
---|
[3191] | 143 | #else // !defined (VBOX_WITH_XPCOM)
|
---|
[1] | 144 |
|
---|
[2672] | 145 | /**
|
---|
| 146 | * Initializes itself by fetching error information from the given error info
|
---|
| 147 | * object.
|
---|
| 148 | */
|
---|
| 149 | HRESULT VirtualBoxErrorInfo::init (nsIException *aInfo)
|
---|
| 150 | {
|
---|
[21878] | 151 | AssertReturn(aInfo, E_FAIL);
|
---|
[2672] | 152 |
|
---|
| 153 | HRESULT rc = S_OK;
|
---|
| 154 |
|
---|
| 155 | /* We don't return a failure if talking to nsIException fails below to
|
---|
| 156 | * protect ourselves from bad nsIException implementations (the
|
---|
| 157 | * corresponding fields will simply remain null in this case). */
|
---|
| 158 |
|
---|
| 159 | rc = aInfo->GetResult (&mResultCode);
|
---|
| 160 | AssertComRC (rc);
|
---|
| 161 | Utf8Str message;
|
---|
[21079] | 162 | rc = aInfo->GetMessage(message.asOutParam());
|
---|
| 163 | message.jolt();
|
---|
[2672] | 164 | AssertComRC (rc);
|
---|
| 165 | mText = message;
|
---|
[14950] | 166 |
|
---|
[2672] | 167 | return S_OK;
|
---|
| 168 | }
|
---|
| 169 |
|
---|
[1] | 170 | // nsIException methods
|
---|
| 171 | ////////////////////////////////////////////////////////////////////////////////
|
---|
| 172 |
|
---|
| 173 | /* readonly attribute string message; */
|
---|
| 174 | NS_IMETHODIMP VirtualBoxErrorInfo::GetMessage (char **aMessage)
|
---|
| 175 | {
|
---|
[14972] | 176 | CheckComArgOutPointerValid(aMessage);
|
---|
[1] | 177 |
|
---|
[21878] | 178 | Utf8Str (mText).cloneTo(aMessage);
|
---|
[1] | 179 | return S_OK;
|
---|
| 180 | }
|
---|
| 181 |
|
---|
| 182 | /* readonly attribute nsresult result; */
|
---|
| 183 | NS_IMETHODIMP VirtualBoxErrorInfo::GetResult (nsresult *aResult)
|
---|
| 184 | {
|
---|
[20267] | 185 | if (!aResult)
|
---|
| 186 | return NS_ERROR_INVALID_POINTER;
|
---|
| 187 |
|
---|
| 188 | PRInt32 lrc;
|
---|
| 189 | nsresult rc = COMGETTER(ResultCode) (&lrc);
|
---|
| 190 | if (SUCCEEDED(rc))
|
---|
| 191 | *aResult = lrc;
|
---|
| 192 | return rc;
|
---|
[1] | 193 | }
|
---|
| 194 |
|
---|
| 195 | /* readonly attribute string name; */
|
---|
[17911] | 196 | NS_IMETHODIMP VirtualBoxErrorInfo::GetName (char ** /* aName */)
|
---|
[1] | 197 | {
|
---|
| 198 | return NS_ERROR_NOT_IMPLEMENTED;
|
---|
| 199 | }
|
---|
| 200 |
|
---|
| 201 | /* readonly attribute string filename; */
|
---|
[17911] | 202 | NS_IMETHODIMP VirtualBoxErrorInfo::GetFilename (char ** /* aFilename */)
|
---|
[1] | 203 | {
|
---|
| 204 | return NS_ERROR_NOT_IMPLEMENTED;
|
---|
| 205 | }
|
---|
| 206 |
|
---|
| 207 | /* readonly attribute PRUint32 lineNumber; */
|
---|
[17911] | 208 | NS_IMETHODIMP VirtualBoxErrorInfo::GetLineNumber (PRUint32 * /* aLineNumber */)
|
---|
[1] | 209 | {
|
---|
| 210 | return NS_ERROR_NOT_IMPLEMENTED;
|
---|
| 211 | }
|
---|
| 212 |
|
---|
| 213 | /* readonly attribute PRUint32 columnNumber; */
|
---|
[17911] | 214 | NS_IMETHODIMP VirtualBoxErrorInfo::GetColumnNumber (PRUint32 * /*aColumnNumber */)
|
---|
[1] | 215 | {
|
---|
| 216 | return NS_ERROR_NOT_IMPLEMENTED;
|
---|
| 217 | }
|
---|
| 218 |
|
---|
| 219 | /* readonly attribute nsIStackFrame location; */
|
---|
[17911] | 220 | NS_IMETHODIMP VirtualBoxErrorInfo::GetLocation (nsIStackFrame ** /* aLocation */)
|
---|
[1] | 221 | {
|
---|
| 222 | return NS_ERROR_NOT_IMPLEMENTED;
|
---|
| 223 | }
|
---|
| 224 |
|
---|
| 225 | /* readonly attribute nsIException inner; */
|
---|
| 226 | NS_IMETHODIMP VirtualBoxErrorInfo::GetInner (nsIException **aInner)
|
---|
| 227 | {
|
---|
[21878] | 228 | ComPtr<IVirtualBoxErrorInfo> info;
|
---|
[2463] | 229 | nsresult rv = COMGETTER(Next) (info.asOutParam());
|
---|
[25149] | 230 | if (FAILED(rv)) return rv;
|
---|
[21878] | 231 | return info.queryInterfaceTo(aInner);
|
---|
[1] | 232 | }
|
---|
| 233 |
|
---|
| 234 | /* readonly attribute nsISupports data; */
|
---|
[17911] | 235 | NS_IMETHODIMP VirtualBoxErrorInfo::GetData (nsISupports ** /* aData */)
|
---|
[1] | 236 | {
|
---|
| 237 | return NS_ERROR_NOT_IMPLEMENTED;
|
---|
| 238 | }
|
---|
| 239 |
|
---|
| 240 | /* string toString (); */
|
---|
[17911] | 241 | NS_IMETHODIMP VirtualBoxErrorInfo::ToString (char ** /* retval */)
|
---|
[1] | 242 | {
|
---|
| 243 | return NS_ERROR_NOT_IMPLEMENTED;
|
---|
| 244 | }
|
---|
| 245 |
|
---|
| 246 | NS_IMPL_THREADSAFE_ISUPPORTS2 (VirtualBoxErrorInfo,
|
---|
| 247 | nsIException, IVirtualBoxErrorInfo)
|
---|
| 248 |
|
---|
[3191] | 249 | #endif // !defined (VBOX_WITH_XPCOM)
|
---|
[14772] | 250 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|