Author: janderwald
Date: Thu Sep 18 04:01:52 2008
New Revision: 36298
URL:
http://svn.reactos.org/svn/reactos?rev=36298&view=rev
Log:
- Refresh adapter statistics when INetConnection_GetProperties is called
- Perform icon change when the adapter receives operational / disconnected state
Modified:
trunk/reactos/dll/win32/netshell/connectmanager.c
trunk/reactos/dll/win32/netshell/lanstatusui.c
Modified: trunk/reactos/dll/win32/netshell/connectmanager.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netshell/connect…
==============================================================================
--- trunk/reactos/dll/win32/netshell/connectmanager.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netshell/connectmanager.c [iso-8859-1] Thu Sep 18 04:01:52
2008
@@ -3,6 +3,7 @@
typedef struct tagINetConnectionItem
{
struct tagINetConnectionItem * Next;
+ DWORD dwAdapterIndex;
NETCON_PROPERTIES Props;
}INetConnectionItem, *PINetConnectionItem;
@@ -21,6 +22,7 @@
const INetConnectionVtbl * lpVtbl;
LONG ref;
NETCON_PROPERTIES Props;
+ DWORD dwAdapterIndex;
} INetConnectionImpl, *LPINetConnectionImpl;
@@ -29,6 +31,7 @@
return (LPINetConnectionManagerImpl)((char *)iface -
FIELD_OFFSET(INetConnectionManagerImpl, lpVtblNetConnection));
}
+VOID NormalizeOperStatus(MIB_IFROW *IfEntry, NETCON_PROPERTIES * Props);
static
HRESULT
@@ -211,7 +214,7 @@
INetConnection * iface,
NETCON_PROPERTIES **ppProps)
{
-
+ MIB_IFROW IfEntry;
NETCON_PROPERTIES * pProperties;
INetConnectionImpl * This = (INetConnectionImpl*)iface;
@@ -238,6 +241,17 @@
}
*ppProps = pProperties;
+
+ /* get updated adapter characteristics */
+ ZeroMemory(&IfEntry, sizeof(IfEntry));
+ IfEntry.dwIndex = This->dwAdapterIndex;
+ if(GetIfEntry(&IfEntry) != NO_ERROR)
+ return NOERROR;
+
+ NormalizeOperStatus(&IfEntry, pProperties);
+
+
+
return NOERROR;
}
@@ -298,7 +312,7 @@
This->ref = 1;
This->lpVtbl = &vt_NetConnection;
-
+ This->dwAdapterIndex = pItem->dwAdapterIndex;
CopyMemory(&This->Props, &pItem->Props, sizeof(NETCON_PROPERTIES));
if (pItem->Props.pszwName)
@@ -479,6 +493,37 @@
}
return FALSE;
}
+
+VOID
+NormalizeOperStatus(
+ MIB_IFROW *IfEntry,
+ NETCON_PROPERTIES * Props)
+{
+ switch(IfEntry->dwOperStatus)
+ {
+ case MIB_IF_OPER_STATUS_NON_OPERATIONAL:
+ Props->Status = NCS_HARDWARE_DISABLED;
+ break;
+ case MIB_IF_OPER_STATUS_UNREACHABLE:
+ Props->Status = NCS_DISCONNECTED;
+ break;
+ case MIB_IF_OPER_STATUS_DISCONNECTED:
+ Props->Status = NCS_MEDIA_DISCONNECTED;
+ break;
+ case MIB_IF_OPER_STATUS_CONNECTING:
+ Props->Status = NCS_CONNECTING;
+ break;
+ case MIB_IF_OPER_STATUS_CONNECTED:
+ Props->Status = NCS_CONNECTED;
+ break;
+ case MIB_IF_OPER_STATUS_OPERATIONAL:
+ Props->Status = NCS_CONNECTED;
+ break;
+ default:
+ break;
+ }
+}
+
static
BOOL
@@ -589,32 +634,10 @@
break;
ZeroMemory(pNew, sizeof(INetConnectionItem));
-
+ pNew->dwAdapterIndex = dwAdapterIndex;
/* store NetCfgInstanceId */
CLSIDFromString(szNetCfg, &pNew->Props.guidId);
- switch(IfEntry.dwOperStatus)
- {
- case MIB_IF_OPER_STATUS_NON_OPERATIONAL:
- pNew->Props.Status = NCS_HARDWARE_DISABLED;
- break;
- case MIB_IF_OPER_STATUS_UNREACHABLE:
- pNew->Props.Status = NCS_DISCONNECTED;
- break;
- case MIB_IF_OPER_STATUS_DISCONNECTED:
- pNew->Props.Status = NCS_MEDIA_DISCONNECTED;
- break;
- case MIB_IF_OPER_STATUS_CONNECTING:
- pNew->Props.Status = NCS_CONNECTING;
- break;
- case MIB_IF_OPER_STATUS_CONNECTED:
- pNew->Props.Status = NCS_CONNECTED;
- break;
- case MIB_IF_OPER_STATUS_OPERATIONAL:
- pNew->Props.Status = NCS_CONNECTED;
- break;
- default:
- break;
- }
+ NormalizeOperStatus(&IfEntry, &pNew->Props);
switch(IfEntry.dwType)
{
Modified: trunk/reactos/dll/win32/netshell/lanstatusui.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netshell/lanstat…
==============================================================================
--- trunk/reactos/dll/win32/netshell/lanstatusui.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netshell/lanstatusui.c [iso-8859-1] Thu Sep 18 04:01:52 2008
@@ -141,31 +141,49 @@
}
hIcon = NULL;
- if (pContext->dwInOctets == IfEntry.dwInOctets && pContext->dwOutOctets
== IfEntry.dwOutOctets && pContext->Status != 0)
- {
- hIcon = LoadImage(netshell_hInstance, MAKEINTRESOURCE(IDI_NET_IDLE), IMAGE_ICON,
0, 0, LR_DEFAULTCOLOR);
- pContext->Status = 0;
- }
- else if (pContext->dwInOctets != IfEntry.dwInOctets &&
pContext->dwOutOctets != IfEntry.dwOutOctets && pContext->Status != 1)
- {
- pContext->Status = 1;
- hIcon = LoadImage(netshell_hInstance, MAKEINTRESOURCE(IDI_NET_TRANSREC),
IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
- }
- else if (pContext->dwInOctets != IfEntry.dwInOctets && pContext->Status
!= 2)
- {
- hIcon = LoadImage(netshell_hInstance, MAKEINTRESOURCE(IDI_NET_REC), IMAGE_ICON,
0, 0, LR_DEFAULTCOLOR);
- pContext->Status = 2;
- }
- else if (pContext->dwOutOctets != IfEntry.dwOutOctets &&
pContext->Status != 3)
- {
- hIcon = LoadImage(netshell_hInstance, MAKEINTRESOURCE(IDI_NET_TRANS), IMAGE_ICON,
0, 0, LR_DEFAULTCOLOR);
- pContext->Status = 3;
+ if (IfEntry.dwOperStatus == MIB_IF_OPER_STATUS_CONNECTED || IfEntry.dwOperStatus ==
MIB_IF_OPER_STATUS_OPERATIONAL)
+ {
+ if (pContext->dwInOctets == IfEntry.dwInOctets &&
pContext->dwOutOctets == IfEntry.dwOutOctets && pContext->Status != 0)
+ {
+ hIcon = LoadImage(netshell_hInstance, MAKEINTRESOURCE(IDI_NET_IDLE),
IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
+ pContext->Status = 0;
+ }
+ else if (pContext->dwInOctets != IfEntry.dwInOctets &&
pContext->dwOutOctets != IfEntry.dwOutOctets && pContext->Status != 1)
+ {
+ pContext->Status = 1;
+ hIcon = LoadImage(netshell_hInstance, MAKEINTRESOURCE(IDI_NET_TRANSREC),
IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
+ }
+ else if (pContext->dwInOctets != IfEntry.dwInOctets &&
pContext->Status != 2)
+ {
+ hIcon = LoadImage(netshell_hInstance, MAKEINTRESOURCE(IDI_NET_REC),
IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
+ pContext->Status = 2;
+ }
+ else if (pContext->dwOutOctets != IfEntry.dwOutOctets &&
pContext->Status != 3)
+ {
+ hIcon = LoadImage(netshell_hInstance, MAKEINTRESOURCE(IDI_NET_TRANS),
IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
+ pContext->Status = 3;
+ }
+ }
+ else if (IfEntry.dwOperStatus == MIB_IF_OPER_STATUS_UNREACHABLE ||
MIB_IF_OPER_STATUS_DISCONNECTED)
+ {
+ if (pContext->Status != 4)
+ {
+ hIcon = LoadImage(netshell_hInstance, MAKEINTRESOURCE(IDI_NET_OFF),
IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
+ pContext->Status = 4;
+ }
+ }
+ else if (MIB_IF_OPER_STATUS_NON_OPERATIONAL)
+ {
+ if (pContext->Status != 5)
+ {
+ hIcon = LoadImage(netshell_hInstance, MAKEINTRESOURCE(IDI_NET_OFF),
IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
+ pContext->Status = 5;
+ }
}
if (hIcon)
{
hOldIcon = (HICON)SendDlgItemMessageW(hwndDlg, IDC_NETSTAT, STM_SETICON,
(WPARAM)hIcon, 0);
-
ZeroMemory(&nid, sizeof(nid));
nid.cbSize = sizeof(nid);
@@ -420,6 +438,9 @@
return S_OK;
/* get an instance to of IConnectionManager */
+
+ //hr = CoCreateInstance(&CLSID_ConnectionManager, NULL, CLSCTX_INPROC_SERVER,
&IID_INetConnectionManager, (LPVOID*)&INetConMan);
+
hr = INetConnectionManager_Constructor(NULL, &IID_INetConnectionManager,
(LPVOID*)&INetConMan);
if (FAILED(hr))
return hr;