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
31 #include "wine/debug.h"
32 #include "wine/heap.h"
33 #include "wine/unicode.h"
34 #include "hnetcfg_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(hnetcfg
);
40 INetFwAuthorizedApplication INetFwAuthorizedApplication_iface
;
45 static inline fw_app
*impl_from_INetFwAuthorizedApplication( INetFwAuthorizedApplication
*iface
)
47 return CONTAINING_RECORD(iface
, fw_app
, INetFwAuthorizedApplication_iface
);
50 static ULONG WINAPI
fw_app_AddRef(
51 INetFwAuthorizedApplication
*iface
)
53 fw_app
*fw_app
= impl_from_INetFwAuthorizedApplication( iface
);
54 return InterlockedIncrement( &fw_app
->refs
);
57 static ULONG WINAPI
fw_app_Release(
58 INetFwAuthorizedApplication
*iface
)
60 fw_app
*fw_app
= impl_from_INetFwAuthorizedApplication( iface
);
61 LONG refs
= InterlockedDecrement( &fw_app
->refs
);
64 TRACE("destroying %p\n", fw_app
);
65 SysFreeString( fw_app
->filename
);
66 HeapFree( GetProcessHeap(), 0, fw_app
);
71 static HRESULT WINAPI
fw_app_QueryInterface(
72 INetFwAuthorizedApplication
*iface
,
76 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
78 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppvObject
);
80 if ( IsEqualGUID( riid
, &IID_INetFwAuthorizedApplication
) ||
81 IsEqualGUID( riid
, &IID_IDispatch
) ||
82 IsEqualGUID( riid
, &IID_IUnknown
) )
88 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
91 INetFwAuthorizedApplication_AddRef( iface
);
95 static HRESULT WINAPI
fw_app_GetTypeInfoCount(
96 INetFwAuthorizedApplication
*iface
,
99 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
101 TRACE("%p %p\n", This
, pctinfo
);
106 static ITypeLib
*typelib
;
107 static ITypeInfo
*typeinfo
[last_tid
];
109 static REFIID tid_id
[] =
111 &IID_INetFwAuthorizedApplication
,
112 &IID_INetFwAuthorizedApplications
,
115 &IID_INetFwOpenPorts
,
121 HRESULT
get_typeinfo( enum type_id tid
, ITypeInfo
**ret
)
129 hr
= LoadRegTypeLib( &LIBID_NetFwPublicTypeLib
, 1, 0, LOCALE_SYSTEM_DEFAULT
, &lib
);
132 ERR("LoadRegTypeLib failed: %08x\n", hr
);
135 if (InterlockedCompareExchangePointer( (void **)&typelib
, lib
, NULL
))
136 ITypeLib_Release( lib
);
142 hr
= ITypeLib_GetTypeInfoOfGuid( typelib
, tid_id
[tid
], &info
);
145 ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_id
[tid
]), hr
);
148 if (InterlockedCompareExchangePointer( (void **)(typeinfo
+ tid
), info
, NULL
))
149 ITypeInfo_Release( info
);
151 *ret
= typeinfo
[tid
];
152 ITypeInfo_AddRef(typeinfo
[tid
]);
156 void release_typelib(void)
160 for (i
= 0; i
< ARRAY_SIZE(typeinfo
); i
++)
162 ITypeInfo_Release(typeinfo
[i
]);
165 ITypeLib_Release(typelib
);
168 static HRESULT WINAPI
fw_app_GetTypeInfo(
169 INetFwAuthorizedApplication
*iface
,
172 ITypeInfo
**ppTInfo
)
174 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
176 TRACE("%p %u %u %p\n", This
, iTInfo
, lcid
, ppTInfo
);
177 return get_typeinfo( INetFwAuthorizedApplication_tid
, ppTInfo
);
180 static HRESULT WINAPI
fw_app_GetIDsOfNames(
181 INetFwAuthorizedApplication
*iface
,
188 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
192 TRACE("%p %s %p %u %u %p\n", This
, debugstr_guid(riid
), rgszNames
, cNames
, lcid
, rgDispId
);
194 hr
= get_typeinfo( INetFwAuthorizedApplication_tid
, &typeinfo
);
197 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, rgszNames
, cNames
, rgDispId
);
198 ITypeInfo_Release( typeinfo
);
203 static HRESULT WINAPI
fw_app_Invoke(
204 INetFwAuthorizedApplication
*iface
,
209 DISPPARAMS
*pDispParams
,
211 EXCEPINFO
*pExcepInfo
,
214 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
218 TRACE("%p %d %s %d %d %p %p %p %p\n", This
, dispIdMember
, debugstr_guid(riid
),
219 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
221 hr
= get_typeinfo( INetFwAuthorizedApplication_tid
, &typeinfo
);
224 hr
= ITypeInfo_Invoke( typeinfo
, &This
->INetFwAuthorizedApplication_iface
, dispIdMember
,
225 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
226 ITypeInfo_Release( typeinfo
);
231 static HRESULT WINAPI
fw_app_get_Name(
232 INetFwAuthorizedApplication
*iface
,
235 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
237 FIXME("%p, %p\n", This
, name
);
241 static HRESULT WINAPI
fw_app_put_Name(
242 INetFwAuthorizedApplication
*iface
,
245 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
247 FIXME("%p, %s\n", This
, debugstr_w(name
));
251 static HRESULT WINAPI
fw_app_get_ProcessImageFileName(
252 INetFwAuthorizedApplication
*iface
,
253 BSTR
*imageFileName
)
255 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
257 FIXME("%p, %p\n", This
, imageFileName
);
262 *imageFileName
= SysAllocString( This
->filename
);
263 return *imageFileName
|| !This
->filename
? S_OK
: E_OUTOFMEMORY
;
266 static HRESULT WINAPI
fw_app_put_ProcessImageFileName(
267 INetFwAuthorizedApplication
*iface
, BSTR image
)
269 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
270 UNIVERSAL_NAME_INFOW
*info
;
275 FIXME("%p, %s\n", This
, debugstr_w(image
));
277 if (!image
|| !image
[0])
281 res
= WNetGetUniversalNameW(image
, UNIVERSAL_NAME_INFO_LEVEL
, NULL
, &sz
);
282 if (res
== WN_MORE_DATA
)
284 if (!(path
= heap_alloc(sz
)))
285 return E_OUTOFMEMORY
;
287 info
= (UNIVERSAL_NAME_INFOW
*)&path
;
288 res
= WNetGetUniversalNameW(image
, UNIVERSAL_NAME_INFO_LEVEL
, &info
, &sz
);
291 SysFreeString(This
->filename
);
292 This
->filename
= SysAllocString(info
->lpUniversalName
);
295 return HRESULT_FROM_WIN32(res
);
298 sz
= GetFullPathNameW(image
, 0, NULL
, NULL
);
299 if (!(path
= heap_alloc(++sz
* sizeof(WCHAR
))))
300 return E_OUTOFMEMORY
;
301 GetFullPathNameW(image
, sz
, path
, NULL
);
303 longsz
= GetLongPathNameW(path
, path
, sz
);
306 if (!(path
= heap_realloc(path
, longsz
* sizeof(WCHAR
))))
309 return E_OUTOFMEMORY
;
311 GetLongPathNameW(path
, path
, longsz
);
314 SysFreeString( This
->filename
);
315 This
->filename
= SysAllocString(path
);
317 return This
->filename
? S_OK
: E_OUTOFMEMORY
;
320 static HRESULT WINAPI
fw_app_get_IpVersion(
321 INetFwAuthorizedApplication
*iface
,
322 NET_FW_IP_VERSION
*ipVersion
)
324 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
326 TRACE("%p, %p\n", This
, ipVersion
);
330 *ipVersion
= NET_FW_IP_VERSION_ANY
;
334 static HRESULT WINAPI
fw_app_put_IpVersion(
335 INetFwAuthorizedApplication
*iface
,
336 NET_FW_IP_VERSION ipVersion
)
338 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
340 TRACE("%p, %u\n", This
, ipVersion
);
344 static HRESULT WINAPI
fw_app_get_Scope(
345 INetFwAuthorizedApplication
*iface
,
346 NET_FW_SCOPE
*scope
)
348 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
350 FIXME("%p, %p\n", This
, scope
);
354 static HRESULT WINAPI
fw_app_put_Scope(
355 INetFwAuthorizedApplication
*iface
,
358 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
360 FIXME("%p, %u\n", This
, scope
);
364 static HRESULT WINAPI
fw_app_get_RemoteAddresses(
365 INetFwAuthorizedApplication
*iface
,
368 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
370 FIXME("%p, %p\n", This
, remoteAddrs
);
374 static HRESULT WINAPI
fw_app_put_RemoteAddresses(
375 INetFwAuthorizedApplication
*iface
,
378 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
380 FIXME("%p, %s\n", This
, debugstr_w(remoteAddrs
));
384 static HRESULT WINAPI
fw_app_get_Enabled(
385 INetFwAuthorizedApplication
*iface
,
386 VARIANT_BOOL
*enabled
)
388 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
390 FIXME("%p, %p\n", This
, enabled
);
392 *enabled
= VARIANT_FALSE
;
396 static HRESULT WINAPI
fw_app_put_Enabled(
397 INetFwAuthorizedApplication
*iface
,
398 VARIANT_BOOL enabled
)
400 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
402 FIXME("%p, %d\n", This
, enabled
);
406 static const struct INetFwAuthorizedApplicationVtbl fw_app_vtbl
=
408 fw_app_QueryInterface
,
411 fw_app_GetTypeInfoCount
,
413 fw_app_GetIDsOfNames
,
417 fw_app_get_ProcessImageFileName
,
418 fw_app_put_ProcessImageFileName
,
419 fw_app_get_IpVersion
,
420 fw_app_put_IpVersion
,
423 fw_app_get_RemoteAddresses
,
424 fw_app_put_RemoteAddresses
,
429 HRESULT
NetFwAuthorizedApplication_create( IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
433 TRACE("(%p,%p)\n", pUnkOuter
, ppObj
);
435 fa
= HeapAlloc( GetProcessHeap(), 0, sizeof(*fa
) );
436 if (!fa
) return E_OUTOFMEMORY
;
438 fa
->INetFwAuthorizedApplication_iface
.lpVtbl
= &fw_app_vtbl
;
442 *ppObj
= &fa
->INetFwAuthorizedApplication_iface
;
444 TRACE("returning iface %p\n", *ppObj
);
447 typedef struct fw_apps
449 INetFwAuthorizedApplications INetFwAuthorizedApplications_iface
;
453 static inline fw_apps
*impl_from_INetFwAuthorizedApplications( INetFwAuthorizedApplications
*iface
)
455 return CONTAINING_RECORD(iface
, fw_apps
, INetFwAuthorizedApplications_iface
);
458 static ULONG WINAPI
fw_apps_AddRef(
459 INetFwAuthorizedApplications
*iface
)
461 fw_apps
*fw_apps
= impl_from_INetFwAuthorizedApplications( iface
);
462 return InterlockedIncrement( &fw_apps
->refs
);
465 static ULONG WINAPI
fw_apps_Release(
466 INetFwAuthorizedApplications
*iface
)
468 fw_apps
*fw_apps
= impl_from_INetFwAuthorizedApplications( iface
);
469 LONG refs
= InterlockedDecrement( &fw_apps
->refs
);
472 TRACE("destroying %p\n", fw_apps
);
473 HeapFree( GetProcessHeap(), 0, fw_apps
);
478 static HRESULT WINAPI
fw_apps_QueryInterface(
479 INetFwAuthorizedApplications
*iface
,
483 fw_apps
*This
= impl_from_INetFwAuthorizedApplications( iface
);
485 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppvObject
);
487 if ( IsEqualGUID( riid
, &IID_INetFwAuthorizedApplications
) ||
488 IsEqualGUID( riid
, &IID_IDispatch
) ||
489 IsEqualGUID( riid
, &IID_IUnknown
) )
495 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
496 return E_NOINTERFACE
;
498 INetFwAuthorizedApplications_AddRef( iface
);
502 static HRESULT WINAPI
fw_apps_GetTypeInfoCount(
503 INetFwAuthorizedApplications
*iface
,
506 fw_apps
*This
= impl_from_INetFwAuthorizedApplications( iface
);
508 FIXME("%p %p\n", This
, pctinfo
);
512 static HRESULT WINAPI
fw_apps_GetTypeInfo(
513 INetFwAuthorizedApplications
*iface
,
516 ITypeInfo
**ppTInfo
)
518 fw_apps
*This
= impl_from_INetFwAuthorizedApplications( iface
);
520 TRACE("%p %u %u %p\n", This
, iTInfo
, lcid
, ppTInfo
);
521 return get_typeinfo( INetFwAuthorizedApplications_tid
, ppTInfo
);
524 static HRESULT WINAPI
fw_apps_GetIDsOfNames(
525 INetFwAuthorizedApplications
*iface
,
532 fw_apps
*This
= impl_from_INetFwAuthorizedApplications( iface
);
536 TRACE("%p %s %p %u %u %p\n", This
, debugstr_guid(riid
), rgszNames
, cNames
, lcid
, rgDispId
);
538 hr
= get_typeinfo( INetFwAuthorizedApplications_tid
, &typeinfo
);
541 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, rgszNames
, cNames
, rgDispId
);
542 ITypeInfo_Release( typeinfo
);
547 static HRESULT WINAPI
fw_apps_Invoke(
548 INetFwAuthorizedApplications
*iface
,
553 DISPPARAMS
*pDispParams
,
555 EXCEPINFO
*pExcepInfo
,
558 fw_apps
*This
= impl_from_INetFwAuthorizedApplications( iface
);
562 TRACE("%p %d %s %d %d %p %p %p %p\n", This
, dispIdMember
, debugstr_guid(riid
),
563 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
565 hr
= get_typeinfo( INetFwAuthorizedApplications_tid
, &typeinfo
);
568 hr
= ITypeInfo_Invoke( typeinfo
, &This
->INetFwAuthorizedApplications_iface
, dispIdMember
,
569 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
570 ITypeInfo_Release( typeinfo
);
575 static HRESULT WINAPI
fw_apps_get_Count(
576 INetFwAuthorizedApplications
*iface
,
579 fw_apps
*This
= impl_from_INetFwAuthorizedApplications( iface
);
581 FIXME("%p, %p\n", This
, count
);
585 static HRESULT WINAPI
fw_apps_Add(
586 INetFwAuthorizedApplications
*iface
,
587 INetFwAuthorizedApplication
*app
)
589 fw_apps
*This
= impl_from_INetFwAuthorizedApplications( iface
);
591 FIXME("%p, %p\n", This
, app
);
595 static HRESULT WINAPI
fw_apps_Remove(
596 INetFwAuthorizedApplications
*iface
,
599 fw_apps
*This
= impl_from_INetFwAuthorizedApplications( iface
);
601 FIXME("%p, %s\n", This
, debugstr_w(imageFileName
));
605 static HRESULT WINAPI
fw_apps_Item(
606 INetFwAuthorizedApplications
*iface
,
608 INetFwAuthorizedApplication
**app
)
610 fw_apps
*This
= impl_from_INetFwAuthorizedApplications( iface
);
612 TRACE("%p, %s, %p\n", This
, debugstr_w(imageFileName
), app
);
613 return NetFwAuthorizedApplication_create( NULL
, (void **)app
);
616 static HRESULT WINAPI
fw_apps_get__NewEnum(
617 INetFwAuthorizedApplications
*iface
,
620 fw_apps
*This
= impl_from_INetFwAuthorizedApplications( iface
);
622 FIXME("%p, %p\n", This
, newEnum
);
626 static const struct INetFwAuthorizedApplicationsVtbl fw_apps_vtbl
=
628 fw_apps_QueryInterface
,
631 fw_apps_GetTypeInfoCount
,
633 fw_apps_GetIDsOfNames
,
642 HRESULT
NetFwAuthorizedApplications_create( IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
646 TRACE("(%p,%p)\n", pUnkOuter
, ppObj
);
648 fa
= HeapAlloc( GetProcessHeap(), 0, sizeof(*fa
) );
649 if (!fa
) return E_OUTOFMEMORY
;
651 fa
->INetFwAuthorizedApplications_iface
.lpVtbl
= &fw_apps_vtbl
;
654 *ppObj
= &fa
->INetFwAuthorizedApplications_iface
;
656 TRACE("returning iface %p\n", *ppObj
);