- Changed an interval of writing network statistics from a minute to two minutes.

- Code cosmetic changes.
This commit is contained in:
spx 2012-02-15 02:51:27 +00:00
parent 3acb191e56
commit dbd43ddfbc
5 changed files with 41 additions and 29 deletions

View File

@ -495,7 +495,7 @@ void CMeasureNet::ReadConfig(CConfigParser& parser, const WCHAR* section, NET ne
m_Cumulative = 0!=parser.ReadInt(section, L"Cumulative", 0); m_Cumulative = 0!=parser.ReadInt(section, L"Cumulative", 0);
if (m_Cumulative) if (m_Cumulative)
{ {
CSystem::SetNetworkStatisticsTimer(); Rainmeter->SetNetworkStatisticsTimer();
} }
m_TrafficValue = parser.ReadFloat(section, L"TrafficValue", 0.0); m_TrafficValue = parser.ReadFloat(section, L"TrafficValue", 0.0);

View File

@ -33,6 +33,15 @@
using namespace Gdiplus; using namespace Gdiplus;
enum TIMER
{
TIMER_NETSTATS = 1
};
enum INTERVAL
{
INTERVAL_NETSTATS = 120000
};
CRainmeter* Rainmeter; // The module CRainmeter* Rainmeter; // The module
/* /*
@ -681,6 +690,8 @@ CRainmeter::CRainmeter() :
*/ */
CRainmeter::~CRainmeter() CRainmeter::~CRainmeter()
{ {
KillTimer(m_Window, TIMER_NETSTATS);
DeleteMeterWindow(NULL); DeleteMeterWindow(NULL);
delete m_TrayWindow; delete m_TrayWindow;
@ -1075,9 +1086,18 @@ LRESULT CALLBACK CRainmeter::MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LP
} }
break; break;
case WM_TIMER:
if (wParam == TIMER_NETSTATS)
{
CMeasureNet::UpdateIFTable();
CMeasureNet::UpdateStats();
Rainmeter->WriteStats(false);
}
break;
case WM_RAINMETER_DELAYED_REFRESH_ALL: case WM_RAINMETER_DELAYED_REFRESH_ALL:
Rainmeter->RefreshAll(); Rainmeter->RefreshAll();
return 0; break;
case WM_RAINMETER_DELAYED_EXECUTE: case WM_RAINMETER_DELAYED_EXECUTE:
if (lParam) if (lParam)
@ -1087,7 +1107,7 @@ LRESULT CALLBACK CRainmeter::MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LP
Rainmeter->ExecuteCommand(bang, NULL); Rainmeter->ExecuteCommand(bang, NULL);
free(bang); // _wcsdup() free(bang); // _wcsdup()
} }
return 0; break;
default: default:
return DefWindowProc(hWnd, uMsg, wParam, lParam); return DefWindowProc(hWnd, uMsg, wParam, lParam);
@ -1096,6 +1116,11 @@ LRESULT CALLBACK CRainmeter::MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LP
return 0; return 0;
} }
void CRainmeter::SetNetworkStatisticsTimer()
{
static bool set = SetTimer(m_Window, TIMER_NETSTATS, INTERVAL_NETSTATS, NULL);
}
/* /*
** CreateDefaultConfigFile ** CreateDefaultConfigFile
** **
@ -2489,7 +2514,7 @@ void CRainmeter::ReadStats()
/* /*
** WriteStats ** WriteStats
** **
** Writes the statistics to the ini-file. If bForce is false the stats are written only once per minute. ** Writes the statistics to the ini-file. If bForce is false the stats are written only once per an appropriate interval.
** **
*/ */
void CRainmeter::WriteStats(bool bForce) void CRainmeter::WriteStats(bool bForce)
@ -2498,7 +2523,7 @@ void CRainmeter::WriteStats(bool bForce)
ULONGLONG ticks = CSystem::GetTickCount64(); ULONGLONG ticks = CSystem::GetTickCount64();
if (bForce || (lastWrite + 1000 * 60 < ticks)) if (bForce || (lastWrite + INTERVAL_NETSTATS < ticks))
{ {
lastWrite = ticks; lastWrite = ticks;

View File

@ -123,6 +123,8 @@ public:
int Initialize(HINSTANCE hInstance, LPCWSTR szPath); int Initialize(HINSTANCE hInstance, LPCWSTR szPath);
int MessagePump(); int MessagePump();
void SetNetworkStatisticsTimer();
CConfigParser* GetCurrentParser() { return m_CurrentParser; } CConfigParser* GetCurrentParser() { return m_CurrentParser; }
void SetCurrentParser(CConfigParser* parser) { m_CurrentParser = parser; } void SetCurrentParser(CConfigParser* parser) { m_CurrentParser = parser; }

View File

@ -32,14 +32,12 @@ using namespace Gdiplus;
enum TIMER enum TIMER
{ {
TIMER_SHOWDESKTOP = 1, TIMER_SHOWDESKTOP = 1
TIMER_NETSTATS = 2
}; };
enum INTERVAL enum INTERVAL
{ {
INTERVAL_SHOWDESKTOP = 250, INTERVAL_SHOWDESKTOP = 250,
INTERVAL_RESTOREWINDOWS = 100, INTERVAL_RESTOREWINDOWS = 100
INTERVAL_NETSTATS = 60000
}; };
MULTIMONITOR_INFO CSystem::c_Monitors = { 0 }; MULTIMONITOR_INFO CSystem::c_Monitors = { 0 };
@ -135,7 +133,6 @@ void CSystem::Initialize(HINSTANCE instance)
void CSystem::Finalize() void CSystem::Finalize()
{ {
KillTimer(c_Window, TIMER_SHOWDESKTOP); KillTimer(c_Window, TIMER_SHOWDESKTOP);
KillTimer(c_Window, TIMER_NETSTATS);
if (c_WinEventHook) if (c_WinEventHook)
{ {
@ -156,11 +153,6 @@ void CSystem::Finalize()
} }
} }
void CSystem::SetNetworkStatisticsTimer()
{
static bool set = SetTimer(c_Window, TIMER_NETSTATS, INTERVAL_NETSTATS, NULL);
}
/* /*
** MyInfoEnumProc ** MyInfoEnumProc
** **
@ -1004,20 +996,12 @@ LRESULT CALLBACK CSystem::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
{ {
case WM_WINDOWPOSCHANGING: case WM_WINDOWPOSCHANGING:
((LPWINDOWPOS)lParam)->flags |= SWP_NOZORDER; ((LPWINDOWPOS)lParam)->flags |= SWP_NOZORDER;
return 0; break;
case WM_TIMER: case WM_TIMER:
switch (wParam) if (wParam == TIMER_SHOWDESKTOP)
{ {
case TIMER_SHOWDESKTOP:
CheckDesktopState(GetWorkerW()); CheckDesktopState(GetWorkerW());
return 0;
case TIMER_NETSTATS:
CMeasureNet::UpdateIFTable();
CMeasureNet::UpdateStats();
Rainmeter->WriteStats(false);
return 0;
} }
break; break;
@ -1042,10 +1026,13 @@ LRESULT CALLBACK CSystem::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
PostMessage((*iter).second->GetWindow(), WM_DELAYED_MOVE, (WPARAM)uMsg, (LPARAM)0); PostMessage((*iter).second->GetWindow(), WM_DELAYED_MOVE, (WPARAM)uMsg, (LPARAM)0);
} }
} }
return 0; break;
default:
return DefWindowProc(hWnd, uMsg, wParam, lParam);
} }
return DefWindowProc(hWnd, uMsg, wParam, lParam); return 0;
} }
/* /*

View File

@ -56,8 +56,6 @@ public:
static void Initialize(HINSTANCE instance); static void Initialize(HINSTANCE instance);
static void Finalize(); static void Finalize();
static void SetNetworkStatisticsTimer();
static const MULTIMONITOR_INFO& GetMultiMonitorInfo() { return c_Monitors; } static const MULTIMONITOR_INFO& GetMultiMonitorInfo() { return c_Monitors; }
static size_t GetMonitorCount(); static size_t GetMonitorCount();