Owen Rudge : wsdapi: Implement UnPublish.

Alexandre Julliard julliard at winehq.org
Fri Apr 27 13:26:03 CDT 2018


Module: wine
Branch: master
Commit: 399c142702260343e09be94a145de4ab76b1a492
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=399c142702260343e09be94a145de4ab76b1a492

Author: Owen Rudge <orudge at codeweavers.com>
Date:   Thu Apr 26 23:35:59 2018 +0100

wsdapi: Implement UnPublish.

Signed-off-by: Owen Rudge <orudge at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wsdapi/discovery.c       | 14 +++++++--
 dlls/wsdapi/soap.c            | 72 +++++++++++++++++++++++++++++++++++++++++++
 dlls/wsdapi/wsdapi_internal.h |  3 ++
 3 files changed, 86 insertions(+), 3 deletions(-)

diff --git a/dlls/wsdapi/discovery.c b/dlls/wsdapi/discovery.c
index fc8acfb..9971219 100644
--- a/dlls/wsdapi/discovery.c
+++ b/dlls/wsdapi/discovery.c
@@ -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,
diff --git a/dlls/wsdapi/soap.c b/dlls/wsdapi/soap.c
index 943a6a3..d0fb0af 100644
--- a/dlls/wsdapi/soap.c
+++ b/dlls/wsdapi/soap.c
@@ -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;
+}
diff --git a/dlls/wsdapi/wsdapi_internal.h b/dlls/wsdapi/wsdapi_internal.h
index 57bf58c..45d54c2 100644
--- a/dlls/wsdapi/wsdapi_internal.h
+++ b/dlls/wsdapi/wsdapi_internal.h
@@ -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 */




More information about the wine-cvs mailing list