1 #include "precomp.h"
2 
3 typedef struct
4 {
5     const INetCfgBindingInterface *lpVtbl;
6     LONG ref;
7 } INetCfgBindingInterfaceImpl;
8 
9 typedef struct
10 {
11     const IEnumNetCfgBindingInterface *lpVtbl;
12     LONG ref;
13 } IEnumNetCfgBindingInterfaceImpl;
14 
15 
16 /***************************************************************
17  * INetCfgBindingInterface
18  */
19 
20 HRESULT
21 WINAPI
22 INetCfgBindingInterface_fnQueryInterface(
23     INetCfgBindingInterface *iface,
24     REFIID iid,
25     LPVOID *ppvObj)
26 {
27     INetCfgBindingInterfaceImpl *This = (INetCfgBindingInterfaceImpl*)iface;
28     *ppvObj = NULL;
29 
30     if (IsEqualIID (iid, &IID_IUnknown) ||
31         IsEqualIID (iid, &IID_INetCfgBindingInterface))
32     {
33         *ppvObj = This;
34         return S_OK;
35     }
36 
37     return E_NOINTERFACE;
38 }
39 
40 ULONG
41 WINAPI
42 INetCfgBindingInterface_fnAddRef(
43     INetCfgBindingInterface *iface)
44 {
45     INetCfgBindingInterfaceImpl *This = (INetCfgBindingInterfaceImpl*)iface;
46     ULONG refCount = InterlockedIncrement(&This->ref);
47 
48     return refCount;
49 }
50 
51 ULONG
52 WINAPI
53 INetCfgBindingInterface_fnRelease(
54     INetCfgBindingInterface *iface)
55 {
56     INetCfgBindingInterfaceImpl *This = (INetCfgBindingInterfaceImpl*)iface;
57     ULONG refCount = InterlockedDecrement(&This->ref);
58 
59     if (!refCount)
60     {
61        CoTaskMemFree(This);
62     }
63     return refCount;
64 }
65 
66 HRESULT
67 WINAPI
68 INetCfgBindingInterface_fnGetName(
69     INetCfgBindingInterface *iface,
70     LPWSTR *ppszwInterfaceName)
71 {
72     return E_NOTIMPL;
73 }
74 
75 HRESULT
76 WINAPI
77 INetCfgBindingInterface_fnGetUpperComponent(
78     INetCfgBindingInterface *iface,
79     INetCfgComponent **ppnccItem)
80 {
81     return E_NOTIMPL;
82 }
83 
84 HRESULT
85 WINAPI
86 INetCfgBindingInterface_fnGetLowerComponent(
87     INetCfgBindingInterface *iface,
88     INetCfgComponent **ppnccItem)
89 {
90     return E_NOTIMPL;
91 }
92 
93 static const INetCfgBindingInterfaceVtbl vt_NetCfgBindingInterface =
94 {
95     INetCfgBindingInterface_fnQueryInterface,
96     INetCfgBindingInterface_fnAddRef,
97     INetCfgBindingInterface_fnRelease,
98     INetCfgBindingInterface_fnGetName,
99     INetCfgBindingInterface_fnGetUpperComponent,
100     INetCfgBindingInterface_fnGetLowerComponent,
101 };
102 
103 HRESULT
104 WINAPI
105 INetCfgBindingInterface_Constructor(
106     IUnknown *pUnkOuter,
107     REFIID riid,
108     LPVOID *ppv)
109 {
110     INetCfgBindingInterfaceImpl *This;
111 
112     if (!ppv)
113         return E_POINTER;
114 
115     This = (INetCfgBindingInterfaceImpl *)CoTaskMemAlloc(sizeof(INetCfgBindingInterfaceImpl));
116     if (!This)
117         return E_OUTOFMEMORY;
118 
119     This->ref = 1;
120     This->lpVtbl = (const INetCfgBindingInterface*)&vt_NetCfgBindingInterface;
121 
122     if (!SUCCEEDED(INetCfgBindingInterface_QueryInterface((INetCfgBindingInterface*)This, riid, ppv)))
123     {
124         return E_NOINTERFACE;
125     }
126 
127     INetCfgBindingInterface_Release((INetCfgBindingInterface*)This);
128     return S_OK;
129 }
130 
131 
132 /***************************************************************
133  * IEnumNetCfgBindingInterface
134  */
135 
136 HRESULT
137 WINAPI
138 IEnumNetCfgBindingInterface_fnQueryInterface(
139     IEnumNetCfgBindingInterface *iface,
140     REFIID iid,
141     LPVOID *ppvObj)
142 {
143     IEnumNetCfgBindingInterfaceImpl *This = (IEnumNetCfgBindingInterfaceImpl*)iface;
144     *ppvObj = NULL;
145 
146     if (IsEqualIID (iid, &IID_IUnknown) ||
147         IsEqualIID (iid, &IID_IEnumNetCfgBindingInterface))
148     {
149         *ppvObj = This;
150         return S_OK;
151     }
152 
153     return E_NOINTERFACE;
154 }
155 
156 
157 ULONG
158 WINAPI
159 IEnumNetCfgBindingInterface_fnAddRef(
160     IEnumNetCfgBindingInterface *iface)
161 {
162     IEnumNetCfgBindingInterfaceImpl *This = (IEnumNetCfgBindingInterfaceImpl*)iface;
163     ULONG refCount = InterlockedIncrement(&This->ref);
164 
165     return refCount;
166 }
167 
168 ULONG
169 WINAPI
170 IEnumNetCfgBindingInterface_fnRelease(
171     IEnumNetCfgBindingInterface *iface)
172 {
173     IEnumNetCfgBindingInterfaceImpl *This = (IEnumNetCfgBindingInterfaceImpl*)iface;
174     ULONG refCount = InterlockedDecrement(&This->ref);
175 
176     return refCount;
177 }
178 
179 HRESULT
180 WINAPI
181 IEnumNetCfgBindingInterface_fnNext(
182     IEnumNetCfgBindingInterface *iface,
183     ULONG celt,
184     INetCfgBindingInterface **rgelt,
185     ULONG *pceltFetched)
186 {
187 #if 0
188     IEnumNetCfgBindingInterfaceImpl *This = (IEnumNetCfgBindingInterfaceImpl*)iface;
189     HRESULT hr;
190 
191     if (!iface || !rgelt)
192         return E_POINTER;
193 
194     if (celt != 1)
195         return E_INVALIDARG;
196 
197     if (!This->pCurrent)
198         return S_FALSE;
199 
200     hr = INetCfgBindingInterface_Constructor(NULL, &IID_INetCfgBindingInterface, (LPVOID*)rgelt);
201     if (SUCCEEDED(hr))
202     {
203         This->pCurrent = This->pCurrent->pNext;
204         if (pceltFetched)
205             *pceltFetched = 1;
206     }
207     return hr;
208 #endif
209 
210     return E_NOTIMPL;
211 }
212 
213 HRESULT
214 WINAPI
215 IEnumNetCfgBindingInterface_fnSkip(
216     IEnumNetCfgBindingInterface *iface,
217     ULONG celt)
218 {
219 #if 0
220     IEnumNetCfgBindingInterfaceImpl *This = (IEnumNetCfgBindingInterfaceImpl*)iface;
221 
222     if (!This->pCurrent)
223         return S_FALSE;
224 
225     while (celt-- > 0 && This->pCurrent)
226         This->pCurrent = This->pCurrent->pNext;
227 
228     if (!celt)
229         return S_OK;
230     else
231         return S_FALSE;
232 #endif
233 
234     return E_NOTIMPL;
235 }
236 
237 HRESULT
238 WINAPI
239 IEnumNetCfgBindingInterface_fnReset(
240     IEnumNetCfgBindingInterface *iface)
241 {
242 #if 0
243     IEnumNetCfgBindingInterfaceImpl *This = (IEnumNetCfgBindingInterfaceImpl*)iface;
244 
245     This->pCurrent = This->pHead;
246     return S_OK;
247 #endif
248 
249     return E_NOTIMPL;
250 }
251 
252 HRESULT
253 WINAPI
254 IEnumNetCfgBindingInterface_fnClone(
255     IEnumNetCfgBindingInterface *iface,
256     IEnumNetCfgBindingInterface **ppenum)
257 {
258     return E_NOTIMPL;
259 }
260 
261 static const IEnumNetCfgBindingInterfaceVtbl vt_EnumNetCfgBindingInterface =
262 {
263     IEnumNetCfgBindingInterface_fnQueryInterface,
264     IEnumNetCfgBindingInterface_fnAddRef,
265     IEnumNetCfgBindingInterface_fnRelease,
266     IEnumNetCfgBindingInterface_fnNext,
267     IEnumNetCfgBindingInterface_fnSkip,
268     IEnumNetCfgBindingInterface_fnReset,
269     IEnumNetCfgBindingInterface_fnClone
270 };
271 
272 HRESULT
273 WINAPI
274 IEnumNetCfgBindingInterface_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppv)
275 {
276     IEnumNetCfgBindingInterfaceImpl *This;
277 
278     if (!ppv)
279         return E_POINTER;
280 
281     This = (IEnumNetCfgBindingInterfaceImpl *)CoTaskMemAlloc(sizeof(IEnumNetCfgBindingInterfaceImpl));
282     if (!This)
283         return E_OUTOFMEMORY;
284 
285     This->ref = 1;
286     This->lpVtbl = (const IEnumNetCfgBindingInterface*)&vt_EnumNetCfgBindingInterface;
287 #if 0
288     This->pCurrent = pItem;
289     This->pHead = pItem;
290     This->pNCfg = pNCfg;
291 #endif
292 
293     if (!SUCCEEDED (IEnumNetCfgBindingInterface_QueryInterface((INetCfgBindingInterface*)This, riid, ppv)))
294     {
295         IEnumNetCfgBindingInterface_Release((INetCfg*)This);
296         return E_NOINTERFACE;
297     }
298 
299     IEnumNetCfgBindingInterface_Release((IEnumNetCfgBindingInterface*)This);
300     return S_OK;
301 }
302