2 * Internet Security and Zone Manager
4 * Copyright (c) 2004 Huw D M Davies
5 * Copyright 2004 Jacek Caban
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #include "wine/debug.h"
32 #include "wine/unicode.h"
34 #include "urlmon_main.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
38 /***********************************************************************
39 * InternetSecurityManager implementation
43 const IInternetSecurityManagerVtbl* lpInternetSecurityManagerVtbl;
47 IInternetSecurityMgrSite *mgrsite;
48 IInternetSecurityManager *custom_manager;
51 #define SECMGR_THIS(iface) DEFINE_THIS(SecManagerImpl, InternetSecurityManager, iface)
53 static HRESULT WINAPI SecManagerImpl_QueryInterface(IInternetSecurityManager* iface,REFIID riid,void** ppvObject)
55 SecManagerImpl *This = SECMGR_THIS(iface);
57 TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppvObject);
59 /* Perform a sanity check on the parameters.*/
60 if ( (This==0) || (ppvObject==0) )
63 /* Initialize the return parameter */
66 /* Compare the riid with the interface IDs implemented by this object.*/
67 if (IsEqualIID(&IID_IUnknown, riid) ||
68 IsEqualIID(&IID_IInternetSecurityManager, riid))
71 /* Check that we obtained an interface.*/
73 WARN("not supported interface %s\n", debugstr_guid(riid));
77 /* Query Interface always increases the reference count by one when it is successful */
78 IInternetSecurityManager_AddRef(iface);
83 static ULONG WINAPI SecManagerImpl_AddRef(IInternetSecurityManager* iface)
85 SecManagerImpl *This = SECMGR_THIS(iface);
86 ULONG refCount = InterlockedIncrement(&This->ref);
88 TRACE("(%p) ref=%lu\n", This, refCount);
93 static ULONG WINAPI SecManagerImpl_Release(IInternetSecurityManager* iface)
95 SecManagerImpl *This = SECMGR_THIS(iface);
96 ULONG refCount = InterlockedDecrement(&This->ref);
98 TRACE("(%p) ref=%lu\n", This, refCount);
100 /* destroy the object if there's no more reference on it */
103 IInternetSecurityMgrSite_Release(This->mgrsite);
104 if(This->custom_manager)
105 IInternetSecurityManager_Release(This->custom_manager);
107 HeapFree(GetProcessHeap(),0,This);
109 URLMON_UnlockModule();
115 static HRESULT WINAPI SecManagerImpl_SetSecuritySite(IInternetSecurityManager *iface,
116 IInternetSecurityMgrSite *pSite)
118 SecManagerImpl *This = SECMGR_THIS(iface);
120 TRACE("(%p)->(%p)\n", This, pSite);
123 IInternetSecurityMgrSite_Release(This->mgrsite);
125 if(This->custom_manager) {
126 IInternetSecurityManager_Release(This->custom_manager);
127 This->custom_manager = NULL;
130 This->mgrsite = pSite;
133 IServiceProvider *servprov;
136 IInternetSecurityMgrSite_AddRef(pSite);
138 hres = IInternetSecurityMgrSite_QueryInterface(pSite, &IID_IServiceProvider,
140 if(SUCCEEDED(hres)) {
141 IServiceProvider_QueryService(servprov, &SID_SInternetSecurityManager,
142 &IID_IInternetSecurityManager, (void**)&This->custom_manager);
143 IServiceProvider_Release(servprov);
150 static HRESULT WINAPI SecManagerImpl_GetSecuritySite(IInternetSecurityManager *iface,
151 IInternetSecurityMgrSite **ppSite)
153 SecManagerImpl *This = SECMGR_THIS(iface);
155 TRACE("(%p)->(%p)\n", This, ppSite);
161 IInternetSecurityMgrSite_AddRef(This->mgrsite);
163 *ppSite = This->mgrsite;
167 static HRESULT WINAPI SecManagerImpl_MapUrlToZone(IInternetSecurityManager *iface,
168 LPCWSTR pwszUrl, DWORD *pdwZone,
171 SecManagerImpl *This = SECMGR_THIS(iface);
174 TRACE("(%p)->(%s %p %08lx)\n", iface, debugstr_w(pwszUrl), pdwZone, dwFlags);
176 if(This->custom_manager) {
177 hres = IInternetSecurityManager_MapUrlToZone(This->custom_manager,
178 pwszUrl, pdwZone, dwFlags);
179 if(hres != INET_E_DEFAULT_ACTION)
183 FIXME("Default action is not implemented\n");
187 static HRESULT WINAPI SecManagerImpl_GetSecurityId(IInternetSecurityManager *iface,
189 BYTE *pbSecurityId, DWORD *pcbSecurityId,
190 DWORD_PTR dwReserved)
192 SecManagerImpl *This = SECMGR_THIS(iface);
195 TRACE("(%p)->(%s %p %p %08lx)\n", iface, debugstr_w(pwszUrl), pbSecurityId, pcbSecurityId,
198 if(This->custom_manager) {
199 hres = IInternetSecurityManager_GetSecurityId(This->custom_manager,
200 pwszUrl, pbSecurityId, pcbSecurityId, dwReserved);
201 if(hres != INET_E_DEFAULT_ACTION)
205 FIXME("Default action is not implemented\n");
210 static HRESULT WINAPI SecManagerImpl_ProcessUrlAction(IInternetSecurityManager *iface,
211 LPCWSTR pwszUrl, DWORD dwAction,
212 BYTE *pPolicy, DWORD cbPolicy,
213 BYTE *pContext, DWORD cbContext,
214 DWORD dwFlags, DWORD dwReserved)
216 SecManagerImpl *This = SECMGR_THIS(iface);
219 TRACE("(%p)->(%s %08lx %p %08lx %p %08lx %08lx %08lx)\n", iface, debugstr_w(pwszUrl), dwAction,
220 pPolicy, cbPolicy, pContext, cbContext, dwFlags, dwReserved);
222 if(This->custom_manager) {
223 hres = IInternetSecurityManager_ProcessUrlAction(This->custom_manager, pwszUrl, dwAction,
224 pPolicy, cbPolicy, pContext, cbContext, dwFlags, dwReserved);
225 if(hres != INET_E_DEFAULT_ACTION)
229 FIXME("Default action is not implemented\n");
234 static HRESULT WINAPI SecManagerImpl_QueryCustomPolicy(IInternetSecurityManager *iface,
235 LPCWSTR pwszUrl, REFGUID guidKey,
236 BYTE **ppPolicy, DWORD *pcbPolicy,
237 BYTE *pContext, DWORD cbContext,
240 SecManagerImpl *This = SECMGR_THIS(iface);
243 TRACE("(%p)->(%s %s %p %p %p %08lx %08lx )\n", iface, debugstr_w(pwszUrl), debugstr_guid(guidKey),
244 ppPolicy, pcbPolicy, pContext, cbContext, dwReserved);
246 if(This->custom_manager) {
247 hres = IInternetSecurityManager_QueryCustomPolicy(This->custom_manager, pwszUrl, guidKey,
248 ppPolicy, pcbPolicy, pContext, cbContext, dwReserved);
249 if(hres != INET_E_DEFAULT_ACTION)
253 FIXME("Default action is not implemented\n");
257 static HRESULT WINAPI SecManagerImpl_SetZoneMapping(IInternetSecurityManager *iface,
258 DWORD dwZone, LPCWSTR pwszPattern, DWORD dwFlags)
260 SecManagerImpl *This = SECMGR_THIS(iface);
263 TRACE("(%p)->(%08lx %s %08lx)\n", iface, dwZone, debugstr_w(pwszPattern),dwFlags);
265 if(This->custom_manager) {
266 hres = IInternetSecurityManager_SetZoneMapping(This->custom_manager, dwZone,
267 pwszPattern, dwFlags);
268 if(hres != INET_E_DEFAULT_ACTION)
272 FIXME("Default action is not implemented\n");
276 static HRESULT WINAPI SecManagerImpl_GetZoneMappings(IInternetSecurityManager *iface,
277 DWORD dwZone, IEnumString **ppenumString, DWORD dwFlags)
279 SecManagerImpl *This = SECMGR_THIS(iface);
282 TRACE("(%p)->(%08lx %p %08lx)\n", iface, dwZone, ppenumString,dwFlags);
284 if(This->custom_manager) {
285 hres = IInternetSecurityManager_GetZoneMappings(This->custom_manager, dwZone,
286 ppenumString, dwFlags);
287 if(hres != INET_E_DEFAULT_ACTION)
291 FIXME("Default action is not implemented\n");
295 static const IInternetSecurityManagerVtbl VT_SecManagerImpl =
297 SecManagerImpl_QueryInterface,
298 SecManagerImpl_AddRef,
299 SecManagerImpl_Release,
300 SecManagerImpl_SetSecuritySite,
301 SecManagerImpl_GetSecuritySite,
302 SecManagerImpl_MapUrlToZone,
303 SecManagerImpl_GetSecurityId,
304 SecManagerImpl_ProcessUrlAction,
305 SecManagerImpl_QueryCustomPolicy,
306 SecManagerImpl_SetZoneMapping,
307 SecManagerImpl_GetZoneMappings
310 HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
312 SecManagerImpl *This;
314 TRACE("(%p,%p)\n",pUnkOuter,ppobj);
315 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
317 /* Initialize the virtual function table. */
318 This->lpInternetSecurityManagerVtbl = &VT_SecManagerImpl;
321 This->mgrsite = NULL;
322 This->custom_manager = NULL;
331 /***********************************************************************
332 * InternetZoneManager implementation
336 const IInternetZoneManagerVtbl* lpVtbl;
340 /********************************************************************
341 * IInternetZoneManager_QueryInterface
343 static HRESULT WINAPI ZoneMgrImpl_QueryInterface(IInternetZoneManager* iface, REFIID riid, void** ppvObject)
345 ZoneMgrImpl* This = (ZoneMgrImpl*)iface;
347 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppvObject);
349 if(!This || !ppvObject)
352 if(!IsEqualIID(&IID_IUnknown, riid) && !IsEqualIID(&IID_IInternetZoneManager, riid)) {
353 FIXME("Unknown interface: %s\n", debugstr_guid(riid));
355 return E_NOINTERFACE;
359 IInternetZoneManager_AddRef(iface);
364 /********************************************************************
365 * IInternetZoneManager_AddRef
367 static ULONG WINAPI ZoneMgrImpl_AddRef(IInternetZoneManager* iface)
369 ZoneMgrImpl* This = (ZoneMgrImpl*)iface;
370 ULONG refCount = InterlockedIncrement(&This->ref);
372 TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
377 /********************************************************************
378 * IInternetZoneManager_Release
380 static ULONG WINAPI ZoneMgrImpl_Release(IInternetZoneManager* iface)
382 ZoneMgrImpl* This = (ZoneMgrImpl*)iface;
383 ULONG refCount = InterlockedDecrement(&This->ref);
385 TRACE("(%p)->(ref before=%lu)\n",This, refCount + 1);
388 HeapFree(GetProcessHeap(), 0, This);
389 URLMON_UnlockModule();
395 /********************************************************************
396 * IInternetZoneManager_GetZoneAttributes
398 static HRESULT WINAPI ZoneMgrImpl_GetZoneAttributes(IInternetZoneManager* iface,
400 ZONEATTRIBUTES* pZoneAttributes)
402 FIXME("(%p)->(%ld %p) stub\n", iface, dwZone, pZoneAttributes);
406 /********************************************************************
407 * IInternetZoneManager_SetZoneAttributes
409 static HRESULT WINAPI ZoneMgrImpl_SetZoneAttributes(IInternetZoneManager* iface,
411 ZONEATTRIBUTES* pZoneAttributes)
413 FIXME("(%p)->(%08lx %p) stub\n", iface, dwZone, pZoneAttributes);
417 /********************************************************************
418 * IInternetZoneManager_GetZoneCustomPolicy
420 static HRESULT WINAPI ZoneMgrImpl_GetZoneCustomPolicy(IInternetZoneManager* iface,
425 URLZONEREG ulrZoneReg)
427 FIXME("(%p)->(%08lx %s %p %p %08x) stub\n", iface, dwZone, debugstr_guid(guidKey),
428 ppPolicy, pcbPolicy, ulrZoneReg);
432 /********************************************************************
433 * IInternetZoneManager_SetZoneCustomPolicy
435 static HRESULT WINAPI ZoneMgrImpl_SetZoneCustomPolicy(IInternetZoneManager* iface,
440 URLZONEREG ulrZoneReg)
442 FIXME("(%p)->(%08lx %s %p %08lx %08x) stub\n", iface, dwZone, debugstr_guid(guidKey),
443 ppPolicy, cbPolicy, ulrZoneReg);
447 /********************************************************************
448 * IInternetZoneManager_GetZoneActionPolicy
450 static HRESULT WINAPI ZoneMgrImpl_GetZoneActionPolicy(IInternetZoneManager* iface,
455 URLZONEREG urlZoneReg)
457 FIXME("(%p)->(%08lx %08lx %p %08lx %08x) stub\n", iface, dwZone, dwAction, pPolicy,
458 cbPolicy, urlZoneReg);
462 /********************************************************************
463 * IInternetZoneManager_SetZoneActionPolicy
465 static HRESULT WINAPI ZoneMgrImpl_SetZoneActionPolicy(IInternetZoneManager* iface,
470 URLZONEREG urlZoneReg)
472 FIXME("(%p)->(%08lx %08lx %p %08lx %08x) stub\n", iface, dwZone, dwAction, pPolicy,
473 cbPolicy, urlZoneReg);
477 /********************************************************************
478 * IInternetZoneManager_PromptAction
480 static HRESULT WINAPI ZoneMgrImpl_PromptAction(IInternetZoneManager* iface,
487 FIXME("%p %08lx %p %s %s %08lx\n", iface, dwAction, hwndParent,
488 debugstr_w(pwszUrl), debugstr_w(pwszText), dwPromptFlags );
492 /********************************************************************
493 * IInternetZoneManager_LogAction
495 static HRESULT WINAPI ZoneMgrImpl_LogAction(IInternetZoneManager* iface,
501 FIXME("(%p)->(%08lx %s %s %08lx) stub\n", iface, dwAction, debugstr_w(pwszUrl),
502 debugstr_w(pwszText), dwLogFlags);
506 /********************************************************************
507 * IInternetZoneManager_CreateZoneEnumerator
509 static HRESULT WINAPI ZoneMgrImpl_CreateZoneEnumerator(IInternetZoneManager* iface,
514 FIXME("(%p)->(%p %p %08lx) stub\n", iface, pdwEnum, pdwCount, dwFlags);
518 /********************************************************************
519 * IInternetZoneManager_GetZoneAt
521 static HRESULT WINAPI ZoneMgrImpl_GetZoneAt(IInternetZoneManager* iface,
526 FIXME("(%p)->(%08lx %08lx %p) stub\n", iface, dwEnum, dwIndex, pdwZone);
530 /********************************************************************
531 * IInternetZoneManager_DestroyZoneEnumerator
533 static HRESULT WINAPI ZoneMgrImpl_DestroyZoneEnumerator(IInternetZoneManager* iface,
536 FIXME("(%p)->(%08lx) stub\n", iface, dwEnum);
540 /********************************************************************
541 * IInternetZoneManager_CopyTemplatePoliciesToZone
543 static HRESULT WINAPI ZoneMgrImpl_CopyTemplatePoliciesToZone(IInternetZoneManager* iface,
548 FIXME("(%p)->(%08lx %08lx %08lx) stub\n", iface, dwTemplate, dwZone, dwReserved);
552 /********************************************************************
553 * IInternetZoneManager_Construct
555 static const IInternetZoneManagerVtbl ZoneMgrImplVtbl = {
556 ZoneMgrImpl_QueryInterface,
559 ZoneMgrImpl_GetZoneAttributes,
560 ZoneMgrImpl_SetZoneAttributes,
561 ZoneMgrImpl_GetZoneCustomPolicy,
562 ZoneMgrImpl_SetZoneCustomPolicy,
563 ZoneMgrImpl_GetZoneActionPolicy,
564 ZoneMgrImpl_SetZoneActionPolicy,
565 ZoneMgrImpl_PromptAction,
566 ZoneMgrImpl_LogAction,
567 ZoneMgrImpl_CreateZoneEnumerator,
568 ZoneMgrImpl_GetZoneAt,
569 ZoneMgrImpl_DestroyZoneEnumerator,
570 ZoneMgrImpl_CopyTemplatePoliciesToZone,
573 HRESULT ZoneMgrImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
575 ZoneMgrImpl* ret = HeapAlloc(GetProcessHeap(), 0, sizeof(ZoneMgrImpl));
577 TRACE("(%p %p)\n", pUnkOuter, ppobj);
578 ret->lpVtbl = &ZoneMgrImplVtbl;
580 *ppobj = (IInternetZoneManager*)ret;
587 /***********************************************************************
588 * CoInternetCreateSecurityManager (URLMON.@)
591 HRESULT WINAPI CoInternetCreateSecurityManager( IServiceProvider *pSP,
592 IInternetSecurityManager **ppSM, DWORD dwReserved )
594 TRACE("%p %p %ld\n", pSP, ppSM, dwReserved );
597 FIXME("pSP not supported\n");
599 return SecManagerImpl_Construct(NULL, (void**) ppSM);
602 /********************************************************************
603 * CoInternetCreateZoneManager (URLMON.@)
605 HRESULT WINAPI CoInternetCreateZoneManager(IServiceProvider* pSP, IInternetZoneManager** ppZM, DWORD dwReserved)
607 TRACE("(%p %p %lx)\n", pSP, ppZM, dwReserved);
608 return ZoneMgrImpl_Construct(NULL, (void**)ppZM);