opcservices: Keep target uri and mode for relationships.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2018-09-05 08:37:26 +03:00 committed by Alexandre Julliard
parent 2ff3f6892b
commit 40e276f75d
2 changed files with 35 additions and 9 deletions

View File

@ -66,6 +66,8 @@ struct opc_relationship
LONG refcount;
WCHAR *id;
IUri *target;
OPC_URI_TARGET_MODE target_mode;
};
struct opc_relationship_set
@ -397,6 +399,7 @@ static ULONG WINAPI opc_relationship_Release(IOpcRelationship *iface)
if (!refcount)
{
CoTaskMemFree(relationship->id);
IUri_Release(relationship->target);
heap_free(relationship);
}
@ -429,16 +432,25 @@ static HRESULT WINAPI opc_relationship_GetSourceUri(IOpcRelationship *iface, IOp
static HRESULT WINAPI opc_relationship_GetTargetUri(IOpcRelationship *iface, IUri **target)
{
FIXME("iface %p, target %p stub!\n", iface, target);
struct opc_relationship *relationship = impl_from_IOpcRelationship(iface);
return E_NOTIMPL;
TRACE("iface %p, target %p.\n", iface, target);
*target = relationship->target;
IUri_AddRef(*target);
return S_OK;
}
static HRESULT WINAPI opc_relationship_GetTargetMode(IOpcRelationship *iface, OPC_URI_TARGET_MODE *target_mode)
{
FIXME("iface %p, target_mode %p stub!\n", iface, target_mode);
struct opc_relationship *relationship = impl_from_IOpcRelationship(iface);
return E_NOTIMPL;
TRACE("iface %p, target_mode %p.\n", iface, target_mode);
*target_mode = relationship->target_mode;
return S_OK;
}
static const IOpcRelationshipVtbl opc_relationship_vtbl =
@ -453,7 +465,8 @@ static const IOpcRelationshipVtbl opc_relationship_vtbl =
opc_relationship_GetTargetMode,
};
static HRESULT opc_relationship_create(struct opc_relationship_set *set, const WCHAR *id, IOpcRelationship **out)
static HRESULT opc_relationship_create(struct opc_relationship_set *set, const WCHAR *id, IUri *target_uri,
OPC_URI_TARGET_MODE target_mode, IOpcRelationship **out)
{
struct opc_relationship *relationship;
@ -488,6 +501,9 @@ static HRESULT opc_relationship_create(struct opc_relationship_set *set, const W
return E_OUTOFMEMORY;
}
relationship->target = target_uri;
IUri_AddRef(relationship->target);
set->relationships[set->count++] = relationship;
IOpcRelationship_AddRef(&relationship->IOpcRelationship_iface);
@ -561,7 +577,7 @@ static HRESULT WINAPI opc_relationship_set_CreateRelationship(IOpcRelationshipSe
if (!type || !target_uri)
return E_POINTER;
return opc_relationship_create(relationship_set, id, relationship);
return opc_relationship_create(relationship_set, id, target_uri, target_mode, relationship);
}
static HRESULT WINAPI opc_relationship_set_DeleteRelationship(IOpcRelationshipSet *iface, const WCHAR *id)

View File

@ -205,16 +205,17 @@ static void test_file_stream(void)
DeleteFileW(pathW);
}
static void test_relationship_id(void)
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};
IUri *target_uri, *target_uri2;
IUri *target_uri, *target_uri2, *uri;
IOpcRelationshipSet *rels;
IOpcRelationship *rel;
IOpcFactory *factory;
IOpcPackage *package;
DWORD mode;
HRESULT hr;
WCHAR *id;
@ -257,6 +258,15 @@ todo_wine
ok(lstrlenW(id) == 9 && *id == 'R', "Unexpected relationship id %s.\n", wine_dbgstr_w(id));
CoTaskMemFree(id);
hr = IOpcRelationship_GetTargetUri(rel, &uri);
ok(SUCCEEDED(hr), "Failed to get target uri, hr %#x.\n", hr);
ok(uri == target_uri, "Unexpected uri.\n");
IUri_Release(uri);
hr = IOpcRelationship_GetTargetMode(rel, &mode);
ok(SUCCEEDED(hr), "Failed to get target mode, hr %#x.\n", hr);
ok(mode == OPC_URI_TARGET_MODE_INTERNAL, "Unexpected mode %d.\n", mode);
IOpcRelationship_Release(rel);
IOpcRelationshipSet_Release(rels);
@ -283,7 +293,7 @@ START_TEST(opcservices)
test_package();
test_file_stream();
test_relationship_id();
test_relationship();
IOpcFactory_Release(factory);