VirtualBox

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

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

Main: bugref:1909: Added API localization

  • 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 90828 2021-08-24 09:44:46Z 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 , public VirtualBoxTranslatable
34#endif
35{
36public:
37
38 DECLARE_NOT_AGGREGATABLE(VirtualBoxErrorInfo)
39
40 DECLARE_PROTECT_FINAL_CONSTRUCT()
41
42 BEGIN_COM_MAP(VirtualBoxErrorInfo)
43 COM_INTERFACE_ENTRY(IErrorInfo)
44 COM_INTERFACE_ENTRY(IVirtualBoxErrorInfo)
45 COM_INTERFACE_ENTRY(IDispatch)
46 COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler)
47 END_COM_MAP()
48
49 DECLARE_TRANSLATE_METHODS(VirtualBoxErrorInfo)
50
51 HRESULT FinalConstruct()
52 {
53#ifndef VBOX_WITH_XPCOM
54 return CoCreateFreeThreadedMarshaler((IUnknown *)(void *)this, &m_pUnkMarshaler);
55#else
56 return S_OK;
57#endif
58 }
59
60 void FinalRelease()
61 {
62#ifndef VBOX_WITH_XPCOM
63 if (m_pUnkMarshaler)
64 {
65 m_pUnkMarshaler->Release();
66 m_pUnkMarshaler = NULL;
67 }
68#endif
69 }
70
71#ifndef VBOX_WITH_XPCOM
72
73 HRESULT init(IErrorInfo *aInfo);
74
75 STDMETHOD(GetGUID)(GUID *guid);
76 STDMETHOD(GetSource)(BSTR *pBstrSource);
77 STDMETHOD(GetDescription)(BSTR *description);
78 STDMETHOD(GetHelpFile)(BSTR *pBstrHelpFile);
79 STDMETHOD(GetHelpContext)(DWORD *pdwHelpContext);
80
81 // IDispatch forwarding - 3am hack.
82 typedef IDispatchImpl<IVirtualBoxErrorInfo, &IID_IVirtualBoxErrorInfo, &LIBID_VirtualBox, kTypeLibraryMajorVersion, kTypeLibraryMinorVersion> idi;
83
84 STDMETHOD(GetTypeInfoCount)(UINT *pcInfo)
85 {
86 return idi::GetTypeInfoCount(pcInfo);
87 }
88
89 STDMETHOD(GetTypeInfo)(UINT iInfo, LCID Lcid, ITypeInfo **ppTypeInfo)
90 {
91 return idi::GetTypeInfo(iInfo, Lcid, ppTypeInfo);
92 }
93
94 STDMETHOD(GetIDsOfNames)(REFIID rIID, LPOLESTR *papwszNames, UINT cNames, LCID Lcid, DISPID *paDispIDs)
95 {
96 return idi::GetIDsOfNames(rIID, papwszNames, cNames, Lcid, paDispIDs);
97 }
98
99 STDMETHOD(Invoke)(DISPID idDispMember, REFIID rIID, LCID Lcid, WORD fw, DISPPARAMS *pDispParams,
100 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *piErrArg)
101 {
102 return idi::Invoke(idDispMember, rIID, Lcid, fw, pDispParams, pVarResult, pExcepInfo, piErrArg);
103 }
104
105#else // defined(VBOX_WITH_XPCOM)
106
107 HRESULT init(nsIException *aInfo);
108
109 NS_DECL_NSIEXCEPTION
110
111#endif
112
113 VirtualBoxErrorInfo()
114 : m_resultCode(S_OK),
115 m_resultDetail(0)
116 {}
117 virtual ~VirtualBoxErrorInfo() {}
118
119 // public initializer/uninitializer for internal purposes only
120 HRESULT init(HRESULT aResultCode,
121 const GUID &aIID,
122 const char *pcszComponent,
123 const Utf8Str &strText,
124 IVirtualBoxErrorInfo *aNext = NULL);
125
126 HRESULT initEx(HRESULT aResultCode,
127 LONG aResultDetail,
128 const GUID &aIID,
129 const char *pcszComponent,
130 const Utf8Str &strText,
131 IVirtualBoxErrorInfo *aNext = NULL);
132
133 HRESULT init(const com::ErrorInfo &ei,
134 IVirtualBoxErrorInfo *aNext = NULL);
135
136 // IVirtualBoxErrorInfo properties
137 STDMETHOD(COMGETTER(ResultCode))(LONG *aResultCode);
138 STDMETHOD(COMGETTER(ResultDetail))(LONG *aResultDetail);
139 STDMETHOD(COMGETTER(InterfaceID))(BSTR *aIID);
140 STDMETHOD(COMGETTER(Component))(BSTR *aComponent);
141 STDMETHOD(COMGETTER(Text))(BSTR *aText);
142 STDMETHOD(COMGETTER(Next))(IVirtualBoxErrorInfo **aNext);
143
144 const char* getComponentName() const { return "VirtualBoxErrorInfo"; }
145
146private:
147 static HRESULT setError(HRESULT rc,
148 const char * /* a */,
149 const char * /* b */,
150 void * /* c */) { return rc; }
151
152 HRESULT m_resultCode;
153 LONG m_resultDetail;
154 Utf8Str m_strText;
155 Guid m_IID;
156 Utf8Str m_strComponent;
157 ComPtr<IVirtualBoxErrorInfo> mNext;
158
159#ifndef VBOX_WITH_XPCOM
160 IUnknown *m_pUnkMarshaler;
161#endif
162};
163
164#endif /* !MAIN_INCLUDED_VirtualBoxErrorInfoImpl_h */
165
166/* 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