Module: wine Branch: master Commit: be767562ae230a7e21b840947c6b9b008ed179e9 URL: http://source.winehq.org/git/wine.git/?a=commit;h=be767562ae230a7e21b840947c...
Author: Hans Leidekker hans@codeweavers.com Date: Fri Apr 22 09:42:45 2016 +0200
webservices: Implement WsOpenChannel and WsCloseChannel.
Signed-off-by: Hans Leidekker hans@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/webservices/channel.c | 44 ++++++++++++++++++++++++++++++++++ dlls/webservices/tests/channel.c | 40 +++++++++++++++++++++++++++++++ dlls/webservices/webservices.spec | 4 ++-- dlls/webservices/webservices_private.h | 3 +++ 4 files changed, 89 insertions(+), 2 deletions(-)
diff --git a/dlls/webservices/channel.c b/dlls/webservices/channel.c index d02bfa1..9081d95 100644 --- a/dlls/webservices/channel.c +++ b/dlls/webservices/channel.c @@ -162,3 +162,47 @@ 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 ) +{ + channel->state = WS_CHANNEL_STATE_OPEN; + return S_OK; +} + +/************************************************************************** + * WsOpenChannel [webservices.@] + */ +HRESULT WINAPI WsOpenChannel( WS_CHANNEL *handle, const WS_ENDPOINT_ADDRESS *endpoint, + const WS_ASYNC_CONTEXT *ctx, WS_ERROR *error ) +{ + struct channel *channel = (struct channel *)handle; + + TRACE( "%p %p %p %p\n", handle, endpoint, ctx, error ); + if (error) FIXME( "ignoring error parameter\n" ); + if (ctx) FIXME( "ignoring ctx parameter\n" ); + + if (!endpoint) return E_INVALIDARG; + if (channel->state != WS_CHANNEL_STATE_CREATED) return WS_E_INVALID_OPERATION; + + return open_channel( channel, endpoint ); +} + +HRESULT close_channel( struct channel *channel ) +{ + channel->state = WS_CHANNEL_STATE_CLOSED; + return S_OK; +} + +/************************************************************************** + * WsCloseChannel [webservices.@] + */ +HRESULT WINAPI WsCloseChannel( WS_CHANNEL *handle, const WS_ASYNC_CONTEXT *ctx, WS_ERROR *error ) +{ + struct channel *channel = (struct channel *)handle; + + TRACE( "%p %p %p\n", handle, ctx, error ); + if (error) FIXME( "ignoring error parameter\n" ); + if (ctx) FIXME( "ignoring ctx parameter\n" ); + + return close_channel( channel ); +} diff --git a/dlls/webservices/tests/channel.c b/dlls/webservices/tests/channel.c index 82a7a69..d85a151 100644 --- a/dlls/webservices/tests/channel.c +++ b/dlls/webservices/tests/channel.c @@ -57,7 +57,47 @@ static void test_WsCreateChannel(void) WsFreeChannel( channel ); }
+static void test_WsOpenChannel(void) +{ + WCHAR url[] = {'h','t','t','p',':','/','/','l','o','c','a','l','h','o','s','t'}; + HRESULT hr; + WS_CHANNEL *channel; + WS_ENDPOINT_ADDRESS addr; + + hr = WsCreateChannel( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, 0, NULL, &channel, NULL ) ; + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsCloseChannel( channel, NULL, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + WsFreeChannel( channel ); + + hr = WsCreateChannel( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, 0, NULL, &channel, NULL ) ; + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsOpenChannel( channel, NULL, NULL, NULL ); + ok( hr == E_INVALIDARG, "got %08x\n", hr ); + + addr.url.length = sizeof(url)/sizeof(url[0]); + addr.url.chars = url; + addr.headers = NULL; + addr.extensions = NULL; + addr.identity = NULL; + hr = WsOpenChannel( channel, &addr, NULL, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsOpenChannel( channel, &addr, NULL, NULL ); + ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr ); + + hr = WsCloseChannel( channel, NULL, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsCloseChannel( channel, NULL, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + WsFreeChannel( channel ); +} + START_TEST(channel) { test_WsCreateChannel(); + test_WsOpenChannel(); } diff --git a/dlls/webservices/webservices.spec b/dlls/webservices/webservices.spec index b39f715..95a8c1f 100644 --- a/dlls/webservices/webservices.spec +++ b/dlls/webservices/webservices.spec @@ -13,7 +13,7 @@ @ stub WsAsyncExecute @ stub WsCall @ stub WsCheckMustUnderstandHeaders -@ stub WsCloseChannel +@ stdcall WsCloseChannel(ptr ptr ptr) @ stub WsCloseListener @ stub WsCloseServiceHost @ stub WsCloseServiceProxy @@ -95,7 +95,7 @@ @ stub WsMatchPolicyAlternative @ stdcall WsMoveReader(ptr long ptr ptr) @ stub WsMoveWriter -@ stub WsOpenChannel +@ stdcall WsOpenChannel(ptr ptr ptr ptr) @ stub WsOpenListener @ stub WsOpenServiceHost @ stub WsOpenServiceProxy diff --git a/dlls/webservices/webservices_private.h b/dlls/webservices/webservices_private.h index 1a7b729..c33038d 100644 --- a/dlls/webservices/webservices_private.h +++ b/dlls/webservices/webservices_private.h @@ -74,6 +74,7 @@ struct channel { WS_CHANNEL_TYPE type; WS_CHANNEL_BINDING binding; + WS_CHANNEL_STATE state; ULONG prop_count; struct prop prop[9]; }; @@ -81,6 +82,8 @@ struct channel 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 void *heap_alloc( SIZE_T size ) {