From 2d1371001e4053b4d5a922a2f4af86a61ce3b4b6 Mon Sep 17 00:00:00 2001 From: Owen Rudge Date: Wed, 19 Sep 2018 21:29:07 +0100 Subject: [PATCH] wsdapi: Implement matching of names in MatchProbeEx. Signed-off-by: Owen Rudge Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/wsdapi/discovery.c | 58 ++++++++++++++++++++++++++++++++--- dlls/wsdapi/soap.c | 9 ++++++ dlls/wsdapi/wsdapi_internal.h | 6 ++++ 3 files changed, 69 insertions(+), 4 deletions(-) diff --git a/dlls/wsdapi/discovery.c b/dlls/wsdapi/discovery.c index a016e8deac5..fcbdfef2ab2 100644 --- a/dlls/wsdapi/discovery.c +++ b/dlls/wsdapi/discovery.c @@ -233,11 +233,13 @@ static HRESULT WINAPI IWSDiscoveryPublisherImpl_MatchProbe(IWSDiscoveryPublisher const WSD_NAME_LIST *pTypesList, const WSD_URI_LIST *pScopesList, const WSD_URI_LIST *pXAddrsList) { - FIXME("(%p, %p, %p, %s, %s, %s, %s, %s, %p, %p, %p)\n", This, pProbeMessage, pMessageParameters, debugstr_w(pszId), + TRACE("(%p, %p, %p, %s, %s, %s, %s, %s, %p, %p, %p)\n", This, pProbeMessage, pMessageParameters, debugstr_w(pszId), wine_dbgstr_longlong(ullMetadataVersion), wine_dbgstr_longlong(ullInstanceId), wine_dbgstr_longlong(ullMessageNumber), debugstr_w(pszSessionId), pTypesList, pScopesList, pXAddrsList); - return E_NOTIMPL; + return IWSDiscoveryPublisher_MatchProbeEx(This, pProbeMessage, pMessageParameters, pszId, ullMetadataVersion, + ullInstanceId, ullMessageNumber, pszSessionId, pTypesList, pScopesList, pXAddrsList, NULL, NULL, NULL, NULL, + NULL); } static HRESULT WINAPI IWSDiscoveryPublisherImpl_MatchResolve(IWSDiscoveryPublisher *This, const WSD_SOAP_MESSAGE *pResolveMessage, @@ -276,6 +278,24 @@ static HRESULT WINAPI IWSDiscoveryPublisherImpl_PublishEx(IWSDiscoveryPublisher pTypesList, pScopesList, pXAddrsList, pHeaderAny, pReferenceParameterAny, pEndpointReferenceAny, pAny); } +static BOOL is_name_in_list(WSDXML_NAME *name, const WSD_NAME_LIST *list) +{ + const WSD_NAME_LIST *next = list; + + while (next != NULL) + { + if ((lstrcmpW(next->Element->LocalName, name->LocalName) == 0) && + (lstrcmpW(next->Element->Space->PreferredPrefix, name->Space->PreferredPrefix) == 0)) + { + return TRUE; + } + + next = next->Next; + } + + return FALSE; +} + static HRESULT WINAPI IWSDiscoveryPublisherImpl_MatchProbeEx(IWSDiscoveryPublisher *This, const WSD_SOAP_MESSAGE *pProbeMessage, IWSDMessageParameters *pMessageParameters, LPCWSTR pszId, ULONGLONG ullMetadataVersion, ULONGLONG ullInstanceId, ULONGLONG ullMessageNumber, LPCWSTR pszSessionId, @@ -284,11 +304,41 @@ static HRESULT WINAPI IWSDiscoveryPublisherImpl_MatchProbeEx(IWSDiscoveryPublish const WSDXML_ELEMENT *pReferenceParameterAny, const WSDXML_ELEMENT *pPolicyAny, const WSDXML_ELEMENT *pEndpointReferenceAny, const WSDXML_ELEMENT *pAny) { - FIXME("(%p, %p, %p, %s, %s, %s, %s, %s, %p, %p, %p, %p, %p, %p, %p, %p)\n", This, pProbeMessage, pMessageParameters, debugstr_w(pszId), + IWSDiscoveryPublisherImpl *impl = impl_from_IWSDiscoveryPublisher(This); + WSD_NAME_LIST *next_name; + WSD_PROBE *probe_msg; + + TRACE("(%p, %p, %p, %s, %s, %s, %s, %s, %p, %p, %p, %p, %p, %p, %p, %p)\n", This, pProbeMessage, pMessageParameters, debugstr_w(pszId), wine_dbgstr_longlong(ullMetadataVersion), wine_dbgstr_longlong(ullInstanceId), wine_dbgstr_longlong(ullMessageNumber), debugstr_w(pszSessionId), pTypesList, pScopesList, pXAddrsList, pHeaderAny, pReferenceParameterAny, pPolicyAny, pEndpointReferenceAny, pAny); - return E_NOTIMPL; + if (!impl->publisherStarted) return E_ABORT; + + if ((pszId == NULL) || (lstrlenW(pszId) > WSD_MAX_TEXT_LENGTH) || + ((pszSessionId != NULL) && (lstrlenW(pszSessionId) > WSD_MAX_TEXT_LENGTH)) || (pProbeMessage == NULL) || + (pProbeMessage->Body == NULL)) + { + return E_INVALIDARG; + } + + probe_msg = (WSD_PROBE *) pProbeMessage->Body; + next_name = probe_msg->Types; + + /* Verify that all names in the probe message are present in the types list */ + while (next_name != NULL) + { + /* If a name isn't present, return success; we simply don't send a Probe Match message */ + if (!is_name_in_list(next_name->Element, pTypesList)) return S_OK; + + next_name = next_name->Next; + } + + if ((probe_msg->Scopes != NULL) && (probe_msg->Scopes->Scopes != NULL)) + FIXME("Scopes matching currently unimplemented\n"); + + return send_probe_matches_message(impl, pProbeMessage, pMessageParameters, pszId, ullMetadataVersion, ullInstanceId, + ullMessageNumber, pszSessionId, pTypesList, pScopesList, pXAddrsList, pHeaderAny, pReferenceParameterAny, + pEndpointReferenceAny, pAny); } static HRESULT WINAPI IWSDiscoveryPublisherImpl_MatchResolveEx(IWSDiscoveryPublisher *This, const WSD_SOAP_MESSAGE *pResolveMessage, diff --git a/dlls/wsdapi/soap.c b/dlls/wsdapi/soap.c index e2746b98337..ef191a4ab6e 100644 --- a/dlls/wsdapi/soap.c +++ b/dlls/wsdapi/soap.c @@ -1110,6 +1110,15 @@ cleanup: return ret; } +HRESULT send_probe_matches_message(IWSDiscoveryPublisherImpl *impl, const WSD_SOAP_MESSAGE *probe_msg, + IWSDMessageParameters *message_params, LPCWSTR id, ULONGLONG metadata_ver, ULONGLONG instance_id, + ULONGLONG msg_num, LPCWSTR session_id, const WSD_NAME_LIST *types_list, const WSD_URI_LIST *scopes_list, + const WSD_URI_LIST *xaddrs_list, const WSDXML_ELEMENT *header_any, const WSDXML_ELEMENT *ref_param_any, + const WSDXML_ELEMENT *endpoint_ref_any, const WSDXML_ELEMENT *any) +{ + return E_NOTIMPL; +} + static LPWSTR xml_text_to_wide_string(void *parent_memory, WS_XML_TEXT *text) { if (text->textType == WS_XML_TEXT_TYPE_UTF8) diff --git a/dlls/wsdapi/wsdapi_internal.h b/dlls/wsdapi/wsdapi_internal.h index 3c9390a899e..a2b89026b28 100644 --- a/dlls/wsdapi/wsdapi_internal.h +++ b/dlls/wsdapi/wsdapi_internal.h @@ -78,6 +78,12 @@ HRESULT send_hello_message(IWSDiscoveryPublisherImpl *impl, LPCWSTR id, ULONGLON HRESULT send_bye_message(IWSDiscoveryPublisherImpl *impl, LPCWSTR id, ULONGLONG instance_id, ULONGLONG msg_num, LPCWSTR session_id, const WSDXML_ELEMENT *any); +HRESULT send_probe_matches_message(IWSDiscoveryPublisherImpl *impl, const WSD_SOAP_MESSAGE *probe_msg, + IWSDMessageParameters *message_params, LPCWSTR id, ULONGLONG metadata_ver, ULONGLONG instance_id, + ULONGLONG msg_num, LPCWSTR session_id, const WSD_NAME_LIST *types_list, const WSD_URI_LIST *scopes_list, + const WSD_URI_LIST *xaddrs_list, const WSDXML_ELEMENT *header_any, const WSDXML_ELEMENT *ref_param_any, + const WSDXML_ELEMENT *endpoint_ref_any, const WSDXML_ELEMENT *any); + HRESULT register_namespaces(IWSDXMLContext *xml_context); HRESULT read_message(IWSDiscoveryPublisherImpl *impl, const char *xml, int xml_length, WSD_SOAP_MESSAGE **out_msg,