2013-03-16 20:25:38 +00:00
|
|
|
/*
|
2006-06-15 14:16:29 +00:00
|
|
|
* PROJECT: ReactOS Power Configuration Applet
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* FILE: dll/cpl/powercfg/alarms.c
|
|
|
|
* PURPOSE: alarms tab of applet
|
|
|
|
* PROGRAMMERS: Alexander Wurzinger (Lohnegrim at gmx dot net)
|
2013-09-15 13:06:05 +00:00
|
|
|
* Johannes Anderwald (johannes.anderwald@reactos.org)
|
2006-06-15 14:16:29 +00:00
|
|
|
* Martin Rottensteiner
|
2007-11-30 18:52:33 +00:00
|
|
|
* Dmitry Chapyshev (lentind@yandex.ru)
|
2006-06-15 14:16:29 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "powercfg.h"
|
|
|
|
|
2007-12-02 14:25:17 +00:00
|
|
|
static BOOLEAN
|
|
|
|
Ala_InitData(HWND hwndDlg)
|
2006-06-15 14:16:29 +00:00
|
|
|
{
|
2015-09-07 21:56:38 +00:00
|
|
|
TCHAR szAction[MAX_PATH];
|
|
|
|
TCHAR szText[MAX_PATH];
|
|
|
|
TCHAR szSound[MAX_PATH];
|
|
|
|
TCHAR szMessage[MAX_PATH];
|
|
|
|
TCHAR szTemp[MAX_PATH];
|
|
|
|
TCHAR szBatteryLevel[MAX_PATH];
|
|
|
|
TCHAR szProgram[MAX_PATH];
|
|
|
|
|
|
|
|
if (!ReadGlobalPwrPolicy(&gGPP))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gGPP.user.DischargePolicy[DISCHARGE_POLICY_LOW].Enable)
|
|
|
|
{
|
|
|
|
CheckDlgButton(hwndDlg, IDC_ALARM1,
|
|
|
|
gGPP.user.DischargePolicy[DISCHARGE_POLICY_LOW].Enable ? BST_CHECKED : BST_UNCHECKED);
|
|
|
|
|
2019-04-26 19:51:48 +00:00
|
|
|
if (LoadString(hApplet, IDS_PERCENT, szTemp, MAX_PATH))
|
2015-09-07 21:56:38 +00:00
|
|
|
{
|
|
|
|
_stprintf(szBatteryLevel, szTemp, gGPP.user.DischargePolicy[DISCHARGE_POLICY_LOW].BatteryLevel);
|
|
|
|
SetDlgItemText(hwndDlg, IDC_ALARMVALUE1, szBatteryLevel);
|
|
|
|
}
|
|
|
|
|
|
|
|
SendDlgItemMessage(hwndDlg, IDC_ALARMBAR1,
|
|
|
|
TBM_SETRANGE,
|
|
|
|
(WPARAM)TRUE,
|
|
|
|
(LPARAM)MAKELONG(0, 100));
|
|
|
|
SendDlgItemMessage(hwndDlg, IDC_ALARMBAR1,
|
|
|
|
TBM_SETTICFREQ,
|
|
|
|
(WPARAM)TRUE,
|
|
|
|
(LPARAM)20);
|
|
|
|
SendDlgItemMessage(hwndDlg, IDC_ALARMBAR1,
|
|
|
|
TBM_SETPOS,
|
|
|
|
(WPARAM)TRUE,
|
|
|
|
(LPARAM)gGPP.user.DischargePolicy[DISCHARGE_POLICY_LOW].BatteryLevel);
|
|
|
|
|
|
|
|
if (LoadString(hApplet, gGPP.user.DischargePolicy[DISCHARGE_POLICY_LOW].PowerPolicy.Action+IDS_PowerActionNone1, szAction, MAX_PATH))
|
|
|
|
{
|
|
|
|
SetDlgItemText(hwndDlg, IDC_ALARMAKTION1, szAction);
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(szMessage, 0x0, sizeof(szMessage));
|
|
|
|
LoadString(hApplet, IDS_NOACTION, szMessage, MAX_PATH);
|
|
|
|
|
|
|
|
if (LOWORD(gGPP.user.DischargePolicy[DISCHARGE_POLICY_LOW].PowerPolicy.EventCode) & POWER_LEVEL_USER_NOTIFY_TEXT)
|
|
|
|
{
|
|
|
|
if (LOWORD(gGPP.user.DischargePolicy[DISCHARGE_POLICY_LOW].PowerPolicy.EventCode) & POWER_LEVEL_USER_NOTIFY_SOUND)
|
|
|
|
{
|
|
|
|
if (LoadString(hApplet, IDS_SOUND, szSound, MAX_PATH) && LoadString(hApplet, IDS_TEXT, szText, MAX_PATH))
|
|
|
|
{
|
|
|
|
_stprintf(szMessage,_T("%s, %s"),szSound,szText);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (LoadString(hApplet, IDS_TEXT, szText, MAX_PATH))
|
|
|
|
{
|
|
|
|
_stprintf(szMessage,_T("%s"),szText);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (LOWORD(gGPP.user.DischargePolicy[DISCHARGE_POLICY_LOW].PowerPolicy.EventCode) & POWER_LEVEL_USER_NOTIFY_SOUND)
|
|
|
|
{
|
|
|
|
if (LoadString(hApplet, IDS_SOUND, szSound, MAX_PATH))
|
|
|
|
{
|
|
|
|
_stprintf(szMessage,_T("%s"),szSound);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SetDlgItemText(hwndDlg, IDC_ALARMMSG1, szMessage);
|
|
|
|
|
|
|
|
if (LoadString(hApplet, IDS_PowerActionNone2, szProgram, MAX_PATH))
|
|
|
|
{
|
|
|
|
SetDlgItemText(hwndDlg, IDC_ALARMPROG1, szProgram);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gGPP.user.DischargePolicy[DISCHARGE_POLICY_CRITICAL].Enable)
|
|
|
|
{
|
|
|
|
CheckDlgButton(hwndDlg, IDC_ALARM2,
|
|
|
|
gGPP.user.DischargePolicy[DISCHARGE_POLICY_CRITICAL].Enable ? BST_CHECKED : BST_UNCHECKED);
|
|
|
|
|
2019-04-26 19:51:48 +00:00
|
|
|
if (LoadString(hApplet, IDS_PERCENT, szTemp, MAX_PATH))
|
2015-09-07 21:56:38 +00:00
|
|
|
{
|
|
|
|
_stprintf(szBatteryLevel, szTemp, gGPP.user.DischargePolicy[DISCHARGE_POLICY_CRITICAL].BatteryLevel);
|
|
|
|
SetDlgItemText(hwndDlg, IDC_ALARMVALUE2, szBatteryLevel);
|
|
|
|
}
|
|
|
|
|
|
|
|
SendDlgItemMessage(hwndDlg, IDC_ALARMBAR2,
|
|
|
|
TBM_SETRANGE,
|
|
|
|
(WPARAM)TRUE,
|
|
|
|
(LPARAM)MAKELONG(0, 100));
|
|
|
|
SendDlgItemMessage(hwndDlg, IDC_ALARMBAR2,
|
|
|
|
TBM_SETPOS,
|
|
|
|
(WPARAM)TRUE,
|
|
|
|
(LPARAM)gGPP.user.DischargePolicy[DISCHARGE_POLICY_CRITICAL].BatteryLevel);
|
|
|
|
|
|
|
|
if (LoadString(hApplet, gGPP.user.DischargePolicy[DISCHARGE_POLICY_CRITICAL].PowerPolicy.Action+IDS_PowerActionNone1, szAction, MAX_PATH))
|
|
|
|
{
|
|
|
|
SetDlgItemText(hwndDlg, IDC_ALARMAKTION2, szAction);
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(szMessage, 0x0, sizeof(szMessage));
|
|
|
|
LoadString(hApplet, IDS_NOACTION, szMessage, MAX_PATH);
|
|
|
|
|
|
|
|
if (LOWORD(gGPP.user.DischargePolicy[DISCHARGE_POLICY_CRITICAL].PowerPolicy.EventCode) & POWER_LEVEL_USER_NOTIFY_TEXT)
|
|
|
|
{
|
|
|
|
if (LOWORD(gGPP.user.DischargePolicy[DISCHARGE_POLICY_CRITICAL].PowerPolicy.EventCode) & POWER_LEVEL_USER_NOTIFY_SOUND)
|
|
|
|
{
|
|
|
|
if (LoadString(hApplet, IDS_TEXT, szText, MAX_PATH) && LoadString(hApplet, IDS_SOUND, szSound, MAX_PATH))
|
|
|
|
{
|
|
|
|
_stprintf(szMessage,_T("%s, %s"),szSound,szText);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (LoadString(hApplet, IDS_TEXT, szText, MAX_PATH))
|
|
|
|
{
|
|
|
|
_stprintf(szMessage,_T("%s"),szText);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (LOWORD(gGPP.user.DischargePolicy[DISCHARGE_POLICY_CRITICAL].PowerPolicy.EventCode) & POWER_LEVEL_USER_NOTIFY_SOUND)
|
|
|
|
{
|
|
|
|
if (LoadString(hApplet, IDS_SOUND, szSound, MAX_PATH))
|
|
|
|
{
|
|
|
|
_stprintf(szMessage,_T("%s"),szSound);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SetDlgItemText(hwndDlg, IDC_ALARMMSG2, szMessage);
|
|
|
|
|
|
|
|
if (LoadString(hApplet, IDS_PowerActionNone2, szProgram, MAX_PATH))
|
|
|
|
{
|
|
|
|
SetDlgItemText(hwndDlg, IDC_ALARMPROG2, szProgram);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2006-06-15 14:16:29 +00:00
|
|
|
}
|
2007-12-02 14:25:17 +00:00
|
|
|
|
|
|
|
/* Property page dialog callback */
|
|
|
|
INT_PTR CALLBACK
|
|
|
|
AlarmsDlgProc(HWND hwndDlg,
|
|
|
|
UINT uMsg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
|
|
|
{
|
2019-09-25 08:51:55 +00:00
|
|
|
UNREFERENCED_PARAMETER(lParam);
|
|
|
|
UNREFERENCED_PARAMETER(wParam);
|
|
|
|
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
if (!Ala_InitData(hwndDlg))
|
|
|
|
{
|
|
|
|
// TODO:
|
|
|
|
// Handle initialization error
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2007-12-02 14:25:17 +00:00
|
|
|
}
|