opcservices: Implement GetSourceUri().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
d99f682118
commit
951741e649
|
@ -336,7 +336,7 @@ static HRESULT WINAPI opc_factory_CreatePackage(IOpcFactory *iface, IOpcPackage
|
|||
{
|
||||
TRACE("iface %p, package %p.\n", iface, package);
|
||||
|
||||
return opc_package_create(package);
|
||||
return opc_package_create(iface, package);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI opc_factory_ReadPackageFromStream(IOpcFactory *iface, IStream *stream,
|
||||
|
|
|
@ -45,6 +45,6 @@ static inline BOOL opc_array_reserve(void **elements, size_t *capacity, size_t c
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
extern HRESULT opc_package_create(IOpcPackage **package) DECLSPEC_HIDDEN;
|
||||
extern HRESULT opc_package_create(IOpcFactory *factory, 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;
|
||||
|
|
|
@ -37,6 +37,7 @@ struct opc_package
|
|||
|
||||
IOpcPartSet *part_set;
|
||||
IOpcRelationshipSet *relationship_set;
|
||||
IOpcUri *source_uri;
|
||||
};
|
||||
|
||||
struct opc_part
|
||||
|
@ -69,6 +70,7 @@ struct opc_relationship
|
|||
WCHAR *type;
|
||||
IUri *target;
|
||||
OPC_URI_TARGET_MODE target_mode;
|
||||
IOpcUri *source_uri;
|
||||
};
|
||||
|
||||
struct opc_relationship_set
|
||||
|
@ -79,6 +81,7 @@ struct opc_relationship_set
|
|||
struct opc_relationship **relationships;
|
||||
size_t size;
|
||||
size_t count;
|
||||
IOpcUri *source_uri;
|
||||
};
|
||||
|
||||
static inline struct opc_package *impl_from_IOpcPackage(IOpcPackage *iface)
|
||||
|
@ -106,7 +109,7 @@ static inline struct opc_relationship *impl_from_IOpcRelationship(IOpcRelationsh
|
|||
return CONTAINING_RECORD(iface, struct opc_relationship, IOpcRelationship_iface);
|
||||
}
|
||||
|
||||
static HRESULT opc_relationship_set_create(IOpcRelationshipSet **relationship_set);
|
||||
static HRESULT opc_relationship_set_create(IOpcUri *source_uri, IOpcRelationshipSet **relationship_set);
|
||||
|
||||
static WCHAR *opc_strdupW(const WCHAR *str)
|
||||
{
|
||||
|
@ -177,7 +180,7 @@ static HRESULT WINAPI opc_part_GetRelationshipSet(IOpcPart *iface, IOpcRelations
|
|||
|
||||
TRACE("iface %p, relationship_set %p.\n", iface, relationship_set);
|
||||
|
||||
if (!part->relationship_set && FAILED(hr = opc_relationship_set_create(&part->relationship_set)))
|
||||
if (!part->relationship_set && FAILED(hr = opc_relationship_set_create((IOpcUri *)part->name, &part->relationship_set)))
|
||||
return hr;
|
||||
|
||||
*relationship_set = part->relationship_set;
|
||||
|
@ -401,6 +404,7 @@ static ULONG WINAPI opc_relationship_Release(IOpcRelationship *iface)
|
|||
{
|
||||
CoTaskMemFree(relationship->id);
|
||||
CoTaskMemFree(relationship->type);
|
||||
IOpcUri_Release(relationship->source_uri);
|
||||
IUri_Release(relationship->target);
|
||||
heap_free(relationship);
|
||||
}
|
||||
|
@ -430,9 +434,14 @@ static HRESULT WINAPI opc_relationship_GetRelationshipType(IOpcRelationship *ifa
|
|||
|
||||
static HRESULT WINAPI opc_relationship_GetSourceUri(IOpcRelationship *iface, IOpcUri **uri)
|
||||
{
|
||||
FIXME("iface %p, uri %p stub!\n", iface, uri);
|
||||
struct opc_relationship *relationship = impl_from_IOpcRelationship(iface);
|
||||
|
||||
return E_NOTIMPL;
|
||||
TRACE("iface %p, uri %p.\n", iface, uri);
|
||||
|
||||
*uri = relationship->source_uri;
|
||||
IOpcUri_AddRef(*uri);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI opc_relationship_GetTargetUri(IOpcRelationship *iface, IUri **target)
|
||||
|
@ -486,6 +495,8 @@ static HRESULT opc_relationship_create(struct opc_relationship_set *set, const W
|
|||
|
||||
relationship->target = target_uri;
|
||||
IUri_AddRef(relationship->target);
|
||||
relationship->source_uri = set->source_uri;
|
||||
IOpcUri_AddRef(relationship->source_uri);
|
||||
|
||||
/* FIXME: test that id is unique */
|
||||
if (id)
|
||||
|
@ -557,6 +568,7 @@ static ULONG WINAPI opc_relationship_set_Release(IOpcRelationshipSet *iface)
|
|||
|
||||
for (i = 0; i < relationship_set->count; ++i)
|
||||
IOpcRelationship_Release(&relationship_set->relationships[i]->IOpcRelationship_iface);
|
||||
IOpcUri_Release(relationship_set->source_uri);
|
||||
heap_free(relationship_set->relationships);
|
||||
heap_free(relationship_set);
|
||||
}
|
||||
|
@ -637,7 +649,7 @@ static const IOpcRelationshipSetVtbl opc_relationship_set_vtbl =
|
|||
opc_relationship_set_GetRelationshipsContentStream,
|
||||
};
|
||||
|
||||
static HRESULT opc_relationship_set_create(IOpcRelationshipSet **out)
|
||||
static HRESULT opc_relationship_set_create(IOpcUri *source_uri, IOpcRelationshipSet **out)
|
||||
{
|
||||
struct opc_relationship_set *relationship_set;
|
||||
|
||||
|
@ -646,6 +658,8 @@ static HRESULT opc_relationship_set_create(IOpcRelationshipSet **out)
|
|||
|
||||
relationship_set->IOpcRelationshipSet_iface.lpVtbl = &opc_relationship_set_vtbl;
|
||||
relationship_set->refcount = 1;
|
||||
relationship_set->source_uri = source_uri;
|
||||
IOpcUri_AddRef(relationship_set->source_uri);
|
||||
|
||||
*out = &relationship_set->IOpcRelationshipSet_iface;
|
||||
TRACE("Created relationship set %p.\n", *out);
|
||||
|
@ -691,6 +705,8 @@ static ULONG WINAPI opc_package_Release(IOpcPackage *iface)
|
|||
IOpcPartSet_Release(package->part_set);
|
||||
if (package->relationship_set)
|
||||
IOpcRelationshipSet_Release(package->relationship_set);
|
||||
if (package->source_uri)
|
||||
IOpcUri_Release(package->source_uri);
|
||||
heap_free(package);
|
||||
}
|
||||
|
||||
|
@ -728,8 +744,11 @@ static HRESULT WINAPI opc_package_GetRelationshipSet(IOpcPackage *iface, IOpcRel
|
|||
|
||||
TRACE("iface %p, relationship_set %p.\n", iface, relationship_set);
|
||||
|
||||
if (!package->relationship_set && FAILED(hr = opc_relationship_set_create(&package->relationship_set)))
|
||||
if (!package->relationship_set)
|
||||
{
|
||||
if (FAILED(hr = opc_relationship_set_create(package->source_uri, &package->relationship_set)))
|
||||
return hr;
|
||||
}
|
||||
|
||||
*relationship_set = package->relationship_set;
|
||||
IOpcRelationshipSet_AddRef(*relationship_set);
|
||||
|
@ -746,9 +765,10 @@ static const IOpcPackageVtbl opc_package_vtbl =
|
|||
opc_package_GetRelationshipSet,
|
||||
};
|
||||
|
||||
HRESULT opc_package_create(IOpcPackage **out)
|
||||
HRESULT opc_package_create(IOpcFactory *factory, IOpcPackage **out)
|
||||
{
|
||||
struct opc_package *package;
|
||||
HRESULT hr;
|
||||
|
||||
if (!(package = heap_alloc_zero(sizeof(*package))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
@ -756,6 +776,12 @@ HRESULT opc_package_create(IOpcPackage **out)
|
|||
package->IOpcPackage_iface.lpVtbl = &opc_package_vtbl;
|
||||
package->refcount = 1;
|
||||
|
||||
if (FAILED(hr = IOpcFactory_CreatePackageRootUri(factory, &package->source_uri)))
|
||||
{
|
||||
heap_free(package);
|
||||
return hr;
|
||||
}
|
||||
|
||||
*out = &package->IOpcPackage_iface;
|
||||
TRACE("Created package %p.\n", *out);
|
||||
return S_OK;
|
||||
|
|
|
@ -38,12 +38,16 @@ static IOpcFactory *create_factory(void)
|
|||
static void test_package(void)
|
||||
{
|
||||
static const WCHAR typeW[] = {'t','y','p','e','/','s','u','b','t','y','p','e',0};
|
||||
static const WCHAR targetW[] = {'t','a','r','g','e','t',0};
|
||||
static const WCHAR uriW[] = {'/','u','r','i',0};
|
||||
IOpcRelationshipSet *relset, *relset2;
|
||||
IOpcPartSet *partset, *partset2;
|
||||
IOpcRelationship *rel;
|
||||
IOpcPartUri *part_uri;
|
||||
IOpcFactory *factory;
|
||||
IOpcPackage *package;
|
||||
IOpcUri *source_uri;
|
||||
IUri *target_uri;
|
||||
IOpcPart *part;
|
||||
HRESULT hr;
|
||||
BOOL ret;
|
||||
|
@ -81,6 +85,22 @@ static void test_package(void)
|
|||
hr = IOpcPart_GetRelationshipSet(part, &relset2);
|
||||
ok(SUCCEEDED(hr), "Failed to get relationship set, hr %#x.\n", hr);
|
||||
ok(relset == relset2, "Expected same part set instance.\n");
|
||||
|
||||
hr = CreateUri(targetW, Uri_CREATE_ALLOW_RELATIVE, 0, &target_uri);
|
||||
ok(SUCCEEDED(hr), "Failed to create target uri, hr %#x.\n", hr);
|
||||
|
||||
hr = IOpcRelationshipSet_CreateRelationship(relset, NULL, typeW, target_uri, OPC_URI_TARGET_MODE_INTERNAL, &rel);
|
||||
ok(SUCCEEDED(hr), "Failed to create relationship, hr %#x.\n", hr);
|
||||
|
||||
hr = IOpcRelationship_GetSourceUri(rel, &source_uri);
|
||||
ok(SUCCEEDED(hr), "Failed to get source uri, hr %#x.\n", hr);
|
||||
ok(source_uri == (IOpcUri *)part_uri, "Unexpected source uri.\n");
|
||||
|
||||
IOpcUri_Release(source_uri);
|
||||
|
||||
IOpcRelationship_Release(rel);
|
||||
IUri_Release(target_uri);
|
||||
|
||||
IOpcRelationshipSet_Release(relset);
|
||||
IOpcRelationshipSet_Release(relset2);
|
||||
|
||||
|
@ -212,11 +232,11 @@ static void test_relationship(void)
|
|||
static const WCHAR typeW[] = {'t','y','p','e',0};
|
||||
static const WCHAR rootW[] = {'/',0};
|
||||
IUri *target_uri, *target_uri2, *uri;
|
||||
IOpcUri *source_uri, *source_uri2;
|
||||
IOpcRelationship *rel, *rel2;
|
||||
IOpcRelationshipSet *rels;
|
||||
IOpcRelationship *rel;
|
||||
IOpcFactory *factory;
|
||||
IOpcPackage *package;
|
||||
IOpcUri *source_uri;
|
||||
IUnknown *unk;
|
||||
DWORD mode;
|
||||
HRESULT hr;
|
||||
|
@ -256,6 +276,9 @@ todo_wine
|
|||
hr = IOpcRelationshipSet_CreateRelationship(rels, NULL, typeW, target_uri, OPC_URI_TARGET_MODE_INTERNAL, &rel);
|
||||
ok(SUCCEEDED(hr), "Failed to create relationship, hr %#x.\n", hr);
|
||||
|
||||
hr = IOpcRelationshipSet_CreateRelationship(rels, NULL, typeW, target_uri, OPC_URI_TARGET_MODE_INTERNAL, &rel2);
|
||||
ok(SUCCEEDED(hr), "Failed to create relationship, hr %#x.\n", hr);
|
||||
|
||||
/* Autogenerated relationship id */
|
||||
hr = IOpcRelationship_GetId(rel, &id);
|
||||
ok(SUCCEEDED(hr), "Failed to get id, hr %#x.\n", hr);
|
||||
|
@ -272,8 +295,17 @@ todo_wine
|
|||
ok(mode == OPC_URI_TARGET_MODE_INTERNAL, "Unexpected mode %d.\n", mode);
|
||||
|
||||
/* Source uri */
|
||||
hr = IOpcFactory_CreatePackageRootUri(factory, &source_uri);
|
||||
ok(SUCCEEDED(hr), "Failed to create root uri, hr %#x.\n", hr);
|
||||
|
||||
hr = IOpcFactory_CreatePackageRootUri(factory, &source_uri2);
|
||||
ok(SUCCEEDED(hr), "Failed to create root uri, hr %#x.\n", hr);
|
||||
ok(source_uri != source_uri2, "Unexpected uri instance.\n");
|
||||
|
||||
IOpcUri_Release(source_uri);
|
||||
IOpcUri_Release(source_uri2);
|
||||
|
||||
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);
|
||||
|
@ -282,12 +314,17 @@ todo_wine
|
|||
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);
|
||||
|
||||
hr = IOpcRelationship_GetSourceUri(rel2, &source_uri2);
|
||||
ok(SUCCEEDED(hr), "Failed to get source uri, hr %#x.\n", hr);
|
||||
ok(source_uri2 == source_uri, "Unexpected source uri.\n");
|
||||
|
||||
IOpcUri_Release(source_uri2);
|
||||
IOpcUri_Release(source_uri);
|
||||
|
||||
IOpcRelationship_Release(rel2);
|
||||
IOpcRelationship_Release(rel);
|
||||
|
||||
IOpcRelationshipSet_Release(rels);
|
||||
|
|
Loading…
Reference in New Issue