Owen Rudge : wsdapi: Implement probe message parsing.

Alexandre Julliard julliard at winehq.org
Thu Jun 14 16:53:23 CDT 2018


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

Author: Owen Rudge <orudge at codeweavers.com>
Date:   Wed Jun 13 19:11:28 2018 +0100

wsdapi: Implement probe message parsing.

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/soap.c            | 40 +++++++++++++++++++++++++++++++++++++++-
 dlls/wsdapi/tests/discovery.c |  4 ++--
 2 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/dlls/wsdapi/soap.c b/dlls/wsdapi/soap.c
index 34b9490..85a5fba 100644
--- a/dlls/wsdapi/soap.c
+++ b/dlls/wsdapi/soap.c
@@ -89,6 +89,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 probeString[] = { 'P','r','o','b','e', 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 };
@@ -1346,6 +1347,19 @@ static void remove_element(WSDXML_ELEMENT *element)
     WSDFreeLinkedMemory(element);
 }
 
+static WSDXML_TYPE *generate_type(LPCWSTR uri, void *parent)
+{
+    WSDXML_TYPE *type = WSDAllocateLinkedMemory(parent, sizeof(WSDXML_TYPE));
+
+    if (type == NULL)
+        return NULL;
+
+    type->Uri = duplicate_string(parent, uri);
+    type->Table = NULL;
+
+    return type;
+}
+
 HRESULT read_message(const char *xml, int xml_length, WSD_SOAP_MESSAGE **out_msg, int *msg_type)
 {
     WSDXML_ELEMENT *envelope = NULL, *header_element, *body_element;
@@ -1491,7 +1505,31 @@ HRESULT read_message(const char *xml, int xml_length, WSD_SOAP_MESSAGE **out_msg
     /* Now figure out which message we've been sent */
     if (lstrcmpW(soap_msg->Header.Action, actionProbe) == 0)
     {
-        /* TODO: Parse the Probe message */
+        WSDXML_ELEMENT *probe_element;
+        WSD_PROBE *probe = NULL;
+
+        probe_element = find_element(body_element, probeString, discoveryNsUri);
+        if (probe_element == NULL) goto cleanup;
+
+        probe = WSDAllocateLinkedMemory(soap_msg, sizeof(WSD_PROBE));
+        if (probe == NULL) goto cleanup;
+
+        ZeroMemory(probe, sizeof(WSD_PROBE));
+
+        /* TODO: Check for the "types" element */
+
+        /* Now detach and free known headers to leave the "any" elements */
+        remove_element(find_element(probe_element, typesString, discoveryNsUri));
+        remove_element(find_element(probe_element, scopesString, discoveryNsUri));
+
+        probe->Any = (WSDXML_ELEMENT *) probe_element->FirstChild;
+
+        if (probe->Any != NULL)
+            probe->Any->Node.Parent = NULL;
+
+        soap_msg->Body = probe;
+        soap_msg->BodyType = generate_type(actionProbe, soap_msg);
+        if (soap_msg->BodyType == NULL) goto cleanup;
 
         *out_msg = soap_msg;
         soap_msg = NULL; /* caller will clean this up */
diff --git a/dlls/wsdapi/tests/discovery.c b/dlls/wsdapi/tests/discovery.c
index b7496ea..94a5ebf 100644
--- a/dlls/wsdapi/tests/discovery.c
+++ b/dlls/wsdapi/tests/discovery.c
@@ -534,7 +534,7 @@ static HRESULT WINAPI IWSDiscoveryPublisherNotifyImpl_ProbeHandler(IWSDiscoveryP
         static const WCHAR extra_info[] = {'E','x','t','r','a','I','n','f','o',0};
         WSD_PROBE *probe_msg = (WSD_PROBE *) pSoap->Body;
 
-        todo_wine ok(pSoap->Body != NULL, "pSoap->Body == NULL\n");
+        ok(pSoap->Body != NULL, "pSoap->Body == NULL\n");
         ok(pSoap->Header.To != NULL && lstrcmpW(pSoap->Header.To, discoveryTo) == 0,
             "pSoap->Header.To == '%s'\n", wine_dbgstr_w(pSoap->Header.To));
         ok(pSoap->Header.Action != NULL && lstrcmpW(pSoap->Header.Action, actionProbe) == 0,
@@ -564,7 +564,7 @@ static HRESULT WINAPI IWSDiscoveryPublisherNotifyImpl_ProbeHandler(IWSDiscoveryP
             static const WCHAR lager[] = {'L','a','g','e','r',0};
             static const WCHAR more_info[] = {'M','o','r','e','I','n','f','o',0};
 
-            ok(probe_msg->Types != NULL, "Probe message Types == NULL\n");
+            todo_wine ok(probe_msg->Types != NULL, "Probe message Types == NULL\n");
 
             if (probe_msg->Types != NULL)
             {




More information about the wine-cvs mailing list