1 | /* $Id: VirtualBoxErrorInfo.h 23223 2009-09-22 15:50:03Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | * MS COM / XPCOM Abstraction Layer:
|
---|
5 | * VirtualBoxErrorInfo COM class declaration
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2008-2009 Sun Microsystems, Inc.
|
---|
10 | *
|
---|
11 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | * available from http://www.virtualbox.org. This file is free software;
|
---|
13 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | * General Public License (GPL) as published by the Free Software
|
---|
15 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 | *
|
---|
19 | * The contents of this file may alternatively be used under the terms
|
---|
20 | * of the Common Development and Distribution License Version 1.0
|
---|
21 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
22 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
23 | * CDDL are applicable instead of those of the GPL.
|
---|
24 | *
|
---|
25 | * You may elect to license modified versions of this file under the
|
---|
26 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
27 | *
|
---|
28 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
29 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
30 | * additional information or have any questions.
|
---|
31 | */
|
---|
32 |
|
---|
33 | #ifndef ___VBox_com_VirtualBoxErrorInfo_h
|
---|
34 | #define ___VBox_com_VirtualBoxErrorInfo_h
|
---|
35 |
|
---|
36 | #include "VBox/com/defs.h"
|
---|
37 | #include "VBox/com/string.h"
|
---|
38 | #include "VBox/com/ptr.h"
|
---|
39 | #include "VBox/com/Guid.h"
|
---|
40 |
|
---|
41 | /// @todo this is for IVirtualBoxErrorInfo, see the @todo below.
|
---|
42 | #include "VBox/com/VirtualBox.h"
|
---|
43 |
|
---|
44 | namespace com
|
---|
45 | {
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * The VirtualBoxErrorInfo class implements the IVirtualBoxErrorInfo interface
|
---|
49 | * that provides extended error information about interface/component method
|
---|
50 | * invocation.
|
---|
51 | *
|
---|
52 | * @todo Rename IVirtualBoxErrorInfo/VirtualBoxErrorInfo to something like
|
---|
53 | * IExtendedErrorInfo since it's not actually VirtualBox-dependent any
|
---|
54 | * more. This will also require to create IExtendedErrorInfo.idl/h etc to
|
---|
55 | * let adding this class to custom type libraries.
|
---|
56 | */
|
---|
57 | class ATL_NO_VTABLE VirtualBoxErrorInfo
|
---|
58 | : public CComObjectRootEx <CComMultiThreadModel>
|
---|
59 | , public IVirtualBoxErrorInfo
|
---|
60 | {
|
---|
61 | public:
|
---|
62 |
|
---|
63 | DECLARE_NOT_AGGREGATABLE (VirtualBoxErrorInfo)
|
---|
64 |
|
---|
65 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
66 |
|
---|
67 | BEGIN_COM_MAP (VirtualBoxErrorInfo)
|
---|
68 | COM_INTERFACE_ENTRY (IErrorInfo)
|
---|
69 | COM_INTERFACE_ENTRY (IVirtualBoxErrorInfo)
|
---|
70 | END_COM_MAP()
|
---|
71 |
|
---|
72 | VirtualBoxErrorInfo() : mResultCode (S_OK) {}
|
---|
73 |
|
---|
74 | // public initializer/uninitializer for internal purposes only
|
---|
75 |
|
---|
76 | HRESULT init(HRESULT aResultCode,
|
---|
77 | const GUID *aIID,
|
---|
78 | const char *aComponent,
|
---|
79 | const Utf8Str &strText,
|
---|
80 | IVirtualBoxErrorInfo *aNext = NULL);
|
---|
81 |
|
---|
82 | // IVirtualBoxErrorInfo properties
|
---|
83 | STDMETHOD(COMGETTER(ResultCode)) (LONG *aResultCode);
|
---|
84 | STDMETHOD(COMGETTER(InterfaceID)) (BSTR *aIID);
|
---|
85 | STDMETHOD(COMGETTER(Component)) (BSTR *aComponent);
|
---|
86 | STDMETHOD(COMGETTER(Text)) (BSTR *aText);
|
---|
87 | STDMETHOD(COMGETTER(Next)) (IVirtualBoxErrorInfo **aNext);
|
---|
88 |
|
---|
89 | #if !defined (VBOX_WITH_XPCOM)
|
---|
90 |
|
---|
91 | HRESULT init (IErrorInfo *aInfo);
|
---|
92 |
|
---|
93 | STDMETHOD(GetGUID) (GUID *guid);
|
---|
94 | STDMETHOD(GetSource) (BSTR *source);
|
---|
95 | STDMETHOD(GetDescription) (BSTR *description);
|
---|
96 | STDMETHOD(GetHelpFile) (BSTR *pBstrHelpFile);
|
---|
97 | STDMETHOD(GetHelpContext) (DWORD *pdwHelpContext);
|
---|
98 |
|
---|
99 | #else /* !defined (VBOX_WITH_XPCOM) */
|
---|
100 |
|
---|
101 | HRESULT init (nsIException *aInfo);
|
---|
102 |
|
---|
103 | NS_DECL_NSIEXCEPTION
|
---|
104 | #endif
|
---|
105 |
|
---|
106 | private:
|
---|
107 |
|
---|
108 | HRESULT mResultCode;
|
---|
109 | Bstr mText;
|
---|
110 | Guid mIID;
|
---|
111 | Bstr mComponent;
|
---|
112 | ComPtr <IVirtualBoxErrorInfo> mNext;
|
---|
113 | };
|
---|
114 |
|
---|
115 | /**
|
---|
116 | * The VirtualBoxErrorInfoGlue class glues two IVirtualBoxErrorInfo chains by
|
---|
117 | * attaching the head of the second chain to the tail of the first one.
|
---|
118 | *
|
---|
119 | * This is done by wrapping around each member of the first chain and
|
---|
120 | * substituting the next attribute implementation.
|
---|
121 | */
|
---|
122 | class ATL_NO_VTABLE VirtualBoxErrorInfoGlue
|
---|
123 | : public CComObjectRootEx <CComMultiThreadModel>
|
---|
124 | , public IVirtualBoxErrorInfo
|
---|
125 | {
|
---|
126 | public:
|
---|
127 |
|
---|
128 | DECLARE_NOT_AGGREGATABLE (VirtualBoxErrorInfoGlue)
|
---|
129 |
|
---|
130 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
131 |
|
---|
132 | BEGIN_COM_MAP (VirtualBoxErrorInfoGlue)
|
---|
133 | COM_INTERFACE_ENTRY (IErrorInfo)
|
---|
134 | COM_INTERFACE_ENTRY (IVirtualBoxErrorInfo)
|
---|
135 | END_COM_MAP()
|
---|
136 |
|
---|
137 | VirtualBoxErrorInfoGlue() {}
|
---|
138 |
|
---|
139 | // public initializer/uninitializer for internal purposes only
|
---|
140 |
|
---|
141 | HRESULT init (IVirtualBoxErrorInfo *aReal, IVirtualBoxErrorInfo *aNext);
|
---|
142 |
|
---|
143 | protected:
|
---|
144 |
|
---|
145 | HRESULT protectedInit (IVirtualBoxErrorInfo *aReal, IVirtualBoxErrorInfo *aNext);
|
---|
146 |
|
---|
147 | private:
|
---|
148 |
|
---|
149 | // IVirtualBoxErrorInfo properties
|
---|
150 | COM_FORWARD_IVirtualBoxErrorInfo_GETTER_ResultCode_TO_OBJ (mReal)
|
---|
151 | COM_FORWARD_IVirtualBoxErrorInfo_GETTER_InterfaceID_TO_OBJ (mReal)
|
---|
152 | COM_FORWARD_IVirtualBoxErrorInfo_GETTER_Component_TO_OBJ (mReal)
|
---|
153 | COM_FORWARD_IVirtualBoxErrorInfo_GETTER_Text_TO_OBJ (mReal)
|
---|
154 | STDMETHOD(COMGETTER(Next)) (IVirtualBoxErrorInfo **aNext);
|
---|
155 |
|
---|
156 | #if !defined (VBOX_WITH_XPCOM)
|
---|
157 |
|
---|
158 | STDMETHOD(GetGUID) (GUID *guid) { return mReal->GetGUID (guid); }
|
---|
159 | STDMETHOD(GetSource) (BSTR *source) { return mReal->GetSource (source); }
|
---|
160 | STDMETHOD(GetDescription) (BSTR *description) { return mReal->GetDescription (description); }
|
---|
161 | STDMETHOD(GetHelpFile) (BSTR *pBstrHelpFile) { return mReal->GetHelpFile (pBstrHelpFile); }
|
---|
162 | STDMETHOD(GetHelpContext) (DWORD *pdwHelpContext) { return mReal->GetHelpContext (pdwHelpContext); }
|
---|
163 |
|
---|
164 | #else /* !defined (VBOX_WITH_XPCOM) */
|
---|
165 |
|
---|
166 | NS_FORWARD_NSIEXCEPTION (mReal->)
|
---|
167 |
|
---|
168 | #endif
|
---|
169 |
|
---|
170 | private:
|
---|
171 |
|
---|
172 | ComPtr <IVirtualBoxErrorInfo> mReal;
|
---|
173 | ComPtr <IVirtualBoxErrorInfo> mNext;
|
---|
174 | };
|
---|
175 |
|
---|
176 | } /* namespace com */
|
---|
177 |
|
---|
178 | #endif /* ___VBox_com_VirtualBoxErrorInfo_h */
|
---|
179 |
|
---|