Implement COM local servers using table marshaling to avoid doing the
[wine/multimedia.git] / dlls / urlmon / sec_mgr.c
blob549d39528ca3ddc547e6390816837b089a1ddd34
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 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;
82 TRACE("(%p)\n",This);
84 return InterlockedIncrement(&This->ref);
87 static ULONG WINAPI SecManagerImpl_Release(IInternetSecurityManager* iface)
89 SecManagerImpl *This = (SecManagerImpl *)iface;
90 ULONG ref;
91 TRACE("(%p)\n",This);
93 ref = InterlockedDecrement(&This->ref);
95 /* destroy the object if there's no more reference on it */
96 if (ref==0){
97 HeapFree(GetProcessHeap(),0,This);
99 return ref;
102 static HRESULT WINAPI SecManagerImpl_SetSecuritySite(IInternetSecurityManager *iface,
103 IInternetSecurityMgrSite *pSite)
105 FIXME("(%p)->(%p)\n", iface, pSite);
106 return E_NOTIMPL;
109 static HRESULT WINAPI SecManagerImpl_GetSecuritySite(IInternetSecurityManager *iface,
110 IInternetSecurityMgrSite **ppSite)
112 FIXME("(%p)->( %p)\n", iface, ppSite);
113 return E_NOTIMPL;
116 static HRESULT WINAPI SecManagerImpl_MapUrlToZone(IInternetSecurityManager *iface,
117 LPCWSTR pwszUrl, DWORD *pdwZone,
118 DWORD dwFlags)
120 FIXME("(%p)->(%s %p %08lx)\n", iface, debugstr_w(pwszUrl), pdwZone, dwFlags);
121 return E_NOTIMPL;
124 static HRESULT WINAPI SecManagerImpl_GetSecurityId(IInternetSecurityManager *iface,
125 LPCWSTR pwszUrl,
126 BYTE *pbSecurityId, DWORD *pcbSecurityId,
127 DWORD dwReserved)
129 FIXME("(%p)->(%s %p %p %08lx)\n", iface, debugstr_w(pwszUrl), pbSecurityId, pcbSecurityId,
130 dwReserved);
131 return E_NOTIMPL;
135 static HRESULT WINAPI SecManagerImpl_ProcessUrlAction(IInternetSecurityManager *iface,
136 LPCWSTR pwszUrl, DWORD dwAction,
137 BYTE *pPolicy, DWORD cbPolicy,
138 BYTE *pContext, DWORD cbContext,
139 DWORD dwFlags, DWORD dwReserved)
141 FIXME("(%p)->(%s %08lx %p %08lx %p %08lx %08lx %08lx)\n", iface, debugstr_w(pwszUrl), dwAction,
142 pPolicy, cbPolicy, pContext, cbContext, dwFlags, dwReserved);
143 return E_NOTIMPL;
147 static HRESULT WINAPI SecManagerImpl_QueryCustomPolicy(IInternetSecurityManager *iface,
148 LPCWSTR pwszUrl, REFGUID guidKey,
149 BYTE **ppPolicy, DWORD *pcbPolicy,
150 BYTE *pContext, DWORD cbContext,
151 DWORD dwReserved)
153 FIXME("(%p)->(%s %s %p %p %p %08lx %08lx )\n", iface, debugstr_w(pwszUrl), debugstr_guid(guidKey),
154 ppPolicy, pcbPolicy, pContext, cbContext, dwReserved);
155 return E_NOTIMPL;
158 static HRESULT WINAPI SecManagerImpl_SetZoneMapping(IInternetSecurityManager *iface,
159 DWORD dwZone, LPCWSTR pwszPattern, DWORD dwFlags)
161 FIXME("(%p)->(%08lx %s %08lx)\n", iface, dwZone, debugstr_w(pwszPattern),dwFlags);
162 return E_NOTIMPL;
165 static HRESULT WINAPI SecManagerImpl_GetZoneMappings(IInternetSecurityManager *iface,
166 DWORD dwZone, IEnumString **ppenumString, DWORD dwFlags)
168 FIXME("(%p)->(%08lx %p %08lx)\n", iface, dwZone, ppenumString,dwFlags);
169 return E_NOTIMPL;
172 static IInternetSecurityManagerVtbl VT_SecManagerImpl =
174 SecManagerImpl_QueryInterface,
175 SecManagerImpl_AddRef,
176 SecManagerImpl_Release,
177 SecManagerImpl_SetSecuritySite,
178 SecManagerImpl_GetSecuritySite,
179 SecManagerImpl_MapUrlToZone,
180 SecManagerImpl_GetSecurityId,
181 SecManagerImpl_ProcessUrlAction,
182 SecManagerImpl_QueryCustomPolicy,
183 SecManagerImpl_SetZoneMapping,
184 SecManagerImpl_GetZoneMappings
187 HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
189 SecManagerImpl *This;
191 TRACE("(%p,%p)\n",pUnkOuter,ppobj);
192 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
194 /* Initialize the virtual function table. */
195 This->lpvtbl1 = &VT_SecManagerImpl;
196 This->ref = 1;
198 *ppobj = This;
199 return S_OK;
202 /***********************************************************************
203 * InternetZoneManager implementation
206 typedef struct {
207 IInternetZoneManagerVtbl* lpVtbl;
208 ULONG ref;
209 } ZoneMgrImpl;
211 /********************************************************************
212 * IInternetZoneManager_QueryInterface
214 static HRESULT WINAPI ZoneMgrImpl_QueryInterface(IInternetZoneManager* iface, REFIID riid, void** ppvObject)
216 ZoneMgrImpl* This = (ZoneMgrImpl*)iface;
218 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppvObject);
220 if(!This || !ppvObject)
221 return E_INVALIDARG;
223 if(!IsEqualIID(&IID_IUnknown, riid) && !IsEqualIID(&IID_IInternetZoneManager, riid)) {
224 FIXME("Unknown interface: %s\n", debugstr_guid(riid));
225 *ppvObject = NULL;
226 return E_NOINTERFACE;
229 *ppvObject = iface;
230 IInternetZoneManager_AddRef(iface);
232 return S_OK;
235 /********************************************************************
236 * IInternetZoneManager_AddRef
238 static ULONG WINAPI ZoneMgrImpl_AddRef(IInternetZoneManager* iface)
240 ZoneMgrImpl* This = (ZoneMgrImpl*)iface;
242 TRACE("(%p) was %lu\n", This, This->ref);
244 return InterlockedIncrement(&This->ref);
247 /********************************************************************
248 * IInternetZoneManager_Release
250 static ULONG WINAPI ZoneMgrImpl_Release(IInternetZoneManager* iface)
252 ZoneMgrImpl* This = (ZoneMgrImpl*)iface;
253 ULONG ref;
255 TRACE("(%p) was %lu\n", This, This->ref);
256 ref = InterlockedDecrement(&This->ref);
258 if(!ref)
259 HeapFree(GetProcessHeap(), 0, This);
261 return ref;
264 /********************************************************************
265 * IInternetZoneManager_GetZoneAttributes
267 static HRESULT WINAPI ZoneMgrImpl_GetZoneAttributes(IInternetZoneManager* iface,
268 DWORD dwZone,
269 ZONEATTRIBUTES* pZoneAttributes)
271 FIXME("(%p)->(%ld %p) stub\n", iface, dwZone, pZoneAttributes);
272 return E_NOTIMPL;
275 /********************************************************************
276 * IInternetZoneManager_SetZoneAttributes
278 static HRESULT WINAPI ZoneMgrImpl_SetZoneAttributes(IInternetZoneManager* iface,
279 DWORD dwZone,
280 ZONEATTRIBUTES* pZoneAttributes)
282 FIXME("(%p)->(%08lx %p) stub\n", iface, dwZone, pZoneAttributes);
283 return E_NOTIMPL;
286 /********************************************************************
287 * IInternetZoneManager_GetZoneCustomPolicy
289 static HRESULT WINAPI ZoneMgrImpl_GetZoneCustomPolicy(IInternetZoneManager* iface,
290 DWORD dwZone,
291 REFGUID guidKey,
292 BYTE** ppPolicy,
293 DWORD* pcbPolicy,
294 URLZONEREG ulrZoneReg)
296 FIXME("(%p)->(%08lx %s %p %p %08x) stub\n", iface, dwZone, debugstr_guid(guidKey),
297 ppPolicy, pcbPolicy, ulrZoneReg);
298 return E_NOTIMPL;
301 /********************************************************************
302 * IInternetZoneManager_SetZoneCustomPolicy
304 static HRESULT WINAPI ZoneMgrImpl_SetZoneCustomPolicy(IInternetZoneManager* iface,
305 DWORD dwZone,
306 REFGUID guidKey,
307 BYTE* ppPolicy,
308 DWORD cbPolicy,
309 URLZONEREG ulrZoneReg)
311 FIXME("(%p)->(%08lx %s %p %08lx %08x) stub\n", iface, dwZone, debugstr_guid(guidKey),
312 ppPolicy, cbPolicy, ulrZoneReg);
313 return E_NOTIMPL;
316 /********************************************************************
317 * IInternetZoneManager_GetZoneActionPolicy
319 static HRESULT WINAPI ZoneMgrImpl_GetZoneActionPolicy(IInternetZoneManager* iface,
320 DWORD dwZone,
321 DWORD dwAction,
322 BYTE* pPolicy,
323 DWORD cbPolicy,
324 URLZONEREG urlZoneReg)
326 FIXME("(%p)->(%08lx %08lx %p %08lx %08x) stub\n", iface, dwZone, dwAction, pPolicy,
327 cbPolicy, urlZoneReg);
328 return E_NOTIMPL;
331 /********************************************************************
332 * IInternetZoneManager_SetZoneActionPolicy
334 static HRESULT WINAPI ZoneMgrImpl_SetZoneActionPolicy(IInternetZoneManager* iface,
335 DWORD dwZone,
336 DWORD dwAction,
337 BYTE* pPolicy,
338 DWORD cbPolicy,
339 URLZONEREG urlZoneReg)
341 FIXME("(%p)->(%08lx %08lx %p %08lx %08x) stub\n", iface, dwZone, dwAction, pPolicy,
342 cbPolicy, urlZoneReg);
343 return E_NOTIMPL;
346 /********************************************************************
347 * IInternetZoneManager_LogAction
349 static HRESULT WINAPI ZoneMgrImpl_LogAction(IInternetZoneManager* iface,
350 DWORD dwAction,
351 LPCWSTR pwszUrl,
352 LPCWSTR pwszText,
353 DWORD dwLogFlags)
355 FIXME("(%p)->(%08lx %s %s %08lx) stub\n", iface, dwAction, debugstr_w(pwszUrl),
356 debugstr_w(pwszText), dwLogFlags);
357 return E_NOTIMPL;
360 /********************************************************************
361 * IInternetZoneManager_CreateZoneEnumerator
363 static HRESULT WINAPI ZoneMgrImpl_CreateZoneEnumerator(IInternetZoneManager* iface,
364 DWORD* pdwEnum,
365 DWORD* pdwCount,
366 DWORD dwFlags)
368 FIXME("(%p)->(%p %p %08lx) stub\n", iface, pdwEnum, pdwCount, dwFlags);
369 return E_NOTIMPL;
372 /********************************************************************
373 * IInternetZoneManager_GetZoneAt
375 static HRESULT WINAPI ZoneMgrImpl_GetZoneAt(IInternetZoneManager* iface,
376 DWORD dwEnum,
377 DWORD dwIndex,
378 DWORD* pdwZone)
380 FIXME("(%p)->(%08lx %08lx %p) stub\n", iface, dwEnum, dwIndex, pdwZone);
381 return E_NOTIMPL;
384 /********************************************************************
385 * IInternetZoneManager_DestroyZoneEnumerator
387 static HRESULT WINAPI ZoneMgrImpl_DestroyZoneEnumerator(IInternetZoneManager* iface,
388 DWORD dwEnum)
390 FIXME("(%p)->(%08lx) stub\n", iface, dwEnum);
391 return E_NOTIMPL;
394 /********************************************************************
395 * IInternetZoneManager_CopyTemplatePoliciesToZone
397 static HRESULT WINAPI ZoneMgrImpl_CopyTemplatePoliciesToZone(IInternetZoneManager* iface,
398 DWORD dwTemplate,
399 DWORD dwZone,
400 DWORD dwReserved)
402 FIXME("(%p)->(%08lx %08lx %08lx) stub\n", iface, dwTemplate, dwZone, dwReserved);
403 return E_NOTIMPL;
406 /********************************************************************
407 * IInternetZoneManager_Construct
409 static IInternetZoneManagerVtbl ZoneMgrImplVtbl = {
410 ZoneMgrImpl_QueryInterface,
411 ZoneMgrImpl_AddRef,
412 ZoneMgrImpl_Release,
413 ZoneMgrImpl_GetZoneAttributes,
414 ZoneMgrImpl_SetZoneAttributes,
415 ZoneMgrImpl_GetZoneCustomPolicy,
416 ZoneMgrImpl_SetZoneCustomPolicy,
417 ZoneMgrImpl_GetZoneActionPolicy,
418 ZoneMgrImpl_SetZoneActionPolicy,
419 ZoneMgrImpl_LogAction,
420 ZoneMgrImpl_CreateZoneEnumerator,
421 ZoneMgrImpl_GetZoneAt,
422 ZoneMgrImpl_DestroyZoneEnumerator,
423 ZoneMgrImpl_CopyTemplatePoliciesToZone,
425 HRESULT ZoneMgrImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
427 ZoneMgrImpl* ret = HeapAlloc(GetProcessHeap(), 0, sizeof(ZoneMgrImpl));
429 TRACE("(%p %p)\n", pUnkOuter, ppobj);
430 ret->lpVtbl = &ZoneMgrImplVtbl;
431 ret->ref = 1;
432 *ppobj = (IInternetZoneManager*)ret;
434 return S_OK;
437 /***********************************************************************
438 * CoInternetCreateSecurityManager (URLMON.@)
441 HRESULT WINAPI CoInternetCreateSecurityManager( IServiceProvider *pSP,
442 IInternetSecurityManager **ppSM, DWORD dwReserved )
444 TRACE("%p %p %ld\n", pSP, ppSM, dwReserved );
445 return SecManagerImpl_Construct(NULL, (void**) ppSM);
448 /********************************************************************
449 * CoInternetCreateZoneManager (URLMON.@)
451 HRESULT WINAPI CoInternetCreateZoneManager(IServiceProvider* pSP, IInternetZoneManager** ppZM, DWORD dwReserved)
453 TRACE("(%p %p %lx)\n", pSP, ppZM, dwReserved);
454 return ZoneMgrImpl_Construct(NULL, (void**)ppZM);