winmm: Fix a memory leak in mciSendStringW (valgrind).
[wine.git] / dlls / netprofm / list.c
blobb9ab1cc695dc6670adfbd0dbcb9a54ff2e49dbe7
1 /*
2 * Copyright 2014 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 #define COBJMACROS
21 #include "config.h"
22 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "initguid.h"
26 #include "objbase.h"
27 #include "ocidl.h"
28 #include "netlistmgr.h"
30 #include "wine/debug.h"
31 #include "netprofm_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(netprofm);
35 struct list_manager
37 INetworkListManager INetworkListManager_iface;
38 INetworkCostManager INetworkCostManager_iface;
39 IConnectionPointContainer IConnectionPointContainer_iface;
40 LONG refs;
43 static inline struct list_manager *impl_from_IConnectionPointContainer(IConnectionPointContainer *iface)
45 return CONTAINING_RECORD(iface, struct list_manager, IConnectionPointContainer_iface);
48 static inline struct list_manager *impl_from_INetworkCostManager(
49 INetworkCostManager *iface )
51 return CONTAINING_RECORD( iface, struct list_manager, INetworkCostManager_iface );
54 static HRESULT WINAPI cost_manager_QueryInterface(
55 INetworkCostManager *iface,
56 REFIID riid,
57 void **obj )
59 struct list_manager *mgr = impl_from_INetworkCostManager( iface );
60 return INetworkListManager_QueryInterface( &mgr->INetworkListManager_iface, riid, obj );
63 static ULONG WINAPI cost_manager_AddRef(
64 INetworkCostManager *iface )
66 struct list_manager *mgr = impl_from_INetworkCostManager( iface );
67 return INetworkListManager_AddRef( &mgr->INetworkListManager_iface );
70 static ULONG WINAPI cost_manager_Release(
71 INetworkCostManager *iface )
73 struct list_manager *mgr = impl_from_INetworkCostManager( iface );
74 return INetworkListManager_Release( &mgr->INetworkListManager_iface );
77 static HRESULT WINAPI cost_manager_GetCost(
78 INetworkCostManager *iface, DWORD *pCost, NLM_SOCKADDR *pDestIPAddr)
80 FIXME( "%p, %p, %p\n", iface, pCost, pDestIPAddr );
82 if (!pCost) return E_POINTER;
84 *pCost = NLM_CONNECTION_COST_UNRESTRICTED;
85 return S_OK;
88 static HRESULT WINAPI cost_manager_GetDataPlanStatus(
89 INetworkCostManager *iface, NLM_DATAPLAN_STATUS *pDataPlanStatus,
90 NLM_SOCKADDR *pDestIPAddr)
92 FIXME( "%p, %p, %p\n", iface, pDataPlanStatus, pDestIPAddr );
93 return E_NOTIMPL;
96 static HRESULT WINAPI cost_manager_SetDestinationAddresses(
97 INetworkCostManager *iface, UINT32 length, NLM_SOCKADDR *pDestIPAddrList,
98 VARIANT_BOOL bAppend)
100 FIXME( "%p, %u, %p, %x\n", iface, length, pDestIPAddrList, bAppend );
101 return E_NOTIMPL;
104 static const INetworkCostManagerVtbl cost_manager_vtbl =
106 cost_manager_QueryInterface,
107 cost_manager_AddRef,
108 cost_manager_Release,
109 cost_manager_GetCost,
110 cost_manager_GetDataPlanStatus,
111 cost_manager_SetDestinationAddresses
114 static inline struct list_manager *impl_from_INetworkListManager(
115 INetworkListManager *iface )
117 return CONTAINING_RECORD( iface, struct list_manager, INetworkListManager_iface );
120 static ULONG WINAPI list_manager_AddRef(
121 INetworkListManager *iface )
123 struct list_manager *mgr = impl_from_INetworkListManager( iface );
124 return InterlockedIncrement( &mgr->refs );
127 static ULONG WINAPI list_manager_Release(
128 INetworkListManager *iface )
130 struct list_manager *mgr = impl_from_INetworkListManager( iface );
131 LONG refs = InterlockedDecrement( &mgr->refs );
132 if (!refs)
134 TRACE( "destroying %p\n", mgr );
135 HeapFree( GetProcessHeap(), 0, mgr );
137 return refs;
140 static HRESULT WINAPI list_manager_QueryInterface(
141 INetworkListManager *iface,
142 REFIID riid,
143 void **obj )
145 struct list_manager *mgr = impl_from_INetworkListManager( iface );
147 TRACE( "%p, %s, %p\n", mgr, debugstr_guid(riid), obj );
149 if (IsEqualGUID( riid, &IID_INetworkListManager ) ||
150 IsEqualGUID( riid, &IID_IUnknown ))
152 *obj = iface;
154 else if (IsEqualGUID( riid, &IID_INetworkCostManager ))
156 *obj = &mgr->INetworkCostManager_iface;
158 else if (IsEqualGUID( riid, &IID_IConnectionPointContainer ))
160 *obj = &mgr->IConnectionPointContainer_iface;
162 else
164 FIXME( "interface %s not implemented\n", debugstr_guid(riid) );
165 return E_NOINTERFACE;
167 INetworkListManager_AddRef( iface );
168 return S_OK;
171 static HRESULT WINAPI list_manager_GetTypeInfoCount(
172 INetworkListManager *iface,
173 UINT *count )
175 FIXME("\n");
176 return E_NOTIMPL;
179 static HRESULT WINAPI list_manager_GetTypeInfo(
180 INetworkListManager *iface,
181 UINT index,
182 LCID lcid,
183 ITypeInfo **info )
185 FIXME("\n");
186 return E_NOTIMPL;
189 static HRESULT WINAPI list_manager_GetIDsOfNames(
190 INetworkListManager *iface,
191 REFIID riid,
192 LPOLESTR *names,
193 UINT count,
194 LCID lcid,
195 DISPID *dispid )
197 FIXME("\n");
198 return E_NOTIMPL;
201 static HRESULT WINAPI list_manager_Invoke(
202 INetworkListManager *iface,
203 DISPID member,
204 REFIID riid,
205 LCID lcid,
206 WORD flags,
207 DISPPARAMS *params,
208 VARIANT *result,
209 EXCEPINFO *excep_info,
210 UINT *arg_err )
212 FIXME("\n");
213 return E_NOTIMPL;
216 static HRESULT WINAPI list_manager_GetNetworks(
217 INetworkListManager *iface,
218 NLM_ENUM_NETWORK Flags,
219 IEnumNetworks **ppEnumNetwork )
221 FIXME( "%p, %x, %p\n", iface, Flags, ppEnumNetwork );
222 return E_NOTIMPL;
225 static HRESULT WINAPI list_manager_GetNetwork(
226 INetworkListManager *iface,
227 GUID gdNetworkId,
228 INetwork **ppNetwork )
230 FIXME( "%p, %s, %p\n", iface, debugstr_guid(&gdNetworkId), ppNetwork );
231 return E_NOTIMPL;
234 static HRESULT WINAPI list_manager_GetNetworkConnections(
235 INetworkListManager *iface,
236 IEnumNetworkConnections **ppEnum )
238 FIXME( "%p, %p\n", iface, ppEnum );
239 return E_NOTIMPL;
242 static HRESULT WINAPI list_manager_GetNetworkConnection(
243 INetworkListManager *iface,
244 GUID gdNetworkConnectionId,
245 INetworkConnection **ppNetworkConnection )
247 FIXME( "%p, %s, %p\n", iface, debugstr_guid(&gdNetworkConnectionId),
248 ppNetworkConnection );
249 return E_NOTIMPL;
252 static HRESULT WINAPI list_manager_IsConnectedToInternet(
253 INetworkListManager *iface,
254 VARIANT_BOOL *pbIsConnected )
256 FIXME( "%p, %p\n", iface, pbIsConnected );
258 *pbIsConnected = VARIANT_TRUE;
259 return S_OK;
262 static HRESULT WINAPI list_manager_IsConnected(
263 INetworkListManager *iface,
264 VARIANT_BOOL *pbIsConnected )
266 FIXME( "%p, %p\n", iface, pbIsConnected );
268 *pbIsConnected = VARIANT_TRUE;
269 return S_OK;
272 static HRESULT WINAPI list_manager_GetConnectivity(
273 INetworkListManager *iface,
274 NLM_CONNECTIVITY *pConnectivity )
276 FIXME( "%p, %p\n", iface, pConnectivity );
278 *pConnectivity = NLM_CONNECTIVITY_IPV4_INTERNET;
279 return S_OK;
282 static const INetworkListManagerVtbl list_manager_vtbl =
284 list_manager_QueryInterface,
285 list_manager_AddRef,
286 list_manager_Release,
287 list_manager_GetTypeInfoCount,
288 list_manager_GetTypeInfo,
289 list_manager_GetIDsOfNames,
290 list_manager_Invoke,
291 list_manager_GetNetworks,
292 list_manager_GetNetwork,
293 list_manager_GetNetworkConnections,
294 list_manager_GetNetworkConnection,
295 list_manager_IsConnectedToInternet,
296 list_manager_IsConnected,
297 list_manager_GetConnectivity
300 static HRESULT WINAPI ConnectionPointContainer_QueryInterface(IConnectionPointContainer *iface,
301 REFIID riid, void **ppv)
303 struct list_manager *This = impl_from_IConnectionPointContainer( iface );
304 return INetworkListManager_QueryInterface(&This->INetworkListManager_iface, riid, ppv);
307 static ULONG WINAPI ConnectionPointContainer_AddRef(IConnectionPointContainer *iface)
309 struct list_manager *This = impl_from_IConnectionPointContainer( iface );
310 return INetworkListManager_AddRef(&This->INetworkListManager_iface);
313 static ULONG WINAPI ConnectionPointContainer_Release(IConnectionPointContainer *iface)
315 struct list_manager *This = impl_from_IConnectionPointContainer( iface );
316 return INetworkListManager_Release(&This->INetworkListManager_iface);
319 static HRESULT WINAPI ConnectionPointContainer_EnumConnectionPoints(IConnectionPointContainer *iface,
320 IEnumConnectionPoints **ppEnum)
322 struct list_manager *This = impl_from_IConnectionPointContainer( iface );
323 FIXME("(%p)->(%p): stub\n", This, ppEnum);
324 return E_NOTIMPL;
327 static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPointContainer *iface,
328 REFIID riid, IConnectionPoint **cp)
330 struct list_manager *This = impl_from_IConnectionPointContainer( iface );
331 FIXME("(%p)->(%s %p): stub\n", This, debugstr_guid(riid), cp);
332 return E_NOTIMPL;
335 static const struct IConnectionPointContainerVtbl cpc_vtbl =
337 ConnectionPointContainer_QueryInterface,
338 ConnectionPointContainer_AddRef,
339 ConnectionPointContainer_Release,
340 ConnectionPointContainer_EnumConnectionPoints,
341 ConnectionPointContainer_FindConnectionPoint
344 HRESULT list_manager_create( void **obj )
346 struct list_manager *mgr;
348 TRACE( "%p\n", obj );
350 if (!(mgr = HeapAlloc( GetProcessHeap(), 0, sizeof(*mgr) ))) return E_OUTOFMEMORY;
351 mgr->INetworkListManager_iface.lpVtbl = &list_manager_vtbl;
352 mgr->INetworkCostManager_iface.lpVtbl = &cost_manager_vtbl;
353 mgr->IConnectionPointContainer_iface.lpVtbl = &cpc_vtbl;
354 mgr->refs = 1;
356 *obj = &mgr->INetworkListManager_iface;
357 TRACE( "returning iface %p\n", *obj );
358 return S_OK;