Module: wine Branch: master Commit: 81e4dbcdac81c437f584520a997157f8c24eafce URL: https://source.winehq.org/git/wine.git/?a=commit;h=81e4dbcdac81c437f584520a9...
Author: Owen Rudge orudge@codeweavers.com Date: Mon Mar 19 21:46:08 2018 +0000
wsdapi: Add stub implementation of IWSDiscoveryPublisher_PublishEx.
Signed-off-by: Owen Rudge orudge@codeweavers.com Signed-off-by: Huw Davies huw@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/wsdapi/Makefile.in | 1 + dlls/wsdapi/discovery.c | 40 +++++++++----------------- dlls/wsdapi/soap.c | 66 +++++++++++++++++++++++++++++++++++++++++++ dlls/wsdapi/wsdapi_internal.h | 24 ++++++++++++++++ 4 files changed, 105 insertions(+), 26 deletions(-)
diff --git a/dlls/wsdapi/Makefile.in b/dlls/wsdapi/Makefile.in index 5c95351..155d004 100644 --- a/dlls/wsdapi/Makefile.in +++ b/dlls/wsdapi/Makefile.in @@ -8,4 +8,5 @@ C_SRCS = \ main.c \ memory.c \ msgparams.c \ + soap.c \ xml.c diff --git a/dlls/wsdapi/discovery.c b/dlls/wsdapi/discovery.c index 82a1ca0..7fa417b 100644 --- a/dlls/wsdapi/discovery.c +++ b/dlls/wsdapi/discovery.c @@ -23,30 +23,12 @@ #define COBJMACROS #define INITGUID
-#include "windef.h" -#include "winbase.h" +#include "wsdapi_internal.h" #include "wine/debug.h" -#include "wine/list.h" -#include "objbase.h" #include "guiddef.h" -#include "wsdapi.h"
WINE_DEFAULT_DEBUG_CHANNEL(wsdapi);
-struct notificationSink -{ - struct list entry; - IWSDiscoveryPublisherNotify *notificationSink; -}; - -typedef struct IWSDiscoveryPublisherImpl { - IWSDiscoveryPublisher IWSDiscoveryPublisher_iface; - LONG ref; - IWSDXMLContext *xmlContext; - DWORD addressFamily; - struct list notificationSinks; -} IWSDiscoveryPublisherImpl; - static inline IWSDiscoveryPublisherImpl *impl_from_IWSDiscoveryPublisher(IWSDiscoveryPublisher *iface) { return CONTAINING_RECORD(iface, IWSDiscoveryPublisherImpl, IWSDiscoveryPublisher_iface); @@ -200,10 +182,8 @@ static HRESULT WINAPI IWSDiscoveryPublisherImpl_Publish(IWSDiscoveryPublisher *T ULONGLONG ullMessageNumber, LPCWSTR pszSessionId, const WSD_NAME_LIST *pTypesList, const WSD_URI_LIST *pScopesList, const WSD_URI_LIST *pXAddrsList) { - FIXME("(%p, %s, %s, %s, %s, %s, %p, %p, %p)\n", This, 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_PublishEx(This, pszId, ullMetadataVersion, ullInstanceId, ullMessageNumber, + pszSessionId, pTypesList, pScopesList, pXAddrsList, NULL, NULL, NULL, NULL, NULL); }
static HRESULT WINAPI IWSDiscoveryPublisherImpl_UnPublish(IWSDiscoveryPublisher *This, LPCWSTR pszId, ULONGLONG ullInstanceId, ULONGLONG ullMessageNumber, @@ -248,13 +228,21 @@ static HRESULT WINAPI IWSDiscoveryPublisherImpl_PublishEx(IWSDiscoveryPublisher const WSDXML_ELEMENT *pReferenceParameterAny, const WSDXML_ELEMENT *pPolicyAny, const WSDXML_ELEMENT *pEndpointReferenceAny, const WSDXML_ELEMENT *pAny) { - FIXME("(%p, %s, %s, %s, %s, %s, %p, %p, %p, %p, %p, %p, %p, %p)\n", This, debugstr_w(pszId), wine_dbgstr_longlong(ullMetadataVersion), + IWSDiscoveryPublisherImpl *impl = impl_from_IWSDiscoveryPublisher(This); + + TRACE("(%p, %s, %s, %s, %s, %s, %p, %p, %p, %p, %p, %p, %p, %p)\n", This, 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) || (pszId == NULL) || (lstrlenW(pszId) > WSD_MAX_TEXT_LENGTH) || + ((pszSessionId != NULL) && (lstrlenW(pszSessionId) > WSD_MAX_TEXT_LENGTH))) + { + return E_INVALIDARG; + }
+ return send_hello_message(impl, pszId, ullMetadataVersion, ullInstanceId, ullMessageNumber, pszSessionId, + pTypesList, pScopesList, pXAddrsList, pHeaderAny, pReferenceParameterAny, pEndpointReferenceAny, pAny); +}
static HRESULT WINAPI IWSDiscoveryPublisherImpl_MatchProbeEx(IWSDiscoveryPublisher *This, const WSD_SOAP_MESSAGE *pProbeMessage, IWSDMessageParameters *pMessageParameters, LPCWSTR pszId, ULONGLONG ullMetadataVersion, diff --git a/dlls/wsdapi/soap.c b/dlls/wsdapi/soap.c new file mode 100644 index 0000000..0cc2580 --- /dev/null +++ b/dlls/wsdapi/soap.c @@ -0,0 +1,66 @@ +/* + * Web Services on Devices + * + * Copyright 2017-2018 Owen Rudge for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <stdarg.h> +#include <limits.h> + +#define COBJMACROS + +#include "wsdapi_internal.h" +#include "wine/debug.h" +#include "wine/heap.h" + +#define APP_MAX_DELAY 500 + +static HRESULT write_and_send_message(IWSDiscoveryPublisherImpl *impl, WSD_SOAP_HEADER *header, WSDXML_ELEMENT *body_element, + struct list *discovered_namespaces, IWSDUdpAddress *remote_address, int max_initial_delay) +{ + static const char xml_header[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"; + ULONG xml_header_len = sizeof(xml_header) - 1; + char *full_xml; + + /* TODO: Create SOAP envelope */ + + /* Prefix the XML header */ + full_xml = heap_alloc(xml_header_len + 1); + + if (full_xml == NULL) + return E_OUTOFMEMORY; + + memcpy(full_xml, xml_header, xml_header_len); + full_xml[xml_header_len] = 0; + + /* TODO: Send the message */ + + heap_free(full_xml); + + return S_OK; +} + +HRESULT send_hello_message(IWSDiscoveryPublisherImpl *impl, 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 *hdr_any, const WSDXML_ELEMENT *ref_param_any, + const WSDXML_ELEMENT *endpoint_ref_any, const WSDXML_ELEMENT *any) +{ + /* TODO: Populate message body */ + + /* Write and send the message */ + return write_and_send_message(impl, NULL, NULL, NULL, NULL, APP_MAX_DELAY); +} diff --git a/dlls/wsdapi/wsdapi_internal.h b/dlls/wsdapi/wsdapi_internal.h index 22de4a8..631dfb3 100644 --- a/dlls/wsdapi/wsdapi_internal.h +++ b/dlls/wsdapi/wsdapi_internal.h @@ -32,4 +32,28 @@
#define WSD_MAX_TEXT_LENGTH 8192
+/* discovery.c */ + +struct notificationSink +{ + struct list entry; + IWSDiscoveryPublisherNotify *notificationSink; +}; + +typedef struct IWSDiscoveryPublisherImpl { + IWSDiscoveryPublisher IWSDiscoveryPublisher_iface; + LONG ref; + IWSDXMLContext *xmlContext; + DWORD addressFamily; + struct list notificationSinks; + BOOL publisherStarted; +} IWSDiscoveryPublisherImpl; + +/* soap.c */ + +HRESULT send_hello_message(IWSDiscoveryPublisherImpl *impl, 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 *hdr_any, const WSDXML_ELEMENT *ref_param_any, + const WSDXML_ELEMENT *endpoint_ref_any, const WSDXML_ELEMENT *any); + #endif