PageRenderTime 56ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/dlls/hnetcfg/port.c

https://github.com/wesgarner/wine
C | 546 lines | 437 code | 92 blank | 17 comment | 7 complexity | f6738029c8011e13b48808c361acabd8 MD5 | raw file
  1. /*
  2. * Copyright 2009 Hans Leidekker for CodeWeavers
  3. *
  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.
  8. *
  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.
  13. *
  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
  17. */
  18. #include "config.h"
  19. #include <stdarg.h>
  20. #include <stdio.h>
  21. #define COBJMACROS
  22. #include "windef.h"
  23. #include "winbase.h"
  24. #include "winuser.h"
  25. #include "ole2.h"
  26. #include "netfw.h"
  27. #include "wine/debug.h"
  28. #include "wine/unicode.h"
  29. #include "hnetcfg_private.h"
  30. WINE_DEFAULT_DEBUG_CHANNEL(hnetcfg);
  31. typedef struct fw_port
  32. {
  33. const INetFwOpenPortVtbl *vtbl;
  34. LONG refs;
  35. } fw_port;
  36. static inline fw_port *impl_from_INetFwOpenPort( INetFwOpenPort *iface )
  37. {
  38. return (fw_port *)((char *)iface - FIELD_OFFSET( fw_port, vtbl ));
  39. }
  40. static ULONG WINAPI fw_port_AddRef(
  41. INetFwOpenPort *iface )
  42. {
  43. fw_port *fw_port = impl_from_INetFwOpenPort( iface );
  44. return InterlockedIncrement( &fw_port->refs );
  45. }
  46. static ULONG WINAPI fw_port_Release(
  47. INetFwOpenPort *iface )
  48. {
  49. fw_port *fw_port = impl_from_INetFwOpenPort( iface );
  50. LONG refs = InterlockedDecrement( &fw_port->refs );
  51. if (!refs)
  52. {
  53. TRACE("destroying %p\n", fw_port);
  54. HeapFree( GetProcessHeap(), 0, fw_port );
  55. }
  56. return refs;
  57. }
  58. static HRESULT WINAPI fw_port_QueryInterface(
  59. INetFwOpenPort *iface,
  60. REFIID riid,
  61. void **ppvObject )
  62. {
  63. fw_port *This = impl_from_INetFwOpenPort( iface );
  64. TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
  65. if ( IsEqualGUID( riid, &IID_INetFwOpenPort ) ||
  66. IsEqualGUID( riid, &IID_IDispatch ) ||
  67. IsEqualGUID( riid, &IID_IUnknown ) )
  68. {
  69. *ppvObject = iface;
  70. }
  71. else
  72. {
  73. FIXME("interface %s not implemented\n", debugstr_guid(riid));
  74. return E_NOINTERFACE;
  75. }
  76. INetFwOpenPort_AddRef( iface );
  77. return S_OK;
  78. }
  79. static HRESULT WINAPI fw_port_GetTypeInfoCount(
  80. INetFwOpenPort *iface,
  81. UINT *pctinfo )
  82. {
  83. fw_port *This = impl_from_INetFwOpenPort( iface );
  84. FIXME("%p %p\n", This, pctinfo);
  85. return E_NOTIMPL;
  86. }
  87. static HRESULT WINAPI fw_port_GetTypeInfo(
  88. INetFwOpenPort *iface,
  89. UINT iTInfo,
  90. LCID lcid,
  91. ITypeInfo **ppTInfo )
  92. {
  93. fw_port *This = impl_from_INetFwOpenPort( iface );
  94. FIXME("%p %u %u %p\n", This, iTInfo, lcid, ppTInfo);
  95. return E_NOTIMPL;
  96. }
  97. static HRESULT WINAPI fw_port_GetIDsOfNames(
  98. INetFwOpenPort *iface,
  99. REFIID riid,
  100. LPOLESTR *rgszNames,
  101. UINT cNames,
  102. LCID lcid,
  103. DISPID *rgDispId )
  104. {
  105. fw_port *This = impl_from_INetFwOpenPort( iface );
  106. FIXME("%p %s %p %u %u %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
  107. return E_NOTIMPL;
  108. }
  109. static HRESULT WINAPI fw_port_Invoke(
  110. INetFwOpenPort *iface,
  111. DISPID dispIdMember,
  112. REFIID riid,
  113. LCID lcid,
  114. WORD wFlags,
  115. DISPPARAMS *pDispParams,
  116. VARIANT *pVarResult,
  117. EXCEPINFO *pExcepInfo,
  118. UINT *puArgErr )
  119. {
  120. fw_port *This = impl_from_INetFwOpenPort( iface );
  121. FIXME("%p %d %s %d %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
  122. lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
  123. return E_NOTIMPL;
  124. }
  125. static HRESULT WINAPI fw_port_get_Name(
  126. INetFwOpenPort *iface,
  127. BSTR *name)
  128. {
  129. fw_port *This = impl_from_INetFwOpenPort( iface );
  130. FIXME("%p %p\n", This, name);
  131. return E_NOTIMPL;
  132. }
  133. static HRESULT WINAPI fw_port_put_Name(
  134. INetFwOpenPort *iface,
  135. BSTR name)
  136. {
  137. fw_port *This = impl_from_INetFwOpenPort( iface );
  138. FIXME("%p %s\n", This, debugstr_w(name));
  139. return E_NOTIMPL;
  140. }
  141. static HRESULT WINAPI fw_port_get_IpVersion(
  142. INetFwOpenPort *iface,
  143. NET_FW_IP_VERSION *ipVersion)
  144. {
  145. fw_port *This = impl_from_INetFwOpenPort( iface );
  146. FIXME("%p %p\n", This, ipVersion);
  147. return E_NOTIMPL;
  148. }
  149. static HRESULT WINAPI fw_port_put_IpVersion(
  150. INetFwOpenPort *iface,
  151. NET_FW_IP_VERSION ipVersion)
  152. {
  153. fw_port *This = impl_from_INetFwOpenPort( iface );
  154. FIXME("%p %u\n", This, ipVersion);
  155. return E_NOTIMPL;
  156. }
  157. static HRESULT WINAPI fw_port_get_Protocol(
  158. INetFwOpenPort *iface,
  159. NET_FW_IP_PROTOCOL *ipProtocol)
  160. {
  161. fw_port *This = impl_from_INetFwOpenPort( iface );
  162. FIXME("%p %p\n", This, ipProtocol);
  163. return E_NOTIMPL;
  164. }
  165. static HRESULT WINAPI fw_port_put_Protocol(
  166. INetFwOpenPort *iface,
  167. NET_FW_IP_PROTOCOL ipProtocol)
  168. {
  169. fw_port *This = impl_from_INetFwOpenPort( iface );
  170. FIXME("%p %u\n", This, ipProtocol);
  171. return E_NOTIMPL;
  172. }
  173. static HRESULT WINAPI fw_port_get_Port(
  174. INetFwOpenPort *iface,
  175. LONG *portNumber)
  176. {
  177. fw_port *This = impl_from_INetFwOpenPort( iface );
  178. FIXME("%p %p\n", This, portNumber);
  179. return E_NOTIMPL;
  180. }
  181. static HRESULT WINAPI fw_port_put_Port(
  182. INetFwOpenPort *iface,
  183. LONG portNumber)
  184. {
  185. fw_port *This = impl_from_INetFwOpenPort( iface );
  186. FIXME("%p %d\n", This, portNumber);
  187. return E_NOTIMPL;
  188. }
  189. static HRESULT WINAPI fw_port_get_Scope(
  190. INetFwOpenPort *iface,
  191. NET_FW_SCOPE *scope)
  192. {
  193. fw_port *This = impl_from_INetFwOpenPort( iface );
  194. FIXME("%p %p\n", This, scope);
  195. return E_NOTIMPL;
  196. }
  197. static HRESULT WINAPI fw_port_put_Scope(
  198. INetFwOpenPort *iface,
  199. NET_FW_SCOPE scope)
  200. {
  201. fw_port *This = impl_from_INetFwOpenPort( iface );
  202. FIXME("%p %u\n", This, scope);
  203. return E_NOTIMPL;
  204. }
  205. static HRESULT WINAPI fw_port_get_RemoteAddresses(
  206. INetFwOpenPort *iface,
  207. BSTR *remoteAddrs)
  208. {
  209. fw_port *This = impl_from_INetFwOpenPort( iface );
  210. FIXME("%p %p\n", This, remoteAddrs);
  211. return E_NOTIMPL;
  212. }
  213. static HRESULT WINAPI fw_port_put_RemoteAddresses(
  214. INetFwOpenPort *iface,
  215. BSTR remoteAddrs)
  216. {
  217. fw_port *This = impl_from_INetFwOpenPort( iface );
  218. FIXME("%p %s\n", This, debugstr_w(remoteAddrs));
  219. return E_NOTIMPL;
  220. }
  221. static HRESULT WINAPI fw_port_get_Enabled(
  222. INetFwOpenPort *iface,
  223. VARIANT_BOOL *enabled)
  224. {
  225. fw_port *This = impl_from_INetFwOpenPort( iface );
  226. FIXME("%p %p\n", This, enabled);
  227. *enabled = VARIANT_TRUE;
  228. return S_OK;
  229. }
  230. static HRESULT WINAPI fw_port_put_Enabled(
  231. INetFwOpenPort *iface,
  232. VARIANT_BOOL enabled)
  233. {
  234. fw_port *This = impl_from_INetFwOpenPort( iface );
  235. FIXME("%p %d\n", This, enabled);
  236. return E_NOTIMPL;
  237. }
  238. static HRESULT WINAPI fw_port_get_BuiltIn(
  239. INetFwOpenPort *iface,
  240. VARIANT_BOOL *builtIn)
  241. {
  242. fw_port *This = impl_from_INetFwOpenPort( iface );
  243. FIXME("%p %p\n", This, builtIn);
  244. return E_NOTIMPL;
  245. }
  246. static const struct INetFwOpenPortVtbl fw_port_vtbl =
  247. {
  248. fw_port_QueryInterface,
  249. fw_port_AddRef,
  250. fw_port_Release,
  251. fw_port_GetTypeInfoCount,
  252. fw_port_GetTypeInfo,
  253. fw_port_GetIDsOfNames,
  254. fw_port_Invoke,
  255. fw_port_get_Name,
  256. fw_port_put_Name,
  257. fw_port_get_IpVersion,
  258. fw_port_put_IpVersion,
  259. fw_port_get_Protocol,
  260. fw_port_put_Protocol,
  261. fw_port_get_Port,
  262. fw_port_put_Port,
  263. fw_port_get_Scope,
  264. fw_port_put_Scope,
  265. fw_port_get_RemoteAddresses,
  266. fw_port_put_RemoteAddresses,
  267. fw_port_get_Enabled,
  268. fw_port_put_Enabled,
  269. fw_port_get_BuiltIn
  270. };
  271. static HRESULT NetFwOpenPort_create( IUnknown *pUnkOuter, LPVOID *ppObj )
  272. {
  273. fw_port *fp;
  274. TRACE("(%p,%p)\n", pUnkOuter, ppObj);
  275. fp = HeapAlloc( GetProcessHeap(), 0, sizeof(*fp) );
  276. if (!fp) return E_OUTOFMEMORY;
  277. fp->vtbl = &fw_port_vtbl;
  278. fp->refs = 1;
  279. *ppObj = &fp->vtbl;
  280. TRACE("returning iface %p\n", *ppObj);
  281. return S_OK;
  282. }
  283. typedef struct fw_ports
  284. {
  285. const INetFwOpenPortsVtbl *vtbl;
  286. LONG refs;
  287. } fw_ports;
  288. static inline fw_ports *impl_from_INetFwOpenPorts( INetFwOpenPorts *iface )
  289. {
  290. return (fw_ports *)((char *)iface - FIELD_OFFSET( fw_ports, vtbl ));
  291. }
  292. static ULONG WINAPI fw_ports_AddRef(
  293. INetFwOpenPorts *iface )
  294. {
  295. fw_ports *fw_ports = impl_from_INetFwOpenPorts( iface );
  296. return InterlockedIncrement( &fw_ports->refs );
  297. }
  298. static ULONG WINAPI fw_ports_Release(
  299. INetFwOpenPorts *iface )
  300. {
  301. fw_ports *fw_ports = impl_from_INetFwOpenPorts( iface );
  302. LONG refs = InterlockedDecrement( &fw_ports->refs );
  303. if (!refs)
  304. {
  305. TRACE("destroying %p\n", fw_ports);
  306. HeapFree( GetProcessHeap(), 0, fw_ports );
  307. }
  308. return refs;
  309. }
  310. static HRESULT WINAPI fw_ports_QueryInterface(
  311. INetFwOpenPorts *iface,
  312. REFIID riid,
  313. void **ppvObject )
  314. {
  315. fw_ports *This = impl_from_INetFwOpenPorts( iface );
  316. TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
  317. if ( IsEqualGUID( riid, &IID_INetFwOpenPorts ) ||
  318. IsEqualGUID( riid, &IID_IDispatch ) ||
  319. IsEqualGUID( riid, &IID_IUnknown ) )
  320. {
  321. *ppvObject = iface;
  322. }
  323. else
  324. {
  325. FIXME("interface %s not implemented\n", debugstr_guid(riid));
  326. return E_NOINTERFACE;
  327. }
  328. INetFwOpenPorts_AddRef( iface );
  329. return S_OK;
  330. }
  331. static HRESULT WINAPI fw_ports_GetTypeInfoCount(
  332. INetFwOpenPorts *iface,
  333. UINT *pctinfo )
  334. {
  335. fw_ports *This = impl_from_INetFwOpenPorts( iface );
  336. FIXME("%p %p\n", This, pctinfo);
  337. return E_NOTIMPL;
  338. }
  339. static HRESULT WINAPI fw_ports_GetTypeInfo(
  340. INetFwOpenPorts *iface,
  341. UINT iTInfo,
  342. LCID lcid,
  343. ITypeInfo **ppTInfo )
  344. {
  345. fw_ports *This = impl_from_INetFwOpenPorts( iface );
  346. FIXME("%p %u %u %p\n", This, iTInfo, lcid, ppTInfo);
  347. return E_NOTIMPL;
  348. }
  349. static HRESULT WINAPI fw_ports_GetIDsOfNames(
  350. INetFwOpenPorts *iface,
  351. REFIID riid,
  352. LPOLESTR *rgszNames,
  353. UINT cNames,
  354. LCID lcid,
  355. DISPID *rgDispId )
  356. {
  357. fw_ports *This = impl_from_INetFwOpenPorts( iface );
  358. FIXME("%p %s %p %u %u %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
  359. return E_NOTIMPL;
  360. }
  361. static HRESULT WINAPI fw_ports_Invoke(
  362. INetFwOpenPorts *iface,
  363. DISPID dispIdMember,
  364. REFIID riid,
  365. LCID lcid,
  366. WORD wFlags,
  367. DISPPARAMS *pDispParams,
  368. VARIANT *pVarResult,
  369. EXCEPINFO *pExcepInfo,
  370. UINT *puArgErr )
  371. {
  372. fw_ports *This = impl_from_INetFwOpenPorts( iface );
  373. FIXME("%p %d %s %d %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
  374. lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
  375. return E_NOTIMPL;
  376. }
  377. static HRESULT WINAPI fw_ports_get_Count(
  378. INetFwOpenPorts *iface,
  379. LONG *count)
  380. {
  381. fw_ports *This = impl_from_INetFwOpenPorts( iface );
  382. FIXME("%p, %p\n", This, count);
  383. *count = 0;
  384. return S_OK;
  385. }
  386. static HRESULT WINAPI fw_ports_Add(
  387. INetFwOpenPorts *iface,
  388. INetFwOpenPort *port)
  389. {
  390. fw_ports *This = impl_from_INetFwOpenPorts( iface );
  391. FIXME("%p, %p\n", This, port);
  392. return E_NOTIMPL;
  393. }
  394. static HRESULT WINAPI fw_ports_Remove(
  395. INetFwOpenPorts *iface,
  396. LONG portNumber,
  397. NET_FW_IP_PROTOCOL ipProtocol)
  398. {
  399. fw_ports *This = impl_from_INetFwOpenPorts( iface );
  400. FIXME("%p, %d, %u\n", This, portNumber, ipProtocol);
  401. return E_NOTIMPL;
  402. }
  403. static HRESULT WINAPI fw_ports_Item(
  404. INetFwOpenPorts *iface,
  405. LONG portNumber,
  406. NET_FW_IP_PROTOCOL ipProtocol,
  407. INetFwOpenPort **openPort)
  408. {
  409. HRESULT hr;
  410. fw_ports *This = impl_from_INetFwOpenPorts( iface );
  411. FIXME("%p, %d, %u, %p\n", This, portNumber, ipProtocol, openPort);
  412. hr = NetFwOpenPort_create( NULL, (void **)openPort );
  413. if (SUCCEEDED(hr))
  414. {
  415. INetFwOpenPort_put_Protocol( *openPort, ipProtocol );
  416. INetFwOpenPort_put_Port( *openPort, portNumber );
  417. }
  418. return hr;
  419. }
  420. static HRESULT WINAPI fw_ports_get__NewEnum(
  421. INetFwOpenPorts *iface,
  422. IUnknown **newEnum)
  423. {
  424. fw_ports *This = impl_from_INetFwOpenPorts( iface );
  425. FIXME("%p, %p\n", This, newEnum);
  426. return E_NOTIMPL;
  427. }
  428. static const struct INetFwOpenPortsVtbl fw_ports_vtbl =
  429. {
  430. fw_ports_QueryInterface,
  431. fw_ports_AddRef,
  432. fw_ports_Release,
  433. fw_ports_GetTypeInfoCount,
  434. fw_ports_GetTypeInfo,
  435. fw_ports_GetIDsOfNames,
  436. fw_ports_Invoke,
  437. fw_ports_get_Count,
  438. fw_ports_Add,
  439. fw_ports_Remove,
  440. fw_ports_Item,
  441. fw_ports_get__NewEnum
  442. };
  443. HRESULT NetFwOpenPorts_create( IUnknown *pUnkOuter, LPVOID *ppObj )
  444. {
  445. fw_ports *fp;
  446. TRACE("(%p,%p)\n", pUnkOuter, ppObj);
  447. fp = HeapAlloc( GetProcessHeap(), 0, sizeof(*fp) );
  448. if (!fp) return E_OUTOFMEMORY;
  449. fp->vtbl = &fw_ports_vtbl;
  450. fp->refs = 1;
  451. *ppObj = &fp->vtbl;
  452. TRACE("returning iface %p\n", *ppObj);
  453. return S_OK;
  454. }