
Signed-off-by: Owen Rudge <orudge@codeweavers.com> Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
80 lines
2.6 KiB
C
80 lines
2.6 KiB
C
/*
|
|
* 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"
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(wsdapi);
|
|
|
|
#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;
|
|
HRESULT ret = E_FAIL;
|
|
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;
|
|
|
|
if (remote_address == NULL)
|
|
{
|
|
/* Send the message via UDP multicast */
|
|
if (send_udp_multicast(impl, full_xml, sizeof(xml_header), max_initial_delay))
|
|
ret = S_OK;
|
|
}
|
|
else
|
|
{
|
|
/* TODO: Send the message via UDP unicast */
|
|
FIXME("TODO: Send the message via UDP unicast\n");
|
|
}
|
|
|
|
heap_free(full_xml);
|
|
|
|
return ret;
|
|
}
|
|
|
|
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);
|
|
}
|