[1] | 1 | /** @file
|
---|
| 2 | *
|
---|
| 3 | * VirtualBoxErrorInfo COM classe implementation
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[8155] | 7 | * Copyright (C) 2006-2007 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,
|
---|
| 29 | const BSTR aComponent, const BSTR aText,
|
---|
| 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 |
|
---|
[2463] | 44 | STDMETHODIMP VirtualBoxErrorInfo::COMGETTER(ResultCode) (HRESULT *aResultCode)
|
---|
[1] | 45 | {
|
---|
[2463] | 46 | if (!aResultCode)
|
---|
[1] | 47 | return E_POINTER;
|
---|
| 48 |
|
---|
[2463] | 49 | *aResultCode = mResultCode;
|
---|
[1] | 50 | return S_OK;
|
---|
| 51 | }
|
---|
| 52 |
|
---|
[2463] | 53 | STDMETHODIMP VirtualBoxErrorInfo::COMGETTER(InterfaceID) (GUIDPARAMOUT aIID)
|
---|
[1] | 54 | {
|
---|
[2463] | 55 | if (!aIID)
|
---|
[1] | 56 | return E_POINTER;
|
---|
| 57 |
|
---|
[2463] | 58 | mIID.cloneTo (aIID);
|
---|
[1] | 59 | return S_OK;
|
---|
| 60 | }
|
---|
| 61 |
|
---|
[2463] | 62 | STDMETHODIMP VirtualBoxErrorInfo::COMGETTER(Component) (BSTR *aComponent)
|
---|
[1] | 63 | {
|
---|
[2463] | 64 | if (!aComponent)
|
---|
[1] | 65 | return E_POINTER;
|
---|
| 66 |
|
---|
[2463] | 67 | mComponent.cloneTo (aComponent);
|
---|
[1] | 68 | return S_OK;
|
---|
| 69 | }
|
---|
| 70 |
|
---|
[2463] | 71 | STDMETHODIMP VirtualBoxErrorInfo::COMGETTER(Text) (BSTR *aText)
|
---|
[1] | 72 | {
|
---|
[2463] | 73 | if (!aText)
|
---|
[1] | 74 | return E_POINTER;
|
---|
| 75 |
|
---|
[2463] | 76 | mText.cloneTo (aText);
|
---|
[1] | 77 | return S_OK;
|
---|
| 78 | }
|
---|
| 79 |
|
---|
[2463] | 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 |
|
---|
[3191] | 89 | #if !defined (VBOX_WITH_XPCOM)
|
---|
[1] | 90 |
|
---|
[2672] | 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 |
|
---|
[1] | 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 |
|
---|
[3191] | 144 | #else // !defined (VBOX_WITH_XPCOM)
|
---|
[1] | 145 |
|
---|
[2672] | 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 |
|
---|
[1] | 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 | {
|
---|
[2463] | 222 | ComPtr <IVirtualBoxErrorInfo> info;
|
---|
| 223 | nsresult rv = COMGETTER(Next) (info.asOutParam());
|
---|
| 224 | CheckComRCReturnRC (rv);
|
---|
| 225 | return info.queryInterfaceTo (aInner);
|
---|
[1] | 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 |
|
---|
[3191] | 243 | #endif // !defined (VBOX_WITH_XPCOM)
|
---|
[1] | 244 |
|
---|