[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,
|
---|
[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 |
|
---|
[2463] | 44 | STDMETHODIMP VirtualBoxErrorInfo::COMGETTER(ResultCode) (HRESULT *aResultCode)
|
---|
[1] | 45 | {
|
---|
[14972] | 46 | CheckComArgOutPointerValid(aResultCode);
|
---|
[1] | 47 |
|
---|
[2463] | 48 | *aResultCode = mResultCode;
|
---|
[1] | 49 | return S_OK;
|
---|
| 50 | }
|
---|
| 51 |
|
---|
[15051] | 52 | STDMETHODIMP VirtualBoxErrorInfo::COMGETTER(InterfaceID) (OUT_GUID aIID)
|
---|
[1] | 53 | {
|
---|
[14972] | 54 | CheckComArgOutPointerValid(aIID);
|
---|
[1] | 55 |
|
---|
[2463] | 56 | mIID.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 |
|
---|
[2463] | 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 |
|
---|
[2463] | 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 */
|
---|
| 81 | return mNext.queryInterfaceTo (aNext);
|
---|
| 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 | {
|
---|
| 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);
|
---|
[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 | {
|
---|
| 121 | return COMGETTER(InterfaceID) (guid);
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 | STDMETHODIMP VirtualBoxErrorInfo::GetHelpContext (DWORD *pdwHelpContext)
|
---|
| 125 | {
|
---|
[14718] | 126 | return E_NOTIMPL;
|
---|
[1] | 127 | }
|
---|
| 128 |
|
---|
| 129 | STDMETHODIMP VirtualBoxErrorInfo::GetHelpFile (BSTR *pbstrHelpFile)
|
---|
| 130 | {
|
---|
[14718] | 131 | return E_NOTIMPL;
|
---|
[1] | 132 | }
|
---|
| 133 |
|
---|
| 134 | STDMETHODIMP VirtualBoxErrorInfo::GetSource (BSTR *source)
|
---|
| 135 | {
|
---|
| 136 | return COMGETTER(Component) (source);
|
---|
| 137 | }
|
---|
| 138 |
|
---|
[3191] | 139 | #else // !defined (VBOX_WITH_XPCOM)
|
---|
[1] | 140 |
|
---|
[2672] | 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 | AssertComRC (rc);
|
---|
| 160 | mText = message;
|
---|
[14950] | 161 |
|
---|
[2672] | 162 | return S_OK;
|
---|
| 163 | }
|
---|
| 164 |
|
---|
[1] | 165 | // nsIException methods
|
---|
| 166 | ////////////////////////////////////////////////////////////////////////////////
|
---|
| 167 |
|
---|
| 168 | /* readonly attribute string message; */
|
---|
| 169 | NS_IMETHODIMP VirtualBoxErrorInfo::GetMessage (char **aMessage)
|
---|
| 170 | {
|
---|
[14972] | 171 | CheckComArgOutPointerValid(aMessage);
|
---|
[1] | 172 |
|
---|
| 173 | Utf8Str (mText).cloneTo (aMessage);
|
---|
| 174 | return S_OK;
|
---|
| 175 | }
|
---|
| 176 |
|
---|
| 177 | /* readonly attribute nsresult result; */
|
---|
| 178 | NS_IMETHODIMP VirtualBoxErrorInfo::GetResult (nsresult *aResult)
|
---|
| 179 | {
|
---|
| 180 | return COMGETTER(ResultCode) (aResult);
|
---|
| 181 | }
|
---|
| 182 |
|
---|
| 183 | /* readonly attribute string name; */
|
---|
| 184 | NS_IMETHODIMP VirtualBoxErrorInfo::GetName (char **aName)
|
---|
| 185 | {
|
---|
| 186 | return NS_ERROR_NOT_IMPLEMENTED;
|
---|
| 187 | }
|
---|
| 188 |
|
---|
| 189 | /* readonly attribute string filename; */
|
---|
| 190 | NS_IMETHODIMP VirtualBoxErrorInfo::GetFilename (char **aFilename)
|
---|
| 191 | {
|
---|
| 192 | return NS_ERROR_NOT_IMPLEMENTED;
|
---|
| 193 | }
|
---|
| 194 |
|
---|
| 195 | /* readonly attribute PRUint32 lineNumber; */
|
---|
| 196 | NS_IMETHODIMP VirtualBoxErrorInfo::GetLineNumber (PRUint32 *aLineNumber)
|
---|
| 197 | {
|
---|
| 198 | return NS_ERROR_NOT_IMPLEMENTED;
|
---|
| 199 | }
|
---|
| 200 |
|
---|
| 201 | /* readonly attribute PRUint32 columnNumber; */
|
---|
| 202 | NS_IMETHODIMP VirtualBoxErrorInfo::GetColumnNumber (PRUint32 *aColumnNumber)
|
---|
| 203 | {
|
---|
| 204 | return NS_ERROR_NOT_IMPLEMENTED;
|
---|
| 205 | }
|
---|
| 206 |
|
---|
| 207 | /* readonly attribute nsIStackFrame location; */
|
---|
| 208 | NS_IMETHODIMP VirtualBoxErrorInfo::GetLocation (nsIStackFrame **aLocation)
|
---|
| 209 | {
|
---|
| 210 | return NS_ERROR_NOT_IMPLEMENTED;
|
---|
| 211 | }
|
---|
| 212 |
|
---|
| 213 | /* readonly attribute nsIException inner; */
|
---|
| 214 | NS_IMETHODIMP VirtualBoxErrorInfo::GetInner (nsIException **aInner)
|
---|
| 215 | {
|
---|
[2463] | 216 | ComPtr <IVirtualBoxErrorInfo> info;
|
---|
| 217 | nsresult rv = COMGETTER(Next) (info.asOutParam());
|
---|
| 218 | CheckComRCReturnRC (rv);
|
---|
| 219 | return info.queryInterfaceTo (aInner);
|
---|
[1] | 220 | }
|
---|
| 221 |
|
---|
| 222 | /* readonly attribute nsISupports data; */
|
---|
| 223 | NS_IMETHODIMP VirtualBoxErrorInfo::GetData (nsISupports **aData)
|
---|
| 224 | {
|
---|
| 225 | return NS_ERROR_NOT_IMPLEMENTED;
|
---|
| 226 | }
|
---|
| 227 |
|
---|
| 228 | /* string toString (); */
|
---|
| 229 | NS_IMETHODIMP VirtualBoxErrorInfo::ToString (char **_retval)
|
---|
| 230 | {
|
---|
| 231 | return NS_ERROR_NOT_IMPLEMENTED;
|
---|
| 232 | }
|
---|
| 233 |
|
---|
| 234 | NS_IMPL_THREADSAFE_ISUPPORTS2 (VirtualBoxErrorInfo,
|
---|
| 235 | nsIException, IVirtualBoxErrorInfo)
|
---|
| 236 |
|
---|
[3191] | 237 | #endif // !defined (VBOX_WITH_XPCOM)
|
---|
[14772] | 238 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|