urlmon: Added StdURLMoniker implementation.

This commit is contained in:
Jacek Caban 2009-03-23 18:30:47 +01:00 committed by Alexandre Julliard
parent 53b1a310fe
commit a5b2075ef1
4 changed files with 55 additions and 13 deletions

View File

@ -2571,6 +2571,25 @@ static void test_BindToStorage_fail(void)
test_ReportResult(S_FALSE);
}
static void test_StdURLMoniker(void)
{
IMoniker *mon, *async_mon;
HRESULT hres;
hres = CoCreateInstance(&IID_IInternet, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
&IID_IMoniker, (void**)&mon);
ok(hres == S_OK, "Could not create IInternet instance: %08x\n", hres);
if(FAILED(hres))
return;
hres = IMoniker_QueryInterface(mon, &IID_IAsyncMoniker, (void**)&async_mon);
ok(hres == S_OK, "Could not get IAsyncMoniker iface: %08x\n", hres);
ok(mon == async_mon, "mon != async_mon\n");
IMoniker_Release(async_mon);
IMoniker_Release(mon);
}
static void gecko_installer_workaround(BOOL disable)
{
HKEY hkey;
@ -2622,6 +2641,9 @@ START_TEST(url)
CoInitialize(NULL);
trace("test StdURLMoniker...");
test_StdURLMoniker();
trace("synchronous http test...\n");
test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);

View File

@ -376,7 +376,7 @@ static HRESULT WINAPI URLMoniker_GetDisplayName(IMoniker *iface, IBindCtx *pbc,
if(!ppszDisplayName)
return E_INVALIDARG;
/* FIXME: If this is a partial URL, try and get a URL moniker from SZ_URLCONTEXT in the bind context,
then look at pmkToLeft to try and complete the URL
*/
@ -436,19 +436,28 @@ static const IMonikerVtbl URLMonikerVtbl =
URLMoniker_IsSystemMoniker
};
/******************************************************************************
* URLMoniker_Construct (local function)
*******************************************************************************/
static HRESULT URLMoniker_Construct(URLMoniker *This, LPCOLESTR lpszLeftURLName, LPCOLESTR lpszURLName)
static URLMoniker *alloc_moniker(void)
{
URLMoniker *ret;
ret = heap_alloc(sizeof(URLMoniker));
if(!ret)
return NULL;
ret->lpIMonikerVtbl = &URLMonikerVtbl;
ret->ref = 1;
ret->URLName = NULL;
return ret;
}
static HRESULT URLMoniker_Init(URLMoniker *This, LPCOLESTR lpszLeftURLName, LPCOLESTR lpszURLName)
{
HRESULT hres;
DWORD sizeStr = 0;
TRACE("(%p,%s,%s)\n",This,debugstr_w(lpszLeftURLName),debugstr_w(lpszURLName));
This->lpIMonikerVtbl = &URLMonikerVtbl;
This->ref = 0;
This->URLName = heap_alloc(INTERNET_MAX_URL_LENGTH*sizeof(WCHAR));
if(lpszLeftURLName)
@ -473,6 +482,14 @@ static HRESULT URLMoniker_Construct(URLMoniker *This, LPCOLESTR lpszLeftURLName,
return S_OK;
}
HRESULT StdURLMoniker_Construct(IUnknown *outer, void **ppv)
{
TRACE("(%p %p)\n", outer, ppv);
*ppv = alloc_moniker();
return *ppv ? S_OK : E_OUTOFMEMORY;
}
/***********************************************************************
* CreateURLMonikerEx (URLMON.@)
*
@ -499,7 +516,7 @@ HRESULT WINAPI CreateURLMonikerEx(IMoniker *pmkContext, LPCWSTR szURL, IMoniker
if (dwFlags & URL_MK_UNIFORM) FIXME("ignoring flag URL_MK_UNIFORM\n");
if(!(obj = heap_alloc(sizeof(*obj))))
if(!(obj = alloc_moniker()))
return E_OUTOFMEMORY;
if(pmkContext) {
@ -513,12 +530,11 @@ HRESULT WINAPI CreateURLMonikerEx(IMoniker *pmkContext, LPCWSTR szURL, IMoniker
}
}
hres = URLMoniker_Construct(obj, lefturl, szURL);
hres = URLMoniker_Init(obj, lefturl, szURL);
CoTaskMemFree(lefturl);
if(SUCCEEDED(hres))
hres = URLMoniker_QueryInterface((IMoniker*)obj, &IID_IMoniker, (void**)ppmk);
else
heap_free(obj);
IMoniker_Release((IMoniker*)obj);
return hres;
}

View File

@ -185,6 +185,8 @@ static const ClassFactory SecurityManagerCF =
{ &ClassFactoryVtbl, SecManagerImpl_Construct};
static const ClassFactory ZoneManagerCF =
{ &ClassFactoryVtbl, ZoneMgrImpl_Construct};
static const ClassFactory StdURLMonikerCF =
{ &ClassFactoryVtbl, StdURLMoniker_Construct};
struct object_creation_info
{
@ -209,7 +211,8 @@ static const struct object_creation_info object_creation[] =
{ &CLSID_HttpSProtocol, CLASSFACTORY(&HttpSProtocolCF), wszHttps },
{ &CLSID_MkProtocol, CLASSFACTORY(&MkProtocolCF), wszMk },
{ &CLSID_InternetSecurityManager, CLASSFACTORY(&SecurityManagerCF), NULL },
{ &CLSID_InternetZoneManager, CLASSFACTORY(&ZoneManagerCF), NULL }
{ &CLSID_InternetZoneManager, CLASSFACTORY(&ZoneManagerCF), NULL },
{ &CLSID_StdURLMoniker, CLASSFACTORY(&StdURLMonikerCF), NULL }
};
static void init_session(BOOL init)

View File

@ -38,6 +38,7 @@
extern HINSTANCE URLMON_hInstance;
extern HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
extern HRESULT ZoneMgrImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
extern HRESULT StdURLMoniker_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
extern HRESULT FileProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
extern HRESULT HttpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
extern HRESULT HttpSProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);