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 "hnetcfg_private.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(hnetcfg
);
38 INetFwAuthorizedApplication INetFwAuthorizedApplication_iface
;
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
);
62 TRACE("destroying %p\n", fw_app
);
63 SysFreeString( fw_app
->filename
);
69 static HRESULT WINAPI
fw_app_QueryInterface(
70 INetFwAuthorizedApplication
*iface
,
74 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
76 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppvObject
);
78 if ( IsEqualGUID( riid
, &IID_INetFwAuthorizedApplication
) ||
79 IsEqualGUID( riid
, &IID_IDispatch
) ||
80 IsEqualGUID( riid
, &IID_IUnknown
) )
86 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
89 INetFwAuthorizedApplication_AddRef( iface
);
93 static HRESULT WINAPI
fw_app_GetTypeInfoCount(
94 INetFwAuthorizedApplication
*iface
,
97 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
99 TRACE("%p %p\n", This
, pctinfo
);
104 static ITypeLib
*typelib
;
105 static ITypeInfo
*typeinfo
[last_tid
];
107 static REFIID tid_id
[] =
109 &IID_INetFwAuthorizedApplication
,
110 &IID_INetFwAuthorizedApplications
,
113 &IID_INetFwOpenPorts
,
118 &IID_IStaticPortMappingCollection
,
119 &IID_IStaticPortMapping
,
122 HRESULT
get_typeinfo( enum type_id tid
, ITypeInfo
**ret
)
130 hr
= LoadRegTypeLib( &LIBID_NetFwPublicTypeLib
, 1, 0, LOCALE_SYSTEM_DEFAULT
, &lib
);
133 ERR("LoadRegTypeLib failed: %08lx\n", hr
);
136 if (InterlockedCompareExchangePointer( (void **)&typelib
, lib
, NULL
))
137 ITypeLib_Release( lib
);
143 hr
= ITypeLib_GetTypeInfoOfGuid( typelib
, tid_id
[tid
], &info
);
146 ERR("GetTypeInfoOfGuid(%s) failed: %08lx\n", debugstr_guid(tid_id
[tid
]), hr
);
149 if (InterlockedCompareExchangePointer( (void **)(typeinfo
+ tid
), info
, NULL
))
150 ITypeInfo_Release( info
);
152 *ret
= typeinfo
[tid
];
153 ITypeInfo_AddRef(typeinfo
[tid
]);
157 void release_typelib(void)
161 for (i
= 0; i
< ARRAY_SIZE(typeinfo
); i
++)
163 ITypeInfo_Release(typeinfo
[i
]);
166 ITypeLib_Release(typelib
);
169 static HRESULT WINAPI
fw_app_GetTypeInfo(
170 INetFwAuthorizedApplication
*iface
,
173 ITypeInfo
**ppTInfo
)
175 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
177 TRACE("%p %u %lu %p\n", This
, iTInfo
, lcid
, ppTInfo
);
178 return get_typeinfo( INetFwAuthorizedApplication_tid
, ppTInfo
);
181 static HRESULT WINAPI
fw_app_GetIDsOfNames(
182 INetFwAuthorizedApplication
*iface
,
189 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
193 TRACE("%p %s %p %u %lu %p\n", This
, debugstr_guid(riid
), rgszNames
, cNames
, lcid
, rgDispId
);
195 hr
= get_typeinfo( INetFwAuthorizedApplication_tid
, &typeinfo
);
198 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, rgszNames
, cNames
, rgDispId
);
199 ITypeInfo_Release( typeinfo
);
204 static HRESULT WINAPI
fw_app_Invoke(
205 INetFwAuthorizedApplication
*iface
,
210 DISPPARAMS
*pDispParams
,
212 EXCEPINFO
*pExcepInfo
,
215 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
219 TRACE("%p %ld %s %ld %d %p %p %p %p\n", This
, dispIdMember
, debugstr_guid(riid
),
220 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
222 hr
= get_typeinfo( INetFwAuthorizedApplication_tid
, &typeinfo
);
225 hr
= ITypeInfo_Invoke( typeinfo
, &This
->INetFwAuthorizedApplication_iface
, dispIdMember
,
226 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
227 ITypeInfo_Release( typeinfo
);
232 static HRESULT WINAPI
fw_app_get_Name(
233 INetFwAuthorizedApplication
*iface
,
236 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
238 FIXME("%p, %p\n", This
, name
);
242 static HRESULT WINAPI
fw_app_put_Name(
243 INetFwAuthorizedApplication
*iface
,
246 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
248 FIXME("%p, %s\n", This
, debugstr_w(name
));
252 static HRESULT WINAPI
fw_app_get_ProcessImageFileName(
253 INetFwAuthorizedApplication
*iface
,
254 BSTR
*imageFileName
)
256 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
258 FIXME("%p, %p\n", This
, imageFileName
);
263 *imageFileName
= SysAllocString( This
->filename
);
264 return *imageFileName
|| !This
->filename
? S_OK
: E_OUTOFMEMORY
;
267 static HRESULT WINAPI
fw_app_put_ProcessImageFileName(
268 INetFwAuthorizedApplication
*iface
, BSTR image
)
270 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
271 UNIVERSAL_NAME_INFOW
*info
;
273 WCHAR
*path
, *new_path
;
276 FIXME("%p, %s\n", This
, debugstr_w(image
));
278 if (!image
|| !image
[0])
282 res
= WNetGetUniversalNameW(image
, UNIVERSAL_NAME_INFO_LEVEL
, NULL
, &sz
);
283 if (res
== WN_MORE_DATA
)
285 if (!(path
= malloc(sz
)))
286 return E_OUTOFMEMORY
;
288 info
= (UNIVERSAL_NAME_INFOW
*)&path
;
289 res
= WNetGetUniversalNameW(image
, UNIVERSAL_NAME_INFO_LEVEL
, &info
, &sz
);
292 SysFreeString(This
->filename
);
293 This
->filename
= SysAllocString(info
->lpUniversalName
);
296 return HRESULT_FROM_WIN32(res
);
299 sz
= GetFullPathNameW(image
, 0, NULL
, NULL
);
300 if (!(path
= malloc(++sz
* sizeof(WCHAR
))))
301 return E_OUTOFMEMORY
;
302 GetFullPathNameW(image
, sz
, path
, NULL
);
304 longsz
= GetLongPathNameW(path
, path
, sz
);
307 if (!(new_path
= realloc(path
, longsz
* sizeof(WCHAR
))))
310 return E_OUTOFMEMORY
;
313 GetLongPathNameW(path
, path
, longsz
);
316 SysFreeString( This
->filename
);
317 This
->filename
= SysAllocString(path
);
319 return This
->filename
? S_OK
: E_OUTOFMEMORY
;
322 static HRESULT WINAPI
fw_app_get_IpVersion(
323 INetFwAuthorizedApplication
*iface
,
324 NET_FW_IP_VERSION
*ipVersion
)
326 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
328 TRACE("%p, %p\n", This
, ipVersion
);
332 *ipVersion
= NET_FW_IP_VERSION_ANY
;
336 static HRESULT WINAPI
fw_app_put_IpVersion(
337 INetFwAuthorizedApplication
*iface
,
338 NET_FW_IP_VERSION ipVersion
)
340 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
342 TRACE("%p, %u\n", This
, ipVersion
);
346 static HRESULT WINAPI
fw_app_get_Scope(
347 INetFwAuthorizedApplication
*iface
,
348 NET_FW_SCOPE
*scope
)
350 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
352 FIXME("%p, %p\n", This
, scope
);
356 static HRESULT WINAPI
fw_app_put_Scope(
357 INetFwAuthorizedApplication
*iface
,
360 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
362 FIXME("%p, %u\n", This
, scope
);
366 static HRESULT WINAPI
fw_app_get_RemoteAddresses(
367 INetFwAuthorizedApplication
*iface
,
370 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
372 FIXME("%p, %p\n", This
, remoteAddrs
);
376 static HRESULT WINAPI
fw_app_put_RemoteAddresses(
377 INetFwAuthorizedApplication
*iface
,
380 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
382 FIXME("%p, %s\n", This
, debugstr_w(remoteAddrs
));
386 static HRESULT WINAPI
fw_app_get_Enabled(
387 INetFwAuthorizedApplication
*iface
,
388 VARIANT_BOOL
*enabled
)
390 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
392 FIXME("%p, %p\n", This
, enabled
);
394 *enabled
= VARIANT_FALSE
;
398 static HRESULT WINAPI
fw_app_put_Enabled(
399 INetFwAuthorizedApplication
*iface
,
400 VARIANT_BOOL enabled
)
402 fw_app
*This
= impl_from_INetFwAuthorizedApplication( iface
);
404 FIXME("%p, %d\n", This
, enabled
);
408 static const struct INetFwAuthorizedApplicationVtbl fw_app_vtbl
=
410 fw_app_QueryInterface
,
413 fw_app_GetTypeInfoCount
,
415 fw_app_GetIDsOfNames
,
419 fw_app_get_ProcessImageFileName
,
420 fw_app_put_ProcessImageFileName
,
421 fw_app_get_IpVersion
,
422 fw_app_put_IpVersion
,
425 fw_app_get_RemoteAddresses
,
426 fw_app_put_RemoteAddresses
,
431 HRESULT
NetFwAuthorizedApplication_create( IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
435 TRACE("(%p,%p)\n", pUnkOuter
, ppObj
);
437 fa
= malloc( sizeof(*fa
) );
438 if (!fa
) return E_OUTOFMEMORY
;
440 fa
->INetFwAuthorizedApplication_iface
.lpVtbl
= &fw_app_vtbl
;
444 *ppObj
= &fa
->INetFwAuthorizedApplication_iface
;
446 TRACE("returning iface %p\n", *ppObj
);
449 typedef struct fw_apps
451 INetFwAuthorizedApplications INetFwAuthorizedApplications_iface
;
455 static inline fw_apps
*impl_from_INetFwAuthorizedApplications( INetFwAuthorizedApplications
*iface
)
457 return CONTAINING_RECORD(iface
, fw_apps
, INetFwAuthorizedApplications_iface
);
460 static ULONG WINAPI
fw_apps_AddRef(
461 INetFwAuthorizedApplications
*iface
)
463 fw_apps
*fw_apps
= impl_from_INetFwAuthorizedApplications( iface
);
464 return InterlockedIncrement( &fw_apps
->refs
);
467 static ULONG WINAPI
fw_apps_Release(
468 INetFwAuthorizedApplications
*iface
)
470 fw_apps
*fw_apps
= impl_from_INetFwAuthorizedApplications( iface
);
471 LONG refs
= InterlockedDecrement( &fw_apps
->refs
);
474 TRACE("destroying %p\n", fw_apps
);
480 static HRESULT WINAPI
fw_apps_QueryInterface(
481 INetFwAuthorizedApplications
*iface
,
485 fw_apps
*This
= impl_from_INetFwAuthorizedApplications( iface
);
487 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppvObject
);
489 if ( IsEqualGUID( riid
, &IID_INetFwAuthorizedApplications
) ||
490 IsEqualGUID( riid
, &IID_IDispatch
) ||
491 IsEqualGUID( riid
, &IID_IUnknown
) )
497 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
498 return E_NOINTERFACE
;
500 INetFwAuthorizedApplications_AddRef( iface
);
504 static HRESULT WINAPI
fw_apps_GetTypeInfoCount(
505 INetFwAuthorizedApplications
*iface
,
508 fw_apps
*This
= impl_from_INetFwAuthorizedApplications( iface
);
510 FIXME("%p %p\n", This
, pctinfo
);
514 static HRESULT WINAPI
fw_apps_GetTypeInfo(
515 INetFwAuthorizedApplications
*iface
,
518 ITypeInfo
**ppTInfo
)
520 fw_apps
*This
= impl_from_INetFwAuthorizedApplications( iface
);
522 TRACE("%p %u %lu %p\n", This
, iTInfo
, lcid
, ppTInfo
);
523 return get_typeinfo( INetFwAuthorizedApplications_tid
, ppTInfo
);
526 static HRESULT WINAPI
fw_apps_GetIDsOfNames(
527 INetFwAuthorizedApplications
*iface
,
534 fw_apps
*This
= impl_from_INetFwAuthorizedApplications( iface
);
538 TRACE("%p %s %p %u %lu %p\n", This
, debugstr_guid(riid
), rgszNames
, cNames
, lcid
, rgDispId
);
540 hr
= get_typeinfo( INetFwAuthorizedApplications_tid
, &typeinfo
);
543 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, rgszNames
, cNames
, rgDispId
);
544 ITypeInfo_Release( typeinfo
);
549 static HRESULT WINAPI
fw_apps_Invoke(
550 INetFwAuthorizedApplications
*iface
,
555 DISPPARAMS
*pDispParams
,
557 EXCEPINFO
*pExcepInfo
,
560 fw_apps
*This
= impl_from_INetFwAuthorizedApplications( iface
);
564 TRACE("%p %ld %s %ld %d %p %p %p %p\n", This
, dispIdMember
, debugstr_guid(riid
),
565 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
567 hr
= get_typeinfo( INetFwAuthorizedApplications_tid
, &typeinfo
);
570 hr
= ITypeInfo_Invoke( typeinfo
, &This
->INetFwAuthorizedApplications_iface
, dispIdMember
,
571 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
572 ITypeInfo_Release( typeinfo
);
577 static HRESULT WINAPI
fw_apps_get_Count(
578 INetFwAuthorizedApplications
*iface
,
581 fw_apps
*This
= impl_from_INetFwAuthorizedApplications( iface
);
583 FIXME("%p, %p\n", This
, count
);
587 static HRESULT WINAPI
fw_apps_Add(
588 INetFwAuthorizedApplications
*iface
,
589 INetFwAuthorizedApplication
*app
)
591 fw_apps
*This
= impl_from_INetFwAuthorizedApplications( iface
);
593 FIXME("%p, %p\n", This
, app
);
597 static HRESULT WINAPI
fw_apps_Remove(
598 INetFwAuthorizedApplications
*iface
,
601 fw_apps
*This
= impl_from_INetFwAuthorizedApplications( iface
);
603 FIXME("%p, %s\n", This
, debugstr_w(imageFileName
));
607 static HRESULT WINAPI
fw_apps_Item(
608 INetFwAuthorizedApplications
*iface
,
610 INetFwAuthorizedApplication
**app
)
612 fw_apps
*This
= impl_from_INetFwAuthorizedApplications( iface
);
614 TRACE("%p, %s, %p\n", This
, debugstr_w(imageFileName
), app
);
615 return NetFwAuthorizedApplication_create( NULL
, (void **)app
);
618 static HRESULT WINAPI
fw_apps_get__NewEnum(
619 INetFwAuthorizedApplications
*iface
,
622 fw_apps
*This
= impl_from_INetFwAuthorizedApplications( iface
);
624 FIXME("%p, %p\n", This
, newEnum
);
628 static const struct INetFwAuthorizedApplicationsVtbl fw_apps_vtbl
=
630 fw_apps_QueryInterface
,
633 fw_apps_GetTypeInfoCount
,
635 fw_apps_GetIDsOfNames
,
644 HRESULT
NetFwAuthorizedApplications_create( IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
648 TRACE("(%p,%p)\n", pUnkOuter
, ppObj
);
650 fa
= malloc( sizeof(*fa
) );
651 if (!fa
) return E_OUTOFMEMORY
;
653 fa
->INetFwAuthorizedApplications_iface
.lpVtbl
= &fw_apps_vtbl
;
656 *ppObj
= &fa
->INetFwAuthorizedApplications_iface
;
658 TRACE("returning iface %p\n", *ppObj
);