Break out all the file related actions and helper functions into
[wine/multimedia.git] / dlls / urlmon / sec_mgr.c
blob215d74cf5ffdbe2fbd1125eef43b459e21148cfb
1 /*
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
22 #include <stdarg.h>
23 #include <stdio.h>
25 #define COBJMACROS
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winuser.h"
30 #include "wine/debug.h"
31 #include "ole2.h"
32 #include "wine/unicode.h"
33 #include "urlmon.h"
34 #include "urlmon_main.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
38 /***********************************************************************
39 * InternetSecurityManager implementation
42 typedef struct SecManagerImpl{
44 const IInternetSecurityManagerVtbl* lpvtbl1; /* VTable relative to the IInternetSecurityManager interface.*/
46 ULONG ref; /* reference counter for this object */
48 } SecManagerImpl;
50 static HRESULT WINAPI SecManagerImpl_QueryInterface(IInternetSecurityManager* iface,REFIID riid,void** ppvObject)
52 SecManagerImpl *This = (SecManagerImpl *)iface;
54 TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppvObject);
56 /* Perform a sanity check on the parameters.*/
57 if ( (This==0) || (ppvObject==0) )
58 return E_INVALIDARG;
60 /* Initialize the return parameter */
61 *ppvObject = 0;
63 /* Compare the riid with the interface IDs implemented by this object.*/
64 if (IsEqualIID(&IID_IUnknown, riid) ||
65 IsEqualIID(&IID_IInternetSecurityManager, riid))
66 *ppvObject = iface;
68 /* Check that we obtained an interface.*/
69 if ((*ppvObject)==0)
70 return E_NOINTERFACE;
72 /* Query Interface always increases the reference count by one when it is successful */
73 IInternetSecurityManager_AddRef(iface);
75 return S_OK;
78 static ULONG WINAPI SecManagerImpl_AddRef(IInternetSecurityManager* iface)
80 SecManagerImpl *This = (SecManagerImpl *)iface;
81 ULONG refCount = InterlockedIncrement(&This->ref);
83 TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
85 URLMON_LockModule();
87 return refCount;
90 static ULONG WINAPI SecManagerImpl_Release(IInternetSecurityManager* iface)
92 SecManagerImpl *This = (SecManagerImpl *)iface;
93 ULONG refCount = InterlockedDecrement(&This->ref);
95 TRACE("(%p)->(ref before=%lu)\n",This, refCount + 1);
97 /* destroy the object if there's no more reference on it */
98 if (!refCount){
99 HeapFree(GetProcessHeap(),0,This);
102 URLMON_UnlockModule();
104 return refCount;
107 static HRESULT WINAPI SecManagerImpl_SetSecuritySite(IInternetSecurityManager *iface,
108 IInternetSecurityMgrSite *pSite)
110 FIXME("(%p)->(%p)\n", iface, pSite);
111 return E_NOTIMPL;
114 static HRESULT WINAPI SecManagerImpl_GetSecuritySite(IInternetSecurityManager *iface,
115 IInternetSecurityMgrSite **ppSite)
117 FIXME("(%p)->( %p)\n", iface, ppSite);
118 return E_NOTIMPL;
121 static HRESULT WINAPI SecManagerImpl_MapUrlToZone(IInternetSecurityManager *iface,
122 LPCWSTR pwszUrl, DWORD *pdwZone,
123 DWORD dwFlags)
125 FIXME("(%p)->(%s %p %08lx)\n", iface, debugstr_w(pwszUrl), pdwZone, dwFlags);
126 return E_NOTIMPL;
129 static HRESULT WINAPI SecManagerImpl_GetSecurityId(IInternetSecurityManager *iface,
130 LPCWSTR pwszUrl,
131 BYTE *pbSecurityId, DWORD *pcbSecurityId,
132 DWORD dwReserved)
134 FIXME("(%p)->(%s %p %p %08lx)\n", iface, debugstr_w(pwszUrl), pbSecurityId, pcbSecurityId,
135 dwReserved);
136 return E_NOTIMPL;
140 static HRESULT WINAPI SecManagerImpl_ProcessUrlAction(IInternetSecurityManager *iface,
141 LPCWSTR pwszUrl, DWORD dwAction,
142 BYTE *pPolicy, DWORD cbPolicy,
143 BYTE *pContext, DWORD cbContext,
144 DWORD dwFlags, DWORD dwReserved)
146 FIXME("(%p)->(%s %08lx %p %08lx %p %08lx %08lx %08lx)\n", iface, debugstr_w(pwszUrl), dwAction,
147 pPolicy, cbPolicy, pContext, cbContext, dwFlags, dwReserved);
148 return E_NOTIMPL;
152 static HRESULT WINAPI SecManagerImpl_QueryCustomPolicy(IInternetSecurityManager *iface,
153 LPCWSTR pwszUrl, REFGUID guidKey,
154 BYTE **ppPolicy, DWORD *pcbPolicy,
155 BYTE *pContext, DWORD cbContext,
156 DWORD dwReserved)
158 FIXME("(%p)->(%s %s %p %p %p %08lx %08lx )\n", iface, debugstr_w(pwszUrl), debugstr_guid(guidKey),
159 ppPolicy, pcbPolicy, pContext, cbContext, dwReserved);
160 return E_NOTIMPL;
163 static HRESULT WINAPI SecManagerImpl_SetZoneMapping(IInternetSecurityManager *iface,
164 DWORD dwZone, LPCWSTR pwszPattern, DWORD dwFlags)
166 FIXME("(%p)->(%08lx %s %08lx)\n", iface, dwZone, debugstr_w(pwszPattern),dwFlags);
167 return E_NOTIMPL;
170 static HRESULT WINAPI SecManagerImpl_GetZoneMappings(IInternetSecurityManager *iface,
171 DWORD dwZone, IEnumString **ppenumString, DWORD dwFlags)
173 FIXME("(%p)->(%08lx %p %08lx)\n", iface, dwZone, ppenumString,dwFlags);
174 return E_NOTIMPL;
177 static const IInternetSecurityManagerVtbl VT_SecManagerImpl =
179 SecManagerImpl_QueryInterface,
180 SecManagerImpl_AddRef,
181 SecManagerImpl_Release,
182 SecManagerImpl_SetSecuritySite,
183 SecManagerImpl_GetSecuritySite,
184 SecManagerImpl_MapUrlToZone,
185 SecManagerImpl_GetSecurityId,
186 SecManagerImpl_ProcessUrlAction,
187 SecManagerImpl_QueryCustomPolicy,
188 SecManagerImpl_SetZoneMapping,
189 SecManagerImpl_GetZoneMappings
192 HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
194 SecManagerImpl *This;
196 TRACE("(%p,%p)\n",pUnkOuter,ppobj);
197 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
199 /* Initialize the virtual function table. */
200 This->lpvtbl1 = &VT_SecManagerImpl;
201 This->ref = 1;
203 *ppobj = This;
204 return S_OK;
207 /***********************************************************************
208 * InternetZoneManager implementation
211 typedef struct {
212 const IInternetZoneManagerVtbl* lpVtbl;
213 ULONG ref;
214 } ZoneMgrImpl;
216 /********************************************************************
217 * IInternetZoneManager_QueryInterface
219 static HRESULT WINAPI ZoneMgrImpl_QueryInterface(IInternetZoneManager* iface, REFIID riid, void** ppvObject)
221 ZoneMgrImpl* This = (ZoneMgrImpl*)iface;
223 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppvObject);
225 if(!This || !ppvObject)
226 return E_INVALIDARG;
228 if(!IsEqualIID(&IID_IUnknown, riid) && !IsEqualIID(&IID_IInternetZoneManager, riid)) {
229 FIXME("Unknown interface: %s\n", debugstr_guid(riid));
230 *ppvObject = NULL;
231 return E_NOINTERFACE;
234 *ppvObject = iface;
235 IInternetZoneManager_AddRef(iface);
237 return S_OK;
240 /********************************************************************
241 * IInternetZoneManager_AddRef
243 static ULONG WINAPI ZoneMgrImpl_AddRef(IInternetZoneManager* iface)
245 ZoneMgrImpl* This = (ZoneMgrImpl*)iface;
246 ULONG refCount = InterlockedIncrement(&This->ref);
248 TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
250 URLMON_LockModule();
252 return refCount;
255 /********************************************************************
256 * IInternetZoneManager_Release
258 static ULONG WINAPI ZoneMgrImpl_Release(IInternetZoneManager* iface)
260 ZoneMgrImpl* This = (ZoneMgrImpl*)iface;
261 ULONG refCount = InterlockedDecrement(&This->ref);
263 TRACE("(%p)->(ref before=%lu)\n",This, refCount + 1);
265 if(!refCount)
266 HeapFree(GetProcessHeap(), 0, This);
268 URLMON_UnlockModule();
270 return refCount;
273 /********************************************************************
274 * IInternetZoneManager_GetZoneAttributes
276 static HRESULT WINAPI ZoneMgrImpl_GetZoneAttributes(IInternetZoneManager* iface,
277 DWORD dwZone,
278 ZONEATTRIBUTES* pZoneAttributes)
280 FIXME("(%p)->(%ld %p) stub\n", iface, dwZone, pZoneAttributes);
281 return E_NOTIMPL;
284 /********************************************************************
285 * IInternetZoneManager_SetZoneAttributes
287 static HRESULT WINAPI ZoneMgrImpl_SetZoneAttributes(IInternetZoneManager* iface,
288 DWORD dwZone,
289 ZONEATTRIBUTES* pZoneAttributes)
291 FIXME("(%p)->(%08lx %p) stub\n", iface, dwZone, pZoneAttributes);
292 return E_NOTIMPL;
295 /********************************************************************
296 * IInternetZoneManager_GetZoneCustomPolicy
298 static HRESULT WINAPI ZoneMgrImpl_GetZoneCustomPolicy(IInternetZoneManager* iface,
299 DWORD dwZone,
300 REFGUID guidKey,
301 BYTE** ppPolicy,
302 DWORD* pcbPolicy,
303 URLZONEREG ulrZoneReg)
305 FIXME("(%p)->(%08lx %s %p %p %08x) stub\n", iface, dwZone, debugstr_guid(guidKey),
306 ppPolicy, pcbPolicy, ulrZoneReg);
307 return E_NOTIMPL;
310 /********************************************************************
311 * IInternetZoneManager_SetZoneCustomPolicy
313 static HRESULT WINAPI ZoneMgrImpl_SetZoneCustomPolicy(IInternetZoneManager* iface,
314 DWORD dwZone,
315 REFGUID guidKey,
316 BYTE* ppPolicy,
317 DWORD cbPolicy,
318 URLZONEREG ulrZoneReg)
320 FIXME("(%p)->(%08lx %s %p %08lx %08x) stub\n", iface, dwZone, debugstr_guid(guidKey),
321 ppPolicy, cbPolicy, ulrZoneReg);
322 return E_NOTIMPL;
325 /********************************************************************
326 * IInternetZoneManager_GetZoneActionPolicy
328 static HRESULT WINAPI ZoneMgrImpl_GetZoneActionPolicy(IInternetZoneManager* iface,
329 DWORD dwZone,
330 DWORD dwAction,
331 BYTE* pPolicy,
332 DWORD cbPolicy,
333 URLZONEREG urlZoneReg)
335 FIXME("(%p)->(%08lx %08lx %p %08lx %08x) stub\n", iface, dwZone, dwAction, pPolicy,
336 cbPolicy, urlZoneReg);
337 return E_NOTIMPL;
340 /********************************************************************
341 * IInternetZoneManager_SetZoneActionPolicy
343 static HRESULT WINAPI ZoneMgrImpl_SetZoneActionPolicy(IInternetZoneManager* iface,
344 DWORD dwZone,
345 DWORD dwAction,
346 BYTE* pPolicy,
347 DWORD cbPolicy,
348 URLZONEREG urlZoneReg)
350 FIXME("(%p)->(%08lx %08lx %p %08lx %08x) stub\n", iface, dwZone, dwAction, pPolicy,
351 cbPolicy, urlZoneReg);
352 return E_NOTIMPL;
355 /********************************************************************
356 * IInternetZoneManager_PromptAction
358 static HRESULT WINAPI ZoneMgrImpl_PromptAction(IInternetZoneManager* iface,
359 DWORD dwAction,
360 HWND hwndParent,
361 LPCWSTR pwszUrl,
362 LPCWSTR pwszText,
363 DWORD dwPromptFlags)
365 FIXME("%p %08lx %p %s %s %08lx\n", iface, dwAction, hwndParent,
366 debugstr_w(pwszUrl), debugstr_w(pwszText), dwPromptFlags );
367 return E_NOTIMPL;
370 /********************************************************************
371 * IInternetZoneManager_LogAction
373 static HRESULT WINAPI ZoneMgrImpl_LogAction(IInternetZoneManager* iface,
374 DWORD dwAction,
375 LPCWSTR pwszUrl,
376 LPCWSTR pwszText,
377 DWORD dwLogFlags)
379 FIXME("(%p)->(%08lx %s %s %08lx) stub\n", iface, dwAction, debugstr_w(pwszUrl),
380 debugstr_w(pwszText), dwLogFlags);
381 return E_NOTIMPL;
384 /********************************************************************
385 * IInternetZoneManager_CreateZoneEnumerator
387 static HRESULT WINAPI ZoneMgrImpl_CreateZoneEnumerator(IInternetZoneManager* iface,
388 DWORD* pdwEnum,
389 DWORD* pdwCount,
390 DWORD dwFlags)
392 FIXME("(%p)->(%p %p %08lx) stub\n", iface, pdwEnum, pdwCount, dwFlags);
393 return E_NOTIMPL;
396 /********************************************************************
397 * IInternetZoneManager_GetZoneAt
399 static HRESULT WINAPI ZoneMgrImpl_GetZoneAt(IInternetZoneManager* iface,
400 DWORD dwEnum,
401 DWORD dwIndex,
402 DWORD* pdwZone)
404 FIXME("(%p)->(%08lx %08lx %p) stub\n", iface, dwEnum, dwIndex, pdwZone);
405 return E_NOTIMPL;
408 /********************************************************************
409 * IInternetZoneManager_DestroyZoneEnumerator
411 static HRESULT WINAPI ZoneMgrImpl_DestroyZoneEnumerator(IInternetZoneManager* iface,
412 DWORD dwEnum)
414 FIXME("(%p)->(%08lx) stub\n", iface, dwEnum);
415 return E_NOTIMPL;
418 /********************************************************************
419 * IInternetZoneManager_CopyTemplatePoliciesToZone
421 static HRESULT WINAPI ZoneMgrImpl_CopyTemplatePoliciesToZone(IInternetZoneManager* iface,
422 DWORD dwTemplate,
423 DWORD dwZone,
424 DWORD dwReserved)
426 FIXME("(%p)->(%08lx %08lx %08lx) stub\n", iface, dwTemplate, dwZone, dwReserved);
427 return E_NOTIMPL;
430 /********************************************************************
431 * IInternetZoneManager_Construct
433 static const IInternetZoneManagerVtbl ZoneMgrImplVtbl = {
434 ZoneMgrImpl_QueryInterface,
435 ZoneMgrImpl_AddRef,
436 ZoneMgrImpl_Release,
437 ZoneMgrImpl_GetZoneAttributes,
438 ZoneMgrImpl_SetZoneAttributes,
439 ZoneMgrImpl_GetZoneCustomPolicy,
440 ZoneMgrImpl_SetZoneCustomPolicy,
441 ZoneMgrImpl_GetZoneActionPolicy,
442 ZoneMgrImpl_SetZoneActionPolicy,
443 ZoneMgrImpl_PromptAction,
444 ZoneMgrImpl_LogAction,
445 ZoneMgrImpl_CreateZoneEnumerator,
446 ZoneMgrImpl_GetZoneAt,
447 ZoneMgrImpl_DestroyZoneEnumerator,
448 ZoneMgrImpl_CopyTemplatePoliciesToZone,
451 HRESULT ZoneMgrImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
453 ZoneMgrImpl* ret = HeapAlloc(GetProcessHeap(), 0, sizeof(ZoneMgrImpl));
455 TRACE("(%p %p)\n", pUnkOuter, ppobj);
456 ret->lpVtbl = &ZoneMgrImplVtbl;
457 ret->ref = 1;
458 *ppobj = (IInternetZoneManager*)ret;
460 return S_OK;
463 /***********************************************************************
464 * CoInternetCreateSecurityManager (URLMON.@)
467 HRESULT WINAPI CoInternetCreateSecurityManager( IServiceProvider *pSP,
468 IInternetSecurityManager **ppSM, DWORD dwReserved )
470 TRACE("%p %p %ld\n", pSP, ppSM, dwReserved );
471 return SecManagerImpl_Construct(NULL, (void**) ppSM);
474 /********************************************************************
475 * CoInternetCreateZoneManager (URLMON.@)
477 HRESULT WINAPI CoInternetCreateZoneManager(IServiceProvider* pSP, IInternetZoneManager** ppZM, DWORD dwReserved)
479 TRACE("(%p %p %lx)\n", pSP, ppZM, dwReserved);
480 return ZoneMgrImpl_Construct(NULL, (void**)ppZM);