Author: janderwald
Date: Sun Sep 7 13:28:37 2008
New Revision: 36041
URL:
http://svn.reactos.org/svn/reactos?rev=36041&view=rev
Log:
- Acquire INetCfgLock before enumerating the items
- Check if a network component is enabled for a specific network adapter
- Get INetCfgComponent from the INetComponent
- Use ReportView for component dialog
Modified:
trunk/reactos/dll/win32/netshell/lanconnectui.c
trunk/reactos/dll/win32/netshell/lang/de-DE.rc
trunk/reactos/dll/win32/netshell/lang/en-US.rc
trunk/reactos/dll/win32/netshell/lang/ru-RU.rc
Modified: trunk/reactos/dll/win32/netshell/lanconnectui.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netshell/lanconn…
==============================================================================
--- trunk/reactos/dll/win32/netshell/lanconnectui.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netshell/lanconnectui.c [iso-8859-1] Sun Sep 7 13:28:37 2008
@@ -24,6 +24,7 @@
{
INetConnectionPropertyUi *lpVtbl;
INetConnection * pCon;
+ INetCfgLock *NCfgLock;
INetCfg * pNCfg;
LONG ref;
}INetConnectionPropertyUiImpl, *LPINetConnectionPropertyUiImpl;
@@ -49,7 +50,7 @@
}
VOID
-AddItemToListView(HWND hDlgCtrl, PNET_ITEM pItem, LPWSTR szName)
+AddItemToListView(HWND hDlgCtrl, PNET_ITEM pItem, LPWSTR szName, BOOL bChecked)
{
LVITEMW lvItem;
@@ -59,20 +60,63 @@
lvItem.lParam = (LPARAM)pItem;
lvItem.iItem = ListView_GetItemCount(hDlgCtrl);
lvItem.iItem = SendMessageW(hDlgCtrl, LVM_INSERTITEMW, 0, (LPARAM)&lvItem);
- ListView_SetCheckState(hDlgCtrl, lvItem.iItem, TRUE);
+ ListView_SetCheckState(hDlgCtrl, lvItem.iItem, bChecked);
+}
+
+BOOL
+GetINetCfgComponent(INetCfg * pNCfg, INetConnection * pNetCon, INetCfgComponent ** pOut)
+{
+ LPWSTR pName;
+ HRESULT hr;
+ NETCON_PROPERTIES* pProps;
+ INetCfgComponent * pNCg;
+ ULONG Fetched;
+ IEnumNetCfgComponent * pEnumCfg;
+
+ hr = INetConnection_GetProperties(pNetCon, &pProps);
+ if (FAILED(hr))
+ return FALSE;
+
+ hr = INetCfg_EnumComponents(pNCfg, &GUID_DEVCLASS_NET, &pEnumCfg);
+ if (FAILED(hr))
+ {
+ NcFreeNetconProperties(pProps);
+ return FALSE;
+ }
+
+ while(IEnumNetCfgComponent_Next(pEnumCfg, 1, &pNCg, &Fetched) == S_OK)
+ {
+ hr = INetCfgComponent_GetDisplayName(pNCg, &pName);
+ if (SUCCEEDED(hr))
+ {
+ if (!wcsicmp(pName, pProps->pszwDeviceName))
+ {
+ *pOut = pNCg;
+ IEnumNetCfgComponent_Release(pEnumCfg);
+ NcFreeNetconProperties(pProps);
+ return TRUE;
+ }
+ CoTaskMemFree(pName);
+ }
+ INetCfgComponent_Release(pNCg);
+ }
+ IEnumNetCfgComponent_Release(pEnumCfg);
+ NcFreeNetconProperties(pProps);
+ return FALSE;
}
VOID
-EnumComponents(HWND hDlgCtrl, INetCfg * pNCfg, const GUID * CompGuid, UINT Type)
+EnumComponents(HWND hDlgCtrl, INetConnectionPropertyUiImpl * This, INetCfg * pNCfg, const
GUID * CompGuid, UINT Type)
{
HRESULT hr;
IEnumNetCfgComponent * pENetCfg;
- INetCfgComponent *pNCfgComp;
+ INetCfgComponent *pNCfgComp, *pAdapterCfgComp;
+ INetCfgComponentBindings * pCompBind;
ULONG Num;
DWORD dwCharacteristics;
LPOLESTR pDisplayName, pHelpText;
PNET_ITEM pItem;
-
+ BOOL bChecked;
hr = INetCfg_EnumComponents(pNCfg, CompGuid, &pENetCfg);
if (FAILED(hr))
@@ -92,16 +136,29 @@
pHelpText = NULL;
hr = INetCfgComponent_GetDisplayName(pNCfgComp, &pDisplayName);
hr = INetCfgComponent_GetHelpText(pNCfgComp, &pHelpText);
-
- pItem = CoTaskMemAlloc(sizeof(NET_ITEM));
- if (!pItem)
- continue;
+ hr = INetCfgComponent_QueryInterface(pNCfgComp,
&IID_INetCfgComponentBindings, (LPVOID*)&pCompBind);
+
+ bChecked = FALSE;
+ if (GetINetCfgComponent(pNCfg, This->pCon, &pAdapterCfgComp))
+ {
+ hr = INetCfgComponentBindings_IsBoundTo(pCompBind, pAdapterCfgComp);
+ if (hr == S_OK)
+ bChecked = TRUE;
+ else
+ bChecked = FALSE;
+ INetCfgComponent_Release(pAdapterCfgComp);
+ }
+ pItem = CoTaskMemAlloc(sizeof(NET_ITEM));
+ if (!pItem)
+ continue;
pItem->dwCharacteristics = dwCharacteristics;
pItem->szHelp = pHelpText;
pItem->Type = Type;
pItem->pNCfgComp = pNCfgComp;
pItem->NumPropDialogOpen = 0;
- AddItemToListView(hDlgCtrl, pItem, pDisplayName);
+
+
+ AddItemToListView(hDlgCtrl, pItem, pDisplayName, bChecked);
CoTaskMemFree(pDisplayName);
}
IEnumNetCfgComponent_Release(pENetCfg);
@@ -113,11 +170,14 @@
{
HRESULT hr;
INetCfg * pNCfg;
+ INetCfgLock * pNCfgLock;
HWND hDlgCtrl = GetDlgItem(hwndDlg, IDC_COMPONENTSLIST);
LVCOLUMNW lc;
RECT rc;
DWORD dwStyle;
NETCON_PROPERTIES * pProperties;
+ LPWSTR pDisplayName;
+ LVITEMW li;
hr = INetConnection_GetProperties(This->pCon, &pProperties);
if (FAILED(hr))
@@ -155,6 +215,15 @@
if (FAILED(hr))
return;
+ hr = INetCfgLock_QueryInterface(pNCfg, &IID_INetCfgLock,
(LPVOID*)&pNCfgLock);
+ hr = INetCfgLock_AcquireWriteLock(pNCfgLock, 100, L"", &pDisplayName);
+ if (hr == S_FALSE)
+ {
+ CoTaskMemFree(pDisplayName);
+ return;
+ }
+
+ This->NCfgLock = pNCfgLock;
hr = INetCfg_Initialize(pNCfg, NULL);
if (FAILED(hr))
{
@@ -162,10 +231,16 @@
return;
}
- EnumComponents(hDlgCtrl, pNCfg, &GUID_DEVCLASS_NETCLIENT, NET_TYPE_CLIENT);
- EnumComponents(hDlgCtrl, pNCfg, &GUID_DEVCLASS_NETSERVICE, NET_TYPE_SERVICE);
- EnumComponents(hDlgCtrl, pNCfg, &GUID_DEVCLASS_NETTRANS, NET_TYPE_PROTOCOL);
+ EnumComponents(hDlgCtrl, This, pNCfg, &GUID_DEVCLASS_NETCLIENT,
NET_TYPE_CLIENT);
+ EnumComponents(hDlgCtrl, This, pNCfg, &GUID_DEVCLASS_NETSERVICE,
NET_TYPE_SERVICE);
+ EnumComponents(hDlgCtrl, This, pNCfg, &GUID_DEVCLASS_NETTRANS,
NET_TYPE_PROTOCOL);
This->pNCfg = pNCfg;
+
+ ZeroMemory(&li, sizeof(li));
+ li.mask = LVIF_STATE;
+ li.stateMask = (UINT)-1;
+ li.state = LVIS_FOCUSED|LVIS_SELECTED;
+ (void)SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
}
VOID
@@ -180,8 +255,7 @@
INetConnectionPropertyUi * pConUI = NULL;
INetCfgComponent * pNCfgComp;
PNET_ITEM pItem;
- INetCfgLock * pLock;
- LPWSTR pLockApp;
+ WCHAR szBuffer[200];
hDlgCtrl = GetDlgItem(hwndDlg, IDC_COMPONENTSLIST);
Count = ListView_GetItemCount(hDlgCtrl);
@@ -228,26 +302,15 @@
pItem = (PNET_ITEM)lvItem.lParam;
pNCfgComp = (INetCfgComponent*) pItem->pNCfgComp;
- hr = INetCfg_QueryInterface(This->pNCfg, &IID_INetCfgLock,
(LPVOID*)&pLock);
- if (FAILED(hr))
- return;
-
- hr = INetCfgLock_AcquireWriteLock(pLock, 10000, L"", &pLockApp);
- if (FAILED(hr))
- {
- CoTaskMemFree(pLockApp);
- INetConnectionPropertyUi_Release(pConUI);
- return;
- }
-
-
hr = INetCfgComponent_RaisePropertyUi(pNCfgComp, GetParent(hwndDlg),
NCRP_QUERY_PROPERTY_UI, (IUnknown*)pConUI);
if (SUCCEEDED(hr))
{
hr = INetCfgComponent_RaisePropertyUi(pNCfgComp, GetParent(hwndDlg),
NCRP_SHOW_PROPERTY_UI, (IUnknown*)pConUI);
}
- INetCfgLock_ReleaseWriteLock(pLock);
+ swprintf(szBuffer, L"result %08x", hr);
+ MessageBoxW(NULL, szBuffer, NULL, MB_OK);
+
INetConnectionPropertyUi_Release(pConUI);
}
Modified: trunk/reactos/dll/win32/netshell/lang/de-DE.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netshell/lang/de…
==============================================================================
--- trunk/reactos/dll/win32/netshell/lang/de-DE.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netshell/lang/de-DE.rc [iso-8859-1] Sun Sep 7 13:28:37 2008
@@ -5,7 +5,7 @@
CAPTION "Allgemein"
FONT 8, "MS Shell Dlg"
BEGIN
- CONTROL "List3", IDC_COMPONENTSLIST, "SysListView32",
LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOCOLUMNHEADER | WS_BORDER |
WS_TABSTOP | LVS_EX_FULLROWSELECT, 9, 71, 230, 55
+ CONTROL "", IDC_COMPONENTSLIST, "SysListView32", LVS_REPORT |
LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER |
WS_TABSTOP, 9, 71, 230, 55
LTEXT "Verbindung herstellen über:", -1, 9,9,217,8
EDITTEXT IDC_NETCARDNAME, 9, 21, 230, 12, WS_BORDER | WS_TABSTOP | ES_READONLY
PUSHBUTTON "&Konfigurieren", IDC_CONFIGURE, 189, 38, 50, 14
Modified: trunk/reactos/dll/win32/netshell/lang/en-US.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netshell/lang/en…
==============================================================================
--- trunk/reactos/dll/win32/netshell/lang/en-US.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netshell/lang/en-US.rc [iso-8859-1] Sun Sep 7 13:28:37 2008
@@ -5,7 +5,7 @@
CAPTION "General"
FONT 8, "MS Shell Dlg"
BEGIN
- CONTROL "", IDC_COMPONENTSLIST, "SysListView32", LVS_LIST |
LVS_SHAREIMAGELISTS | WS_BORDER | WS_TABSTOP, 9, 71, 230, 55
+ CONTROL "", IDC_COMPONENTSLIST, "SysListView32", LVS_REPORT |
LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER |
WS_TABSTOP, 9, 71, 230, 55
LTEXT "Connect Using:", -1, 9,9,217,8
EDITTEXT IDC_NETCARDNAME, 9, 21, 230, 12, WS_BORDER | WS_DISABLED | WS_TABSTOP
PUSHBUTTON "&Configure", IDC_CONFIGURE, 189, 38, 50, 14
Modified: trunk/reactos/dll/win32/netshell/lang/ru-RU.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netshell/lang/ru…
==============================================================================
--- trunk/reactos/dll/win32/netshell/lang/ru-RU.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netshell/lang/ru-RU.rc [iso-8859-1] Sun Sep 7 13:28:37 2008
@@ -5,7 +5,7 @@
CAPTION "Îáùèå"
FONT 8, "MS Shell Dlg"
BEGIN
- CONTROL "", IDC_COMPONENTSLIST, "SysListView32", LVS_LIST |
LVS_SHAREIMAGELISTS | WS_BORDER | WS_TABSTOP, 9, 71, 230, 55
+ CONTROL "", IDC_COMPONENTSLIST, "SysListView32", LVS_REPORT |
LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER |
WS_TABSTOP, 9, 71, 230, 55
LTEXT "Ïîäêëþ÷åíèå ÷åðåç:", -1, 9, 9, 217, 8
EDITTEXT IDC_NETCARDNAME, 9, 21, 230, 12, WS_BORDER | WS_DISABLED | WS_TABSTOP
PUSHBUTTON "&Íàñòðîèòü...", IDC_CONFIGURE, 174, 38, 65, 14