- Added IInternetSecurityManager::[SG]etSecuritySite implementation.

- Forward IInternetSecurityManager calls to custom manager.
This commit is contained in:
Jacek Caban 2005-09-07 09:23:18 +00:00 committed by Alexandre Julliard
parent 6f823db58b
commit bac6e12c05
1 changed files with 152 additions and 24 deletions

View File

@ -39,17 +39,20 @@ WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
* InternetSecurityManager implementation
*
*/
typedef struct SecManagerImpl{
typedef struct {
const IInternetSecurityManagerVtbl* lpInternetSecurityManagerVtbl;
const IInternetSecurityManagerVtbl* lpvtbl1; /* VTable relative to the IInternetSecurityManager interface.*/
LONG ref; /* reference counter for this object */
LONG ref;
IInternetSecurityMgrSite *mgrsite;
IInternetSecurityManager *custom_manager;
} SecManagerImpl;
#define SECMGR_THIS(iface) DEFINE_THIS(SecManagerImpl, InternetSecurityManager, iface)
static HRESULT WINAPI SecManagerImpl_QueryInterface(IInternetSecurityManager* iface,REFIID riid,void** ppvObject)
{
SecManagerImpl *This = (SecManagerImpl *)iface;
SecManagerImpl *This = SECMGR_THIS(iface);
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppvObject);
@ -66,8 +69,10 @@ static HRESULT WINAPI SecManagerImpl_QueryInterface(IInternetSecurityManager* if
*ppvObject = iface;
/* Check that we obtained an interface.*/
if ((*ppvObject)==0)
if (!*ppvObject) {
WARN("not supported interface %s\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
/* Query Interface always increases the reference count by one when it is successful */
IInternetSecurityManager_AddRef(iface);
@ -77,24 +82,30 @@ static HRESULT WINAPI SecManagerImpl_QueryInterface(IInternetSecurityManager* if
static ULONG WINAPI SecManagerImpl_AddRef(IInternetSecurityManager* iface)
{
SecManagerImpl *This = (SecManagerImpl *)iface;
SecManagerImpl *This = SECMGR_THIS(iface);
ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
TRACE("(%p) ref=%lu\n", This, refCount);
return refCount;
}
static ULONG WINAPI SecManagerImpl_Release(IInternetSecurityManager* iface)
{
SecManagerImpl *This = (SecManagerImpl *)iface;
SecManagerImpl *This = SECMGR_THIS(iface);
ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p)->(ref before=%lu)\n",This, refCount + 1);
TRACE("(%p) ref=%lu\n", This, refCount);
/* destroy the object if there's no more reference on it */
if (!refCount){
if(This->mgrsite)
IInternetSecurityMgrSite_Release(This->mgrsite);
if(This->custom_manager)
IInternetSecurityManager_Release(This->custom_manager);
HeapFree(GetProcessHeap(),0,This);
URLMON_UnlockModule();
}
@ -104,32 +115,94 @@ static ULONG WINAPI SecManagerImpl_Release(IInternetSecurityManager* iface)
static HRESULT WINAPI SecManagerImpl_SetSecuritySite(IInternetSecurityManager *iface,
IInternetSecurityMgrSite *pSite)
{
FIXME("(%p)->(%p)\n", iface, pSite);
return E_NOTIMPL;
SecManagerImpl *This = SECMGR_THIS(iface);
TRACE("(%p)->(%p)\n", This, pSite);
if(This->mgrsite)
IInternetSecurityMgrSite_Release(This->mgrsite);
if(This->custom_manager) {
IInternetSecurityManager_Release(This->custom_manager);
This->custom_manager = NULL;
}
This->mgrsite = pSite;
if(pSite) {
IServiceProvider *servprov;
HRESULT hres;
IInternetSecurityMgrSite_AddRef(pSite);
hres = IInternetSecurityMgrSite_QueryInterface(pSite, &IID_IServiceProvider,
(void**)&servprov);
if(SUCCEEDED(hres)) {
IServiceProvider_QueryService(servprov, &SID_SInternetSecurityManager,
&IID_IInternetSecurityManager, (void**)&This->custom_manager);
IServiceProvider_Release(servprov);
}
}
return S_OK;
}
static HRESULT WINAPI SecManagerImpl_GetSecuritySite(IInternetSecurityManager *iface,
IInternetSecurityMgrSite **ppSite)
{
FIXME("(%p)->( %p)\n", iface, ppSite);
return E_NOTIMPL;
SecManagerImpl *This = SECMGR_THIS(iface);
TRACE("(%p)->(%p)\n", This, ppSite);
if(!ppSite)
return E_INVALIDARG;
if(This->mgrsite)
IInternetSecurityMgrSite_AddRef(This->mgrsite);
*ppSite = This->mgrsite;
return S_OK;
}
static HRESULT WINAPI SecManagerImpl_MapUrlToZone(IInternetSecurityManager *iface,
LPCWSTR pwszUrl, DWORD *pdwZone,
DWORD dwFlags)
{
FIXME("(%p)->(%s %p %08lx)\n", iface, debugstr_w(pwszUrl), pdwZone, dwFlags);
SecManagerImpl *This = SECMGR_THIS(iface);
HRESULT hres;
TRACE("(%p)->(%s %p %08lx)\n", iface, debugstr_w(pwszUrl), pdwZone, dwFlags);
if(This->custom_manager) {
hres = IInternetSecurityManager_MapUrlToZone(This->custom_manager,
pwszUrl, pdwZone, dwFlags);
if(hres != INET_E_DEFAULT_ACTION)
return hres;
}
FIXME("Default action is not implemented\n");
return E_NOTIMPL;
}
static HRESULT WINAPI SecManagerImpl_GetSecurityId(IInternetSecurityManager *iface,
LPCWSTR pwszUrl,
BYTE *pbSecurityId, DWORD *pcbSecurityId,
DWORD dwReserved)
DWORD_PTR dwReserved)
{
FIXME("(%p)->(%s %p %p %08lx)\n", iface, debugstr_w(pwszUrl), pbSecurityId, pcbSecurityId,
SecManagerImpl *This = SECMGR_THIS(iface);
HRESULT hres;
TRACE("(%p)->(%s %p %p %08lx)\n", iface, debugstr_w(pwszUrl), pbSecurityId, pcbSecurityId,
dwReserved);
if(This->custom_manager) {
hres = IInternetSecurityManager_GetSecurityId(This->custom_manager,
pwszUrl, pbSecurityId, pcbSecurityId, dwReserved);
if(hres != INET_E_DEFAULT_ACTION)
return hres;
}
FIXME("Default action is not implemented\n");
return E_NOTIMPL;
}
@ -140,8 +213,20 @@ static HRESULT WINAPI SecManagerImpl_ProcessUrlAction(IInternetSecurityManager *
BYTE *pContext, DWORD cbContext,
DWORD dwFlags, DWORD dwReserved)
{
FIXME("(%p)->(%s %08lx %p %08lx %p %08lx %08lx %08lx)\n", iface, debugstr_w(pwszUrl), dwAction,
SecManagerImpl *This = SECMGR_THIS(iface);
HRESULT hres;
TRACE("(%p)->(%s %08lx %p %08lx %p %08lx %08lx %08lx)\n", iface, debugstr_w(pwszUrl), dwAction,
pPolicy, cbPolicy, pContext, cbContext, dwFlags, dwReserved);
if(This->custom_manager) {
hres = IInternetSecurityManager_ProcessUrlAction(This->custom_manager, pwszUrl, dwAction,
pPolicy, cbPolicy, pContext, cbContext, dwFlags, dwReserved);
if(hres != INET_E_DEFAULT_ACTION)
return hres;
}
FIXME("Default action is not implemented\n");
return E_NOTIMPL;
}
@ -152,22 +237,58 @@ static HRESULT WINAPI SecManagerImpl_QueryCustomPolicy(IInternetSecurityManager
BYTE *pContext, DWORD cbContext,
DWORD dwReserved)
{
FIXME("(%p)->(%s %s %p %p %p %08lx %08lx )\n", iface, debugstr_w(pwszUrl), debugstr_guid(guidKey),
SecManagerImpl *This = SECMGR_THIS(iface);
HRESULT hres;
TRACE("(%p)->(%s %s %p %p %p %08lx %08lx )\n", iface, debugstr_w(pwszUrl), debugstr_guid(guidKey),
ppPolicy, pcbPolicy, pContext, cbContext, dwReserved);
if(This->custom_manager) {
hres = IInternetSecurityManager_QueryCustomPolicy(This->custom_manager, pwszUrl, guidKey,
ppPolicy, pcbPolicy, pContext, cbContext, dwReserved);
if(hres != INET_E_DEFAULT_ACTION)
return hres;
}
FIXME("Default action is not implemented\n");
return E_NOTIMPL;
}
static HRESULT WINAPI SecManagerImpl_SetZoneMapping(IInternetSecurityManager *iface,
DWORD dwZone, LPCWSTR pwszPattern, DWORD dwFlags)
{
FIXME("(%p)->(%08lx %s %08lx)\n", iface, dwZone, debugstr_w(pwszPattern),dwFlags);
SecManagerImpl *This = SECMGR_THIS(iface);
HRESULT hres;
TRACE("(%p)->(%08lx %s %08lx)\n", iface, dwZone, debugstr_w(pwszPattern),dwFlags);
if(This->custom_manager) {
hres = IInternetSecurityManager_SetZoneMapping(This->custom_manager, dwZone,
pwszPattern, dwFlags);
if(hres != INET_E_DEFAULT_ACTION)
return hres;
}
FIXME("Default action is not implemented\n");
return E_NOTIMPL;
}
static HRESULT WINAPI SecManagerImpl_GetZoneMappings(IInternetSecurityManager *iface,
DWORD dwZone, IEnumString **ppenumString, DWORD dwFlags)
{
FIXME("(%p)->(%08lx %p %08lx)\n", iface, dwZone, ppenumString,dwFlags);
SecManagerImpl *This = SECMGR_THIS(iface);
HRESULT hres;
TRACE("(%p)->(%08lx %p %08lx)\n", iface, dwZone, ppenumString,dwFlags);
if(This->custom_manager) {
hres = IInternetSecurityManager_GetZoneMappings(This->custom_manager, dwZone,
ppenumString, dwFlags);
if(hres != INET_E_DEFAULT_ACTION)
return hres;
}
FIXME("Default action is not implemented\n");
return E_NOTIMPL;
}
@ -194,8 +315,11 @@ HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
/* Initialize the virtual function table. */
This->lpvtbl1 = &VT_SecManagerImpl;
This->lpInternetSecurityManagerVtbl = &VT_SecManagerImpl;
This->ref = 1;
This->mgrsite = NULL;
This->custom_manager = NULL;
*ppobj = This;
@ -468,6 +592,10 @@ HRESULT WINAPI CoInternetCreateSecurityManager( IServiceProvider *pSP,
IInternetSecurityManager **ppSM, DWORD dwReserved )
{
TRACE("%p %p %ld\n", pSP, ppSM, dwReserved );
if(pSP)
FIXME("pSP not supported\n");
return SecManagerImpl_Construct(NULL, (void**) ppSM);
}