VirtualBox

source: vbox/trunk/src/VBox/Main/include/VirtualBoxErrorInfoImpl.h@ 91312

Last change on this file since 91312 was 91312, checked in by vboxsync, 3 years ago

Main: bugref:1909: Prepared the API translation engine to using in ExtPacks and VBoxManage. Added using API translation engine in ExtPacks. Allowed VBox compilation with NLS enabled and GUI disabled. Allowed ExtPacks only compilation with NLS translation enabled.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.9 KB
Line 
1/* $Id: VirtualBoxErrorInfoImpl.h 91312 2021-09-20 11:06:57Z 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
26using namespace com;
27
28class 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{
35public:
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 DECLARE_TRANSLATE_METHODS(VirtualBoxErrorInfo)
49
50 HRESULT FinalConstruct()
51 {
52#ifndef VBOX_WITH_XPCOM
53 return CoCreateFreeThreadedMarshaler((IUnknown *)(void *)this, &m_pUnkMarshaler);
54#else
55 return S_OK;
56#endif
57 }
58
59 void FinalRelease()
60 {
61#ifndef VBOX_WITH_XPCOM
62 if (m_pUnkMarshaler)
63 {
64 m_pUnkMarshaler->Release();
65 m_pUnkMarshaler = NULL;
66 }
67#endif
68 }
69
70#ifndef VBOX_WITH_XPCOM
71
72 HRESULT init(IErrorInfo *aInfo);
73
74 STDMETHOD(GetGUID)(GUID *guid);
75 STDMETHOD(GetSource)(BSTR *pBstrSource);
76 STDMETHOD(GetDescription)(BSTR *description);
77 STDMETHOD(GetHelpFile)(BSTR *pBstrHelpFile);
78 STDMETHOD(GetHelpContext)(DWORD *pdwHelpContext);
79
80 // IDispatch forwarding - 3am hack.
81 typedef IDispatchImpl<IVirtualBoxErrorInfo, &IID_IVirtualBoxErrorInfo, &LIBID_VirtualBox, kTypeLibraryMajorVersion, kTypeLibraryMinorVersion> idi;
82
83 STDMETHOD(GetTypeInfoCount)(UINT *pcInfo)
84 {
85 return idi::GetTypeInfoCount(pcInfo);
86 }
87
88 STDMETHOD(GetTypeInfo)(UINT iInfo, LCID Lcid, ITypeInfo **ppTypeInfo)
89 {
90 return idi::GetTypeInfo(iInfo, Lcid, ppTypeInfo);
91 }
92
93 STDMETHOD(GetIDsOfNames)(REFIID rIID, LPOLESTR *papwszNames, UINT cNames, LCID Lcid, DISPID *paDispIDs)
94 {
95 return idi::GetIDsOfNames(rIID, papwszNames, cNames, Lcid, paDispIDs);
96 }
97
98 STDMETHOD(Invoke)(DISPID idDispMember, REFIID rIID, LCID Lcid, WORD fw, DISPPARAMS *pDispParams,
99 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *piErrArg)
100 {
101 return idi::Invoke(idDispMember, rIID, Lcid, fw, pDispParams, pVarResult, pExcepInfo, piErrArg);
102 }
103
104#else // defined(VBOX_WITH_XPCOM)
105
106 HRESULT init(nsIException *aInfo);
107
108 NS_DECL_NSIEXCEPTION
109
110#endif
111
112 VirtualBoxErrorInfo()
113 : m_resultCode(S_OK),
114 m_resultDetail(0)
115 {}
116 virtual ~VirtualBoxErrorInfo() {}
117
118 // public initializer/uninitializer for internal purposes only
119 HRESULT init(HRESULT aResultCode,
120 const GUID &aIID,
121 const char *pcszComponent,
122 const Utf8Str &strText,
123 IVirtualBoxErrorInfo *aNext = NULL);
124
125 HRESULT initEx(HRESULT aResultCode,
126 LONG aResultDetail,
127 const GUID &aIID,
128 const char *pcszComponent,
129 const Utf8Str &strText,
130 IVirtualBoxErrorInfo *aNext = NULL);
131
132 HRESULT init(const com::ErrorInfo &ei,
133 IVirtualBoxErrorInfo *aNext = NULL);
134
135 // IVirtualBoxErrorInfo properties
136 STDMETHOD(COMGETTER(ResultCode))(LONG *aResultCode);
137 STDMETHOD(COMGETTER(ResultDetail))(LONG *aResultDetail);
138 STDMETHOD(COMGETTER(InterfaceID))(BSTR *aIID);
139 STDMETHOD(COMGETTER(Component))(BSTR *aComponent);
140 STDMETHOD(COMGETTER(Text))(BSTR *aText);
141 STDMETHOD(COMGETTER(Next))(IVirtualBoxErrorInfo **aNext);
142
143 const char* getComponentName() const { return "VirtualBoxErrorInfo"; }
144
145private:
146 static HRESULT setError(HRESULT rc,
147 const char * /* a */,
148 const char * /* b */,
149 void * /* c */) { return rc; }
150
151 HRESULT m_resultCode;
152 LONG m_resultDetail;
153 Utf8Str m_strText;
154 Guid m_IID;
155 Utf8Str m_strComponent;
156 ComPtr<IVirtualBoxErrorInfo> mNext;
157
158#ifndef VBOX_WITH_XPCOM
159 IUnknown *m_pUnkMarshaler;
160#endif
161};
162
163#endif /* !MAIN_INCLUDED_VirtualBoxErrorInfoImpl_h */
164
165/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette