webservices: Add a stub implementation of WS_TYPE_ATTRIBUTE_FIELD_MAPPING in the...
[wine.git] / dlls / webservices / proxy.c
blob96ac1adb265ee2437d8b4d352bda5abceb268a98
1 /*
2 * Copyright 2016 Hans Leidekker for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdio.h>
20 #include <stdarg.h>
22 #include "windef.h"
23 #include "winbase.h"
24 #include "winuser.h"
25 #include "webservices.h"
27 #include "wine/debug.h"
28 #include "wine/list.h"
29 #include "webservices_private.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(webservices);
33 static const struct prop_desc proxy_props[] =
35 { sizeof(ULONG), FALSE, TRUE }, /* WS_PROXY_PROPERTY_CALL_TIMEOUT */
36 { sizeof(WS_MESSAGE_PROPERTIES), FALSE }, /* WS_PROXY_PROPERTY_MESSAGE_PROPERTIES */
37 { sizeof(USHORT), FALSE, TRUE }, /* WS_PROXY_PROPERTY_MAX_CALL_POOL_SIZE */
38 { sizeof(WS_SERVICE_PROXY_STATE), TRUE }, /* WS_PROXY_PROPERTY_STATE */
39 { sizeof(ULONG), FALSE, TRUE }, /* WS_PROXY_PROPERTY_MAX_PENDING_CALLS */
40 { sizeof(ULONG), FALSE, TRUE }, /* WS_PROXY_PROPERTY_MAX_CLOSE_TIMEOUT */
41 { sizeof(LANGID), FALSE, TRUE }, /* WS_PROXY_FAULT_LANG_ID */
44 struct proxy
46 WS_CHANNEL *channel;
47 ULONG prop_count;
48 struct prop prop[sizeof(proxy_props)/sizeof(proxy_props[0])];
51 static struct proxy *alloc_proxy(void)
53 static const ULONG count = sizeof(proxy_props)/sizeof(proxy_props[0]);
54 struct proxy *ret;
55 ULONG size = sizeof(*ret) + prop_size( proxy_props, count );
57 if (!(ret = heap_alloc_zero( size ))) return NULL;
58 prop_init( proxy_props, count, ret->prop, &ret[1] );
59 ret->prop_count = count;
60 return ret;
63 static void free_proxy( struct proxy *proxy )
65 if (!proxy) return;
66 WsFreeChannel( proxy->channel );
67 heap_free( proxy );
70 static HRESULT create_proxy( WS_CHANNEL *channel, const WS_PROXY_PROPERTY *properties, ULONG count,
71 WS_SERVICE_PROXY **handle )
73 struct proxy *proxy;
74 HRESULT hr;
75 ULONG i;
77 if (!(proxy = alloc_proxy())) return E_OUTOFMEMORY;
79 for (i = 0; i < count; i++)
81 hr = prop_set( proxy->prop, proxy->prop_count, properties[i].id, properties[i].value,
82 properties[i].valueSize );
83 if (hr != S_OK)
85 free_proxy( proxy );
86 return hr;
90 proxy->channel = channel;
92 *handle = (WS_SERVICE_PROXY *)proxy;
93 return S_OK;
96 /**************************************************************************
97 * WsCreateServiceProxy [webservices.@]
99 HRESULT WINAPI WsCreateServiceProxy( const WS_CHANNEL_TYPE type, const WS_CHANNEL_BINDING binding,
100 const WS_SECURITY_DESCRIPTION *desc,
101 const WS_PROXY_PROPERTY *proxy_props, ULONG proxy_props_count,
102 const WS_CHANNEL_PROPERTY *channel_props,
103 const ULONG channel_props_count, WS_SERVICE_PROXY **handle,
104 WS_ERROR *error )
106 WS_CHANNEL *channel;
107 HRESULT hr;
109 TRACE( "%u %u %p %p %u %p %u %p %p\n", type, binding, desc, proxy_props, proxy_props_count,
110 channel_props, channel_props_count, handle, error );
111 if (error) FIXME( "ignoring error parameter\n" );
112 if (desc) FIXME( "ignoring security description\n" );
114 if (!handle) return E_INVALIDARG;
116 if ((hr = WsCreateChannel( type, binding, channel_props, channel_props_count, NULL, &channel,
117 NULL )) != S_OK) return hr;
119 if ((hr = create_proxy( channel, proxy_props, proxy_props_count, handle )) != S_OK)
120 WsFreeChannel( channel );
122 return hr;
125 /**************************************************************************
126 * WsCreateServiceProxyFromTemplate [webservices.@]
128 HRESULT WINAPI WsCreateServiceProxyFromTemplate( WS_CHANNEL_TYPE channel_type,
129 const WS_PROXY_PROPERTY *properties, const ULONG count,
130 WS_BINDING_TEMPLATE_TYPE type, void *value, ULONG size,
131 const void *desc, ULONG desc_size, WS_SERVICE_PROXY **handle,
132 WS_ERROR *error )
134 const WS_CHANNEL_PROPERTY *channel_props = NULL;
135 ULONG channel_props_count = 0;
136 WS_CHANNEL_BINDING binding;
137 WS_CHANNEL *channel;
138 HRESULT hr;
140 TRACE( "%u %p %u %u %p %u %p %u %p %p\n", channel_type, properties, count, type, value, size, desc,
141 desc_size, handle, error );
142 if (error) FIXME( "ignoring error parameter\n" );
144 if (!desc || !handle) return E_INVALIDARG;
145 FIXME( "ignoring description\n" );
147 switch (type)
149 case WS_HTTP_BINDING_TEMPLATE_TYPE:
151 WS_HTTP_BINDING_TEMPLATE *http = value;
152 if (http)
154 channel_props = http->channelProperties.properties;
155 channel_props_count = http->channelProperties.propertyCount;
157 binding = WS_HTTP_CHANNEL_BINDING;
158 break;
160 case WS_HTTP_SSL_BINDING_TEMPLATE_TYPE:
162 WS_HTTP_SSL_BINDING_TEMPLATE *https = value;
163 if (https)
165 channel_props = https->channelProperties.properties;
166 channel_props_count = https->channelProperties.propertyCount;
168 binding = WS_HTTP_CHANNEL_BINDING;
169 break;
171 default:
172 FIXME( "template type %u not implemented\n", type );
173 return E_NOTIMPL;
176 if ((hr = WsCreateChannel( channel_type, binding, channel_props, channel_props_count, NULL,
177 &channel, NULL )) != S_OK) return hr;
179 if ((hr = create_proxy( channel, properties, count, handle )) != S_OK) WsFreeChannel( channel );
180 return hr;
183 /**************************************************************************
184 * WsFreeServiceProxy [webservices.@]
186 void WINAPI WsFreeServiceProxy( WS_SERVICE_PROXY *handle )
188 struct proxy *proxy = (struct proxy *)handle;
190 TRACE( "%p\n", handle );
191 free_proxy( proxy );
194 /**************************************************************************
195 * WsGetServiceProxyProperty [webservices.@]
197 HRESULT WINAPI WsGetServiceProxyProperty( WS_SERVICE_PROXY *handle, WS_PROXY_PROPERTY_ID id,
198 void *buf, ULONG size, WS_ERROR *error )
200 struct proxy *proxy = (struct proxy *)handle;
202 TRACE( "%p %u %p %u %p\n", handle, id, buf, size, error );
203 if (error) FIXME( "ignoring error parameter\n" );
205 return prop_get( proxy->prop, proxy->prop_count, id, buf, size );
208 /**************************************************************************
209 * WsOpenServiceProxy [webservices.@]
211 HRESULT WINAPI WsOpenServiceProxy( WS_SERVICE_PROXY *handle, const WS_ENDPOINT_ADDRESS *endpoint,
212 const WS_ASYNC_CONTEXT *ctx, WS_ERROR *error )
214 struct proxy *proxy = (struct proxy *)handle;
216 TRACE( "%p %p %p %p\n", handle, endpoint, ctx, error );
217 if (error) FIXME( "ignoring error parameter\n" );
218 if (ctx) FIXME( "ignoring ctx parameter\n" );
220 if (!handle || !endpoint) return E_INVALIDARG;
221 return WsOpenChannel( proxy->channel, endpoint, NULL, NULL );
224 /**************************************************************************
225 * WsCloseServiceProxy [webservices.@]
227 HRESULT WINAPI WsCloseServiceProxy( WS_SERVICE_PROXY *handle, const WS_ASYNC_CONTEXT *ctx, WS_ERROR *error )
229 struct proxy *proxy = (struct proxy *)handle;
231 TRACE( "%p %p %p\n", handle, ctx, error );
232 if (error) FIXME( "ignoring error parameter\n" );
233 if (ctx) FIXME( "ignoring ctx parameter\n" );
235 if (!handle) return E_INVALIDARG;
236 return WsCloseChannel( proxy->channel, NULL, NULL );
239 /**************************************************************************
240 * WsAbortServiceProxy [webservices.@]
242 HRESULT WINAPI WsAbortServiceProxy( WS_SERVICE_PROXY *handle, WS_ERROR *error )
244 FIXME( "%p %p\n", handle, error );
245 return E_NOTIMPL;
248 /**************************************************************************
249 * WsCall [webservices.@]
251 HRESULT WINAPI WsCall( WS_SERVICE_PROXY *handle, const WS_OPERATION_DESCRIPTION *desc, const void **args,
252 WS_HEAP *heap, const WS_CALL_PROPERTY *properties, const ULONG count,
253 const WS_ASYNC_CONTEXT *ctx, WS_ERROR *error )
255 FIXME( "%p %p %p %p %p %u %p %p\n", handle, desc, args, heap, properties, count, ctx, error );
256 return E_NOTIMPL;