wsdapi: Implement UnPublish.

Signed-off-by: Owen Rudge <orudge@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Owen Rudge 2018-04-26 23:35:59 +01:00 committed by Alexandre Julliard
parent 60fad890db
commit 399c142702
3 changed files with 86 additions and 3 deletions

View File

@ -195,10 +195,18 @@ static HRESULT WINAPI IWSDiscoveryPublisherImpl_Publish(IWSDiscoveryPublisher *T
static HRESULT WINAPI IWSDiscoveryPublisherImpl_UnPublish(IWSDiscoveryPublisher *This, LPCWSTR pszId, ULONGLONG ullInstanceId, ULONGLONG ullMessageNumber,
LPCWSTR pszSessionId, const WSDXML_ELEMENT *pAny)
{
FIXME("(%p, %s, %s, %s, %s, %p)\n", This, debugstr_w(pszId), wine_dbgstr_longlong(ullInstanceId), wine_dbgstr_longlong(ullMessageNumber),
debugstr_w(pszSessionId), pAny);
IWSDiscoveryPublisherImpl *impl = impl_from_IWSDiscoveryPublisher(This);
return E_NOTIMPL;
TRACE("(%p, %s, %s, %s, %s, %p)\n", This, debugstr_w(pszId), wine_dbgstr_longlong(ullInstanceId),
wine_dbgstr_longlong(ullMessageNumber), debugstr_w(pszSessionId), pAny);
if ((!impl->publisherStarted) || (pszId == NULL) || (lstrlenW(pszId) > WSD_MAX_TEXT_LENGTH) ||
((pszSessionId != NULL) && (lstrlenW(pszSessionId) > WSD_MAX_TEXT_LENGTH)))
{
return E_INVALIDARG;
}
return send_bye_message(impl, pszId, ullInstanceId, ullMessageNumber, pszSessionId, pAny);
}
static HRESULT WINAPI IWSDiscoveryPublisherImpl_MatchProbe(IWSDiscoveryPublisher *This, const WSD_SOAP_MESSAGE *pProbeMessage,

View File

@ -45,6 +45,13 @@ static const WCHAR actionHello[] = {
'd','i','s','c','o','v','e','r','y','/',
'H','e','l','l','o', 0 };
static const WCHAR actionBye[] = {
'h','t','t','p',':','/','/',
's','c','h','e','m','a','s','.','x','m','l','s','o','a','p','.','o','r','g','/',
'w','s','/','2','0','0','5','/','0','4','/',
'd','i','s','c','o','v','e','r','y','/',
'B','y','e', 0 };
static const WCHAR addressingNsUri[] = {
'h','t','t','p',':','/','/',
's','c','h','e','m','a','s','.','x','m','l','s','o','a','p','.','o','r','g','/',
@ -75,6 +82,7 @@ static const WCHAR sequenceIdString[] = { 'S','e','q','u','e','n','c','e','I','d
static const WCHAR emptyString[] = { 0 };
static const WCHAR bodyString[] = { 'B','o','d','y', 0 };
static const WCHAR helloString[] = { 'H','e','l','l','o', 0 };
static const WCHAR byeString[] = { 'B','y','e', 0 };
static const WCHAR endpointReferenceString[] = { 'E','n','d','p','o','i','n','t','R','e','f','e','r','e','n','c','e', 0 };
static const WCHAR addressString[] = { 'A','d','d','r','e','s','s', 0 };
static const WCHAR referenceParametersString[] = { 'R','e','f','e','r','e','n','c','e','P','a','r','a','m','e','t','e','r','s', 0 };
@ -1008,3 +1016,67 @@ cleanup:
return ret;
}
HRESULT send_bye_message(IWSDiscoveryPublisherImpl *impl, LPCWSTR id, ULONGLONG instance_id, ULONGLONG msg_num,
LPCWSTR session_id, const WSDXML_ELEMENT *any)
{
WSDXML_ELEMENT *body_element = NULL, *bye_element, *endpoint_reference_element;
struct list *discovered_namespaces = NULL;
WSDXML_NAME *body_name = NULL;
WSD_SOAP_HEADER soap_header;
WSD_APP_SEQUENCE sequence;
WCHAR message_id[64];
HRESULT ret = E_OUTOFMEMORY;
sequence.InstanceId = instance_id;
sequence.MessageNumber = msg_num;
sequence.SequenceId = session_id;
if (!create_guid(message_id)) goto failed;
discovered_namespaces = WSDAllocateLinkedMemory(NULL, sizeof(struct list));
if (!discovered_namespaces) goto failed;
list_init(discovered_namespaces);
populate_soap_header(&soap_header, discoveryTo, actionBye, message_id, &sequence, NULL);
ret = IWSDXMLContext_AddNameToNamespace(impl->xmlContext, envelopeNsUri, bodyString, &body_name);
if (FAILED(ret)) goto cleanup;
/* <soap:Body>, <wsd:Bye> */
ret = WSDXMLBuildAnyForSingleElement(body_name, NULL, &body_element);
if (FAILED(ret)) goto cleanup;
ret = add_child_element(impl->xmlContext, body_element, discoveryNsUri, byeString, NULL, &bye_element);
if (FAILED(ret)) goto cleanup;
/* <wsa:EndpointReference>, <wsa:Address> */
ret = add_child_element(impl->xmlContext, bye_element, addressingNsUri, endpointReferenceString, NULL,
&endpoint_reference_element);
if (FAILED(ret)) goto cleanup;
ret = add_child_element(impl->xmlContext, endpoint_reference_element, addressingNsUri, addressString, id, NULL);
if (FAILED(ret)) goto cleanup;
/* Write any body elements */
if (any != NULL)
{
ret = duplicate_element(bye_element, any, discovered_namespaces);
if (FAILED(ret)) goto cleanup;
}
/* Write and send the message */
ret = write_and_send_message(impl, &soap_header, body_element, discovered_namespaces, NULL, 0);
goto cleanup;
failed:
ret = E_OUTOFMEMORY;
cleanup:
WSDFreeLinkedMemory(body_name);
WSDFreeLinkedMemory(body_element);
WSDFreeLinkedMemory(discovered_namespaces);
return ret;
}

View File

@ -62,6 +62,9 @@ HRESULT send_hello_message(IWSDiscoveryPublisherImpl *impl, LPCWSTR id, ULONGLON
const WSD_URI_LIST *xaddrs_list, const WSDXML_ELEMENT *hdr_any, const WSDXML_ELEMENT *ref_param_any,
const WSDXML_ELEMENT *endpoint_ref_any, const WSDXML_ELEMENT *any);
HRESULT send_bye_message(IWSDiscoveryPublisherImpl *impl, LPCWSTR id, ULONGLONG instance_id, ULONGLONG msg_num,
LPCWSTR session_id, const WSDXML_ELEMENT *any);
HRESULT register_namespaces(IWSDXMLContext *xml_context);
/* xml.c */