setupx.dll16: Use BOOL type where appropriate.
[wine/multimedia.git] / dlls / hnetcfg / apps.c
blob7fd6b55d5fe96091382b1180b5276728135070a8
1 /*
2 * Copyright 2009 Hans Leidekker for CodeWeavers
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.
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.
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
19 #include "config.h"
20 #include <stdarg.h>
21 #include <stdio.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "ole2.h"
29 #include "netfw.h"
31 #include "wine/debug.h"
32 #include "wine/unicode.h"
33 #include "hnetcfg_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(hnetcfg);
37 typedef struct fw_app
39 INetFwAuthorizedApplication INetFwAuthorizedApplication_iface;
40 LONG refs;
41 } fw_app;
43 static inline fw_app *impl_from_INetFwAuthorizedApplication( INetFwAuthorizedApplication *iface )
45 return CONTAINING_RECORD(iface, fw_app, INetFwAuthorizedApplication_iface);
48 static ULONG WINAPI fw_app_AddRef(
49 INetFwAuthorizedApplication *iface )
51 fw_app *fw_app = impl_from_INetFwAuthorizedApplication( iface );
52 return InterlockedIncrement( &fw_app->refs );
55 static ULONG WINAPI fw_app_Release(
56 INetFwAuthorizedApplication *iface )
58 fw_app *fw_app = impl_from_INetFwAuthorizedApplication( iface );
59 LONG refs = InterlockedDecrement( &fw_app->refs );
60 if (!refs)
62 TRACE("destroying %p\n", fw_app);
63 HeapFree( GetProcessHeap(), 0, fw_app );
65 return refs;
68 static HRESULT WINAPI fw_app_QueryInterface(
69 INetFwAuthorizedApplication *iface,
70 REFIID riid,
71 void **ppvObject )
73 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
75 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
77 if ( IsEqualGUID( riid, &IID_INetFwAuthorizedApplication ) ||
78 IsEqualGUID( riid, &IID_IDispatch ) ||
79 IsEqualGUID( riid, &IID_IUnknown ) )
81 *ppvObject = iface;
83 else
85 FIXME("interface %s not implemented\n", debugstr_guid(riid));
86 return E_NOINTERFACE;
88 INetFwAuthorizedApplication_AddRef( iface );
89 return S_OK;
92 static HRESULT WINAPI fw_app_GetTypeInfoCount(
93 INetFwAuthorizedApplication *iface,
94 UINT *pctinfo )
96 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
98 TRACE("%p %p\n", This, pctinfo);
99 *pctinfo = 1;
100 return S_OK;
103 static ITypeLib *typelib;
104 static ITypeInfo *typeinfo[last_tid];
106 static REFIID tid_id[] =
108 &IID_INetFwAuthorizedApplication,
109 &IID_INetFwAuthorizedApplications,
110 &IID_INetFwMgr,
111 &IID_INetFwPolicy,
112 &IID_INetFwProfile
115 HRESULT get_typeinfo( enum type_id tid, ITypeInfo **ret )
117 HRESULT hr;
119 if (!typelib)
121 ITypeLib *lib;
123 hr = LoadRegTypeLib( &LIBID_NetFwPublicTypeLib, 1, 0, LOCALE_SYSTEM_DEFAULT, &lib );
124 if (FAILED(hr))
126 ERR("LoadRegTypeLib failed: %08x\n", hr);
127 return hr;
129 if (InterlockedCompareExchangePointer( (void **)&typelib, lib, NULL ))
130 ITypeLib_Release( lib );
132 if (!typeinfo[tid])
134 ITypeInfo *info;
136 hr = ITypeLib_GetTypeInfoOfGuid( typelib, tid_id[tid], &info );
137 if (FAILED(hr))
139 ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_id[tid]), hr);
140 return hr;
142 if (InterlockedCompareExchangePointer( (void **)(typeinfo + tid), info, NULL ))
143 ITypeInfo_Release( info );
145 *ret = typeinfo[tid];
146 return S_OK;
149 static HRESULT WINAPI fw_app_GetTypeInfo(
150 INetFwAuthorizedApplication *iface,
151 UINT iTInfo,
152 LCID lcid,
153 ITypeInfo **ppTInfo )
155 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
157 TRACE("%p %u %u %p\n", This, iTInfo, lcid, ppTInfo);
158 return get_typeinfo( INetFwAuthorizedApplication_tid, ppTInfo );
161 static HRESULT WINAPI fw_app_GetIDsOfNames(
162 INetFwAuthorizedApplication *iface,
163 REFIID riid,
164 LPOLESTR *rgszNames,
165 UINT cNames,
166 LCID lcid,
167 DISPID *rgDispId )
169 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
170 ITypeInfo *typeinfo;
171 HRESULT hr;
173 TRACE("%p %s %p %u %u %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
175 hr = get_typeinfo( INetFwAuthorizedApplication_tid, &typeinfo );
176 if (SUCCEEDED(hr))
178 hr = ITypeInfo_GetIDsOfNames( typeinfo, rgszNames, cNames, rgDispId );
179 ITypeInfo_Release( typeinfo );
181 return hr;
184 static HRESULT WINAPI fw_app_Invoke(
185 INetFwAuthorizedApplication *iface,
186 DISPID dispIdMember,
187 REFIID riid,
188 LCID lcid,
189 WORD wFlags,
190 DISPPARAMS *pDispParams,
191 VARIANT *pVarResult,
192 EXCEPINFO *pExcepInfo,
193 UINT *puArgErr )
195 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
196 ITypeInfo *typeinfo;
197 HRESULT hr;
199 TRACE("%p %d %s %d %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
200 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
202 hr = get_typeinfo( INetFwAuthorizedApplication_tid, &typeinfo );
203 if (SUCCEEDED(hr))
205 hr = ITypeInfo_Invoke( typeinfo, &This->INetFwAuthorizedApplication_iface, dispIdMember,
206 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr );
207 ITypeInfo_Release( typeinfo );
209 return hr;
212 static HRESULT WINAPI fw_app_get_Name(
213 INetFwAuthorizedApplication *iface,
214 BSTR *name )
216 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
218 FIXME("%p, %p\n", This, name);
219 return E_NOTIMPL;
222 static HRESULT WINAPI fw_app_put_Name(
223 INetFwAuthorizedApplication *iface,
224 BSTR name )
226 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
228 FIXME("%p, %s\n", This, debugstr_w(name));
229 return S_OK;
232 static HRESULT WINAPI fw_app_get_ProcessImageFileName(
233 INetFwAuthorizedApplication *iface,
234 BSTR *imageFileName )
236 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
238 FIXME("%p, %p\n", This, imageFileName);
239 return E_NOTIMPL;
242 static HRESULT WINAPI fw_app_put_ProcessImageFileName(
243 INetFwAuthorizedApplication *iface,
244 BSTR imageFileName )
246 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
248 FIXME("%p, %s\n", This, debugstr_w(imageFileName));
249 return S_OK;
252 static HRESULT WINAPI fw_app_get_IpVersion(
253 INetFwAuthorizedApplication *iface,
254 NET_FW_IP_VERSION *ipVersion )
256 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
258 FIXME("%p, %p\n", This, ipVersion);
259 return E_NOTIMPL;
262 static HRESULT WINAPI fw_app_put_IpVersion(
263 INetFwAuthorizedApplication *iface,
264 NET_FW_IP_VERSION ipVersion )
266 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
268 FIXME("%p, %u\n", This, ipVersion);
269 return E_NOTIMPL;
272 static HRESULT WINAPI fw_app_get_Scope(
273 INetFwAuthorizedApplication *iface,
274 NET_FW_SCOPE *scope )
276 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
278 FIXME("%p, %p\n", This, scope);
279 return E_NOTIMPL;
282 static HRESULT WINAPI fw_app_put_Scope(
283 INetFwAuthorizedApplication *iface,
284 NET_FW_SCOPE scope )
286 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
288 FIXME("%p, %u\n", This, scope);
289 return S_OK;
292 static HRESULT WINAPI fw_app_get_RemoteAddresses(
293 INetFwAuthorizedApplication *iface,
294 BSTR *remoteAddrs )
296 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
298 FIXME("%p, %p\n", This, remoteAddrs);
299 return E_NOTIMPL;
302 static HRESULT WINAPI fw_app_put_RemoteAddresses(
303 INetFwAuthorizedApplication *iface,
304 BSTR remoteAddrs )
306 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
308 FIXME("%p, %s\n", This, debugstr_w(remoteAddrs));
309 return E_NOTIMPL;
312 static HRESULT WINAPI fw_app_get_Enabled(
313 INetFwAuthorizedApplication *iface,
314 VARIANT_BOOL *enabled )
316 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
318 FIXME("%p, %p\n", This, enabled);
320 *enabled = VARIANT_FALSE;
321 return S_OK;
324 static HRESULT WINAPI fw_app_put_Enabled(
325 INetFwAuthorizedApplication *iface,
326 VARIANT_BOOL enabled )
328 fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
330 FIXME("%p, %d\n", This, enabled);
331 return S_OK;
334 static const struct INetFwAuthorizedApplicationVtbl fw_app_vtbl =
336 fw_app_QueryInterface,
337 fw_app_AddRef,
338 fw_app_Release,
339 fw_app_GetTypeInfoCount,
340 fw_app_GetTypeInfo,
341 fw_app_GetIDsOfNames,
342 fw_app_Invoke,
343 fw_app_get_Name,
344 fw_app_put_Name,
345 fw_app_get_ProcessImageFileName,
346 fw_app_put_ProcessImageFileName,
347 fw_app_get_IpVersion,
348 fw_app_put_IpVersion,
349 fw_app_get_Scope,
350 fw_app_put_Scope,
351 fw_app_get_RemoteAddresses,
352 fw_app_put_RemoteAddresses,
353 fw_app_get_Enabled,
354 fw_app_put_Enabled
357 HRESULT NetFwAuthorizedApplication_create( IUnknown *pUnkOuter, LPVOID *ppObj )
359 fw_app *fa;
361 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
363 fa = HeapAlloc( GetProcessHeap(), 0, sizeof(*fa) );
364 if (!fa) return E_OUTOFMEMORY;
366 fa->INetFwAuthorizedApplication_iface.lpVtbl = &fw_app_vtbl;
367 fa->refs = 1;
369 *ppObj = &fa->INetFwAuthorizedApplication_iface;
371 TRACE("returning iface %p\n", *ppObj);
372 return S_OK;
374 typedef struct fw_apps
376 INetFwAuthorizedApplications INetFwAuthorizedApplications_iface;
377 LONG refs;
378 } fw_apps;
380 static inline fw_apps *impl_from_INetFwAuthorizedApplications( INetFwAuthorizedApplications *iface )
382 return CONTAINING_RECORD(iface, fw_apps, INetFwAuthorizedApplications_iface);
385 static ULONG WINAPI fw_apps_AddRef(
386 INetFwAuthorizedApplications *iface )
388 fw_apps *fw_apps = impl_from_INetFwAuthorizedApplications( iface );
389 return InterlockedIncrement( &fw_apps->refs );
392 static ULONG WINAPI fw_apps_Release(
393 INetFwAuthorizedApplications *iface )
395 fw_apps *fw_apps = impl_from_INetFwAuthorizedApplications( iface );
396 LONG refs = InterlockedDecrement( &fw_apps->refs );
397 if (!refs)
399 TRACE("destroying %p\n", fw_apps);
400 HeapFree( GetProcessHeap(), 0, fw_apps );
402 return refs;
405 static HRESULT WINAPI fw_apps_QueryInterface(
406 INetFwAuthorizedApplications *iface,
407 REFIID riid,
408 void **ppvObject )
410 fw_apps *This = impl_from_INetFwAuthorizedApplications( iface );
412 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
414 if ( IsEqualGUID( riid, &IID_INetFwAuthorizedApplications ) ||
415 IsEqualGUID( riid, &IID_IDispatch ) ||
416 IsEqualGUID( riid, &IID_IUnknown ) )
418 *ppvObject = iface;
420 else
422 FIXME("interface %s not implemented\n", debugstr_guid(riid));
423 return E_NOINTERFACE;
425 INetFwAuthorizedApplications_AddRef( iface );
426 return S_OK;
429 static HRESULT WINAPI fw_apps_GetTypeInfoCount(
430 INetFwAuthorizedApplications *iface,
431 UINT *pctinfo )
433 fw_apps *This = impl_from_INetFwAuthorizedApplications( iface );
435 FIXME("%p %p\n", This, pctinfo);
436 return E_NOTIMPL;
439 static HRESULT WINAPI fw_apps_GetTypeInfo(
440 INetFwAuthorizedApplications *iface,
441 UINT iTInfo,
442 LCID lcid,
443 ITypeInfo **ppTInfo )
445 fw_apps *This = impl_from_INetFwAuthorizedApplications( iface );
447 TRACE("%p %u %u %p\n", This, iTInfo, lcid, ppTInfo);
448 return get_typeinfo( INetFwAuthorizedApplications_tid, ppTInfo );
451 static HRESULT WINAPI fw_apps_GetIDsOfNames(
452 INetFwAuthorizedApplications *iface,
453 REFIID riid,
454 LPOLESTR *rgszNames,
455 UINT cNames,
456 LCID lcid,
457 DISPID *rgDispId )
459 fw_apps *This = impl_from_INetFwAuthorizedApplications( iface );
460 ITypeInfo *typeinfo;
461 HRESULT hr;
463 TRACE("%p %s %p %u %u %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
465 hr = get_typeinfo( INetFwAuthorizedApplications_tid, &typeinfo );
466 if (SUCCEEDED(hr))
468 hr = ITypeInfo_GetIDsOfNames( typeinfo, rgszNames, cNames, rgDispId );
469 ITypeInfo_Release( typeinfo );
471 return hr;
474 static HRESULT WINAPI fw_apps_Invoke(
475 INetFwAuthorizedApplications *iface,
476 DISPID dispIdMember,
477 REFIID riid,
478 LCID lcid,
479 WORD wFlags,
480 DISPPARAMS *pDispParams,
481 VARIANT *pVarResult,
482 EXCEPINFO *pExcepInfo,
483 UINT *puArgErr )
485 fw_apps *This = impl_from_INetFwAuthorizedApplications( iface );
486 ITypeInfo *typeinfo;
487 HRESULT hr;
489 TRACE("%p %d %s %d %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
490 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
492 hr = get_typeinfo( INetFwAuthorizedApplications_tid, &typeinfo );
493 if (SUCCEEDED(hr))
495 hr = ITypeInfo_Invoke( typeinfo, &This->INetFwAuthorizedApplications_iface, dispIdMember,
496 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr );
497 ITypeInfo_Release( typeinfo );
499 return hr;
502 static HRESULT WINAPI fw_apps_get_Count(
503 INetFwAuthorizedApplications *iface,
504 LONG *count )
506 fw_apps *This = impl_from_INetFwAuthorizedApplications( iface );
508 FIXME("%p, %p\n", This, count);
509 return E_NOTIMPL;
512 static HRESULT WINAPI fw_apps_Add(
513 INetFwAuthorizedApplications *iface,
514 INetFwAuthorizedApplication *app )
516 fw_apps *This = impl_from_INetFwAuthorizedApplications( iface );
518 FIXME("%p, %p\n", This, app);
519 return S_OK;
522 static HRESULT WINAPI fw_apps_Remove(
523 INetFwAuthorizedApplications *iface,
524 BSTR imageFileName )
526 fw_apps *This = impl_from_INetFwAuthorizedApplications( iface );
528 FIXME("%p, %s\n", This, debugstr_w(imageFileName));
529 return S_OK;
532 static HRESULT WINAPI fw_apps_Item(
533 INetFwAuthorizedApplications *iface,
534 BSTR imageFileName,
535 INetFwAuthorizedApplication **app )
537 fw_apps *This = impl_from_INetFwAuthorizedApplications( iface );
539 TRACE("%p, %s, %p\n", This, debugstr_w(imageFileName), app);
540 return NetFwAuthorizedApplication_create( NULL, (void **)app );
543 static HRESULT WINAPI fw_apps_get__NewEnum(
544 INetFwAuthorizedApplications *iface,
545 IUnknown **newEnum )
547 fw_apps *This = impl_from_INetFwAuthorizedApplications( iface );
549 FIXME("%p, %p\n", This, newEnum);
550 return E_NOTIMPL;
553 static const struct INetFwAuthorizedApplicationsVtbl fw_apps_vtbl =
555 fw_apps_QueryInterface,
556 fw_apps_AddRef,
557 fw_apps_Release,
558 fw_apps_GetTypeInfoCount,
559 fw_apps_GetTypeInfo,
560 fw_apps_GetIDsOfNames,
561 fw_apps_Invoke,
562 fw_apps_get_Count,
563 fw_apps_Add,
564 fw_apps_Remove,
565 fw_apps_Item,
566 fw_apps_get__NewEnum
569 HRESULT NetFwAuthorizedApplications_create( IUnknown *pUnkOuter, LPVOID *ppObj )
571 fw_apps *fa;
573 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
575 fa = HeapAlloc( GetProcessHeap(), 0, sizeof(*fa) );
576 if (!fa) return E_OUTOFMEMORY;
578 fa->INetFwAuthorizedApplications_iface.lpVtbl = &fw_apps_vtbl;
579 fa->refs = 1;
581 *ppObj = &fa->INetFwAuthorizedApplications_iface;
583 TRACE("returning iface %p\n", *ppObj);
584 return S_OK;