Author: janderwald
Date: Wed Sep 17 14:44:05 2008
New Revision: 36292
URL:
http://svn.reactos.org/svn/reactos?rev=36292&view=rev
Log:
- Use Ged's time updating code from ncpa module
- Periodically refresh timer for status dialog
- Make property sheet modal
Modified:
trunk/reactos/dll/win32/netshell/lang/de-DE.rc
trunk/reactos/dll/win32/netshell/lanstatusui.c
trunk/reactos/dll/win32/netshell/resource.h
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] Wed Sep 17 14:44:05 2008
@@ -83,5 +83,6 @@
IDS_FORMAT_KBIT "%u KBit/s"
IDS_FORMAT_MBIT "%u MBit/s"
IDS_FORMAT_GBIT "%u GBit/s"
-
+ IDS_DURATION_DAY "%d Tag %s"
+ IDS_DURATION_DAYS "%d Tage %s"
END
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] Wed Sep 17 14:44:05 2008
@@ -25,37 +25,57 @@
{
INetConnection *pNet;
HWND hwndDlg;
+ DWORD dwAdapterIndex;
+ UINT_PTR nIDEvent;
DWORD dwInOctets;
DWORD dwOutOctets;
}LANSTATUSUI_CONTEXT;
VOID
-UpdateLanStatusUIDlg(HWND hwndDlg, MIB_IFROW * IfEntry)
+UpdateLanStatusUIDlg(HWND hwndDlg, LANSTATUSUI_CONTEXT * pContext)
{
WCHAR szFormat[MAX_PATH] = {0};
WCHAR szBuffer[MAX_PATH] = {0};
-
- if (IfEntry->dwSpeed < 1000)
+ MIB_IFROW IfEntry;
+ SYSTEMTIME TimeConnected;
+ DWORD DurationSeconds;
+ WCHAR Buffer[100];
+ WCHAR DayBuffer[30];
+ WCHAR LocBuffer[50];
+#if 0
+ ULONGLONG Ticks;
+#else
+ DWORD Ticks;
+#endif
+
+ ZeroMemory(&IfEntry, sizeof(IfEntry));
+ IfEntry.dwIndex = pContext->dwAdapterIndex;
+ if(GetIfEntry(&IfEntry) != NO_ERROR)
+ {
+ return;
+ }
+
+ if (IfEntry.dwSpeed < 1000)
{
if (LoadStringW(netshell_hInstance, IDS_FORMAT_BIT, szFormat,
sizeof(szFormat)/sizeof(WCHAR)))
{
- swprintf(szBuffer, szFormat, IfEntry->dwSpeed);
+ swprintf(szBuffer, szFormat, IfEntry.dwSpeed);
SendDlgItemMessageW(hwndDlg, IDC_SPEED, WM_SETTEXT, 0, (LPARAM)szBuffer);
}
}
- else if (IfEntry->dwSpeed < 1000000)
+ else if (IfEntry.dwSpeed < 1000000)
{
if (LoadStringW(netshell_hInstance, IDS_FORMAT_KBIT, szFormat,
sizeof(szFormat)/sizeof(WCHAR)))
{
- swprintf(szBuffer, szFormat, IfEntry->dwSpeed/1000);
+ swprintf(szBuffer, szFormat, IfEntry.dwSpeed/1000);
SendDlgItemMessageW(hwndDlg, IDC_SPEED, WM_SETTEXT, 0, (LPARAM)szBuffer);
}
}
- else if (IfEntry->dwSpeed < 1000000000)
+ else if (IfEntry.dwSpeed < 1000000000)
{
if (LoadStringW(netshell_hInstance, IDS_FORMAT_MBIT, szFormat,
sizeof(szFormat)/sizeof(WCHAR)))
{
- swprintf(szBuffer, szFormat, IfEntry->dwSpeed/1000000);
+ swprintf(szBuffer, szFormat, IfEntry.dwSpeed/1000000);
SendDlgItemMessageW(hwndDlg, IDC_SPEED, WM_SETTEXT, 0, (LPARAM)szBuffer);
}
}
@@ -63,37 +83,71 @@
{
if (LoadStringW(netshell_hInstance, IDS_FORMAT_KBIT, szFormat,
sizeof(szFormat)/sizeof(WCHAR)))
{
- swprintf(szBuffer, szFormat, IfEntry->dwSpeed/1000000000);
+ swprintf(szBuffer, szFormat, IfEntry.dwSpeed/1000000000);
SendDlgItemMessageW(hwndDlg, IDC_SPEED, WM_SETTEXT, 0, (LPARAM)szBuffer);
}
}
- if (StrFormatByteSizeW(IfEntry->dwInOctets, szBuffer,
sizeof(szFormat)/sizeof(WCHAR)))
+ if (StrFormatByteSizeW(IfEntry.dwInOctets, szBuffer,
sizeof(szFormat)/sizeof(WCHAR)))
{
SendDlgItemMessageW(hwndDlg, IDC_RECEIVED, WM_SETTEXT, 0, (LPARAM)szBuffer);
}
- if (StrFormatByteSizeW(IfEntry->dwOutOctets, szBuffer,
sizeof(szFormat)/sizeof(WCHAR)))
+ if (StrFormatByteSizeW(IfEntry.dwOutOctets, szBuffer,
sizeof(szFormat)/sizeof(WCHAR)))
{
SendDlgItemMessageW(hwndDlg, IDC_SEND, WM_SETTEXT, 0, (LPARAM)szBuffer);
}
//FIXME
//set duration
-
-}
+#if 0
+ Ticks = GetTickCount64();
+#else
+ Ticks = GetTickCount();
+#endif
+
+ DurationSeconds = Ticks / 1000;
+ TimeConnected.wSecond = (DurationSeconds % 60);
+ TimeConnected.wMinute = (DurationSeconds / 60) % 60;
+ TimeConnected.wHour = (DurationSeconds / (60 * 60)) % 24;
+ TimeConnected.wDay = DurationSeconds / (60 * 60 * 24);
+
+ if (!GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &TimeConnected,
L"HH':'mm':'ss", LocBuffer, sizeof(LocBuffer) /
sizeof(LocBuffer[0])))
+ return;
+
+ if (!TimeConnected.wDay)
+ {
+ SendDlgItemMessageW(hwndDlg, IDC_DURATION, WM_SETTEXT, 0, (LPARAM)LocBuffer);
+ }
+ else
+ {
+ if (TimeConnected.wDay == 1)
+ {
+ if (!LoadStringW(netshell_hInstance, IDS_DURATION_DAY, DayBuffer,
sizeof(DayBuffer) / sizeof(DayBuffer[0])))
+ DayBuffer[0] = L'\0';
+ }
+ else
+ {
+ if (!LoadStringW(netshell_hInstance, IDS_DURATION_DAYS, DayBuffer,
sizeof(DayBuffer) / sizeof(DayBuffer[0])))
+ DayBuffer[0] = L'\0';
+ }
+ swprintf(Buffer, DayBuffer, TimeConnected.wDay, LocBuffer);
+ SendDlgItemMessageW(hwndDlg, IDC_DURATION, WM_SETTEXT, 0, (LPARAM)Buffer);
+ }
+
+}
+
VOID
-InitializeLANStatusUiDlg(HWND hwndDlg, INetConnection * pNet)
+InitializeLANStatusUiDlg(HWND hwndDlg, LANSTATUSUI_CONTEXT * pContext)
{
WCHAR szBuffer[MAX_PATH] = {0};
NETCON_PROPERTIES * pProperties = NULL;
- MIB_IFROW IfEntry;
DWORD dwSize, dwAdapterIndex, dwResult;
LPOLESTR pStr;
IP_ADAPTER_INFO * pAdapterInfo;
- if (INetConnection_GetProperties(pNet, &pProperties) != NOERROR)
+ if (INetConnection_GetProperties(pContext->pNet, &pProperties) != NOERROR)
return;
if (pProperties->Status == NCS_DISCONNECTED)
@@ -145,18 +199,11 @@
return;
}
CoTaskMemFree(pStr);
-
- /* get detailed adapter info */
- ZeroMemory(&IfEntry, sizeof(IfEntry));
- IfEntry.dwIndex = dwAdapterIndex;
- if(GetIfEntry(&IfEntry) != NO_ERROR)
- {
- CoTaskMemFree(pAdapterInfo);
- return;
- }
-
- UpdateLanStatusUIDlg(hwndDlg, &IfEntry);
-
+ pContext->dwAdapterIndex = dwAdapterIndex;
+
+ /* update adapter info */
+ UpdateLanStatusUIDlg(hwndDlg, pContext);
+ pContext->nIDEvent = SetTimer(hwndDlg, 0xFABC, 1000, NULL);
CoTaskMemFree(pAdapterInfo);
}
@@ -178,7 +225,8 @@
case WM_INITDIALOG:
page = (PROPSHEETPAGE*)lParam;
pContext = (LANSTATUSUI_CONTEXT*)page->lParam;
- InitializeLANStatusUiDlg(hwndDlg, pContext->pNet);
+ pContext->hwndDlg = GetParent(hwndDlg);
+ InitializeLANStatusUiDlg(hwndDlg, pContext);
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pContext);
return TRUE;
case WM_COMMAND:
@@ -203,9 +251,17 @@
if (lppsn->hdr.code == PSN_APPLY || lppsn->hdr.code == PSN_RESET)
{
pContext = (LANSTATUSUI_CONTEXT*)GetWindowLongPtr(hwndDlg, DWLP_USER);
- DestroyWindow(pContext->hwndDlg);
+ KillTimer(hwndDlg, pContext->nIDEvent);
+ SetWindowLong(hwndDlg, DWL_MSGRESULT, PSNRET_NOERROR);
pContext->hwndDlg = NULL;
return PSNRET_NOERROR;
+ }
+ break;
+ case WM_TIMER:
+ pContext = (LANSTATUSUI_CONTEXT*)GetWindowLongPtr(hwndDlg, DWLP_USER);
+ if (wParam == (WPARAM)pContext->nIDEvent)
+ {
+ UpdateLanStatusUIDlg(hwndDlg, pContext);
}
break;
}
@@ -225,7 +281,7 @@
ZeroMemory(&pinfo, sizeof(PROPSHEETHEADERW));
ZeroMemory(hppages, sizeof(hppages));
pinfo.dwSize = sizeof(PROPSHEETHEADERW);
- pinfo.dwFlags = PSH_NOCONTEXTHELP | PSH_PROPTITLE | PSH_NOAPPLYNOW | PSH_MODELESS;
+ pinfo.dwFlags = PSH_NOCONTEXTHELP | PSH_PROPTITLE | PSH_NOAPPLYNOW;
pinfo.u3.phpage = hppages;
pinfo.hwndParent = hwndDlg;
Modified: trunk/reactos/dll/win32/netshell/resource.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netshell/resourc…
==============================================================================
--- trunk/reactos/dll/win32/netshell/resource.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netshell/resource.h [iso-8859-1] Wed Sep 17 14:44:05 2008
@@ -68,4 +68,6 @@
#define IDS_FORMAT_MBIT 10201
#define IDS_FORMAT_KBIT 10202
#define IDS_FORMAT_GBIT 10203
+#define IDS_DURATION_DAY 10204
+#define IDS_DURATION_DAYS 10205