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