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