mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 22:36:23 +00:00
- Refresh adapter statistics when INetConnection_GetProperties is called
- Perform icon change when the adapter receives operational / disconnected state svn path=/trunk/; revision=36298
This commit is contained in:
parent
88a671baa1
commit
15ae0a215b
2 changed files with 85 additions and 41 deletions
|
@ -3,6 +3,7 @@
|
||||||
typedef struct tagINetConnectionItem
|
typedef struct tagINetConnectionItem
|
||||||
{
|
{
|
||||||
struct tagINetConnectionItem * Next;
|
struct tagINetConnectionItem * Next;
|
||||||
|
DWORD dwAdapterIndex;
|
||||||
NETCON_PROPERTIES Props;
|
NETCON_PROPERTIES Props;
|
||||||
}INetConnectionItem, *PINetConnectionItem;
|
}INetConnectionItem, *PINetConnectionItem;
|
||||||
|
|
||||||
|
@ -21,6 +22,7 @@ typedef struct
|
||||||
const INetConnectionVtbl * lpVtbl;
|
const INetConnectionVtbl * lpVtbl;
|
||||||
LONG ref;
|
LONG ref;
|
||||||
NETCON_PROPERTIES Props;
|
NETCON_PROPERTIES Props;
|
||||||
|
DWORD dwAdapterIndex;
|
||||||
} INetConnectionImpl, *LPINetConnectionImpl;
|
} INetConnectionImpl, *LPINetConnectionImpl;
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,6 +31,7 @@ static LPINetConnectionManagerImpl __inline impl_from_EnumNetConnection(IEnumNet
|
||||||
return (LPINetConnectionManagerImpl)((char *)iface - FIELD_OFFSET(INetConnectionManagerImpl, lpVtblNetConnection));
|
return (LPINetConnectionManagerImpl)((char *)iface - FIELD_OFFSET(INetConnectionManagerImpl, lpVtblNetConnection));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID NormalizeOperStatus(MIB_IFROW *IfEntry, NETCON_PROPERTIES * Props);
|
||||||
|
|
||||||
static
|
static
|
||||||
HRESULT
|
HRESULT
|
||||||
|
@ -211,7 +214,7 @@ INetConnection_fnGetProperties(
|
||||||
INetConnection * iface,
|
INetConnection * iface,
|
||||||
NETCON_PROPERTIES **ppProps)
|
NETCON_PROPERTIES **ppProps)
|
||||||
{
|
{
|
||||||
|
MIB_IFROW IfEntry;
|
||||||
NETCON_PROPERTIES * pProperties;
|
NETCON_PROPERTIES * pProperties;
|
||||||
|
|
||||||
INetConnectionImpl * This = (INetConnectionImpl*)iface;
|
INetConnectionImpl * This = (INetConnectionImpl*)iface;
|
||||||
|
@ -238,6 +241,17 @@ INetConnection_fnGetProperties(
|
||||||
}
|
}
|
||||||
|
|
||||||
*ppProps = pProperties;
|
*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;
|
return NOERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,7 +312,7 @@ HRESULT WINAPI IConnection_Constructor (INetConnection **ppv, PINetConnectionIte
|
||||||
|
|
||||||
This->ref = 1;
|
This->ref = 1;
|
||||||
This->lpVtbl = &vt_NetConnection;
|
This->lpVtbl = &vt_NetConnection;
|
||||||
|
This->dwAdapterIndex = pItem->dwAdapterIndex;
|
||||||
CopyMemory(&This->Props, &pItem->Props, sizeof(NETCON_PROPERTIES));
|
CopyMemory(&This->Props, &pItem->Props, sizeof(NETCON_PROPERTIES));
|
||||||
|
|
||||||
if (pItem->Props.pszwName)
|
if (pItem->Props.pszwName)
|
||||||
|
@ -480,6 +494,37 @@ GetAdapterIndexFromNetCfgInstanceId(PIP_ADAPTER_INFO pAdapterInfo, LPWSTR szNetC
|
||||||
return FALSE;
|
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
|
static
|
||||||
BOOL
|
BOOL
|
||||||
EnumerateINetConnections(INetConnectionManagerImpl *This)
|
EnumerateINetConnections(INetConnectionManagerImpl *This)
|
||||||
|
@ -589,32 +634,10 @@ EnumerateINetConnections(INetConnectionManagerImpl *This)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
ZeroMemory(pNew, sizeof(INetConnectionItem));
|
ZeroMemory(pNew, sizeof(INetConnectionItem));
|
||||||
|
pNew->dwAdapterIndex = dwAdapterIndex;
|
||||||
/* store NetCfgInstanceId */
|
/* store NetCfgInstanceId */
|
||||||
CLSIDFromString(szNetCfg, &pNew->Props.guidId);
|
CLSIDFromString(szNetCfg, &pNew->Props.guidId);
|
||||||
switch(IfEntry.dwOperStatus)
|
NormalizeOperStatus(&IfEntry, &pNew->Props);
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(IfEntry.dwType)
|
switch(IfEntry.dwType)
|
||||||
{
|
{
|
||||||
|
|
|
@ -141,32 +141,50 @@ UpdateLanStatusUIDlg(HWND hwndDlg, LANSTATUSUI_CONTEXT * pContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
hIcon = NULL;
|
hIcon = NULL;
|
||||||
if (pContext->dwInOctets == IfEntry.dwInOctets && pContext->dwOutOctets == IfEntry.dwOutOctets && pContext->Status != 0)
|
if (IfEntry.dwOperStatus == MIB_IF_OPER_STATUS_CONNECTED || IfEntry.dwOperStatus == MIB_IF_OPER_STATUS_OPERATIONAL)
|
||||||
{
|
{
|
||||||
hIcon = LoadImage(netshell_hInstance, MAKEINTRESOURCE(IDI_NET_IDLE), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
|
if (pContext->dwInOctets == IfEntry.dwInOctets && pContext->dwOutOctets == IfEntry.dwOutOctets && pContext->Status != 0)
|
||||||
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 (pContext->dwInOctets != IfEntry.dwInOctets && pContext->dwOutOctets != IfEntry.dwOutOctets && pContext->Status != 1)
|
else if (IfEntry.dwOperStatus == MIB_IF_OPER_STATUS_UNREACHABLE || MIB_IF_OPER_STATUS_DISCONNECTED)
|
||||||
{
|
{
|
||||||
pContext->Status = 1;
|
if (pContext->Status != 4)
|
||||||
hIcon = LoadImage(netshell_hInstance, MAKEINTRESOURCE(IDI_NET_TRANSREC), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
|
{
|
||||||
|
hIcon = LoadImage(netshell_hInstance, MAKEINTRESOURCE(IDI_NET_OFF), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
|
||||||
|
pContext->Status = 4;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (pContext->dwInOctets != IfEntry.dwInOctets && pContext->Status != 2)
|
else if (MIB_IF_OPER_STATUS_NON_OPERATIONAL)
|
||||||
{
|
{
|
||||||
hIcon = LoadImage(netshell_hInstance, MAKEINTRESOURCE(IDI_NET_REC), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
|
if (pContext->Status != 5)
|
||||||
pContext->Status = 2;
|
{
|
||||||
}
|
hIcon = LoadImage(netshell_hInstance, MAKEINTRESOURCE(IDI_NET_OFF), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
|
||||||
else if (pContext->dwOutOctets != IfEntry.dwOutOctets && pContext->Status != 3)
|
pContext->Status = 5;
|
||||||
{
|
}
|
||||||
hIcon = LoadImage(netshell_hInstance, MAKEINTRESOURCE(IDI_NET_TRANS), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
|
|
||||||
pContext->Status = 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hIcon)
|
if (hIcon)
|
||||||
{
|
{
|
||||||
hOldIcon = (HICON)SendDlgItemMessageW(hwndDlg, IDC_NETSTAT, STM_SETICON, (WPARAM)hIcon, 0);
|
hOldIcon = (HICON)SendDlgItemMessageW(hwndDlg, IDC_NETSTAT, STM_SETICON, (WPARAM)hIcon, 0);
|
||||||
|
|
||||||
|
|
||||||
ZeroMemory(&nid, sizeof(nid));
|
ZeroMemory(&nid, sizeof(nid));
|
||||||
nid.cbSize = sizeof(nid);
|
nid.cbSize = sizeof(nid);
|
||||||
nid.uID = pContext->uID;
|
nid.uID = pContext->uID;
|
||||||
|
@ -420,6 +438,9 @@ InitializeNetTaskbarNotifications(
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
||||||
/* get an instance to of IConnectionManager */
|
/* 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);
|
hr = INetConnectionManager_Constructor(NULL, &IID_INetConnectionManager, (LPVOID*)&INetConMan);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return hr;
|
return hr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue