Added MapUrlToZone implementation.
This commit is contained in:
parent
fc68475c80
commit
c292c84b8d
|
@ -27,6 +27,7 @@
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
#include "winbase.h"
|
#include "winbase.h"
|
||||||
#include "winuser.h"
|
#include "winuser.h"
|
||||||
|
#include "winreg.h"
|
||||||
#include "wine/debug.h"
|
#include "wine/debug.h"
|
||||||
#include "ole2.h"
|
#include "ole2.h"
|
||||||
#include "wine/unicode.h"
|
#include "wine/unicode.h"
|
||||||
|
@ -50,6 +51,70 @@ typedef struct {
|
||||||
|
|
||||||
#define SECMGR_THIS(iface) DEFINE_THIS(SecManagerImpl, InternetSecurityManager, iface)
|
#define SECMGR_THIS(iface) DEFINE_THIS(SecManagerImpl, InternetSecurityManager, iface)
|
||||||
|
|
||||||
|
static HRESULT map_url_to_zone(LPCWSTR url, DWORD *zone)
|
||||||
|
{
|
||||||
|
WCHAR schema[64];
|
||||||
|
DWORD res, size=0;
|
||||||
|
HKEY hkey;
|
||||||
|
HRESULT hres;
|
||||||
|
|
||||||
|
static const WCHAR wszZoneMapProtocolKey[] =
|
||||||
|
{'S','o','f','t','w','a','r','e','\\',
|
||||||
|
'M','i','c','r','o','s','o','f','t','\\',
|
||||||
|
'W','i','n','d','o','w','s','\\',
|
||||||
|
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
|
||||||
|
'I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s','\\',
|
||||||
|
'Z','o','n','e','M','a','p','\\',
|
||||||
|
'P','r','o','t','o','c','o','l','D','e','f','a','u','l','t','s',0};
|
||||||
|
static const WCHAR wszFile[] = {'f','i','l','e',0};
|
||||||
|
|
||||||
|
hres = CoInternetParseUrl(url, PARSE_SCHEMA, 0, schema, sizeof(schema)/sizeof(WCHAR), &size, 0);
|
||||||
|
if(FAILED(hres))
|
||||||
|
return hres;
|
||||||
|
if(!*schema)
|
||||||
|
return 0x80041001;
|
||||||
|
|
||||||
|
/* file protocol is a special case */
|
||||||
|
if(!strcmpW(schema, wszFile)) {
|
||||||
|
WCHAR path[MAX_PATH];
|
||||||
|
|
||||||
|
hres = CoInternetParseUrl(url, PARSE_PATH_FROM_URL, 0, path,
|
||||||
|
sizeof(path)/sizeof(WCHAR), &size, 0);
|
||||||
|
|
||||||
|
if(SUCCEEDED(hres) && strchrW(path, '\\')) {
|
||||||
|
*zone = 0;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WARN("domains are not yet implemented\n");
|
||||||
|
|
||||||
|
res = RegOpenKeyW(HKEY_CURRENT_USER, wszZoneMapProtocolKey, &hkey);
|
||||||
|
if(res != ERROR_SUCCESS) {
|
||||||
|
ERR("Could not open key %s\n", debugstr_w(wszZoneMapProtocolKey));
|
||||||
|
return E_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
size = sizeof(DWORD);
|
||||||
|
res = RegQueryValueExW(hkey, schema, NULL, NULL, (PBYTE)zone, &size);
|
||||||
|
if(res == ERROR_SUCCESS)
|
||||||
|
return S_OK;
|
||||||
|
|
||||||
|
res = RegOpenKeyW(HKEY_LOCAL_MACHINE, wszZoneMapProtocolKey, &hkey);
|
||||||
|
if(res != ERROR_SUCCESS) {
|
||||||
|
ERR("Could not open key %s\n", debugstr_w(wszZoneMapProtocolKey));
|
||||||
|
return E_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
size = sizeof(DWORD);
|
||||||
|
res = RegQueryValueExW(hkey, schema, NULL, NULL, (PBYTE)zone, &size);
|
||||||
|
if(res == ERROR_SUCCESS)
|
||||||
|
return S_OK;
|
||||||
|
|
||||||
|
*zone = 3;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI SecManagerImpl_QueryInterface(IInternetSecurityManager* iface,REFIID riid,void** ppvObject)
|
static HRESULT WINAPI SecManagerImpl_QueryInterface(IInternetSecurityManager* iface,REFIID riid,void** ppvObject)
|
||||||
{
|
{
|
||||||
SecManagerImpl *This = SECMGR_THIS(iface);
|
SecManagerImpl *This = SECMGR_THIS(iface);
|
||||||
|
@ -169,6 +234,8 @@ static HRESULT WINAPI SecManagerImpl_MapUrlToZone(IInternetSecurityManager *ifac
|
||||||
DWORD dwFlags)
|
DWORD dwFlags)
|
||||||
{
|
{
|
||||||
SecManagerImpl *This = SECMGR_THIS(iface);
|
SecManagerImpl *This = SECMGR_THIS(iface);
|
||||||
|
LPWSTR url;
|
||||||
|
DWORD size;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
TRACE("(%p)->(%s %p %08lx)\n", iface, debugstr_w(pwszUrl), pdwZone, dwFlags);
|
TRACE("(%p)->(%s %p %08lx)\n", iface, debugstr_w(pwszUrl), pdwZone, dwFlags);
|
||||||
|
@ -180,8 +247,24 @@ static HRESULT WINAPI SecManagerImpl_MapUrlToZone(IInternetSecurityManager *ifac
|
||||||
return hres;
|
return hres;
|
||||||
}
|
}
|
||||||
|
|
||||||
FIXME("Default action is not implemented\n");
|
if(!pwszUrl)
|
||||||
return E_NOTIMPL;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
|
if(dwFlags)
|
||||||
|
FIXME("not supported flags: %08lx\n", dwFlags);
|
||||||
|
|
||||||
|
size = (strlenW(pwszUrl)+16) * sizeof(WCHAR);
|
||||||
|
url = HeapAlloc(GetProcessHeap(), 0, size);
|
||||||
|
|
||||||
|
hres = CoInternetParseUrl(pwszUrl, PARSE_SECURITY_URL, 0, url, size/sizeof(WCHAR), &size, 0);
|
||||||
|
if(FAILED(hres))
|
||||||
|
memcpy(url, pwszUrl, size);
|
||||||
|
|
||||||
|
hres = map_url_to_zone(url, pdwZone);
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, url);
|
||||||
|
|
||||||
|
return hres;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI SecManagerImpl_GetSecurityId(IInternetSecurityManager *iface,
|
static HRESULT WINAPI SecManagerImpl_GetSecurityId(IInternetSecurityManager *iface,
|
||||||
|
|
|
@ -409,10 +409,53 @@ static void test_FindMimeFromData(void)
|
||||||
ok(hres == E_INVALIDARG, "FindMimeFromData failed: %08lx, expected E_INVALIDARG\n", hres);
|
ok(hres == E_INVALIDARG, "FindMimeFromData failed: %08lx, expected E_INVALIDARG\n", hres);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct secmgr_test {
|
||||||
|
LPCWSTR url;
|
||||||
|
DWORD zone;
|
||||||
|
HRESULT zone_hres;
|
||||||
|
} secmgr_tests[] = {
|
||||||
|
{url1, 0, S_OK},
|
||||||
|
{url2, 100, 0x80041001},
|
||||||
|
{url3, 0, S_OK},
|
||||||
|
{url4, 3, S_OK},
|
||||||
|
{url5, 3, S_OK},
|
||||||
|
{url6, 3, S_OK},
|
||||||
|
{url7, 3, S_OK}
|
||||||
|
};
|
||||||
|
|
||||||
|
static void test_SecurityManager(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
IInternetSecurityManager *secmgr = NULL;
|
||||||
|
DWORD zone;
|
||||||
|
HRESULT hres;
|
||||||
|
|
||||||
|
hres = CoInternetCreateSecurityManager(NULL, &secmgr, 0);
|
||||||
|
ok(hres == S_OK, "CoInternetCreateSecurityManager failed: %08lx\n", hres);
|
||||||
|
if(FAILED(hres))
|
||||||
|
return;
|
||||||
|
|
||||||
|
for(i=0; i < sizeof(secmgr_tests)/sizeof(secmgr_tests[0]); i++) {
|
||||||
|
zone = 100;
|
||||||
|
hres = IInternetSecurityManager_MapUrlToZone(secmgr, secmgr_tests[i].url, &zone, 0);
|
||||||
|
ok(hres == secmgr_tests[i].zone_hres, "[%d] MapUrlToZone failed: %08lx, expected %08lx\n",
|
||||||
|
i, hres, secmgr_tests[i].zone_hres);
|
||||||
|
ok(zone == secmgr_tests[i].zone, "[%d] zone=%ld, expected %ld\n", i, zone,
|
||||||
|
secmgr_tests[i].zone);
|
||||||
|
}
|
||||||
|
|
||||||
|
zone = 100;
|
||||||
|
hres = IInternetSecurityManager_MapUrlToZone(secmgr, NULL, &zone, 0);
|
||||||
|
ok(hres == E_INVALIDARG, "MapUrlToZone failed: %08lx, expected E_INVALIDARG\n", hres);
|
||||||
|
|
||||||
|
IInternetSecurityManager_Release(secmgr);
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(misc)
|
START_TEST(misc)
|
||||||
{
|
{
|
||||||
test_CreateFormatEnum();
|
test_CreateFormatEnum();
|
||||||
test_RegisterFormatEnumerator();
|
test_RegisterFormatEnumerator();
|
||||||
test_CoInternetParseUrl();
|
test_CoInternetParseUrl();
|
||||||
test_FindMimeFromData();
|
test_FindMimeFromData();
|
||||||
|
test_SecurityManager();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue