Skip to content

Commit 5384683

Browse files
committed
[NETCFGX] Implement INetCfgClass_fnFindComponent() and INetCfgClass_fnEnumComponents()
1 parent 16e711b commit 5384683

File tree

3 files changed

+52
-24
lines changed

3 files changed

+52
-24
lines changed

dll/win32/netcfgx/netcfg_iface.c

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
11
#include "precomp.h"
22

3-
typedef struct
4-
{
5-
const INetCfg * lpVtbl;
6-
const INetCfgLock * lpVtblLock;
7-
const INetCfgPnpReconfigCallback *lpVtblPnpReconfigCallback;
8-
LONG ref;
9-
BOOL bInitialized;
10-
HANDLE hMutex;
11-
NetCfgComponentItem *pNet;
12-
NetCfgComponentItem * pService;
13-
NetCfgComponentItem * pClient;
14-
NetCfgComponentItem * pProtocol;
15-
} INetCfgImpl, *LPINetCfgImpl;
16-
17-
static __inline LPINetCfgImpl impl_from_INetCfgLock(INetCfgLock *iface)
3+
static __inline INetCfgImpl* impl_from_INetCfgLock(INetCfgLock *iface)
184
{
195
return (INetCfgImpl*)((char *)iface - FIELD_OFFSET(INetCfgImpl, lpVtblLock));
206
}
217

22-
static __inline LPINetCfgImpl impl_from_INetCfgPnpReconfigCallback(INetCfgPnpReconfigCallback *iface)
8+
static __inline INetCfgImpl* impl_from_INetCfgPnpReconfigCallback(INetCfgPnpReconfigCallback *iface)
239
{
2410
return (INetCfgImpl*)((char *)iface - FIELD_OFFSET(INetCfgImpl, lpVtblPnpReconfigCallback));
2511
}

dll/win32/netcfgx/netcfgclass_iface.c

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,28 @@ INetCfgClass_fnFindComponent(
170170
LPCWSTR pszwComponentId,
171171
INetCfgComponent **pComponent)
172172
{
173-
// HRESULT hr;
174-
// INetCfgClassImpl *This = (INetCfgClassImpl *)iface;
175-
173+
INetCfgClassImpl *This = (INetCfgClassImpl *)iface;
174+
NetCfgComponentItem *pHead;
175+
176+
if (IsEqualIID(&This->ClassGuid, &GUID_DEVCLASS_NET))
177+
pHead = ((INetCfgImpl*)(This->pNetCfg))->pNet;
178+
else if (IsEqualIID(&This->ClassGuid, &GUID_DEVCLASS_NETTRANS))
179+
pHead = ((INetCfgImpl*)(This->pNetCfg))->pProtocol;
180+
else if (IsEqualIID(&This->ClassGuid, &GUID_DEVCLASS_NETSERVICE))
181+
pHead = ((INetCfgImpl*)(This->pNetCfg))->pService;
182+
else if (IsEqualIID(&This->ClassGuid, &GUID_DEVCLASS_NETCLIENT))
183+
pHead = ((INetCfgImpl*)(This->pNetCfg))->pClient;
184+
else
185+
return E_NOINTERFACE;
176186

177-
/* TODO */
187+
while (pHead)
188+
{
189+
if (!_wcsicmp(pHead->szId, pszwComponentId))
190+
{
191+
return INetCfgComponent_Constructor(NULL, &IID_INetCfgComponent, (LPVOID*)pComponent, pHead, This->pNetCfg);
192+
}
193+
pHead = pHead->pNext;
194+
}
178195

179196
return S_FALSE;
180197
}
@@ -185,10 +202,21 @@ INetCfgClass_fnEnumComponents(
185202
INetCfgClass *iface,
186203
IEnumNetCfgComponent **ppenumComponent)
187204
{
188-
// INetCfgClassImpl *This = (INetCfgClassImpl *)iface;
189-
205+
INetCfgClassImpl *This = (INetCfgClassImpl *)iface;
206+
NetCfgComponentItem *pHead;
207+
208+
if (IsEqualIID(&This->ClassGuid, &GUID_DEVCLASS_NET))
209+
pHead = ((INetCfgImpl*)(This->pNetCfg))->pNet;
210+
else if (IsEqualIID(&This->ClassGuid, &GUID_DEVCLASS_NETTRANS))
211+
pHead = ((INetCfgImpl*)(This->pNetCfg))->pProtocol;
212+
else if (IsEqualIID(&This->ClassGuid, &GUID_DEVCLASS_NETSERVICE))
213+
pHead = ((INetCfgImpl*)(This->pNetCfg))->pService;
214+
else if (IsEqualIID(&This->ClassGuid, &GUID_DEVCLASS_NETCLIENT))
215+
pHead = ((INetCfgImpl*)(This->pNetCfg))->pClient;
216+
else
217+
return E_NOINTERFACE;
190218

191-
return E_NOINTERFACE;
219+
return IEnumNetCfgComponent_Constructor (NULL, &IID_IEnumNetCfgComponent, (LPVOID*)ppenumComponent, pHead, This->pNetCfg);
192220
}
193221

194222
static const INetCfgClassVtbl vt_NetCfgClass =

dll/win32/netcfgx/precomp.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,21 @@ typedef struct tagNetCfgComponentItem
5151
LPWSTR pszBinding;
5252
struct tagNetCfgComponentItem * pNext;
5353
INetCfgComponentControl * pNCCC;
54-
}NetCfgComponentItem;
54+
} NetCfgComponentItem;
55+
56+
typedef struct
57+
{
58+
const INetCfg * lpVtbl;
59+
const INetCfgLock * lpVtblLock;
60+
const INetCfgPnpReconfigCallback *lpVtblPnpReconfigCallback;
61+
LONG ref;
62+
BOOL bInitialized;
63+
HANDLE hMutex;
64+
NetCfgComponentItem *pNet;
65+
NetCfgComponentItem * pService;
66+
NetCfgComponentItem * pClient;
67+
NetCfgComponentItem * pProtocol;
68+
} INetCfgImpl;
5569

5670
/* netcfg_iface.c */
5771
HRESULT WINAPI INetCfg_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv);

0 commit comments

Comments
 (0)