Nikolay Sivov : opcservices: Partially implement CreatePackageRootUri().
Alexandre Julliard
julliard at winehq.org
Wed Sep 5 16:15:27 CDT 2018
Module: wine
Branch: master
Commit: d6c50ee2840f744f7e59407b51c7ef5dc2837f2f
URL: https://source.winehq.org/git/wine.git/?a=commit;h=d6c50ee2840f744f7e59407b51c7ef5dc2837f2f
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Wed Sep 5 08:37:28 2018 +0300
opcservices: Partially implement CreatePackageRootUri().
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/opcservices/factory.c | 6 ++++--
dlls/opcservices/opc_private.h | 1 +
dlls/opcservices/tests/Makefile.in | 2 +-
dlls/opcservices/tests/opcservices.c | 21 +++++++++++++++++++++
dlls/opcservices/uri.c | 23 ++++++++++++++++++++++-
5 files changed, 49 insertions(+), 4 deletions(-)
diff --git a/dlls/opcservices/factory.c b/dlls/opcservices/factory.c
index 7d72b39..0c16cc2 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 30bcb00..80b1e95 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 202bf87..4fa222e 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 2850716..9af7aa4 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 60881e8..651c2e3 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;
+}
More information about the wine-cvs
mailing list