Commit d6c50ee2 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

opcservices: Partially implement CreatePackageRootUri().

parent a2e8bd8f
......@@ -309,9 +309,11 @@ static ULONG WINAPI opc_factory_Release(IOpcFactory *iface)
static HRESULT WINAPI opc_factory_CreatePackageRootUri(IOpcFactory *iface, IOpcUri **uri)
{
FIXME("iface %p, uri %p stub!\n", iface, uri);
static const WCHAR rootW[] = {'/',0};
return E_NOTIMPL;
TRACE("iface %p, uri %p.\n", iface, uri);
return opc_uri_create(rootW, uri);
}
static HRESULT WINAPI opc_factory_CreatePartUri(IOpcFactory *iface, LPCWSTR uri, IOpcPartUri **part_uri)
......
......@@ -47,3 +47,4 @@ static inline BOOL opc_array_reserve(void **elements, size_t *capacity, size_t c
extern HRESULT opc_package_create(IOpcPackage **package) DECLSPEC_HIDDEN;
extern HRESULT opc_part_uri_create(const WCHAR *uri, IOpcPartUri **part_uri) DECLSPEC_HIDDEN;
extern HRESULT opc_uri_create(const WCHAR *uri, IOpcUri **opc_uri) DECLSPEC_HIDDEN;
TESTDLL = opcservices.dll
IMPORTS = ole32 urlmon
IMPORTS = ole32 urlmon oleaut32
C_SRCS = \
opcservices.c
......@@ -210,14 +210,18 @@ static void test_relationship(void)
static const WCHAR absoluteW[] = {'f','i','l','e',':','/','/','h','o','s','t','/','f','i','l','e','.','t','x','t',0};
static const WCHAR targetW[] = {'t','a','r','g','e','t',0};
static const WCHAR typeW[] = {'t','y','p','e',0};
static const WCHAR rootW[] = {'/',0};
IUri *target_uri, *target_uri2, *uri;
IOpcRelationshipSet *rels;
IOpcRelationship *rel;
IOpcFactory *factory;
IOpcPackage *package;
IOpcUri *source_uri;
IUnknown *unk;
DWORD mode;
HRESULT hr;
WCHAR *id;
BSTR str;
factory = create_factory();
......@@ -267,6 +271,23 @@ todo_wine
ok(SUCCEEDED(hr), "Failed to get target mode, hr %#x.\n", hr);
ok(mode == OPC_URI_TARGET_MODE_INTERNAL, "Unexpected mode %d.\n", mode);
/* Source uri */
hr = IOpcRelationship_GetSourceUri(rel, &source_uri);
todo_wine
ok(SUCCEEDED(hr), "Failed to get source uri, hr %#x.\n", hr);
hr = IOpcUri_QueryInterface(source_uri, &IID_IOpcPartUri, (void **)&unk);
ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
str = NULL;
hr = IOpcUri_GetRawUri(source_uri, &str);
ok(SUCCEEDED(hr), "Failed to get raw uri, hr %#x.\n", hr);
todo_wine
ok(!lstrcmpW(rootW, str), "Unexpected uri %s.\n", wine_dbgstr_w(str));
SysFreeString(str);
IOpcUri_Release(source_uri);
IOpcRelationship_Release(rel);
IOpcRelationshipSet_Release(rels);
......
......@@ -32,6 +32,7 @@ struct opc_uri
{
IOpcPartUri IOpcPartUri_iface;
LONG refcount;
BOOL is_part_uri;
};
static inline struct opc_uri *impl_from_IOpcPartUri(IOpcPartUri *iface)
......@@ -41,9 +42,13 @@ static inline struct opc_uri *impl_from_IOpcPartUri(IOpcPartUri *iface)
static HRESULT WINAPI opc_uri_QueryInterface(IOpcPartUri *iface, REFIID iid, void **out)
{
struct opc_uri *uri = impl_from_IOpcPartUri(iface);
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
if (IsEqualIID(iid, &IID_IOpcPartUri) ||
if ((uri->is_part_uri && IsEqualIID(iid, &IID_IOpcPartUri)) ||
IsEqualIID(iid, &IID_IOpcUri) ||
IsEqualIID(iid, &IID_IUri) ||
IsEqualIID(iid, &IID_IUnknown))
{
*out = iface;
......@@ -348,8 +353,24 @@ HRESULT opc_part_uri_create(const WCHAR *str, IOpcPartUri **out)
uri->IOpcPartUri_iface.lpVtbl = &opc_part_uri_vtbl;
uri->refcount = 1;
uri->is_part_uri = TRUE;
*out = &uri->IOpcPartUri_iface;
TRACE("Created part uri %p.\n", *out);
return S_OK;
}
HRESULT opc_uri_create(const WCHAR *str, IOpcUri **out)
{
struct opc_uri *uri;
if (!(uri = heap_alloc_zero(sizeof(*uri))))
return E_OUTOFMEMORY;
uri->IOpcPartUri_iface.lpVtbl = &opc_part_uri_vtbl;
uri->refcount = 1;
*out = (IOpcUri *)&uri->IOpcPartUri_iface;
TRACE("Created part uri %p.\n", *out);
return S_OK;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment