webservices: Use public channel functions in the service proxy implementation.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2016-09-28 12:38:01 +02:00 committed by Alexandre Julliard
parent e4fd90596d
commit c8a1b56c47
3 changed files with 37 additions and 35 deletions

View File

@ -84,6 +84,15 @@ static const struct prop_desc channel_props[] =
{ sizeof(ULONG), FALSE } /* WS_CHANNEL_PROPERTY_MAX_HTTP_REQUEST_HEADERS_BUFFER_SIZE */
};
struct channel
{
WS_CHANNEL_TYPE type;
WS_CHANNEL_BINDING binding;
WS_CHANNEL_STATE state;
ULONG prop_count;
struct prop prop[sizeof(channel_props)/sizeof(channel_props[0])];
};
static struct channel *alloc_channel(void)
{
static const ULONG count = sizeof(channel_props)/sizeof(channel_props[0]);
@ -96,13 +105,14 @@ static struct channel *alloc_channel(void)
return ret;
}
void free_channel( struct channel *channel )
static void free_channel( struct channel *channel )
{
if (!channel) return;
heap_free( channel );
}
HRESULT create_channel( WS_CHANNEL_TYPE type, WS_CHANNEL_BINDING binding,
const WS_CHANNEL_PROPERTY *properties, ULONG count, struct channel **ret )
static HRESULT create_channel( WS_CHANNEL_TYPE type, WS_CHANNEL_BINDING binding,
const WS_CHANNEL_PROPERTY *properties, ULONG count, struct channel **ret )
{
struct channel *channel;
ULONG i, msg_size = 65536;
@ -207,8 +217,14 @@ HRESULT WINAPI WsSetChannelProperty( WS_CHANNEL *handle, WS_CHANNEL_PROPERTY_ID
return prop_set( channel->prop, channel->prop_count, id, value, size );
}
HRESULT open_channel( struct channel *channel, const WS_ENDPOINT_ADDRESS *endpoint )
static HRESULT open_channel( struct channel *channel, const WS_ENDPOINT_ADDRESS *endpoint )
{
if (endpoint->headers || endpoint->extensions || endpoint->identity)
{
FIXME( "headers, extensions or identity not supported\n" );
return E_NOTIMPL;
}
channel->state = WS_CHANNEL_STATE_OPEN;
return S_OK;
}
@ -231,7 +247,7 @@ HRESULT WINAPI WsOpenChannel( WS_CHANNEL *handle, const WS_ENDPOINT_ADDRESS *end
return open_channel( channel, endpoint );
}
HRESULT close_channel( struct channel *channel )
static HRESULT close_channel( struct channel *channel )
{
channel->state = WS_CHANNEL_STATE_CLOSED;
return S_OK;

View File

@ -43,7 +43,7 @@ static const struct prop_desc proxy_props[] =
struct proxy
{
struct channel *channel;
WS_CHANNEL *channel;
ULONG prop_count;
struct prop prop[sizeof(proxy_props)/sizeof(proxy_props[0])];
};
@ -62,11 +62,12 @@ static struct proxy *alloc_proxy(void)
static void free_proxy( struct proxy *proxy )
{
free_channel( proxy->channel );
if (!proxy) return;
WsFreeChannel( proxy->channel );
heap_free( proxy );
}
static HRESULT create_proxy( struct channel *channel, const WS_PROXY_PROPERTY *properties, ULONG count,
static HRESULT create_proxy( WS_CHANNEL *channel, const WS_PROXY_PROPERTY *properties, ULONG count,
WS_SERVICE_PROXY **handle )
{
struct proxy *proxy;
@ -102,7 +103,7 @@ HRESULT WINAPI WsCreateServiceProxy( const WS_CHANNEL_TYPE type, const WS_CHANNE
const ULONG channel_props_count, WS_SERVICE_PROXY **handle,
WS_ERROR *error )
{
struct channel *channel;
WS_CHANNEL *channel;
HRESULT hr;
TRACE( "%u %u %p %p %u %p %u %p %p\n", type, binding, desc, proxy_props, proxy_props_count,
@ -112,11 +113,11 @@ HRESULT WINAPI WsCreateServiceProxy( const WS_CHANNEL_TYPE type, const WS_CHANNE
if (!handle) return E_INVALIDARG;
if ((hr = create_channel( type, binding, channel_props, channel_props_count, &channel )) != S_OK)
return hr;
if ((hr = WsCreateChannel( type, binding, channel_props, channel_props_count, NULL, &channel,
NULL )) != S_OK) return hr;
if ((hr = create_proxy( channel, proxy_props, proxy_props_count, handle )) != S_OK)
free_channel( channel );
WsFreeChannel( channel );
return hr;
}
@ -133,7 +134,7 @@ HRESULT WINAPI WsCreateServiceProxyFromTemplate( WS_CHANNEL_TYPE channel_type,
const WS_CHANNEL_PROPERTY *channel_props = NULL;
ULONG channel_props_count = 0;
WS_CHANNEL_BINDING binding;
struct channel *channel;
WS_CHANNEL *channel;
HRESULT hr;
TRACE( "%u %p %u %u %p %u %p %u %p %p\n", channel_type, properties, count, type, value, size, desc,
@ -172,12 +173,10 @@ HRESULT WINAPI WsCreateServiceProxyFromTemplate( WS_CHANNEL_TYPE channel_type,
return E_NOTIMPL;
}
if ((hr = create_channel( channel_type, binding, channel_props, channel_props_count, &channel )) != S_OK)
return hr;
if ((hr = create_proxy( channel, properties, count, handle )) != S_OK)
free_channel( channel );
if ((hr = WsCreateChannel( channel_type, binding, channel_props, channel_props_count, NULL,
&channel, NULL )) != S_OK) return hr;
if ((hr = create_proxy( channel, properties, count, handle )) != S_OK) WsFreeChannel( channel );
return hr;
}
@ -218,7 +217,8 @@ HRESULT WINAPI WsOpenServiceProxy( WS_SERVICE_PROXY *handle, const WS_ENDPOINT_A
if (error) FIXME( "ignoring error parameter\n" );
if (ctx) FIXME( "ignoring ctx parameter\n" );
return open_channel( proxy->channel, endpoint );
if (!handle || !endpoint) return E_INVALIDARG;
return WsOpenChannel( proxy->channel, endpoint, NULL, NULL );
}
/**************************************************************************
@ -232,7 +232,8 @@ HRESULT WINAPI WsCloseServiceProxy( WS_SERVICE_PROXY *handle, const WS_ASYNC_CON
if (error) FIXME( "ignoring error parameter\n" );
if (ctx) FIXME( "ignoring ctx parameter\n" );
return close_channel( proxy->channel );
if (!handle) return E_INVALIDARG;
return WsCloseChannel( proxy->channel, NULL, NULL );
}
/**************************************************************************

View File

@ -90,21 +90,6 @@ void prop_init( const struct prop_desc *, ULONG, struct prop *, void * ) DECLSPE
HRESULT prop_set( const struct prop *, ULONG, ULONG, const void *, ULONG ) DECLSPEC_HIDDEN;
HRESULT prop_get( const struct prop *, ULONG, ULONG, void *, ULONG ) DECLSPEC_HIDDEN;
struct channel
{
WS_CHANNEL_TYPE type;
WS_CHANNEL_BINDING binding;
WS_CHANNEL_STATE state;
ULONG prop_count;
struct prop prop[50];
};
HRESULT create_channel( WS_CHANNEL_TYPE, WS_CHANNEL_BINDING, const WS_CHANNEL_PROPERTY *,
ULONG, struct channel ** ) DECLSPEC_HIDDEN;
void free_channel( struct channel * ) DECLSPEC_HIDDEN;
HRESULT open_channel( struct channel *, const WS_ENDPOINT_ADDRESS * ) DECLSPEC_HIDDEN;
HRESULT close_channel( struct channel * ) DECLSPEC_HIDDEN;
static inline BOOL is_nil_value( const char *value, ULONG size )
{
ULONG i;