[4/7] webservices: Implement WsResetServiceProxy.

Hans Leidekker hans at codeweavers.com
Wed Apr 5 04:40:24 CDT 2017


Signed-off-by: Hans Leidekker <hans at codeweavers.com>
---
 dlls/webservices/proxy.c          | 40 +++++++++++++++++++++++++++++++++++
 dlls/webservices/tests/proxy.c    | 44 +++++++++++++++++++++++++++++++++++++++
 dlls/webservices/webservices.spec |  2 +-
 include/webservices.h             |  1 +
 4 files changed, 86 insertions(+), 1 deletion(-)

diff --git a/dlls/webservices/proxy.c b/dlls/webservices/proxy.c
index ac8387a..d9821c7 100644
--- a/dlls/webservices/proxy.c
+++ b/dlls/webservices/proxy.c
@@ -70,9 +70,17 @@ static struct proxy *alloc_proxy(void)
     return ret;
 }
 
+static void reset_proxy( struct proxy *proxy )
+{
+    WsResetChannel( proxy->channel, NULL );
+    proxy->state = WS_SERVICE_PROXY_STATE_CREATED;
+}
+
 static void free_proxy( struct proxy *proxy )
 {
+    reset_proxy( proxy );
     WsFreeChannel( proxy->channel );
+
     proxy->cs.DebugInfo->Spare[0] = 0;
     DeleteCriticalSection( &proxy->cs );
     heap_free( proxy );
@@ -192,6 +200,38 @@ HRESULT WINAPI WsCreateServiceProxyFromTemplate( WS_CHANNEL_TYPE channel_type,
 }
 
 /**************************************************************************
+ *          WsResetServiceProxy		[webservices.@]
+ */
+HRESULT WINAPI WsResetServiceProxy( WS_SERVICE_PROXY *handle, WS_ERROR *error )
+{
+    struct proxy *proxy = (struct proxy *)handle;
+
+    TRACE( "%p %p\n", handle, error );
+    if (error) FIXME( "ignoring error parameter\n" );
+
+    if (!proxy) return E_INVALIDARG;
+
+    EnterCriticalSection( &proxy->cs );
+
+    if (proxy->magic != PROXY_MAGIC)
+    {
+        LeaveCriticalSection( &proxy->cs );
+        return E_INVALIDARG;
+    }
+
+    if (proxy->state != WS_SERVICE_PROXY_STATE_CREATED && proxy->state != WS_SERVICE_PROXY_STATE_CLOSED)
+    {
+        LeaveCriticalSection( &proxy->cs );
+        return WS_E_INVALID_OPERATION;
+    }
+
+    reset_proxy( proxy );
+
+    LeaveCriticalSection( &proxy->cs );
+    return S_OK;
+}
+
+/**************************************************************************
  *          WsFreeServiceProxy		[webservices.@]
  */
 void WINAPI WsFreeServiceProxy( WS_SERVICE_PROXY *handle )
diff --git a/dlls/webservices/tests/proxy.c b/dlls/webservices/tests/proxy.c
index 9351d2d..bc7ef81 100644
--- a/dlls/webservices/tests/proxy.c
+++ b/dlls/webservices/tests/proxy.c
@@ -185,6 +185,49 @@ static void test_WsOpenServiceProxy(void)
     WsFreeServiceProxy( proxy );
 }
 
+static void test_WsResetServiceProxy(void)
+{
+    WCHAR url[] = {'h','t','t','p',':','/','/','l','o','c','a','l','h','o','s','t','/'};
+    HRESULT hr;
+    WS_SERVICE_PROXY *proxy;
+    WS_ENDPOINT_ADDRESS addr;
+    WS_SERVICE_PROXY_STATE state;
+
+    hr = WsCreateServiceProxy( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, NULL,
+                               0, NULL, 0, &proxy, NULL );
+    ok( hr == S_OK, "got %08x\n", hr );
+
+    hr = WsResetServiceProxy( proxy, NULL );
+    ok( hr == S_OK, "got %08x\n", hr );
+
+    state = 0xdeadbeef;
+    hr = WsGetServiceProxyProperty( proxy, WS_PROXY_PROPERTY_STATE, &state, sizeof(state), NULL );
+    ok( hr == S_OK, "got %08x\n", hr );
+    ok( state == WS_SERVICE_PROXY_STATE_CREATED, "got %u\n", state );
+
+    memset( &addr, 0, sizeof(addr) );
+    addr.url.length = sizeof(url)/sizeof(url[0]);
+    addr.url.chars  = url;
+    hr = WsOpenServiceProxy( proxy, &addr, NULL, NULL );
+    ok( hr == S_OK, "got %08x\n", hr );
+
+    hr = WsResetServiceProxy( proxy, NULL );
+    ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
+
+    hr = WsCloseServiceProxy( proxy , NULL, NULL );
+    ok( hr == S_OK, "got %08x\n", hr );
+
+    hr = WsResetServiceProxy( proxy, NULL );
+    ok( hr == S_OK, "got %08x\n", hr );
+
+    state = 0xdeadbeef;
+    hr = WsGetServiceProxyProperty( proxy, WS_PROXY_PROPERTY_STATE, &state, sizeof(state), NULL );
+    ok( hr == S_OK, "got %08x\n", hr );
+    ok( state == WS_SERVICE_PROXY_STATE_CREATED, "got %u\n", state );
+
+    WsFreeServiceProxy( proxy );
+}
+
 static HRESULT create_channel( int port, WS_CHANNEL **ret )
 {
     static const WCHAR fmt[] =
@@ -680,6 +723,7 @@ START_TEST(proxy)
     test_WsCreateServiceProxy();
     test_WsCreateServiceProxyFromTemplate();
     test_WsOpenServiceProxy();
+    test_WsResetServiceProxy();
 
     info.port  = 7533;
     info.event = CreateEventW( NULL, 0, 0, NULL );
diff --git a/dlls/webservices/webservices.spec b/dlls/webservices/webservices.spec
index 0a3057d..def0cca 100644
--- a/dlls/webservices/webservices.spec
+++ b/dlls/webservices/webservices.spec
@@ -140,7 +140,7 @@
 @ stdcall WsResetMessage(ptr ptr)
 @ stub WsResetMetadata
 @ stub WsResetServiceHost
-@ stub WsResetServiceProxy
+@ stdcall WsResetServiceProxy(ptr ptr)
 @ stub WsRevokeSecurityContext
 @ stub WsSendFaultMessageForError
 @ stdcall WsSendMessage(ptr ptr ptr long ptr long ptr ptr)
diff --git a/include/webservices.h b/include/webservices.h
index 9f1d989..783a6ae 100644
--- a/include/webservices.h
+++ b/include/webservices.h
@@ -1631,6 +1631,7 @@ HRESULT WINAPI WsResetError(WS_ERROR*);
 HRESULT WINAPI WsResetHeap(WS_HEAP*, WS_ERROR*);
 HRESULT WINAPI WsResetListener(WS_LISTENER*, WS_ERROR*);
 HRESULT WINAPI WsResetMessage(WS_MESSAGE*, WS_ERROR*);
+HRESULT WINAPI WsResetServiceProxy(WS_SERVICE_PROXY*, WS_ERROR*);
 HRESULT WINAPI WsRequestReply(WS_CHANNEL*, WS_MESSAGE*, const WS_MESSAGE_DESCRIPTION*, WS_WRITE_OPTION,
                               const void*, ULONG, WS_MESSAGE*, const WS_MESSAGE_DESCRIPTION*,
                               WS_READ_OPTION, WS_HEAP*, void*, ULONG, const WS_ASYNC_CONTEXT*, WS_ERROR*);
-- 
2.1.4




More information about the wine-patches mailing list