regedit: Read registry value information before exporting.
[wine.git] / dlls / wsdapi / discovery.c
blob82a1ca0a5a8a4d30bc2daec46fd10558eaa09b20
1 /*
2 * Web Services on Devices
4 * Copyright 2017 Owen Rudge for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #define COBJMACROS
24 #define INITGUID
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wine/debug.h"
29 #include "wine/list.h"
30 #include "objbase.h"
31 #include "guiddef.h"
32 #include "wsdapi.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(wsdapi);
36 struct notificationSink
38 struct list entry;
39 IWSDiscoveryPublisherNotify *notificationSink;
42 typedef struct IWSDiscoveryPublisherImpl {
43 IWSDiscoveryPublisher IWSDiscoveryPublisher_iface;
44 LONG ref;
45 IWSDXMLContext *xmlContext;
46 DWORD addressFamily;
47 struct list notificationSinks;
48 } IWSDiscoveryPublisherImpl;
50 static inline IWSDiscoveryPublisherImpl *impl_from_IWSDiscoveryPublisher(IWSDiscoveryPublisher *iface)
52 return CONTAINING_RECORD(iface, IWSDiscoveryPublisherImpl, IWSDiscoveryPublisher_iface);
55 static HRESULT WINAPI IWSDiscoveryPublisherImpl_QueryInterface(IWSDiscoveryPublisher *iface, REFIID riid, void **ppv)
57 IWSDiscoveryPublisherImpl *This = impl_from_IWSDiscoveryPublisher(iface);
59 TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppv);
61 if (!ppv)
63 WARN("Invalid parameter\n");
64 return E_INVALIDARG;
67 *ppv = NULL;
69 if (IsEqualIID(riid, &IID_IUnknown) ||
70 IsEqualIID(riid, &IID_IWSDiscoveryPublisher))
72 *ppv = &This->IWSDiscoveryPublisher_iface;
74 else
76 WARN("Unknown IID %s\n", debugstr_guid(riid));
77 return E_NOINTERFACE;
80 IUnknown_AddRef((IUnknown*)*ppv);
81 return S_OK;
84 static ULONG WINAPI IWSDiscoveryPublisherImpl_AddRef(IWSDiscoveryPublisher *iface)
86 IWSDiscoveryPublisherImpl *This = impl_from_IWSDiscoveryPublisher(iface);
87 ULONG ref = InterlockedIncrement(&This->ref);
89 TRACE("(%p) ref=%d\n", This, ref);
90 return ref;
93 static ULONG WINAPI IWSDiscoveryPublisherImpl_Release(IWSDiscoveryPublisher *iface)
95 IWSDiscoveryPublisherImpl *This = impl_from_IWSDiscoveryPublisher(iface);
96 ULONG ref = InterlockedDecrement(&This->ref);
97 struct notificationSink *sink, *cursor;
99 TRACE("(%p) ref=%d\n", This, ref);
101 if (ref == 0)
103 if (This->xmlContext != NULL)
105 IWSDXMLContext_Release(This->xmlContext);
108 LIST_FOR_EACH_ENTRY_SAFE(sink, cursor, &This->notificationSinks, struct notificationSink, entry)
110 IWSDiscoveryPublisherNotify_Release(sink->notificationSink);
111 list_remove(&sink->entry);
112 HeapFree(GetProcessHeap(), 0, sink);
115 HeapFree(GetProcessHeap(), 0, This);
118 return ref;
121 static HRESULT WINAPI IWSDiscoveryPublisherImpl_SetAddressFamily(IWSDiscoveryPublisher *This, DWORD dwAddressFamily)
123 IWSDiscoveryPublisherImpl *impl = impl_from_IWSDiscoveryPublisher(This);
125 TRACE("(%p, %d)\n", This, dwAddressFamily);
127 /* Has the address family already been set? */
128 if (impl->addressFamily != 0)
130 return STG_E_INVALIDFUNCTION;
133 if ((dwAddressFamily == WSDAPI_ADDRESSFAMILY_IPV4) || (dwAddressFamily == WSDAPI_ADDRESSFAMILY_IPV6) ||
134 (dwAddressFamily == (WSDAPI_ADDRESSFAMILY_IPV4 | WSDAPI_ADDRESSFAMILY_IPV6)))
136 /* TODO: Check that the address family is supported by the system */
137 impl->addressFamily = dwAddressFamily;
138 return S_OK;
141 return E_INVALIDARG;
144 static HRESULT WINAPI IWSDiscoveryPublisherImpl_RegisterNotificationSink(IWSDiscoveryPublisher *This, IWSDiscoveryPublisherNotify *pSink)
146 IWSDiscoveryPublisherImpl *impl = impl_from_IWSDiscoveryPublisher(This);
147 struct notificationSink *sink;
149 TRACE("(%p, %p)\n", This, pSink);
151 if (pSink == NULL)
153 return E_INVALIDARG;
156 sink = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*sink));
158 if (!sink)
160 return E_OUTOFMEMORY;
163 sink->notificationSink = pSink;
164 IWSDiscoveryPublisherNotify_AddRef(pSink);
166 list_add_tail(&impl->notificationSinks, &sink->entry);
168 return S_OK;
171 static HRESULT WINAPI IWSDiscoveryPublisherImpl_UnRegisterNotificationSink(IWSDiscoveryPublisher *This, IWSDiscoveryPublisherNotify *pSink)
173 IWSDiscoveryPublisherImpl *impl = impl_from_IWSDiscoveryPublisher(This);
174 struct notificationSink *sink;
176 TRACE("(%p, %p)\n", This, pSink);
178 if (pSink == NULL)
180 return E_INVALIDARG;
183 LIST_FOR_EACH_ENTRY(sink, &impl->notificationSinks, struct notificationSink, entry)
185 if (sink->notificationSink == pSink)
187 IWSDiscoveryPublisherNotify_Release(pSink);
188 list_remove(&sink->entry);
189 HeapFree(GetProcessHeap(), 0, sink);
191 return S_OK;
195 /* Notification sink is not registered */
196 return E_FAIL;
199 static HRESULT WINAPI IWSDiscoveryPublisherImpl_Publish(IWSDiscoveryPublisher *This, LPCWSTR pszId, ULONGLONG ullMetadataVersion, ULONGLONG ullInstanceId,
200 ULONGLONG ullMessageNumber, LPCWSTR pszSessionId, const WSD_NAME_LIST *pTypesList,
201 const WSD_URI_LIST *pScopesList, const WSD_URI_LIST *pXAddrsList)
203 FIXME("(%p, %s, %s, %s, %s, %s, %p, %p, %p)\n", This, debugstr_w(pszId), wine_dbgstr_longlong(ullMetadataVersion), wine_dbgstr_longlong(ullInstanceId),
204 wine_dbgstr_longlong(ullMessageNumber), debugstr_w(pszSessionId), pTypesList, pScopesList, pXAddrsList);
206 return E_NOTIMPL;
209 static HRESULT WINAPI IWSDiscoveryPublisherImpl_UnPublish(IWSDiscoveryPublisher *This, LPCWSTR pszId, ULONGLONG ullInstanceId, ULONGLONG ullMessageNumber,
210 LPCWSTR pszSessionId, const WSDXML_ELEMENT *pAny)
212 FIXME("(%p, %s, %s, %s, %s, %p)\n", This, debugstr_w(pszId), wine_dbgstr_longlong(ullInstanceId), wine_dbgstr_longlong(ullMessageNumber),
213 debugstr_w(pszSessionId), pAny);
215 return E_NOTIMPL;
218 static HRESULT WINAPI IWSDiscoveryPublisherImpl_MatchProbe(IWSDiscoveryPublisher *This, const WSD_SOAP_MESSAGE *pProbeMessage,
219 IWSDMessageParameters *pMessageParameters, LPCWSTR pszId, ULONGLONG ullMetadataVersion,
220 ULONGLONG ullInstanceId, ULONGLONG ullMessageNumber, LPCWSTR pszSessionId,
221 const WSD_NAME_LIST *pTypesList, const WSD_URI_LIST *pScopesList,
222 const WSD_URI_LIST *pXAddrsList)
224 FIXME("(%p, %p, %p, %s, %s, %s, %s, %s, %p, %p, %p)\n", This, pProbeMessage, pMessageParameters, debugstr_w(pszId),
225 wine_dbgstr_longlong(ullMetadataVersion), wine_dbgstr_longlong(ullInstanceId), wine_dbgstr_longlong(ullMessageNumber), debugstr_w(pszSessionId),
226 pTypesList, pScopesList, pXAddrsList);
228 return E_NOTIMPL;
231 static HRESULT WINAPI IWSDiscoveryPublisherImpl_MatchResolve(IWSDiscoveryPublisher *This, const WSD_SOAP_MESSAGE *pResolveMessage,
232 IWSDMessageParameters *pMessageParameters, LPCWSTR pszId, ULONGLONG ullMetadataVersion,
233 ULONGLONG ullInstanceId, ULONGLONG ullMessageNumber, LPCWSTR pszSessionId,
234 const WSD_NAME_LIST *pTypesList, const WSD_URI_LIST *pScopesList,
235 const WSD_URI_LIST *pXAddrsList)
237 FIXME("(%p, %p, %p, %s, %s, %s, %s, %s, %p, %p, %p)\n", This, pResolveMessage, pMessageParameters, debugstr_w(pszId),
238 wine_dbgstr_longlong(ullMetadataVersion), wine_dbgstr_longlong(ullInstanceId), wine_dbgstr_longlong(ullMessageNumber), debugstr_w(pszSessionId),
239 pTypesList, pScopesList, pXAddrsList);
241 return E_NOTIMPL;
244 static HRESULT WINAPI IWSDiscoveryPublisherImpl_PublishEx(IWSDiscoveryPublisher *This, LPCWSTR pszId, ULONGLONG ullMetadataVersion,
245 ULONGLONG ullInstanceId, ULONGLONG ullMessageNumber, LPCWSTR pszSessionId,
246 const WSD_NAME_LIST *pTypesList, const WSD_URI_LIST *pScopesList,
247 const WSD_URI_LIST *pXAddrsList, const WSDXML_ELEMENT *pHeaderAny,
248 const WSDXML_ELEMENT *pReferenceParameterAny, const WSDXML_ELEMENT *pPolicyAny,
249 const WSDXML_ELEMENT *pEndpointReferenceAny, const WSDXML_ELEMENT *pAny)
251 FIXME("(%p, %s, %s, %s, %s, %s, %p, %p, %p, %p, %p, %p, %p, %p)\n", This, debugstr_w(pszId), wine_dbgstr_longlong(ullMetadataVersion),
252 wine_dbgstr_longlong(ullInstanceId), wine_dbgstr_longlong(ullMessageNumber), debugstr_w(pszSessionId), pTypesList, pScopesList, pXAddrsList,
253 pHeaderAny, pReferenceParameterAny, pPolicyAny, pEndpointReferenceAny, pAny);
255 return E_NOTIMPL;
259 static HRESULT WINAPI IWSDiscoveryPublisherImpl_MatchProbeEx(IWSDiscoveryPublisher *This, const WSD_SOAP_MESSAGE *pProbeMessage,
260 IWSDMessageParameters *pMessageParameters, LPCWSTR pszId, ULONGLONG ullMetadataVersion,
261 ULONGLONG ullInstanceId, ULONGLONG ullMessageNumber, LPCWSTR pszSessionId,
262 const WSD_NAME_LIST *pTypesList, const WSD_URI_LIST *pScopesList,
263 const WSD_URI_LIST *pXAddrsList, const WSDXML_ELEMENT *pHeaderAny,
264 const WSDXML_ELEMENT *pReferenceParameterAny, const WSDXML_ELEMENT *pPolicyAny,
265 const WSDXML_ELEMENT *pEndpointReferenceAny, const WSDXML_ELEMENT *pAny)
267 FIXME("(%p, %p, %p, %s, %s, %s, %s, %s, %p, %p, %p, %p, %p, %p, %p, %p)\n", This, pProbeMessage, pMessageParameters, debugstr_w(pszId),
268 wine_dbgstr_longlong(ullMetadataVersion), wine_dbgstr_longlong(ullInstanceId), wine_dbgstr_longlong(ullMessageNumber), debugstr_w(pszSessionId),
269 pTypesList, pScopesList, pXAddrsList, pHeaderAny, pReferenceParameterAny, pPolicyAny, pEndpointReferenceAny, pAny);
271 return E_NOTIMPL;
274 static HRESULT WINAPI IWSDiscoveryPublisherImpl_MatchResolveEx(IWSDiscoveryPublisher *This, const WSD_SOAP_MESSAGE *pResolveMessage,
275 IWSDMessageParameters *pMessageParameters, LPCWSTR pszId, ULONGLONG ullMetadataVersion,
276 ULONGLONG ullInstanceId, ULONGLONG ullMessageNumber, LPCWSTR pszSessionId,
277 const WSD_NAME_LIST *pTypesList, const WSD_URI_LIST *pScopesList,
278 const WSD_URI_LIST *pXAddrsList, const WSDXML_ELEMENT *pHeaderAny,
279 const WSDXML_ELEMENT *pReferenceParameterAny, const WSDXML_ELEMENT *pPolicyAny,
280 const WSDXML_ELEMENT *pEndpointReferenceAny, const WSDXML_ELEMENT *pAny)
282 FIXME("(%p, %p, %p, %s, %s, %s, %s, %s, %p, %p, %p, %p, %p, %p, %p, %p)\n", This, pResolveMessage, pMessageParameters, debugstr_w(pszId),
283 wine_dbgstr_longlong(ullMetadataVersion), wine_dbgstr_longlong(ullInstanceId), wine_dbgstr_longlong(ullMessageNumber), debugstr_w(pszSessionId),
284 pTypesList, pScopesList, pXAddrsList, pHeaderAny, pReferenceParameterAny, pPolicyAny, pEndpointReferenceAny, pAny);
286 return E_NOTIMPL;
289 static HRESULT WINAPI IWSDiscoveryPublisherImpl_RegisterScopeMatchingRule(IWSDiscoveryPublisher *This, IWSDScopeMatchingRule *pScopeMatchingRule)
291 FIXME("(%p, %p)\n", This, pScopeMatchingRule);
292 return E_NOTIMPL;
295 static HRESULT WINAPI IWSDiscoveryPublisherImpl_UnRegisterScopeMatchingRule(IWSDiscoveryPublisher *This, IWSDScopeMatchingRule *pScopeMatchingRule)
297 FIXME("(%p, %p)\n", This, pScopeMatchingRule);
298 return E_NOTIMPL;
301 static HRESULT WINAPI IWSDiscoveryPublisherImpl_GetXMLContext(IWSDiscoveryPublisher *This, IWSDXMLContext **ppContext)
303 IWSDiscoveryPublisherImpl *impl = impl_from_IWSDiscoveryPublisher(This);
305 TRACE("%p, %p)\n", This, ppContext);
307 if (ppContext == NULL)
308 return E_INVALIDARG;
310 if (impl->xmlContext != NULL)
312 IWSDXMLContext_AddRef(impl->xmlContext);
315 *ppContext = impl->xmlContext;
316 return S_OK;
319 static const IWSDiscoveryPublisherVtbl publisher_vtbl =
321 IWSDiscoveryPublisherImpl_QueryInterface,
322 IWSDiscoveryPublisherImpl_AddRef,
323 IWSDiscoveryPublisherImpl_Release,
324 IWSDiscoveryPublisherImpl_SetAddressFamily,
325 IWSDiscoveryPublisherImpl_RegisterNotificationSink,
326 IWSDiscoveryPublisherImpl_UnRegisterNotificationSink,
327 IWSDiscoveryPublisherImpl_Publish,
328 IWSDiscoveryPublisherImpl_UnPublish,
329 IWSDiscoveryPublisherImpl_MatchProbe,
330 IWSDiscoveryPublisherImpl_MatchResolve,
331 IWSDiscoveryPublisherImpl_PublishEx,
332 IWSDiscoveryPublisherImpl_MatchProbeEx,
333 IWSDiscoveryPublisherImpl_MatchResolveEx,
334 IWSDiscoveryPublisherImpl_RegisterScopeMatchingRule,
335 IWSDiscoveryPublisherImpl_UnRegisterScopeMatchingRule,
336 IWSDiscoveryPublisherImpl_GetXMLContext
339 HRESULT WINAPI WSDCreateDiscoveryPublisher(IWSDXMLContext *pContext, IWSDiscoveryPublisher **ppPublisher)
341 IWSDiscoveryPublisherImpl *obj;
343 TRACE("(%p, %p)\n", pContext, ppPublisher);
345 if (ppPublisher == NULL)
347 WARN("Invalid parameter: ppPublisher == NULL\n");
348 return E_POINTER;
351 *ppPublisher = NULL;
353 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*obj));
355 if (!obj)
357 WARN("Out of memory\n");
358 return E_OUTOFMEMORY;
361 obj->IWSDiscoveryPublisher_iface.lpVtbl = &publisher_vtbl;
362 obj->ref = 1;
364 if (pContext == NULL)
366 if (FAILED(WSDXMLCreateContext(&obj->xmlContext)))
368 WARN("Unable to create XML context\n");
369 HeapFree (GetProcessHeap(), 0, obj);
370 return E_OUTOFMEMORY;
373 else
375 obj->xmlContext = pContext;
376 IWSDXMLContext_AddRef(pContext);
379 list_init(&obj->notificationSinks);
381 *ppPublisher = &obj->IWSDiscoveryPublisher_iface;
382 TRACE("Returning iface %p\n", *ppPublisher);
384 return S_OK;