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 19 #include <stdarg.h> 20 #include <stdio.h> 21 22 #define COBJMACROS 23 24 #include "windef.h" 25 #include "winbase.h" 26 #include "winuser.h" 27 #include "ole2.h" 28 #include "netfw.h" 29 30 #include "wine/debug.h" 31 #include "hnetcfg_private.h" 32 33 WINE_DEFAULT_DEBUG_CHANNEL(hnetcfg); 34 35 typedef struct fw_profile 36 { 37 INetFwProfile INetFwProfile_iface; 38 LONG refs; 39 } fw_profile; 40 41 static inline fw_profile *impl_from_INetFwProfile( INetFwProfile *iface ) 42 { 43 return CONTAINING_RECORD(iface, fw_profile, INetFwProfile_iface); 44 } 45 46 static ULONG WINAPI fw_profile_AddRef( 47 INetFwProfile *iface ) 48 { 49 fw_profile *fw_profile = impl_from_INetFwProfile( iface ); 50 return InterlockedIncrement( &fw_profile->refs ); 51 } 52 53 static ULONG WINAPI fw_profile_Release( 54 INetFwProfile *iface ) 55 { 56 fw_profile *fw_profile = impl_from_INetFwProfile( iface ); 57 LONG refs = InterlockedDecrement( &fw_profile->refs ); 58 if (!refs) 59 { 60 TRACE("destroying %p\n", fw_profile); 61 HeapFree( GetProcessHeap(), 0, fw_profile ); 62 } 63 return refs; 64 } 65 66 static HRESULT WINAPI fw_profile_QueryInterface( 67 INetFwProfile *iface, 68 REFIID riid, 69 void **ppvObject ) 70 { 71 fw_profile *This = impl_from_INetFwProfile( iface ); 72 73 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject ); 74 75 if ( IsEqualGUID( riid, &IID_INetFwProfile ) || 76 IsEqualGUID( riid, &IID_IDispatch ) || 77 IsEqualGUID( riid, &IID_IUnknown ) ) 78 { 79 *ppvObject = iface; 80 } 81 else 82 { 83 FIXME("interface %s not implemented\n", debugstr_guid(riid)); 84 return E_NOINTERFACE; 85 } 86 INetFwProfile_AddRef( iface ); 87 return S_OK; 88 } 89 90 static HRESULT WINAPI fw_profile_GetTypeInfoCount( 91 INetFwProfile *iface, 92 UINT *pctinfo ) 93 { 94 fw_profile *This = impl_from_INetFwProfile( iface ); 95 96 TRACE("%p %p\n", This, pctinfo); 97 *pctinfo = 1; 98 return S_OK; 99 } 100 101 static HRESULT WINAPI fw_profile_GetTypeInfo( 102 INetFwProfile *iface, 103 UINT iTInfo, 104 LCID lcid, 105 ITypeInfo **ppTInfo ) 106 { 107 fw_profile *This = impl_from_INetFwProfile( iface ); 108 109 TRACE("%p %u %u %p\n", This, iTInfo, lcid, ppTInfo); 110 return get_typeinfo( INetFwProfile_tid, ppTInfo ); 111 } 112 113 static HRESULT WINAPI fw_profile_GetIDsOfNames( 114 INetFwProfile *iface, 115 REFIID riid, 116 LPOLESTR *rgszNames, 117 UINT cNames, 118 LCID lcid, 119 DISPID *rgDispId ) 120 { 121 fw_profile *This = impl_from_INetFwProfile( iface ); 122 ITypeInfo *typeinfo; 123 HRESULT hr; 124 125 TRACE("%p %s %p %u %u %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId); 126 127 hr = get_typeinfo( INetFwProfile_tid, &typeinfo ); 128 if (SUCCEEDED(hr)) 129 { 130 hr = ITypeInfo_GetIDsOfNames( typeinfo, rgszNames, cNames, rgDispId ); 131 ITypeInfo_Release( typeinfo ); 132 } 133 return hr; 134 } 135 136 static HRESULT WINAPI fw_profile_Invoke( 137 INetFwProfile *iface, 138 DISPID dispIdMember, 139 REFIID riid, 140 LCID lcid, 141 WORD wFlags, 142 DISPPARAMS *pDispParams, 143 VARIANT *pVarResult, 144 EXCEPINFO *pExcepInfo, 145 UINT *puArgErr ) 146 { 147 fw_profile *This = impl_from_INetFwProfile( iface ); 148 ITypeInfo *typeinfo; 149 HRESULT hr; 150 151 TRACE("%p %d %s %d %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid), 152 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); 153 154 hr = get_typeinfo( INetFwProfile_tid, &typeinfo ); 155 if (SUCCEEDED(hr)) 156 { 157 hr = ITypeInfo_Invoke( typeinfo, &This->INetFwProfile_iface, dispIdMember, 158 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr ); 159 ITypeInfo_Release( typeinfo ); 160 } 161 return hr; 162 } 163 164 static HRESULT WINAPI fw_profile_get_Type( 165 INetFwProfile *iface, 166 NET_FW_PROFILE_TYPE *type ) 167 { 168 fw_profile *This = impl_from_INetFwProfile( iface ); 169 170 FIXME("%p, %p\n", This, type); 171 return E_NOTIMPL; 172 } 173 174 static HRESULT WINAPI fw_profile_get_FirewallEnabled( 175 INetFwProfile *iface, 176 VARIANT_BOOL *enabled ) 177 { 178 fw_profile *This = impl_from_INetFwProfile( iface ); 179 180 FIXME("%p, %p\n", This, enabled); 181 182 *enabled = VARIANT_FALSE; 183 return S_OK; 184 } 185 186 static HRESULT WINAPI fw_profile_put_FirewallEnabled( 187 INetFwProfile *iface, 188 VARIANT_BOOL enabled ) 189 { 190 fw_profile *This = impl_from_INetFwProfile( iface ); 191 192 FIXME("%p, %d\n", This, enabled); 193 return E_NOTIMPL; 194 } 195 196 static HRESULT WINAPI fw_profile_get_ExceptionsNotAllowed( 197 INetFwProfile *iface, 198 VARIANT_BOOL *notAllowed ) 199 { 200 fw_profile *This = impl_from_INetFwProfile( iface ); 201 202 FIXME("%p, %p\n", This, notAllowed); 203 return E_NOTIMPL; 204 } 205 206 static HRESULT WINAPI fw_profile_put_ExceptionsNotAllowed( 207 INetFwProfile *iface, 208 VARIANT_BOOL notAllowed ) 209 { 210 fw_profile *This = impl_from_INetFwProfile( iface ); 211 212 FIXME("%p, %d\n", This, notAllowed); 213 return E_NOTIMPL; 214 } 215 216 static HRESULT WINAPI fw_profile_get_NotificationsDisabled( 217 INetFwProfile *iface, 218 VARIANT_BOOL *disabled ) 219 { 220 fw_profile *This = impl_from_INetFwProfile( iface ); 221 222 FIXME("%p, %p\n", This, disabled); 223 return E_NOTIMPL; 224 } 225 226 static HRESULT WINAPI fw_profile_put_NotificationsDisabled( 227 INetFwProfile *iface, 228 VARIANT_BOOL disabled ) 229 { 230 fw_profile *This = impl_from_INetFwProfile( iface ); 231 232 FIXME("%p, %d\n", This, disabled); 233 return E_NOTIMPL; 234 } 235 236 static HRESULT WINAPI fw_profile_get_UnicastResponsesToMulticastBroadcastDisabled( 237 INetFwProfile *iface, 238 VARIANT_BOOL *disabled ) 239 { 240 fw_profile *This = impl_from_INetFwProfile( iface ); 241 242 FIXME("%p, %p\n", This, disabled); 243 return E_NOTIMPL; 244 } 245 246 static HRESULT WINAPI fw_profile_put_UnicastResponsesToMulticastBroadcastDisabled( 247 INetFwProfile *iface, 248 VARIANT_BOOL disabled ) 249 { 250 fw_profile *This = impl_from_INetFwProfile( iface ); 251 252 FIXME("%p, %d\n", This, disabled); 253 return E_NOTIMPL; 254 } 255 256 static HRESULT WINAPI fw_profile_get_RemoteAdminSettings( 257 INetFwProfile *iface, 258 INetFwRemoteAdminSettings **remoteAdminSettings ) 259 { 260 fw_profile *This = impl_from_INetFwProfile( iface ); 261 262 FIXME("%p, %p\n", This, remoteAdminSettings); 263 return E_NOTIMPL; 264 } 265 266 static HRESULT WINAPI fw_profile_get_IcmpSettings( 267 INetFwProfile *iface, 268 INetFwIcmpSettings **icmpSettings ) 269 { 270 fw_profile *This = impl_from_INetFwProfile( iface ); 271 272 FIXME("%p, %p\n", This, icmpSettings); 273 return E_NOTIMPL; 274 } 275 276 static HRESULT WINAPI fw_profile_get_GloballyOpenPorts( 277 INetFwProfile *iface, 278 INetFwOpenPorts **openPorts ) 279 { 280 fw_profile *This = impl_from_INetFwProfile( iface ); 281 282 TRACE("%p, %p\n", This, openPorts); 283 return NetFwOpenPorts_create( NULL, (void **)openPorts ); 284 } 285 286 static HRESULT WINAPI fw_profile_get_Services( 287 INetFwProfile *iface, 288 INetFwServices **Services ) 289 { 290 fw_profile *This = impl_from_INetFwProfile( iface ); 291 292 TRACE("%p, %p\n", This, Services); 293 return NetFwServices_create( NULL, (void **)Services ); 294 } 295 296 static HRESULT WINAPI fw_profile_get_AuthorizedApplications( 297 INetFwProfile *iface, 298 INetFwAuthorizedApplications **apps ) 299 { 300 fw_profile *This = impl_from_INetFwProfile( iface ); 301 302 TRACE("%p, %p\n", This, apps); 303 return NetFwAuthorizedApplications_create( NULL, (void **)apps ); 304 } 305 306 static const struct INetFwProfileVtbl fw_profile_vtbl = 307 { 308 fw_profile_QueryInterface, 309 fw_profile_AddRef, 310 fw_profile_Release, 311 fw_profile_GetTypeInfoCount, 312 fw_profile_GetTypeInfo, 313 fw_profile_GetIDsOfNames, 314 fw_profile_Invoke, 315 fw_profile_get_Type, 316 fw_profile_get_FirewallEnabled, 317 fw_profile_put_FirewallEnabled, 318 fw_profile_get_ExceptionsNotAllowed, 319 fw_profile_put_ExceptionsNotAllowed, 320 fw_profile_get_NotificationsDisabled, 321 fw_profile_put_NotificationsDisabled, 322 fw_profile_get_UnicastResponsesToMulticastBroadcastDisabled, 323 fw_profile_put_UnicastResponsesToMulticastBroadcastDisabled, 324 fw_profile_get_RemoteAdminSettings, 325 fw_profile_get_IcmpSettings, 326 fw_profile_get_GloballyOpenPorts, 327 fw_profile_get_Services, 328 fw_profile_get_AuthorizedApplications 329 }; 330 331 HRESULT NetFwProfile_create( IUnknown *pUnkOuter, LPVOID *ppObj ) 332 { 333 fw_profile *fp; 334 335 TRACE("(%p,%p)\n", pUnkOuter, ppObj); 336 337 fp = HeapAlloc( GetProcessHeap(), 0, sizeof(*fp) ); 338 if (!fp) return E_OUTOFMEMORY; 339 340 fp->INetFwProfile_iface.lpVtbl = &fw_profile_vtbl; 341 fp->refs = 1; 342 343 *ppObj = &fp->INetFwProfile_iface; 344 345 TRACE("returning iface %p\n", *ppObj); 346 return S_OK; 347 } 348