diff --git a/dlls/opcservices/factory.c b/dlls/opcservices/factory.c index 7d72b39b7bc..0c16cc25012 100644 --- a/dlls/opcservices/factory.c +++ b/dlls/opcservices/factory.c @@ -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) diff --git a/dlls/opcservices/opc_private.h b/dlls/opcservices/opc_private.h index 30bcb0090c4..80b1e954b71 100644 --- a/dlls/opcservices/opc_private.h +++ b/dlls/opcservices/opc_private.h @@ -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; diff --git a/dlls/opcservices/tests/Makefile.in b/dlls/opcservices/tests/Makefile.in index 202bf87d688..4fa222e9273 100644 --- a/dlls/opcservices/tests/Makefile.in +++ b/dlls/opcservices/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = opcservices.dll -IMPORTS = ole32 urlmon +IMPORTS = ole32 urlmon oleaut32 C_SRCS = \ opcservices.c diff --git a/dlls/opcservices/tests/opcservices.c b/dlls/opcservices/tests/opcservices.c index 28507162c73..9af7aa49b96 100644 --- a/dlls/opcservices/tests/opcservices.c +++ b/dlls/opcservices/tests/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); diff --git a/dlls/opcservices/uri.c b/dlls/opcservices/uri.c index 60881e865e6..651c2e38f07 100644 --- a/dlls/opcservices/uri.c +++ b/dlls/opcservices/uri.c @@ -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; +}