mirror of
https://github.com/reactos/wine.git
synced 2024-11-29 06:30:37 +00:00
Handle context in CreateURLMoniker.
This commit is contained in:
parent
199877a6d7
commit
3d5205ef5f
@ -3,7 +3,7 @@ TOPOBJDIR = ../..
|
||||
SRCDIR = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
MODULE = urlmon.dll
|
||||
IMPORTS = cabinet ole32 wininet user32 advapi32 kernel32 ntdll
|
||||
IMPORTS = cabinet ole32 shlwapi wininet user32 advapi32 kernel32 ntdll
|
||||
EXTRALIBS = -luuid
|
||||
|
||||
C_SRCS = \
|
||||
|
@ -1,3 +1,4 @@
|
||||
Makefile
|
||||
generated.ok
|
||||
testlist.c
|
||||
url.ok
|
||||
|
@ -6,7 +6,8 @@ TESTDLL = urlmon.dll
|
||||
IMPORTS = urlmon
|
||||
|
||||
CTESTS = \
|
||||
generated.c
|
||||
generated.c \
|
||||
url.c
|
||||
|
||||
@MAKE_TEST_RULES@
|
||||
|
||||
|
55
dlls/urlmon/tests/url.c
Normal file
55
dlls/urlmon/tests/url.c
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* UrlMon URL tests
|
||||
*
|
||||
* Copyright 2004 Kevin Koltzau
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "urlmon.h"
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
const WCHAR TEST_URL_1[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','\0'};
|
||||
const WCHAR TEST_PART_URL_1[] = {'/','t','e','s','t','/','\0'};
|
||||
|
||||
static void test_CreateURLMoniker(LPCWSTR url1, LPCWSTR url2)
|
||||
{
|
||||
HRESULT hr;
|
||||
IMoniker *mon1 = NULL;
|
||||
IMoniker *mon2 = NULL;
|
||||
|
||||
hr = CreateURLMoniker(NULL, url1, &mon1);
|
||||
ok(SUCCEEDED(hr), "failed to create moniker: 0x%08lx\n", hr);
|
||||
if(SUCCEEDED(hr)) {
|
||||
hr = CreateURLMoniker(mon1, url2, &mon2);
|
||||
ok(SUCCEEDED(hr), "failed to create moniker: 0x%08lx\n", hr);
|
||||
}
|
||||
if(mon1) IMoniker_Release(mon1);
|
||||
if(mon2) IMoniker_Release(mon2);
|
||||
}
|
||||
|
||||
static void test_create()
|
||||
{
|
||||
test_CreateURLMoniker(TEST_URL_1, TEST_PART_URL_1);
|
||||
}
|
||||
|
||||
START_TEST(url)
|
||||
{
|
||||
test_create();
|
||||
}
|
@ -36,6 +36,7 @@
|
||||
#include "ole2.h"
|
||||
#include "urlmon.h"
|
||||
#include "wininet.h"
|
||||
#include "shlwapi.h"
|
||||
#include "urlmon_main.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
|
||||
@ -106,7 +107,7 @@ static HRESULT WINAPI URLMonikerImpl_IBinding_GetPriority(IBinding* iface, LONG*
|
||||
static HRESULT WINAPI URLMonikerImpl_IBinding_GetBindResult(IBinding* iface, CLSID* pclsidProtocol, DWORD* pdwResult, LPOLESTR* pszResult, DWORD* pdwReserved);
|
||||
|
||||
/* Local function used by urlmoniker implementation */
|
||||
static HRESULT URLMonikerImpl_Construct(URLMonikerImpl* iface, LPCOLESTR lpszURL);
|
||||
static HRESULT URLMonikerImpl_Construct(URLMonikerImpl* iface, LPCOLESTR lpszLeftURL, LPCOLESTR lpszURL);
|
||||
static HRESULT URLMonikerImpl_Destroy(URLMonikerImpl* iface);
|
||||
|
||||
/********************************************************************************/
|
||||
@ -337,11 +338,12 @@ static HRESULT WINAPI URLMonikerImpl_GetSizeMax(IMoniker* iface,
|
||||
/******************************************************************************
|
||||
* URLMoniker_Construct (local function)
|
||||
*******************************************************************************/
|
||||
static HRESULT URLMonikerImpl_Construct(URLMonikerImpl* This, LPCOLESTR lpszURLName)
|
||||
static HRESULT URLMonikerImpl_Construct(URLMonikerImpl* This, LPCOLESTR lpszLeftURLName, LPCOLESTR lpszURLName)
|
||||
{
|
||||
int sizeStr = strlenW(lpszURLName);
|
||||
HRESULT hres;
|
||||
DWORD sizeStr;
|
||||
|
||||
TRACE("(%p,%s)\n",This,debugstr_w(lpszURLName));
|
||||
TRACE("(%p,%s,%s)\n",This,debugstr_w(lpszLeftURLName),debugstr_w(lpszURLName));
|
||||
memset(This, 0, sizeof(*This));
|
||||
|
||||
/* Initialize the virtual function table. */
|
||||
@ -349,12 +351,30 @@ static HRESULT URLMonikerImpl_Construct(URLMonikerImpl* This, LPCOLESTR lpszURLN
|
||||
This->lpvtbl2 = &VTBinding_URLMonikerImpl;
|
||||
This->ref = 0;
|
||||
|
||||
This->URLName=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr+1));
|
||||
if(lpszLeftURLName) {
|
||||
hres = UrlCombineW(lpszLeftURLName, lpszURLName, NULL, &sizeStr, 0);
|
||||
if(FAILED(hres)) {
|
||||
return hres;
|
||||
}
|
||||
sizeStr++;
|
||||
}
|
||||
else
|
||||
sizeStr = lstrlenW(lpszURLName)+1;
|
||||
|
||||
This->URLName=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr));
|
||||
|
||||
if (This->URLName==NULL)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
strcpyW(This->URLName,lpszURLName);
|
||||
if(lpszLeftURLName) {
|
||||
hres = UrlCombineW(lpszLeftURLName, lpszURLName, This->URLName, &sizeStr, 0);
|
||||
if(FAILED(hres)) {
|
||||
HeapFree(GetProcessHeap(), 0, This->URLName);
|
||||
return hres;
|
||||
}
|
||||
}
|
||||
else
|
||||
strcpyW(This->URLName,lpszURLName);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
@ -967,16 +987,25 @@ HRESULT WINAPI CreateURLMoniker(IMoniker *pmkContext, LPCWSTR szURL, IMoniker **
|
||||
URLMonikerImpl *obj;
|
||||
HRESULT hres;
|
||||
IID iid = IID_IMoniker;
|
||||
LPOLESTR lefturl = NULL;
|
||||
|
||||
TRACE("(%p, %s, %p)\n", pmkContext, debugstr_w(szURL), ppmk);
|
||||
|
||||
if (NULL != pmkContext)
|
||||
FIXME("Non-null pmkContext not implemented\n");
|
||||
|
||||
if(!(obj = HeapAlloc(GetProcessHeap(), 0, sizeof(*obj))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
hres = URLMonikerImpl_Construct(obj, szURL);
|
||||
if(pmkContext) {
|
||||
CLSID clsid;
|
||||
IBindCtx* bind;
|
||||
IMoniker_GetClassID(pmkContext, &clsid);
|
||||
if(IsEqualCLSID(&clsid, &CLSID_StdURLMoniker) && SUCCEEDED(CreateBindCtx(0, &bind))) {
|
||||
URLMonikerImpl_GetDisplayName(pmkContext, bind, NULL, &lefturl);
|
||||
IBindCtx_Release(bind);
|
||||
}
|
||||
}
|
||||
|
||||
hres = URLMonikerImpl_Construct(obj, lefturl, szURL);
|
||||
CoTaskMemFree(lefturl);
|
||||
if(SUCCEEDED(hres))
|
||||
hres = URLMonikerImpl_QueryInterface((IMoniker*)obj, &iid, (void**)ppmk);
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user