1 | /* $Id: VirtualBoxErrorInfoImpl.h 82968 2020-02-04 10:35:17Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBoxErrorInfo COM class definition.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2020 Oracle Corporation
|
---|
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 |
|
---|
18 | #ifndef MAIN_INCLUDED_VirtualBoxErrorInfoImpl_h
|
---|
19 | #define MAIN_INCLUDED_VirtualBoxErrorInfoImpl_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #include "VirtualBoxBase.h"
|
---|
25 |
|
---|
26 | using namespace com;
|
---|
27 |
|
---|
28 | class ATL_NO_VTABLE VirtualBoxErrorInfo
|
---|
29 | : public ATL::CComObjectRootEx<ATL::CComMultiThreadModel>
|
---|
30 | , VBOX_SCRIPTABLE_IMPL(IVirtualBoxErrorInfo)
|
---|
31 | #ifndef VBOX_WITH_XPCOM /* IErrorInfo doesn't inherit from IDispatch, ugly 3am hack: */
|
---|
32 | , public IDispatch
|
---|
33 | #endif
|
---|
34 | {
|
---|
35 | public:
|
---|
36 |
|
---|
37 | DECLARE_NOT_AGGREGATABLE(VirtualBoxErrorInfo)
|
---|
38 |
|
---|
39 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
40 |
|
---|
41 | BEGIN_COM_MAP(VirtualBoxErrorInfo)
|
---|
42 | COM_INTERFACE_ENTRY(IErrorInfo)
|
---|
43 | COM_INTERFACE_ENTRY(IVirtualBoxErrorInfo)
|
---|
44 | COM_INTERFACE_ENTRY(IDispatch)
|
---|
45 | COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler)
|
---|
46 | END_COM_MAP()
|
---|
47 |
|
---|
48 | HRESULT FinalConstruct()
|
---|
49 | {
|
---|
50 | #ifndef VBOX_WITH_XPCOM
|
---|
51 | return CoCreateFreeThreadedMarshaler((IUnknown *)(void *)this, &m_pUnkMarshaler);
|
---|
52 | #else
|
---|
53 | return S_OK;
|
---|
54 | #endif
|
---|
55 | }
|
---|
56 |
|
---|
57 | void FinalRelease()
|
---|
58 | {
|
---|
59 | #ifndef VBOX_WITH_XPCOM
|
---|
60 | if (m_pUnkMarshaler)
|
---|
61 | {
|
---|
62 | m_pUnkMarshaler->Release();
|
---|
63 | m_pUnkMarshaler = NULL;
|
---|
64 | }
|
---|
65 | #endif
|
---|
66 | }
|
---|
67 |
|
---|
68 | #ifndef VBOX_WITH_XPCOM
|
---|
69 |
|
---|
70 | HRESULT init(IErrorInfo *aInfo);
|
---|
71 |
|
---|
72 | STDMETHOD(GetGUID)(GUID *guid);
|
---|
73 | STDMETHOD(GetSource)(BSTR *pBstrSource);
|
---|
74 | STDMETHOD(GetDescription)(BSTR *description);
|
---|
75 | STDMETHOD(GetHelpFile)(BSTR *pBstrHelpFile);
|
---|
76 | STDMETHOD(GetHelpContext)(DWORD *pdwHelpContext);
|
---|
77 |
|
---|
78 | // IDispatch forwarding - 3am hack.
|
---|
79 | typedef IDispatchImpl<IVirtualBoxErrorInfo, &IID_IVirtualBoxErrorInfo, &LIBID_VirtualBox, kTypeLibraryMajorVersion, kTypeLibraryMinorVersion> idi;
|
---|
80 |
|
---|
81 | STDMETHOD(GetTypeInfoCount)(UINT *pcInfo)
|
---|
82 | {
|
---|
83 | return idi::GetTypeInfoCount(pcInfo);
|
---|
84 | }
|
---|
85 |
|
---|
86 | STDMETHOD(GetTypeInfo)(UINT iInfo, LCID Lcid, ITypeInfo **ppTypeInfo)
|
---|
87 | {
|
---|
88 | return idi::GetTypeInfo(iInfo, Lcid, ppTypeInfo);
|
---|
89 | }
|
---|
90 |
|
---|
91 | STDMETHOD(GetIDsOfNames)(REFIID rIID, LPOLESTR *papwszNames, UINT cNames, LCID Lcid, DISPID *paDispIDs)
|
---|
92 | {
|
---|
93 | return idi::GetIDsOfNames(rIID, papwszNames, cNames, Lcid, paDispIDs);
|
---|
94 | }
|
---|
95 |
|
---|
96 | STDMETHOD(Invoke)(DISPID idDispMember, REFIID rIID, LCID Lcid, WORD fw, DISPPARAMS *pDispParams,
|
---|
97 | VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *piErrArg)
|
---|
98 | {
|
---|
99 | return idi::Invoke(idDispMember, rIID, Lcid, fw, pDispParams, pVarResult, pExcepInfo, piErrArg);
|
---|
100 | }
|
---|
101 |
|
---|
102 | #else // defined(VBOX_WITH_XPCOM)
|
---|
103 |
|
---|
104 | HRESULT init(nsIException *aInfo);
|
---|
105 |
|
---|
106 | NS_DECL_NSIEXCEPTION
|
---|
107 |
|
---|
108 | #endif
|
---|
109 |
|
---|
110 | VirtualBoxErrorInfo()
|
---|
111 | : m_resultCode(S_OK),
|
---|
112 | m_resultDetail(0)
|
---|
113 | {}
|
---|
114 | virtual ~VirtualBoxErrorInfo() {}
|
---|
115 |
|
---|
116 | // public initializer/uninitializer for internal purposes only
|
---|
117 | HRESULT init(HRESULT aResultCode,
|
---|
118 | const GUID &aIID,
|
---|
119 | const char *pcszComponent,
|
---|
120 | const Utf8Str &strText,
|
---|
121 | IVirtualBoxErrorInfo *aNext = NULL);
|
---|
122 |
|
---|
123 | HRESULT initEx(HRESULT aResultCode,
|
---|
124 | LONG aResultDetail,
|
---|
125 | const GUID &aIID,
|
---|
126 | const char *pcszComponent,
|
---|
127 | const Utf8Str &strText,
|
---|
128 | IVirtualBoxErrorInfo *aNext = NULL);
|
---|
129 |
|
---|
130 | HRESULT init(const com::ErrorInfo &ei,
|
---|
131 | IVirtualBoxErrorInfo *aNext = NULL);
|
---|
132 |
|
---|
133 | // IVirtualBoxErrorInfo properties
|
---|
134 | STDMETHOD(COMGETTER(ResultCode))(LONG *aResultCode);
|
---|
135 | STDMETHOD(COMGETTER(ResultDetail))(LONG *aResultDetail);
|
---|
136 | STDMETHOD(COMGETTER(InterfaceID))(BSTR *aIID);
|
---|
137 | STDMETHOD(COMGETTER(Component))(BSTR *aComponent);
|
---|
138 | STDMETHOD(COMGETTER(Text))(BSTR *aText);
|
---|
139 | STDMETHOD(COMGETTER(Next))(IVirtualBoxErrorInfo **aNext);
|
---|
140 |
|
---|
141 | private:
|
---|
142 | // FIXME: declare these here until VBoxSupportsTranslation base
|
---|
143 | // is available in this class.
|
---|
144 | static const char *tr(const char *a) { return a; }
|
---|
145 | static HRESULT setError(HRESULT rc,
|
---|
146 | const char * /* a */,
|
---|
147 | const char * /* b */,
|
---|
148 | void * /* c */) { return rc; }
|
---|
149 |
|
---|
150 | HRESULT m_resultCode;
|
---|
151 | LONG m_resultDetail;
|
---|
152 | Utf8Str m_strText;
|
---|
153 | Guid m_IID;
|
---|
154 | Utf8Str m_strComponent;
|
---|
155 | ComPtr<IVirtualBoxErrorInfo> mNext;
|
---|
156 |
|
---|
157 | #ifndef VBOX_WITH_XPCOM
|
---|
158 | IUnknown *m_pUnkMarshaler;
|
---|
159 | #endif
|
---|
160 | };
|
---|
161 |
|
---|
162 | #endif /* !MAIN_INCLUDED_VirtualBoxErrorInfoImpl_h */
|
---|
163 |
|
---|
164 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|