Commit 9cacff8e authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

webservices: Implement WsCreateChannelForListener.

parent 823aa24f
......@@ -213,8 +213,35 @@ HRESULT WINAPI WsCreateChannel( WS_CHANNEL_TYPE type, WS_CHANNEL_BINDING binding
return E_NOTIMPL;
}
if ((hr = create_channel( type, binding, properties, count, &channel )) != S_OK)
return hr;
if ((hr = create_channel( type, binding, properties, count, &channel )) != S_OK) return hr;
*handle = (WS_CHANNEL *)channel;
return S_OK;
}
/**************************************************************************
* WsCreateChannelForListener [webservices.@]
*/
HRESULT WINAPI WsCreateChannelForListener( WS_LISTENER *listener_handle, const WS_CHANNEL_PROPERTY *properties,
ULONG count, WS_CHANNEL **handle, WS_ERROR *error )
{
struct channel *channel;
WS_CHANNEL_TYPE type;
WS_CHANNEL_BINDING binding;
HRESULT hr;
TRACE( "%p %p %u %p %p\n", listener_handle, properties, count, handle, error );
if (error) FIXME( "ignoring error parameter\n" );
if (!listener_handle || !handle) return E_INVALIDARG;
if ((hr = WsGetListenerProperty( listener_handle, WS_LISTENER_PROPERTY_CHANNEL_TYPE, &type,
sizeof(type), NULL )) != S_OK) return hr;
if ((hr = WsGetListenerProperty( listener_handle, WS_LISTENER_PROPERTY_CHANNEL_BINDING, &binding,
sizeof(binding), NULL )) != S_OK) return hr;
if ((hr = create_channel( type, binding, properties, count, &channel )) != S_OK) return hr;
*handle = (WS_CHANNEL *)channel;
return S_OK;
......@@ -393,11 +420,10 @@ HRESULT WINAPI WsOpenChannel( WS_CHANNEL *handle, const WS_ENDPOINT_ADDRESS *end
return hr;
}
static HRESULT close_channel( struct channel *channel )
static void close_channel( struct channel *channel )
{
reset_channel( channel );
channel->state = WS_CHANNEL_STATE_CLOSED;
return S_OK;
}
/**************************************************************************
......@@ -406,7 +432,6 @@ static HRESULT close_channel( struct channel *channel )
HRESULT WINAPI WsCloseChannel( WS_CHANNEL *handle, const WS_ASYNC_CONTEXT *ctx, WS_ERROR *error )
{
struct channel *channel = (struct channel *)handle;
HRESULT hr;
TRACE( "%p %p %p\n", handle, ctx, error );
if (error) FIXME( "ignoring error parameter\n" );
......@@ -422,10 +447,10 @@ HRESULT WINAPI WsCloseChannel( WS_CHANNEL *handle, const WS_ASYNC_CONTEXT *ctx,
return E_INVALIDARG;
}
hr = close_channel( channel );
close_channel( channel );
LeaveCriticalSection( &channel->cs );
return hr;
return S_OK;
}
static HRESULT parse_url( const WCHAR *url, ULONG len, URL_COMPONENTS *uc )
......
......@@ -154,8 +154,45 @@ static void test_WsOpenListener(void)
WsFreeListener( listener );
}
static void test_WsCreateChannelForListener(void)
{
WS_LISTENER *listener;
WS_CHANNEL *channel;
WS_CHANNEL_TYPE type;
WS_CHANNEL_STATE state;
HRESULT hr;
hr = WsCreateChannelForListener( NULL, NULL, 0, NULL, NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
hr = WsCreateChannelForListener( NULL, NULL, 0, &channel, NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
hr = WsCreateListener( WS_CHANNEL_TYPE_DUPLEX_SESSION, WS_TCP_CHANNEL_BINDING, NULL, 0, NULL, &listener, NULL );
ok( hr == S_OK, "got %08x\n", hr );
channel = NULL;
hr = WsCreateChannelForListener( listener, NULL, 0, &channel, NULL );
ok( hr == S_OK, "got %08x\n", hr );
ok( channel != NULL, "channel not set\n" );
type = 0xdeadbeef;
hr = WsGetChannelProperty( channel, WS_CHANNEL_PROPERTY_CHANNEL_TYPE, &type, sizeof(type), NULL );
ok( hr == S_OK, "got %08x\n", hr );
ok( type == WS_CHANNEL_TYPE_DUPLEX_SESSION, "got %u\n", type );
state = 0xdeadbeef;
hr = WsGetChannelProperty( channel, WS_CHANNEL_PROPERTY_STATE, &state, sizeof(state), NULL );
ok( hr == S_OK, "got %08x\n", hr );
ok( state == WS_CHANNEL_STATE_CREATED, "got %u\n", state );
WsFreeChannel( channel );
WsFreeListener( listener );
}
START_TEST(listener)
{
test_WsCreateListener();
test_WsOpenListener();
test_WsCreateChannelForListener();
}
......@@ -21,7 +21,7 @@
@ stub WsCopyError
@ stdcall WsCopyNode(ptr ptr ptr)
@ stdcall WsCreateChannel(long long ptr long ptr ptr ptr)
@ stub WsCreateChannelForListener
@ stdcall WsCreateChannelForListener(ptr ptr long ptr ptr)
@ stdcall WsCreateError(ptr long ptr)
@ stub WsCreateFaultFromError
@ stdcall WsCreateHeap(long long ptr long ptr ptr)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment