Commit 40e276f7 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

opcservices: Keep target uri and mode for relationships.

parent 2ff3f689
...@@ -66,6 +66,8 @@ struct opc_relationship ...@@ -66,6 +66,8 @@ struct opc_relationship
LONG refcount; LONG refcount;
WCHAR *id; WCHAR *id;
IUri *target;
OPC_URI_TARGET_MODE target_mode;
}; };
struct opc_relationship_set struct opc_relationship_set
...@@ -397,6 +399,7 @@ static ULONG WINAPI opc_relationship_Release(IOpcRelationship *iface) ...@@ -397,6 +399,7 @@ static ULONG WINAPI opc_relationship_Release(IOpcRelationship *iface)
if (!refcount) if (!refcount)
{ {
CoTaskMemFree(relationship->id); CoTaskMemFree(relationship->id);
IUri_Release(relationship->target);
heap_free(relationship); heap_free(relationship);
} }
...@@ -429,16 +432,25 @@ static HRESULT WINAPI opc_relationship_GetSourceUri(IOpcRelationship *iface, IOp ...@@ -429,16 +432,25 @@ static HRESULT WINAPI opc_relationship_GetSourceUri(IOpcRelationship *iface, IOp
static HRESULT WINAPI opc_relationship_GetTargetUri(IOpcRelationship *iface, IUri **target) 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) 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 = static const IOpcRelationshipVtbl opc_relationship_vtbl =
...@@ -453,7 +465,8 @@ static const IOpcRelationshipVtbl opc_relationship_vtbl = ...@@ -453,7 +465,8 @@ static const IOpcRelationshipVtbl opc_relationship_vtbl =
opc_relationship_GetTargetMode, 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; struct opc_relationship *relationship;
...@@ -488,6 +501,9 @@ static HRESULT opc_relationship_create(struct opc_relationship_set *set, const W ...@@ -488,6 +501,9 @@ static HRESULT opc_relationship_create(struct opc_relationship_set *set, const W
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
relationship->target = target_uri;
IUri_AddRef(relationship->target);
set->relationships[set->count++] = relationship; set->relationships[set->count++] = relationship;
IOpcRelationship_AddRef(&relationship->IOpcRelationship_iface); IOpcRelationship_AddRef(&relationship->IOpcRelationship_iface);
...@@ -561,7 +577,7 @@ static HRESULT WINAPI opc_relationship_set_CreateRelationship(IOpcRelationshipSe ...@@ -561,7 +577,7 @@ static HRESULT WINAPI opc_relationship_set_CreateRelationship(IOpcRelationshipSe
if (!type || !target_uri) if (!type || !target_uri)
return E_POINTER; 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) static HRESULT WINAPI opc_relationship_set_DeleteRelationship(IOpcRelationshipSet *iface, const WCHAR *id)
......
...@@ -205,16 +205,17 @@ static void test_file_stream(void) ...@@ -205,16 +205,17 @@ static void test_file_stream(void)
DeleteFileW(pathW); 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 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 targetW[] = {'t','a','r','g','e','t',0};
static const WCHAR typeW[] = {'t','y','p','e',0}; static const WCHAR typeW[] = {'t','y','p','e',0};
IUri *target_uri, *target_uri2; IUri *target_uri, *target_uri2, *uri;
IOpcRelationshipSet *rels; IOpcRelationshipSet *rels;
IOpcRelationship *rel; IOpcRelationship *rel;
IOpcFactory *factory; IOpcFactory *factory;
IOpcPackage *package; IOpcPackage *package;
DWORD mode;
HRESULT hr; HRESULT hr;
WCHAR *id; WCHAR *id;
...@@ -257,6 +258,15 @@ todo_wine ...@@ -257,6 +258,15 @@ todo_wine
ok(lstrlenW(id) == 9 && *id == 'R', "Unexpected relationship id %s.\n", wine_dbgstr_w(id)); ok(lstrlenW(id) == 9 && *id == 'R', "Unexpected relationship id %s.\n", wine_dbgstr_w(id));
CoTaskMemFree(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); IOpcRelationship_Release(rel);
IOpcRelationshipSet_Release(rels); IOpcRelationshipSet_Release(rels);
...@@ -283,7 +293,7 @@ START_TEST(opcservices) ...@@ -283,7 +293,7 @@ START_TEST(opcservices)
test_package(); test_package();
test_file_stream(); test_file_stream();
test_relationship_id(); test_relationship();
IOpcFactory_Release(factory); IOpcFactory_Release(factory);
......
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