Hopefully create a branch and not destroy the svn repository.
[reactos.git] / dll / win32 / hnetcfg / manager.c
1 /*
2 * Copyright 2009 Hans Leidekker for CodeWeavers
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19 #include "config.h"
20 #include <stdarg.h>
21 #include <stdio.h>
22
23 #define COBJMACROS
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "initguid.h"
29 #include "ole2.h"
30 #include "netfw.h"
31
32 #include "wine/debug.h"
33 #include "wine/unicode.h"
34 #include "hnetcfg_private.h"
35
36 WINE_DEFAULT_DEBUG_CHANNEL(hnetcfg);
37
38 typedef struct fw_manager
39 {
40 const INetFwMgrVtbl *vtbl;
41 LONG refs;
42 } fw_manager;
43
44 static inline fw_manager *impl_from_INetFwMgr( INetFwMgr *iface )
45 {
46 return (fw_manager *)((char *)iface - FIELD_OFFSET( fw_manager, vtbl ));
47 }
48
49 static ULONG WINAPI fw_manager_AddRef(
50 INetFwMgr *iface )
51 {
52 fw_manager *fw_manager = impl_from_INetFwMgr( iface );
53 return InterlockedIncrement( &fw_manager->refs );
54 }
55
56 static ULONG WINAPI fw_manager_Release(
57 INetFwMgr *iface )
58 {
59 fw_manager *fw_manager = impl_from_INetFwMgr( iface );
60 LONG refs = InterlockedDecrement( &fw_manager->refs );
61 if (!refs)
62 {
63 TRACE("destroying %p\n", fw_manager);
64 HeapFree( GetProcessHeap(), 0, fw_manager );
65 }
66 return refs;
67 }
68
69 static HRESULT WINAPI fw_manager_QueryInterface(
70 INetFwMgr *iface,
71 REFIID riid,
72 void **ppvObject )
73 {
74 fw_manager *This = impl_from_INetFwMgr( iface );
75
76 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
77
78 if ( IsEqualGUID( riid, &IID_INetFwMgr ) ||
79 IsEqualGUID( riid, &IID_IDispatch ) ||
80 IsEqualGUID( riid, &IID_IUnknown ) )
81 {
82 *ppvObject = iface;
83 }
84 else
85 {
86 FIXME("interface %s not implemented\n", debugstr_guid(riid));
87 return E_NOINTERFACE;
88 }
89 INetFwMgr_AddRef( iface );
90 return S_OK;
91 }
92
93 static HRESULT WINAPI fw_manager_GetTypeInfoCount(
94 INetFwMgr *iface,
95 UINT *pctinfo )
96 {
97 fw_manager *This = impl_from_INetFwMgr( iface );
98
99 FIXME("%p %p\n", This, pctinfo);
100 return E_NOTIMPL;
101 }
102
103 static HRESULT WINAPI fw_manager_GetTypeInfo(
104 INetFwMgr *iface,
105 UINT iTInfo,
106 LCID lcid,
107 ITypeInfo **ppTInfo )
108 {
109 fw_manager *This = impl_from_INetFwMgr( iface );
110
111 FIXME("%p %u %u %p\n", This, iTInfo, lcid, ppTInfo);
112 return E_NOTIMPL;
113 }
114
115 static HRESULT WINAPI fw_manager_GetIDsOfNames(
116 INetFwMgr *iface,
117 REFIID riid,
118 LPOLESTR *rgszNames,
119 UINT cNames,
120 LCID lcid,
121 DISPID *rgDispId )
122 {
123 fw_manager *This = impl_from_INetFwMgr( iface );
124
125 FIXME("%p %s %p %u %u %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
126 return E_NOTIMPL;
127 }
128
129 static HRESULT WINAPI fw_manager_Invoke(
130 INetFwMgr *iface,
131 DISPID dispIdMember,
132 REFIID riid,
133 LCID lcid,
134 WORD wFlags,
135 DISPPARAMS *pDispParams,
136 VARIANT *pVarResult,
137 EXCEPINFO *pExcepInfo,
138 UINT *puArgErr )
139 {
140 fw_manager *This = impl_from_INetFwMgr( iface );
141
142 FIXME("%p %d %s %d %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
143 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
144 return E_NOTIMPL;
145 }
146
147 static HRESULT WINAPI fw_manager_get_LocalPolicy(
148 INetFwMgr *iface,
149 INetFwPolicy **localPolicy )
150 {
151 fw_manager *This = impl_from_INetFwMgr( iface );
152
153 TRACE("%p, %p\n", This, localPolicy);
154 return NetFwPolicy_create( NULL, (void **)localPolicy );
155 }
156
157 static HRESULT WINAPI fw_manager_get_CurrentProfileType(
158 INetFwMgr *iface,
159 NET_FW_PROFILE_TYPE *profileType )
160 {
161 fw_manager *This = impl_from_INetFwMgr( iface );
162
163 FIXME("%p, %p\n", This, profileType);
164 return E_NOTIMPL;
165 }
166
167 static HRESULT WINAPI fw_manager_RestoreDefaults(
168 INetFwMgr *iface )
169 {
170 fw_manager *This = impl_from_INetFwMgr( iface );
171
172 FIXME("%p\n", This);
173 return E_NOTIMPL;
174 }
175
176 static HRESULT WINAPI fw_manager_IsPortAllowed(
177 INetFwMgr *iface,
178 BSTR imageFileName,
179 NET_FW_IP_VERSION ipVersion,
180 LONG portNumber,
181 BSTR localAddress,
182 NET_FW_IP_PROTOCOL ipProtocol,
183 VARIANT *allowed,
184 VARIANT *restricted )
185 {
186 fw_manager *This = impl_from_INetFwMgr( iface );
187
188 FIXME("%p, %s, %u, %d, %s, %u, %p, %p\n", This, debugstr_w(imageFileName),
189 ipVersion, portNumber, debugstr_w(localAddress), ipProtocol, allowed, restricted);
190 return E_NOTIMPL;
191 }
192
193 static HRESULT WINAPI fw_manager_IsIcmpTypeAllowed(
194 INetFwMgr *iface,
195 NET_FW_IP_VERSION ipVersion,
196 BSTR localAddress,
197 BYTE type,
198 VARIANT *allowed,
199 VARIANT *restricted )
200 {
201 fw_manager *This = impl_from_INetFwMgr( iface );
202
203 FIXME("%p, %u, %s, %u, %p, %p\n", This, ipVersion, debugstr_w(localAddress),
204 type, allowed, restricted);
205 return E_NOTIMPL;
206 }
207
208 static const struct INetFwMgrVtbl fw_manager_vtbl =
209 {
210 fw_manager_QueryInterface,
211 fw_manager_AddRef,
212 fw_manager_Release,
213 fw_manager_GetTypeInfoCount,
214 fw_manager_GetTypeInfo,
215 fw_manager_GetIDsOfNames,
216 fw_manager_Invoke,
217 fw_manager_get_LocalPolicy,
218 fw_manager_get_CurrentProfileType,
219 fw_manager_RestoreDefaults,
220 fw_manager_IsPortAllowed,
221 fw_manager_IsIcmpTypeAllowed
222 };
223
224 HRESULT NetFwMgr_create( IUnknown *pUnkOuter, LPVOID *ppObj )
225 {
226 fw_manager *fm;
227
228 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
229
230 fm = HeapAlloc( GetProcessHeap(), 0, sizeof(*fm) );
231 if (!fm) return E_OUTOFMEMORY;
232
233 fm->vtbl = &fw_manager_vtbl;
234 fm->refs = 1;
235
236 *ppObj = &fm->vtbl;
237
238 TRACE("returning iface %p\n", *ppObj);
239 return S_OK;
240 }