wsdapi: Implement probe message parsing.

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-06-13 19:11:28 +01:00 committed by Alexandre Julliard
parent 098a99fc41
commit 767eeb7078
2 changed files with 41 additions and 3 deletions

View file

@ -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 emptyString[] = { 0 };
static const WCHAR bodyString[] = { 'B','o','d','y', 0 }; static const WCHAR bodyString[] = { 'B','o','d','y', 0 };
static const WCHAR helloString[] = { 'H','e','l','l','o', 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 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 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 addressString[] = { 'A','d','d','r','e','s','s', 0 };
@ -1346,6 +1347,19 @@ static void remove_element(WSDXML_ELEMENT *element)
WSDFreeLinkedMemory(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) 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; 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 */ /* Now figure out which message we've been sent */
if (lstrcmpW(soap_msg->Header.Action, actionProbe) == 0) 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; *out_msg = soap_msg;
soap_msg = NULL; /* caller will clean this up */ soap_msg = NULL; /* caller will clean this up */

View file

@ -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}; static const WCHAR extra_info[] = {'E','x','t','r','a','I','n','f','o',0};
WSD_PROBE *probe_msg = (WSD_PROBE *) pSoap->Body; 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, ok(pSoap->Header.To != NULL && lstrcmpW(pSoap->Header.To, discoveryTo) == 0,
"pSoap->Header.To == '%s'\n", wine_dbgstr_w(pSoap->Header.To)); "pSoap->Header.To == '%s'\n", wine_dbgstr_w(pSoap->Header.To));
ok(pSoap->Header.Action != NULL && lstrcmpW(pSoap->Header.Action, actionProbe) == 0, 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 lager[] = {'L','a','g','e','r',0};
static const WCHAR more_info[] = {'M','o','r','e','I','n','f','o',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) if (probe_msg->Types != NULL)
{ {