1 | /** @file
|
---|
2 | * VirtualBoxErrorInfo COM class definition.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2011 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | */
|
---|
16 |
|
---|
17 | #ifndef ____H_VIRTUALBOXERRORINFOIMPL
|
---|
18 | #define ____H_VIRTUALBOXERRORINFOIMPL
|
---|
19 |
|
---|
20 | #include "VirtualBoxBase.h"
|
---|
21 |
|
---|
22 | using namespace com;
|
---|
23 |
|
---|
24 | class ATL_NO_VTABLE VirtualBoxErrorInfo
|
---|
25 | : public CComObjectRootEx<CComMultiThreadModel>
|
---|
26 | , VBOX_SCRIPTABLE_IMPL(IVirtualBoxErrorInfo)
|
---|
27 | #ifndef VBOX_WITH_XPCOM /* IErrorInfo doesn't inherit from IDispatch, ugly 3am hack: */
|
---|
28 | , public IDispatch
|
---|
29 | #endif
|
---|
30 | {
|
---|
31 | public:
|
---|
32 |
|
---|
33 | DECLARE_NOT_AGGREGATABLE(VirtualBoxErrorInfo)
|
---|
34 |
|
---|
35 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
36 |
|
---|
37 | BEGIN_COM_MAP(VirtualBoxErrorInfo)
|
---|
38 | COM_INTERFACE_ENTRY(IErrorInfo)
|
---|
39 | COM_INTERFACE_ENTRY(IVirtualBoxErrorInfo)
|
---|
40 | COM_INTERFACE_ENTRY(IDispatch)
|
---|
41 | END_COM_MAP()
|
---|
42 |
|
---|
43 | #ifndef VBOX_WITH_XPCOM
|
---|
44 |
|
---|
45 | HRESULT init(IErrorInfo *aInfo);
|
---|
46 |
|
---|
47 | STDMETHOD(GetGUID)(GUID *guid);
|
---|
48 | STDMETHOD(GetSource)(BSTR *source);
|
---|
49 | STDMETHOD(GetDescription)(BSTR *description);
|
---|
50 | STDMETHOD(GetHelpFile)(BSTR *pBstrHelpFile);
|
---|
51 | STDMETHOD(GetHelpContext)(DWORD *pdwHelpContext);
|
---|
52 |
|
---|
53 | // IDispatch forwarding - 3am hack.
|
---|
54 | typedef IDispatchImpl<IVirtualBoxErrorInfo, &IID_IVirtualBoxErrorInfo, &LIBID_VirtualBox, kTypeLibraryMajorVersion, kTypeLibraryMinorVersion> idi;
|
---|
55 |
|
---|
56 | STDMETHOD(GetTypeInfoCount)(UINT *pcInfo)
|
---|
57 | {
|
---|
58 | return idi::GetTypeInfoCount(pcInfo);
|
---|
59 | }
|
---|
60 |
|
---|
61 | STDMETHOD(GetTypeInfo)(UINT iInfo, LCID Lcid, ITypeInfo **ppTypeInfo)
|
---|
62 | {
|
---|
63 | return idi::GetTypeInfo(iInfo, Lcid, ppTypeInfo);
|
---|
64 | }
|
---|
65 |
|
---|
66 | STDMETHOD(GetIDsOfNames)(REFIID rIID, LPOLESTR *papwszNames, UINT cNames, LCID Lcid, DISPID *paDispIDs)
|
---|
67 | {
|
---|
68 | return idi::GetIDsOfNames(rIID, papwszNames, cNames, Lcid, paDispIDs);
|
---|
69 | }
|
---|
70 |
|
---|
71 | STDMETHOD(Invoke)(DISPID idDispMember, REFIID rIID, LCID Lcid, WORD fw, DISPPARAMS *pDispParams,
|
---|
72 | VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *piErrArg)
|
---|
73 | {
|
---|
74 | return idi::Invoke(idDispMember, rIID, Lcid, fw, pDispParams, pVarResult, pExcepInfo, piErrArg);
|
---|
75 | }
|
---|
76 |
|
---|
77 | #else // defined(VBOX_WITH_XPCOM)
|
---|
78 |
|
---|
79 | HRESULT init(nsIException *aInfo);
|
---|
80 |
|
---|
81 | NS_DECL_NSIEXCEPTION
|
---|
82 |
|
---|
83 | #endif
|
---|
84 |
|
---|
85 | VirtualBoxErrorInfo()
|
---|
86 | : m_resultCode(S_OK)
|
---|
87 | {}
|
---|
88 |
|
---|
89 | // public initializer/uninitializer for internal purposes only
|
---|
90 | HRESULT init(HRESULT aResultCode,
|
---|
91 | const GUID &aIID,
|
---|
92 | const char *pcszComponent,
|
---|
93 | const Utf8Str &strText,
|
---|
94 | IVirtualBoxErrorInfo *aNext = NULL);
|
---|
95 |
|
---|
96 | HRESULT initEx(HRESULT aResultCode,
|
---|
97 | LONG aResultDetail,
|
---|
98 | const GUID &aIID,
|
---|
99 | const char *pcszComponent,
|
---|
100 | const Utf8Str &strText,
|
---|
101 | IVirtualBoxErrorInfo *aNext = NULL);
|
---|
102 |
|
---|
103 | HRESULT init(const com::ErrorInfo &ei,
|
---|
104 | IVirtualBoxErrorInfo *aNext = NULL);
|
---|
105 |
|
---|
106 | // IVirtualBoxErrorInfo properties
|
---|
107 | STDMETHOD(COMGETTER(ResultCode))(LONG *aResultCode);
|
---|
108 | STDMETHOD(COMGETTER(ResultDetail))(LONG *aResultDetail);
|
---|
109 | STDMETHOD(COMGETTER(InterfaceID))(BSTR *aIID);
|
---|
110 | STDMETHOD(COMGETTER(Component))(BSTR *aComponent);
|
---|
111 | STDMETHOD(COMGETTER(Text))(BSTR *aText);
|
---|
112 | STDMETHOD(COMGETTER(Next))(IVirtualBoxErrorInfo **aNext);
|
---|
113 |
|
---|
114 | private:
|
---|
115 | // FIXME: declare these here until VBoxSupportsTranslation base
|
---|
116 | // is available in this class.
|
---|
117 | static const char *tr(const char *a) { return a; }
|
---|
118 | static HRESULT setError(HRESULT rc,
|
---|
119 | const char * /* a */,
|
---|
120 | const char * /* b */,
|
---|
121 | void * /* c */) { return rc; }
|
---|
122 |
|
---|
123 | HRESULT m_resultCode;
|
---|
124 | LONG m_resultDetail;
|
---|
125 | Utf8Str m_strText;
|
---|
126 | Guid m_IID;
|
---|
127 | Utf8Str m_strComponent;
|
---|
128 | ComPtr<IVirtualBoxErrorInfo> mNext;
|
---|
129 | };
|
---|
130 |
|
---|
131 | #endif // !____H_VIRTUALBOXERRORINFOIMPL
|
---|
132 |
|
---|
133 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|