diff options
author | Tobias Weimer <wishmaster51@googlemail.com> | 2013-08-22 21:58:50 +0000 |
---|---|---|
committer | Tobias Weimer <wishmaster51@googlemail.com> | 2013-08-22 21:58:50 +0000 |
commit | ae983ffa444902e6354e68317c97fdcbc781afe6 (patch) | |
tree | 820ba440f18583fdafd34bfbd9651c5648c88a26 /plugins/AutoShutdown/src | |
parent | 3fe0183127f71140708186188f14994562f9dd0b (diff) |
AutoShutdown:
- fixed TopToolbar Button (fixes #439)
- redesigned options dialog
git-svn-id: http://svn.miranda-ng.org/main/trunk@5789 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/AutoShutdown/src')
-rw-r--r-- | plugins/AutoShutdown/src/frame.cpp | 22 | ||||
-rw-r--r-- | plugins/AutoShutdown/src/main.cpp | 7 | ||||
-rw-r--r-- | plugins/AutoShutdown/src/resource.h | 4 | ||||
-rw-r--r-- | plugins/AutoShutdown/src/settingsdlg.cpp | 86 | ||||
-rw-r--r-- | plugins/AutoShutdown/src/settingsdlg.h | 5 | ||||
-rw-r--r-- | plugins/AutoShutdown/src/shutdownsvc.cpp | 33 | ||||
-rw-r--r-- | plugins/AutoShutdown/src/watcher.cpp | 31 | ||||
-rw-r--r-- | plugins/AutoShutdown/src/watcher.h | 1 |
8 files changed, 98 insertions, 91 deletions
diff --git a/plugins/AutoShutdown/src/frame.cpp b/plugins/AutoShutdown/src/frame.cpp index 20662698a5..30c356812e 100644 --- a/plugins/AutoShutdown/src/frame.cpp +++ b/plugins/AutoShutdown/src/frame.cpp @@ -227,15 +227,14 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARA return 0;
}
case WM_DESTROY:
- { HICON hIcon;
+ {
if(dat==NULL) return 0;
UnhookEvent(dat->hHookColorsChanged);
UnhookEvent(dat->hHookFontsChanged);
UnhookEvent(dat->hHookIconsChanged);
/* other childs are destroyed automatically */
if(dat->hwndToolTip!=NULL) DestroyWindow(dat->hwndToolTip);
- hIcon=(HICON)SendMessage(dat->hwndIcon,STM_SETIMAGE,IMAGE_ICON,0);
- Skin_ReleaseIcon(hIcon); /* does NULL check */
+ HICON hIcon=(HICON)SendMessage(dat->hwndIcon,STM_SETIMAGE,IMAGE_ICON,0);
break;
}
case WM_NCDESTROY:
@@ -246,14 +245,14 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARA SetWindowLongPtr(hwndFrame, GWLP_USERDATA, (LONG)NULL);
break;
case WM_SIZE:
- { RECT rc;
+ {
+ RECT rc;
LONG width,height;
- HDWP hdwp;
UINT defflg=SWP_NOZORDER|SWP_NOOWNERZORDER|SWP_NOACTIVATE;
SetRect(&rc,0,0,LOWORD(lParam),HIWORD(lParam)); /* width,height */
/* workaround: reduce flickering of frame in clist */
InvalidateRect(hwndFrame,&rc,FALSE);
- hdwp=BeginDeferWindowPos(3);
+ HDWP hdwp=BeginDeferWindowPos(3);
/* progress */
width=rc.right-GetSystemMetrics(SM_CXICON)-10;
height=rc.bottom-(GetSystemMetrics(SM_CYICON)/2)-5;
@@ -267,7 +266,8 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARA return 0;
}
case M_REFRESH_COLORS:
- { COLORREF clrBar;
+ {
+ COLORREF clrBar;
if(FontService_GetColor(_T("Automatic Shutdown"),_T("Progress Bar"),&clrBar))
clrBar=GetDefaultColor(FRAMEELEMENT_BAR);
if(FontService_GetColor(_T("Automatic Shutdown"),_T("Background"),&dat->clrBackground))
@@ -280,13 +280,10 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARA return 0;
}
case M_REFRESH_ICONS:
- if(dat->hwndIcon!=NULL)
- Skin_ReleaseIcon((HICON)SendMessage(dat->hwndIcon,STM_SETIMAGE,IMAGE_ICON,(LPARAM)Skin_GetIcon("AutoShutdown_Header")));
- if(hFrame) /* refresh frame title icon */
- Skin_ReleaseIcon(SetFrameTitleIcon(hFrame,Skin_GetIcon("AutoShutdown_Active")));
return 0;
case M_REFRESH_FONTS:
- { LOGFONT lf;
+ {
+ LOGFONT lf;
if(!FontService_GetFont(_T("Automatic Shutdown"),_T("Countdown on Frame"),&dat->clrText,&lf)) {
if(dat->hFont!=NULL) DeleteObject(dat->hFont);
dat->hFont=CreateFontIndirect(&lf);
@@ -568,7 +565,6 @@ void CloseCountdownFrame(void) if(hwndCountdownFrame!=NULL) {
SendMessage(hwndCountdownFrame,M_CLOSE_COUNTDOWN,0,0);
if(hFrame) {
- Skin_ReleaseIcon(SetFrameTitleIcon(hFrame,NULL));
/* HACKS TO FIX CLUIFrames:
* workaround #6: MS_CLIST_FRAMES_REMOVEFRAME does not finish with
* destroy cycle (clist_modern, clist_nicer crashes) */
diff --git a/plugins/AutoShutdown/src/main.cpp b/plugins/AutoShutdown/src/main.cpp index da5450c630..636fc3e0fd 100644 --- a/plugins/AutoShutdown/src/main.cpp +++ b/plugins/AutoShutdown/src/main.cpp @@ -50,10 +50,15 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, VOID *pReserved) return TRUE;
}
-static int ShutdownModulesLoaded(WPARAM wParam,LPARAM lParam)
+static int ShutdownModulesLoaded(WPARAM,LPARAM)
{
if ( ServiceExists("DBEditorpp/RegisterSingleModule"))
CallService("DBEditorpp/RegisterSingleModule",(WPARAM)"AutoShutdown",0);
+
+ /* Toolbar Item */
+ HookEvent(ME_TTB_MODULELOADED,ToolbarLoaded); /* no service to check for */
+
+ WatcherModulesLoaded();
return 0;
}
diff --git a/plugins/AutoShutdown/src/resource.h b/plugins/AutoShutdown/src/resource.h index 4d8370f00a..f379eb3aab 100644 --- a/plugins/AutoShutdown/src/resource.h +++ b/plugins/AutoShutdown/src/resource.h @@ -1,6 +1,6 @@ //{{NO_DEPENDENCIES}}
-// Microsoft Developer Studio generated include file.
-// Used by resource.rc
+// Microsoft Visual C++ generated include file.
+// Used by ..\res\resource.rc
//
#define IDI_ACTIVE 101
#define IDI_INACTIVE 102
diff --git a/plugins/AutoShutdown/src/settingsdlg.cpp b/plugins/AutoShutdown/src/settingsdlg.cpp index 601922f0ec..6e527eac22 100644 --- a/plugins/AutoShutdown/src/settingsdlg.cpp +++ b/plugins/AutoShutdown/src/settingsdlg.cpp @@ -28,6 +28,9 @@ static HANDLE hServiceShowDlg; static HWND hwndSettingsDlg;
extern HINSTANCE hInst;
+const DWORD unitValues[]={1,60,60*60,60*60*24,60*60*24*7,60*60*24*31};
+const TCHAR *unitNames[]={LPGENT("Second(s)"), LPGENT("Minute(s)"), LPGENT("Hour(s)"), LPGENT("Day(s)"), LPGENT("Week(s)"), LPGENT("Month(s)")};
+
/************************* Dialog *************************************/
static void EnableDlgItem(HWND hwndDlg,int idCtrl,BOOL fEnable)
@@ -39,23 +42,23 @@ static void EnableDlgItem(HWND hwndDlg,int idCtrl,BOOL fEnable) static BOOL CALLBACK DisplayCpuUsageProc(BYTE nCpuUsage,LPARAM lParam)
{
- TCHAR str[64];
/* dialog closed? */
if(!IsWindow((HWND)lParam)) return FALSE; /* stop poll thread */
+ TCHAR str[64];
mir_sntprintf(str,SIZEOF(str),TranslateT("(current: %u%%)"),nCpuUsage);
SetWindowText((HWND)lParam,str);
return TRUE;
}
-static BOOL AnyProtoHasCaps(DWORD caps1)
+static bool AnyProtoHasCaps(DWORD caps1)
{
- int nProtoCount,i;
+ int nProtoCount;
PROTOACCOUNT **protos;
if(!ProtoEnumAccounts(&nProtoCount, &protos))
- for(i=0;i<nProtoCount;++i)
+ for(int i=0;i<nProtoCount;++i)
if(CallProtoService(protos[i]->szModuleName,PS_GETCAPS,(WPARAM)PFLAGNUM_1,0)&caps1)
- return TRUE; /* CALLSERVICE_NOTFOUND also handled gracefully */
- return FALSE;
+ return true; /* CALLSERVICE_NOTFOUND also handled gracefully */
+ return false;
}
#define M_ENABLE_SUBCTLS (WM_APP+111)
@@ -82,8 +85,7 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR }
/* read-in watcher flags */
{
- WORD watcherType;
- watcherType=db_get_w(NULL,"AutoShutdown","WatcherFlags",SETTING_WATCHERFLAGS_DEFAULT);
+ WORD watcherType=db_get_w(NULL,"AutoShutdown","WatcherFlags",SETTING_WATCHERFLAGS_DEFAULT);
CheckRadioButton(hwndDlg,IDC_RADIO_STTIME,IDC_RADIO_STCOUNTDOWN,(watcherType&SDWTF_ST_TIME)?IDC_RADIO_STTIME:IDC_RADIO_STCOUNTDOWN);
CheckDlgButton(hwndDlg,IDC_CHECK_SPECIFICTIME,(watcherType&SDWTF_SPECIFICTIME)!=0);
CheckDlgButton(hwndDlg,IDC_CHECK_MESSAGE,(watcherType&SDWTF_MESSAGE)!=0);
@@ -102,8 +104,7 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR SendMessage(hwndDlg,M_CHECK_DATETIME,0,0);
}
{
- DWORD setting;
- setting=db_get_dw(NULL,"AutoShutdown","Countdown",SETTING_COUNTDOWN_DEFAULT);
+ DWORD setting=db_get_dw(NULL,"AutoShutdown","Countdown",SETTING_COUNTDOWN_DEFAULT);
if(setting<1) setting=SETTING_COUNTDOWN_DEFAULT;
SendDlgItemMessage(hwndDlg,IDC_SPIN_COUNTDOWN,UDM_SETRANGE,0,MAKELPARAM(UD_MAXVAL,1));
SendDlgItemMessage(hwndDlg,IDC_EDIT_COUNTDOWN,EM_SETLIMITTEXT,(WPARAM)10,0);
@@ -111,18 +112,12 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR SetDlgItemInt(hwndDlg,IDC_EDIT_COUNTDOWN,setting,FALSE);
}
{
- HWND hwndCombo;
- DWORD lastUnit;
- int i,index;
- const DWORD unitValues[]={1,60,60*60,60*60*24,60*60*24*7,60*60*24*31};
- const TCHAR *unitNames[]={TranslateT("Second(s)"), TranslateT("Minute(s)"), TranslateT("Hour(s)"),
- TranslateT("Day(s)"), TranslateT("Week(s)"), TranslateT("Month(s)")};
- hwndCombo=GetDlgItem(hwndDlg,IDC_COMBO_COUNTDOWNUNIT);
- lastUnit=db_get_dw(NULL,"AutoShutdown","CountdownUnit",SETTING_COUNTDOWNUNIT_DEFAULT);
+ HWND hwndCombo=GetDlgItem(hwndDlg,IDC_COMBO_COUNTDOWNUNIT);
+ DWORD lastUnit=db_get_dw(NULL,"AutoShutdown","CountdownUnit",SETTING_COUNTDOWNUNIT_DEFAULT);
SendMessage(hwndCombo,CB_SETLOCALE,(WPARAM)locale,0); /* sort order */
SendMessage(hwndCombo,CB_INITSTORAGE,SIZEOF(unitNames),SIZEOF(unitNames)*16); /* approx. */
- for(i=0;i<SIZEOF(unitNames);++i) {
- index=SendMessage(hwndCombo,CB_ADDSTRING,0,(LPARAM)TranslateTS(unitNames[i]));
+ for(int i=0;i<SIZEOF(unitNames);++i) {
+ int index=SendMessage(hwndCombo,CB_ADDSTRING,0,(LPARAM)TranslateTS(unitNames[i]));
if(index!=LB_ERR) {
SendMessage(hwndCombo,CB_SETITEMDATA,index,(LPARAM)unitValues[i]);
if(i==0 || unitValues[i]==lastUnit) SendMessage(hwndCombo,CB_SETCURSEL,index,0);
@@ -140,8 +135,7 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR }
/* cpuusage threshold */
{
- BYTE setting;
- setting=DBGetContactSettingRangedByte(NULL,"AutoShutdown","CpuUsageThreshold",SETTING_CPUUSAGETHRESHOLD_DEFAULT,1,100);
+ BYTE setting=DBGetContactSettingRangedByte(NULL,"AutoShutdown","CpuUsageThreshold",SETTING_CPUUSAGETHRESHOLD_DEFAULT,1,100);
SendDlgItemMessage(hwndDlg,IDC_SPIN_CPUUSAGE,UDM_SETRANGE,0,MAKELPARAM(100,1));
SendDlgItemMessage(hwndDlg,IDC_EDIT_CPUUSAGE,EM_SETLIMITTEXT,(WPARAM)3,0);
SendDlgItemMessage(hwndDlg,IDC_SPIN_CPUUSAGE,UDM_SETPOS,0,MAKELPARAM(setting,0));
@@ -191,7 +185,6 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR CallService(MS_AUTOREPLACER_REMWINHANDLE,0,(LPARAM)GetDlgItem(hwndDlg,IDC_EDIT_MESSAGE));
Utils_SaveWindowPosition(hwndDlg,NULL,"AutoShutdown","SettingsDlg_");
HICON hIcon=(HICON)SendDlgItemMessage(hwndDlg,IDC_ICON_HEADER,STM_SETIMAGE,IMAGE_ICON,0);
- Skin_ReleaseIcon(hIcon); /* does NULL check */
HFONT hFont=(HFONT)SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_GETFONT,0,0);
SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_SETFONT,0,FALSE); /* no return value */
if(hFont!=NULL) DeleteObject(hFont);
@@ -323,8 +316,7 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR case IDC_EDIT_CPUUSAGE:
if(HIWORD(wParam)==EN_KILLFOCUS) {
- WORD val;
- val=(WORD)GetDlgItemInt(hwndDlg,IDC_EDIT_CPUUSAGE,NULL,FALSE);
+ WORD val=(WORD)GetDlgItemInt(hwndDlg,IDC_EDIT_CPUUSAGE,NULL,FALSE);
if(val<1) val=1;
else if(val>100) val=100;
SendDlgItemMessage(hwndDlg,IDC_SPIN_CPUUSAGE,UDM_SETPOS,0,MAKELPARAM(val,0));
@@ -392,9 +384,13 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR db_set_w(NULL,"AutoShutdown","WatcherFlags",watcherType);
ServiceStartWatcher(0,watcherType);
}
+ DestroyWindow(hwndDlg);
+ return TRUE;
/* fall through */
case IDCANCEL: /* WM_CLOSE */
DestroyWindow(hwndDlg);
+ SetShutdownToolbarButton(false);
+ SetShutdownMenuItem(false);
return TRUE;
}
break;
@@ -418,39 +414,45 @@ static INT_PTR ServiceShowSettingsDialog(WPARAM wParam,LPARAM lParam) static HANDLE hToolbarButton;
-static int ToolbarLoaded(WPARAM wParam,LPARAM lParam)
+int ToolbarLoaded(WPARAM,LPARAM)
{
TTBButton ttb = { sizeof(ttb) };
- ttb.hIconHandleUp = iconList[1].hIcolib;
- ttb.hIconHandleDn = iconList[2].hIcolib;
+ ttb.hIconHandleUp = iconList[2].hIcolib;
+ ttb.hIconHandleDn = iconList[1].hIcolib;
ttb.pszService = "AutoShutdown/MenuCommand";
- ttb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP;
+ ttb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP | TTBBF_ASPUSHBUTTON;
ttb.name = LPGEN("Start/Stop automatic shutdown");
- ttb.pszTooltipUp = LPGEN("Stop automatic shutdown");
- ttb.pszTooltipDn = LPGEN("Start automatic shutdown");
+ ttb.pszTooltipUp = LPGEN("Start automatic shutdown");
+ ttb.pszTooltipDn = LPGEN("Stop automatic shutdown");
hToolbarButton = TopToolbar_AddButton(&ttb);
return 0;
}
-void SetShutdownToolbarButton(BOOL fActive)
+void SetShutdownToolbarButton(bool fActive)
{
- if(hToolbarButton) {
+ if(hToolbarButton)
CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hToolbarButton,fActive?TTBST_PUSHED:TTBST_RELEASED);
- CallService(MS_TTB_SETBUTTONOPTIONS,MAKEWPARAM(TTBO_TIPNAME,hToolbarButton),(LPARAM)(fActive?Translate("Stop automatic shutdown"):Translate("Start automatic shutdown")));
- }
}
/************************* Menu Item **********************************/
static HGENMENU hMainMenuItem,hTrayMenuItem;
-void SetShutdownMenuItem(BOOL fActive)
+void SetShutdownMenuItem(bool fActive)
{
/* main menu */
CLISTMENUITEM mi = { sizeof(mi) };
mi.position = 2001090000;
- mi.icolibItem = fActive ? iconList[1].hIcolib : iconList[2].hIcolib;
- mi.ptszName = fActive ? LPGENT("Stop automatic &shutdown") : LPGENT("Automatic &shutdown..."); /* autotranslated */
+ if(fActive)
+ {
+ mi.icolibItem = iconList[1].hIcolib;
+ mi.ptszName = LPGENT("Stop automatic &shutdown");
+ }
+ else
+ {
+ mi.icolibItem = iconList[2].hIcolib;
+ mi.ptszName = LPGENT("Automatic &shutdown...");
+ }
mi.pszService = "AutoShutdown/MenuCommand";
mi.flags = CMIF_TCHAR;
if (hMainMenuItem != NULL) {
@@ -466,11 +468,9 @@ void SetShutdownMenuItem(BOOL fActive) Menu_ModifyItem(hTrayMenuItem, &mi);
}
else hTrayMenuItem = Menu_AddTrayMenuItem(&mi);
-
- Skin_ReleaseIcon(mi.hIcon);
}
-static INT_PTR MenuItemCommand(WPARAM wParam,LPARAM lParam)
+static INT_PTR MenuItemCommand(WPARAM,LPARAM)
{
/* toggle between StopWatcher and ShowSettingsDdialog */
if(ServiceIsWatcherEnabled(0,0))
@@ -487,9 +487,7 @@ void InitSettingsDlg(void) /* Menu Item */
hServiceMenuCommand = CreateServiceFunction("AutoShutdown/MenuCommand", MenuItemCommand);
hMainMenuItem=hTrayMenuItem=NULL;
- SetShutdownMenuItem(FALSE);
- /* Toolbar Item */
- HookEvent(ME_TTB_MODULELOADED,ToolbarLoaded); /* no service to check for */
+ SetShutdownMenuItem(false);
/* Hotkey */
AddHotkey();
/* Services */
diff --git a/plugins/AutoShutdown/src/settingsdlg.h b/plugins/AutoShutdown/src/settingsdlg.h index 2f7bf8ea84..87f9e6a9f9 100644 --- a/plugins/AutoShutdown/src/settingsdlg.h +++ b/plugins/AutoShutdown/src/settingsdlg.h @@ -20,11 +20,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Menu Item */
-void SetShutdownMenuItem(BOOL fActive);
+void SetShutdownMenuItem(bool fActive);
/* Toolbar Button */
-void SetShutdownToolbarButton(BOOL fActive);
+void SetShutdownToolbarButton(bool fActive);
/* Misc */
void InitSettingsDlg(void);
void UninitSettingsDlg(void);
+int ToolbarLoaded(WPARAM,LPARAM);
diff --git a/plugins/AutoShutdown/src/shutdownsvc.cpp b/plugins/AutoShutdown/src/shutdownsvc.cpp index b5e57da955..a2d9f97078 100644 --- a/plugins/AutoShutdown/src/shutdownsvc.cpp +++ b/plugins/AutoShutdown/src/shutdownsvc.cpp @@ -30,6 +30,17 @@ static HANDLE hServiceShutdown,hServiceIsTypeEnabled,hServiceGetTypeDesc; /************************* Utils **************************************/
+TCHAR *desc[]={LPGENT("Miranda NG is going to be automatically closed in %u second(s)."),
+ LPGENT("All Miranda NG protocols are going to be set to offline in %u second(s)."),
+ LPGENT("You will be logged off automatically in %u second(s)."),
+ LPGENT("The computer will automatically be restarted in %u second(s)."),
+ LPGENT("The computer will automatically be set to standby mode in %u second(s)."),
+ LPGENT("The computer will automatically be set to hibernate mode in %u second(s)."),
+ LPGENT("The workstation will automatically get locked in %u second(s)."),
+ LPGENT("All dialup connections will be closed in %u second(s)."),
+ LPGENT("The computer will automatically be shut down in %u second(s).")};
+
+
static BOOL WinNT_SetPrivilege(TCHAR *pszPrivName,BOOL bEnable)
{
BOOL bReturn=FALSE;
@@ -397,16 +408,14 @@ static INT_PTR CALLBACK ShutdownDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR SendMessage(hwndDlg,WM_NEXTDLGCTL,(WPARAM)GetDlgItem(hwndDlg,IDCANCEL),TRUE);
return FALSE; /* focus set on cancel */
case WM_DESTROY:
- { HFONT hFont;
- HICON hIcon;
+ {
hwndShutdownDlg=NULL;
ShowWindow(hwndDlg,SW_HIDE);
/* reallow foreground window changes (WinMe/2000+) */
if(pfnLockSetForegroundWindow) pfnLockSetForegroundWindow(LSFW_UNLOCK);
Utils_SaveWindowPosition(hwndDlg,NULL,"AutoShutdown","ConfirmDlg_");
- hIcon=(HICON)SendDlgItemMessage(hwndDlg,IDC_ICON_HEADER,STM_SETIMAGE,IMAGE_ICON,0);
- Skin_ReleaseIcon(hIcon); /* does NULL check */
- hFont=(HFONT)SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_GETFONT,0,0);
+ HICON hIcon=(HICON)SendDlgItemMessage(hwndDlg,IDC_ICON_HEADER,STM_SETIMAGE,IMAGE_ICON,0);
+ HFONT hFont=(HFONT)SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_GETFONT,0,0);
SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_SETFONT,0,FALSE); /* no return value */
if(hFont!=NULL) DeleteObject(hFont);
return TRUE;
@@ -439,16 +448,8 @@ static INT_PTR CALLBACK ShutdownDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR PostMessage(hwndDlg,M_UPDATE_COUNTDOWN,0,countdown);
return TRUE;
case M_UPDATE_COUNTDOWN: /* lParam=(WORD)countdown */
- { TCHAR szText[256];
- TCHAR *desc[]={LPGENT("Miranda NG is going to be automatically closed in %u second(s)."),
- LPGENT("All Miranda NG protocols are going to be set to offline in %u second(s)."),
- LPGENT("You will be logged off automatically in %u second(s)."),
- LPGENT("The computer will automatically be restarted in %u second(s)."),
- LPGENT("The computer will automatically be set to standby mode in %u second(s)."),
- LPGENT("The computer will automatically be set to hibernate mode in %u second(s)."),
- LPGENT("The workstation will automatically get locked in %u second(s)."),
- LPGENT("All dialup connections will be closed in %u second(s)."),
- LPGENT("The computer will automatically be shut down in %u second(s).")};
+ {
+ TCHAR szText[256];
mir_sntprintf(szText,SIZEOF(szText),TranslateTS(desc[shutdownType-1]),lParam);
SetDlgItemText(hwndDlg,IDC_TEXT_HEADER,szText);
/* countdown finished */
@@ -509,7 +510,7 @@ INT_PTR ServiceShutdown(WPARAM wParam,LPARAM lParam) return 0;
}
-INT_PTR ServiceIsTypeEnabled(WPARAM wParam,LPARAM lParam)
+INT_PTR ServiceIsTypeEnabled(WPARAM wParam,LPARAM)
{
return IsShutdownTypeEnabled((BYTE)wParam); /* does shutdownType range check */
}
diff --git a/plugins/AutoShutdown/src/watcher.cpp b/plugins/AutoShutdown/src/watcher.cpp index a9d3ebb6d8..b4d9d89a05 100644 --- a/plugins/AutoShutdown/src/watcher.cpp +++ b/plugins/AutoShutdown/src/watcher.cpp @@ -166,7 +166,7 @@ static int ProtoAck(WPARAM wParam,LPARAM lParam) /************************* Idle Shutdown ******************************/
-static int IdleChanged(WPARAM wParam,LPARAM lParam)
+static int IdleChanged(WPARAM,LPARAM lParam)
{
if(currentWatcherType&SDWTF_IDLE && lParam&IDF_ISIDLE)
ShutdownAndStopWatcher();
@@ -258,11 +258,19 @@ static int HddOverheat(WPARAM wParam,LPARAM lParam) INT_PTR ServiceStartWatcher(WPARAM wParam,LPARAM lParam)
{
/* passing watcherType as lParam is only to be used internally, undocumented */
- if(lParam==0) lParam=(LPARAM)db_get_w(NULL,"AutoShutdown","WatcherFlags",0);
+ if(lParam==0)
+ lParam=(LPARAM)db_get_w(NULL,"AutoShutdown","WatcherFlags",0);
- if(!(lParam&SDWTF_MASK)) return 1; /* invalid flags or empty? */
- if(lParam&SDWTF_SPECIFICTIME && !(lParam&SDWTF_ST_MASK)) return 2; /* no specific time choice? */
- if(currentWatcherType==(WORD)lParam) return 3;
+ /* invalid flags or empty? */
+ if(!(lParam&SDWTF_MASK))
+ return 1;
+
+ /* no specific time choice? */
+ if(lParam&SDWTF_SPECIFICTIME && !(lParam&SDWTF_ST_MASK))
+ return 2;
+
+ if(currentWatcherType==(WORD)lParam)
+ return 3;
if(currentWatcherType!=0) {
/* Time Shutdown */
@@ -270,8 +278,8 @@ INT_PTR ServiceStartWatcher(WPARAM wParam,LPARAM lParam) /* Cpu Shutdown */
idCpuUsageThread=0;
}
- SetShutdownMenuItem(TRUE);
- SetShutdownToolbarButton(TRUE);
+ SetShutdownMenuItem(true);
+ SetShutdownToolbarButton(true);
currentWatcherType=(WORD)lParam;
NotifyEventHooks(hEventWatcherChanged,TRUE,0);
@@ -290,7 +298,7 @@ INT_PTR ServiceStartWatcher(WPARAM wParam,LPARAM lParam) return 0;
}
-INT_PTR ServiceStopWatcher(WPARAM wParam,LPARAM lParam)
+INT_PTR ServiceStopWatcher(WPARAM,LPARAM)
{
if(currentWatcherType==0) return 1;
@@ -307,14 +315,14 @@ INT_PTR ServiceStopWatcher(WPARAM wParam,LPARAM lParam) return 0;
}
-INT_PTR ServiceIsWatcherEnabled(WPARAM wParam,LPARAM lParam)
+INT_PTR ServiceIsWatcherEnabled(WPARAM,LPARAM)
{
return currentWatcherType!=0;
}
/************************* Misc ***********************************/
-static int WatcherModulesLoaded(WPARAM wParam,LPARAM lParam)
+void WatcherModulesLoaded(void)
{
/* Weather Shutdown */
if(ServiceExists(MS_WEATHER_UPDATE))
@@ -328,7 +336,6 @@ static int WatcherModulesLoaded(WPARAM wParam,LPARAM lParam) db_set_b(NULL,"AutoShutdown","RememberOnRestart",1);
ServiceStartWatcher(0,0); /* after modules loaded */
}
- return 0;
}
void InitWatcher(void)
@@ -354,8 +361,6 @@ void InitWatcher(void) hServiceStartWatcher = CreateServiceFunction(MS_AUTOSHUTDOWN_STARTWATCHER, ServiceStartWatcher);
hServiceStopWatcher = CreateServiceFunction(MS_AUTOSHUTDOWN_STOPWATCHER, ServiceStopWatcher);
hServiceIsEnabled = CreateServiceFunction(MS_AUTOSHUTDOWN_ISWATCHERENABLED, ServiceIsWatcherEnabled);
- /* Misc */
- hHookModulesLoaded=HookEvent(ME_SYSTEM_MODULESLOADED,WatcherModulesLoaded);
}
void UninitWatcher(void)
diff --git a/plugins/AutoShutdown/src/watcher.h b/plugins/AutoShutdown/src/watcher.h index 962378b811..157fc93bd1 100644 --- a/plugins/AutoShutdown/src/watcher.h +++ b/plugins/AutoShutdown/src/watcher.h @@ -27,3 +27,4 @@ INT_PTR ServiceIsWatcherEnabled(WPARAM wParam,LPARAM lParam); /* Misc */
void InitWatcher(void);
void UninitWatcher(void);
+void WatcherModulesLoaded(void);
|