msi: Free the column info data when updating the table column info.
[wine] / dlls / hnetcfg / policy.c
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_policy
38 {
39     const INetFwPolicyVtbl *vtbl;
40     LONG refs;
41 } fw_policy;
42
43 static inline fw_policy *impl_from_INetFwPolicy( INetFwPolicy *iface )
44 {
45     return (fw_policy *)((char *)iface - FIELD_OFFSET( fw_policy, vtbl ));
46 }
47
48 static ULONG WINAPI fw_policy_AddRef(
49     INetFwPolicy *iface )
50 {
51     fw_policy *fw_policy = impl_from_INetFwPolicy( iface );
52     return InterlockedIncrement( &fw_policy->refs );
53 }
54
55 static ULONG WINAPI fw_policy_Release(
56     INetFwPolicy *iface )
57 {
58     fw_policy *fw_policy = impl_from_INetFwPolicy( iface );
59     LONG refs = InterlockedDecrement( &fw_policy->refs );
60     if (!refs)
61     {
62         TRACE("destroying %p\n", fw_policy);
63         HeapFree( GetProcessHeap(), 0, fw_policy );
64     }
65     return refs;
66 }
67
68 static HRESULT WINAPI fw_policy_QueryInterface(
69     INetFwPolicy *iface,
70     REFIID riid,
71     void **ppvObject )
72 {
73     fw_policy *This = impl_from_INetFwPolicy( iface );
74
75     TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
76
77     if ( IsEqualGUID( riid, &IID_INetFwPolicy ) ||
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     INetFwPolicy_AddRef( iface );
89     return S_OK;
90 }
91
92 static HRESULT WINAPI fw_policy_GetTypeInfoCount(
93     INetFwPolicy *iface,
94     UINT *pctinfo )
95 {
96     fw_policy *This = impl_from_INetFwPolicy( iface );
97
98     FIXME("%p %p\n", This, pctinfo);
99     return E_NOTIMPL;
100 }
101
102 static HRESULT WINAPI fw_policy_GetTypeInfo(
103     INetFwPolicy *iface,
104     UINT iTInfo,
105     LCID lcid,
106     ITypeInfo **ppTInfo )
107 {
108     fw_policy *This = impl_from_INetFwPolicy( iface );
109
110     FIXME("%p %u %u %p\n", This, iTInfo, lcid, ppTInfo);
111     return E_NOTIMPL;
112 }
113
114 static HRESULT WINAPI fw_policy_GetIDsOfNames(
115     INetFwPolicy *iface,
116     REFIID riid,
117     LPOLESTR *rgszNames,
118     UINT cNames,
119     LCID lcid,
120     DISPID *rgDispId )
121 {
122     fw_policy *This = impl_from_INetFwPolicy( iface );
123
124     FIXME("%p %s %p %u %u %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
125     return E_NOTIMPL;
126 }
127
128 static HRESULT WINAPI fw_policy_Invoke(
129     INetFwPolicy *iface,
130     DISPID dispIdMember,
131     REFIID riid,
132     LCID lcid,
133     WORD wFlags,
134     DISPPARAMS *pDispParams,
135     VARIANT *pVarResult,
136     EXCEPINFO *pExcepInfo,
137     UINT *puArgErr )
138 {
139     fw_policy *This = impl_from_INetFwPolicy( iface );
140
141     FIXME("%p %d %s %d %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
142           lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
143     return E_NOTIMPL;
144 }
145
146 static HRESULT WINAPI fw_policy_get_CurrentProfile(
147     INetFwPolicy *iface,
148     INetFwProfile **profile )
149 {
150     fw_policy *This = impl_from_INetFwPolicy( iface );
151
152     TRACE("%p, %p\n", This, profile);
153     return NetFwProfile_create( NULL, (void **)profile );
154 }
155
156 static HRESULT WINAPI fw_policy_GetProfileByType(
157     INetFwPolicy *iface,
158     NET_FW_PROFILE_TYPE profileType,
159     INetFwProfile **profile )
160 {
161     fw_policy *This = impl_from_INetFwPolicy( iface );
162
163     FIXME("%p, %u, %p\n", This, profileType, profile);
164     return E_NOTIMPL;
165 }
166
167 static const struct INetFwPolicyVtbl fw_policy_vtbl =
168 {
169     fw_policy_QueryInterface,
170     fw_policy_AddRef,
171     fw_policy_Release,
172     fw_policy_GetTypeInfoCount,
173     fw_policy_GetTypeInfo,
174     fw_policy_GetIDsOfNames,
175     fw_policy_Invoke,
176     fw_policy_get_CurrentProfile,
177     fw_policy_GetProfileByType
178 };
179
180 HRESULT NetFwPolicy_create( IUnknown *pUnkOuter, LPVOID *ppObj )
181 {
182     fw_policy *fp;
183
184     TRACE("(%p,%p)\n", pUnkOuter, ppObj);
185
186     fp = HeapAlloc( GetProcessHeap(), 0, sizeof(*fp) );
187     if (!fp) return E_OUTOFMEMORY;
188
189     fp->vtbl = &fw_policy_vtbl;
190     fp->refs = 1;
191
192     *ppObj = &fp->vtbl;
193
194     TRACE("returning iface %p\n", *ppObj);
195     return S_OK;
196 }