diff options
-rw-r--r-- | plugins/AutoShutdown/src/cpuusage.cpp | 44 | ||||
-rw-r--r-- | plugins/AutoShutdown/src/frame.cpp | 132 | ||||
-rw-r--r-- | plugins/AutoShutdown/src/main.cpp | 4 | ||||
-rw-r--r-- | plugins/AutoShutdown/src/options.cpp | 118 | ||||
-rw-r--r-- | plugins/AutoShutdown/src/settingsdlg.cpp | 108 | ||||
-rw-r--r-- | plugins/AutoShutdown/src/shutdownsvc.cpp | 607 | ||||
-rw-r--r-- | plugins/AutoShutdown/src/utils.cpp | 50 | ||||
-rw-r--r-- | plugins/AutoShutdown/src/watcher.cpp | 182 | ||||
-rw-r--r-- | plugins/Import/src/import.cpp | 2 | ||||
-rw-r--r-- | plugins/Import/src/miranda.cpp | 99 | ||||
-rw-r--r-- | plugins/KeyboardNotify/src/ignore.cpp | 20 | ||||
-rw-r--r-- | plugins/KeyboardNotify/src/main.cpp | 102 | ||||
-rw-r--r-- | plugins/KeyboardNotify/src/options.cpp | 12 | ||||
-rw-r--r-- | plugins/Scriver/src/msgwindow.cpp | 541 | ||||
-rw-r--r-- | plugins/SimpleStatusMsg/src/main.cpp | 84 | ||||
-rw-r--r-- | plugins/StatusPlugins/AdvancedAutoAway/advancedautoaway.cpp | 5 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/gg.h | 5 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber.h | 5 | ||||
-rw-r--r-- | src/core/stdaway/sendmsg.cpp | 6 | ||||
-rw-r--r-- | src/mir_core/winver.cpp | 8 |
20 files changed, 1013 insertions, 1121 deletions
diff --git a/plugins/AutoShutdown/src/cpuusage.cpp b/plugins/AutoShutdown/src/cpuusage.cpp index 8ab1fa91c0..cc4a3fac15 100644 --- a/plugins/AutoShutdown/src/cpuusage.cpp +++ b/plugins/AutoShutdown/src/cpuusage.cpp @@ -31,12 +31,12 @@ static BOOL WinNT_PerfStatsSwitch(TCHAR *pszServiceName,BOOL fDisable) DWORD dwData,dwDataSize;
BOOL fSwitched=FALSE;
/* Win2000+ */
- if(!RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T("System\\CurrentControlSet\\Services"),0,KEY_QUERY_VALUE|KEY_SET_VALUE,&hKeyServices)) {
- if(!RegOpenKeyEx(hKeyServices,pszServiceName,0,KEY_QUERY_VALUE|KEY_SET_VALUE,&hKeyService)) {
- if(!RegOpenKeyEx(hKeyService,_T("Performance"),0,KEY_QUERY_VALUE|KEY_SET_VALUE,&hKeyPerf)) {
+ if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T("System\\CurrentControlSet\\Services"),0,KEY_QUERY_VALUE|KEY_SET_VALUE,&hKeyServices)) {
+ if (!RegOpenKeyEx(hKeyServices,pszServiceName,0,KEY_QUERY_VALUE|KEY_SET_VALUE,&hKeyService)) {
+ if (!RegOpenKeyEx(hKeyService,_T("Performance"),0,KEY_QUERY_VALUE|KEY_SET_VALUE,&hKeyPerf)) {
dwDataSize=sizeof(DWORD);
- if(!RegQueryValueEx(hKeyPerf,_T("Disable Performance Counters"),NULL,NULL,(BYTE*)&dwData,&dwDataSize))
- if((dwData!=0)!=fDisable)
+ if (!RegQueryValueEx(hKeyPerf,_T("Disable Performance Counters"),NULL,NULL,(BYTE*)&dwData,&dwDataSize))
+ if ((dwData != 0) != fDisable)
fSwitched=!RegSetValueEx(hKeyPerf,_T("Disable Performance Counters"),0,REG_DWORD,(BYTE*)&fDisable,dwDataSize);
RegCloseKey(hKeyPerf);
}
@@ -58,7 +58,7 @@ struct CpuUsageThreadParams { static BOOL CallBackAndWait(struct CpuUsageThreadParams *param,BYTE nCpuUsage)
{
- if(param->hFirstEvent!=NULL) {
+ if (param->hFirstEvent != NULL) {
/* return value for PollCpuUsage() */
*param->pidThread=GetCurrentThreadId();
SetEvent(param->hFirstEvent);
@@ -66,7 +66,7 @@ static BOOL CallBackAndWait(struct CpuUsageThreadParams *param,BYTE nCpuUsage) /* lower priority after first call */
SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_IDLE);
}
- if(!param->pfnDataAvailProc(nCpuUsage,param->lParam)) return FALSE;
+ if (!param->pfnDataAvailProc(nCpuUsage,param->lParam)) return FALSE;
SleepEx(param->dwDelayMillis,TRUE);
return !Miranda_Terminated();
}
@@ -102,25 +102,25 @@ static void WinNT_PollThread(void *vparam) res=RegQueryValueExW(HKEY_PERFORMANCE_DATA,wszValueName,NULL,NULL,(BYTE*)pPerfData,&dwBufferSize);
while(!pBuffer || res==ERROR_MORE_DATA) {
pBuffer=(BYTE*)mir_realloc(pPerfData,dwBufferSize+=256);
- if(!pBuffer) break;
+ if (!pBuffer) break;
pPerfData=(PERF_DATA_BLOCK*)pBuffer;
res=RegQueryValueExW(HKEY_PERFORMANCE_DATA,wszValueName,NULL,NULL,pBuffer,&dwBufferSize);
}
- if(res!=ERROR_SUCCESS) break;
+ if (res != ERROR_SUCCESS) break;
/* find object in data */
fFound=FALSE;
/* first object */
pPerfObj=(PERF_OBJECT_TYPE*)((BYTE*)pPerfData+pPerfData->HeaderLength);
for(dwCount=0;dwCount<pPerfData->NumObjectTypes;++dwCount) {
- if(pPerfObj->ObjectNameTitleIndex==dwObjectId) {
+ if (pPerfObj->ObjectNameTitleIndex==dwObjectId) {
/* find counter in object data */
/* first counter */
pPerfCounter=(PERF_COUNTER_DEFINITION*)((BYTE*)pPerfObj+pPerfObj->HeaderLength);
for(dwCount=0;dwCount<(pPerfObj->NumCounters);++dwCount) {
- if(pPerfCounter->CounterNameTitleIndex==dwCounterId) {
+ if (pPerfCounter->CounterNameTitleIndex==dwCounterId) {
/* find instance in counter data */
- if(pPerfObj->NumInstances==PERF_NO_INSTANCES) {
+ if (pPerfObj->NumInstances==PERF_NO_INSTANCES) {
pPerfCounterBlock=(PERF_COUNTER_BLOCK*)((BYTE*)pPerfObj+pPerfObj->DefinitionLength);
liCurrentCounterValue=*(LARGE_INTEGER*)((BYTE*)pPerfCounterBlock+pPerfCounter->CounterOffset);
fFound=TRUE;
@@ -130,7 +130,7 @@ static void WinNT_PollThread(void *vparam) pPerfInstance=(PERF_INSTANCE_DEFINITION*)((BYTE*)pPerfObj+pPerfObj->DefinitionLength);
for(lCount=0;lCount<(pPerfObj->NumInstances);++lCount) {
pPerfCounterBlock=(PERF_COUNTER_BLOCK*)((BYTE*)pPerfInstance+pPerfInstance->ByteLength);
- if(!lstrcmpiW(pwszInstanceName,(WCHAR*)((BYTE*)pPerfInstance+pPerfInstance->NameOffset)) || !pwszInstanceName) {
+ if (!lstrcmpiW(pwszInstanceName,(WCHAR*)((BYTE*)pPerfInstance+pPerfInstance->NameOffset)) || !pwszInstanceName) {
liCurrentCounterValue=*(LARGE_INTEGER*)((BYTE*)pPerfCounterBlock+pPerfCounter->CounterOffset);
fFound=TRUE;
break;
@@ -149,14 +149,14 @@ static void WinNT_PollThread(void *vparam) /* next object */
pPerfObj=(PERF_OBJECT_TYPE*)((BYTE*)pPerfObj+pPerfObj->TotalByteLength);
}
- if(!fFound) break;
+ if (!fFound) break;
/* calc val from data, we need two samplings
* counter type: PERF_100NSEC_TIMER_INV
* calc: time base=100Ns, value=100*(1-(data_diff)/(100NsTime_diff)) */
- if(!fIsFirst) {
+ if (!fIsFirst) {
nCpuUsage=(BYTE)((1.0-(Li2Double(liCurrentCounterValue)-Li2Double(liPrevCounterValue))/(Li2Double(pPerfData->PerfTime100nSec)-Li2Double(liPrevPerfTime100nSec)))*100.0+0.5);
- if(!CallBackAndWait(param,nCpuUsage)) break;
+ if (!CallBackAndWait(param,nCpuUsage)) break;
}
else fIsFirst=FALSE;
/* store current sampling for next */
@@ -165,11 +165,11 @@ static void WinNT_PollThread(void *vparam) }
/* uninit */
- if(pPerfData) mir_free(pPerfData);
- if(fSwitched) WinNT_PerfStatsSwitch(_T("PerfOS"),TRUE);
+ if (pPerfData) mir_free(pPerfData);
+ if (fSwitched) WinNT_PerfStatsSwitch(_T("PerfOS"),TRUE);
/* return error for PollCpuUsage() if never succeeded */
- if(param->hFirstEvent!=NULL) SetEvent(param->hFirstEvent);
+ if (param->hFirstEvent != NULL) SetEvent(param->hFirstEvent);
mir_free(param);
}
@@ -184,18 +184,18 @@ DWORD PollCpuUsage(CPUUSAGEAVAILPROC pfnDataAvailProc,LPARAM lParam,DWORD dwDela /* init params */
param=(struct CpuUsageThreadParams*)mir_alloc(sizeof(struct CpuUsageThreadParams));
- if(param==NULL) return FALSE;
+ if (param==NULL) return FALSE;
param->dwDelayMillis=dwDelayMillis;
param->pfnDataAvailProc=pfnDataAvailProc;
param->lParam=lParam;
param->pidThread=&idThread;
param->hFirstEvent=hFirstEvent=CreateEvent(NULL,FALSE,FALSE,NULL);
- if(hFirstEvent==NULL) {
+ if (hFirstEvent==NULL) {
mir_free(param);
return 0;
}
/* start thread */
- if((int)mir_forkthread(WinNT_PollThread, param) != -1)
+ if ((int)mir_forkthread(WinNT_PollThread, param) != -1)
WaitForSingleObject(hFirstEvent,INFINITE); /* wait for first success */
else
mir_free(param); /* thread not started */
diff --git a/plugins/AutoShutdown/src/frame.cpp b/plugins/AutoShutdown/src/frame.cpp index 04b0a10422..9c0e8ff9fd 100644 --- a/plugins/AutoShutdown/src/frame.cpp +++ b/plugins/AutoShutdown/src/frame.cpp @@ -51,7 +51,7 @@ static LOGFONT* GetDefaultFont(LOGFONT *lf) NONCLIENTMETRICS ncm;
ZeroMemory(&ncm,sizeof(ncm));
ncm.cbSize=sizeof(ncm);
- if(SystemParametersInfo(SPI_GETNONCLIENTMETRICS,ncm.cbSize,&ncm,0)) {
+ if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS,ncm.cbSize,&ncm,0)) {
*lf=ncm.lfStatusFont;
return lf;
}
@@ -63,7 +63,7 @@ static HICON SetFrameTitleIcon(WORD hFrame,HICON hNewIcon) HICON hPrevIcon;
hPrevIcon=(HICON)CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS,MAKEWPARAM(FO_ICON,hFrame),0);
CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_ICON,hFrame),(LPARAM)hNewIcon);
- if((int)hPrevIcon==-1) return (HICON)NULL;
+ if ((int)hPrevIcon==-1) return (HICON)NULL;
return hPrevIcon;
}
@@ -123,7 +123,7 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARA case WM_NCCREATE: /* init window data */
dat=(struct CountdownFrameWndData*)mir_calloc(sizeof(*dat));
SetWindowLongPtr(hwndFrame, GWLP_USERDATA, (LONG)dat);
- if(dat==NULL) return FALSE; /* creation failed */
+ if (dat==NULL) return FALSE; /* creation failed */
dat->fTimeFlags=*(WORD*)((CREATESTRUCT*)lParam)->lpCreateParams;
dat->flags=FWPDF_COUNTDOWNINVALID;
break;
@@ -151,7 +151,7 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARA NULL,
params->hInstance,
NULL);
- if(dat->hwndProgress==NULL) return -1; /* creation failed, calls WM_DESTROY */
+ if (dat->hwndProgress==NULL) return -1; /* creation failed, calls WM_DESTROY */
SendMessage(dat->hwndProgress,PBM_SETSTEP,(WPARAM)1,0);
mir_subclassWindow(dat->hwndProgress, ProgressBarSubclassProc);
dat->hwndDesc=CreateWindowEx(WS_EX_NOPARENTNOTIFY,
@@ -178,7 +178,7 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARA NULL,
params->hInstance,
NULL);
- if(dat->hwndTime==NULL) return -1; /* creation failed, calls WM_DESTROY */
+ if (dat->hwndTime==NULL) return -1; /* creation failed, calls WM_DESTROY */
/* create tooltips */
TTTOOLINFO ti;
dat->hwndToolTip=CreateWindowEx(WS_EX_TOPMOST,
@@ -191,7 +191,7 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARA NULL,
params->hInstance,
NULL);
- if(dat->hwndToolTip!=NULL) {
+ if (dat->hwndToolTip != NULL) {
SetWindowPos(dat->hwndToolTip,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
ZeroMemory(&ti,sizeof(ti));
ti.cbSize=sizeof(ti);
@@ -203,11 +203,11 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARA ti.uFlags&=~TTF_TRANSPARENT;
ti.uId=(UINT)dat->hwndProgress;
SendMessage(dat->hwndToolTip,TTM_ADDTOOL,0,(LPARAM)&ti);
- if(dat->hwndDesc!=NULL) {
+ if (dat->hwndDesc != NULL) {
ti.uId=(UINT)dat->hwndDesc;
SendMessage(dat->hwndToolTip,TTM_ADDTOOL,0,(LPARAM)&ti);
}
- if(dat->hwndIcon!=NULL) {
+ if (dat->hwndIcon != NULL) {
ti.uId=(UINT)dat->hwndIcon;
SendMessage(dat->hwndToolTip,TTM_ADDTOOL,0,(LPARAM)&ti);
}
@@ -221,24 +221,24 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARA SendMessage(hwndFrame,M_REFRESH_ICONS,0,0);
SendMessage(hwndFrame,M_SET_COUNTDOWN,0,0);
SendMessage(hwndFrame,M_UPDATE_COUNTDOWN,0,0);
- if(!SetTimer(hwndFrame,1,1000,NULL)) return -1; /* creation failed, calls WM_DESTROY */
+ if (!SetTimer(hwndFrame,1,1000,NULL)) return -1; /* creation failed, calls WM_DESTROY */
return 0;
}
case WM_DESTROY:
{
- if(dat==NULL) return 0;
+ 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);
+ if (dat->hwndToolTip != NULL) DestroyWindow(dat->hwndToolTip);
HICON hIcon=(HICON)SendMessage(dat->hwndIcon,STM_SETIMAGE,IMAGE_ICON,0);
break;
}
case WM_NCDESTROY:
- if(dat==NULL) return 0;
- if(dat->hFont!=NULL) DeleteObject(dat->hFont);
- if(dat->hbrBackground!=NULL) DeleteObject(dat->hbrBackground);
+ if (dat==NULL) return 0;
+ if (dat->hFont != NULL) DeleteObject(dat->hFont);
+ if (dat->hbrBackground != NULL) DeleteObject(dat->hbrBackground);
mir_free(dat);
SetWindowLongPtr(hwndFrame, GWLP_USERDATA, (LONG)NULL);
break;
@@ -256,7 +256,7 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARA height=rc.bottom-(GetSystemMetrics(SM_CYICON)/2)-5;
hdwp=DeferWindowPos(hdwp,dat->hwndProgress,NULL,0,0,width,height,SWP_NOMOVE|defflg);
/* desc */
- if(dat->hwndDesc!=NULL) hdwp=DeferWindowPos(hdwp,dat->hwndDesc,NULL,GetSystemMetrics(SM_CXICON)+5,5+height,0,0,SWP_NOSIZE|defflg);
+ if (dat->hwndDesc != NULL) hdwp=DeferWindowPos(hdwp,dat->hwndDesc,NULL,GetSystemMetrics(SM_CXICON)+5,5+height,0,0,SWP_NOSIZE|defflg);
/* time */
hdwp=DeferWindowPos(hdwp,dat->hwndTime,NULL,GetSystemMetrics(SM_CXICON)+85,5+height,width-80,(GetSystemMetrics(SM_CXICON)/2),defflg);
EndDeferWindowPos(hdwp);
@@ -266,11 +266,11 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARA case M_REFRESH_COLORS:
{
COLORREF clrBar;
- if(FontService_GetColor(_T("Automatic Shutdown"),_T("Progress Bar"),&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))
+ if (FontService_GetColor(_T("Automatic Shutdown"),_T("Background"),&dat->clrBackground))
dat->clrBackground=GetDefaultColor(FRAMEELEMENT_BKGRND);
- if(dat->hbrBackground!=NULL) DeleteObject(dat->hbrBackground);
+ if (dat->hbrBackground != NULL) DeleteObject(dat->hbrBackground);
dat->hbrBackground=CreateSolidBrush(dat->clrBackground);
SendMessage(dat->hwndProgress,PBM_SETBARCOLOR,0,(LPARAM)clrBar);
SendMessage(dat->hwndProgress,PBM_SETBKCOLOR,0,(LPARAM)dat->clrBackground);
@@ -282,18 +282,18 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARA case M_REFRESH_FONTS:
{
LOGFONT lf;
- if(!FontService_GetFont(_T("Automatic Shutdown"),_T("Countdown on Frame"),&dat->clrText,&lf)) {
- if(dat->hFont!=NULL) DeleteObject(dat->hFont);
+ if (!FontService_GetFont(_T("Automatic Shutdown"),_T("Countdown on Frame"),&dat->clrText,&lf)) {
+ if (dat->hFont != NULL) DeleteObject(dat->hFont);
dat->hFont=CreateFontIndirect(&lf);
}
else {
dat->clrText=GetDefaultColor(FRAMEELEMENT_TEXT);
- if(GetDefaultFont(&lf)!=NULL) {
- if(dat->hFont!=NULL) DeleteObject(dat->hFont);
+ if (GetDefaultFont(&lf) != NULL) {
+ if (dat->hFont != NULL) DeleteObject(dat->hFont);
dat->hFont=CreateFontIndirect(&lf);
}
}
- if(dat->hwndDesc!=NULL)
+ if (dat->hwndDesc != NULL)
SendMessage(dat->hwndDesc,WM_SETFONT,(WPARAM)dat->hFont,FALSE);
SendMessage(dat->hwndTime,WM_SETFONT,(WPARAM)dat->hFont,FALSE);
InvalidateRect(hwndFrame,NULL,FALSE);
@@ -319,20 +319,20 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARA return (BOOL)dat->hbrBackground;
case WM_ERASEBKGND:
{ RECT rc;
- if(dat->hbrBackground!=NULL && GetClientRect(hwndFrame,&rc)) {
+ if (dat->hbrBackground != NULL && GetClientRect(hwndFrame,&rc)) {
FillRect((HDC)wParam,&rc,dat->hbrBackground);
return TRUE;
}
return FALSE;
}
case M_SET_COUNTDOWN:
- if(dat->fTimeFlags&SDWTF_ST_TIME) {
+ if (dat->fTimeFlags&SDWTF_ST_TIME) {
dat->settingLastTime=(time_t)db_get_dw(NULL,"AutoShutdown","TimeStamp",SETTING_TIMESTAMP_DEFAULT);
dat->countdown=time(NULL);
- if(dat->settingLastTime>dat->countdown) dat->countdown=dat->settingLastTime-dat->countdown;
+ if (dat->settingLastTime>dat->countdown) dat->countdown=dat->settingLastTime-dat->countdown;
else dat->countdown=0;
}
- else if(dat->flags&FWPDF_COUNTDOWNINVALID) {
+ else if (dat->flags&FWPDF_COUNTDOWNINVALID) {
dat->countdown=(time_t)db_get_dw(NULL,"AutoShutdown","Countdown",SETTING_COUNTDOWN_DEFAULT);
dat->countdown*=(time_t)db_get_dw(NULL,"AutoShutdown","CountdownUnit",SETTING_COUNTDOWNUNIT_DEFAULT);
}
@@ -341,13 +341,13 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARA SendMessage(dat->hwndProgress,PBM_SETRANGE32,0,(LPARAM)dat->countdown);
return 0;
case WM_TIMER:
- if(dat==NULL) return 0;
- if(dat->countdown!=0 && !(dat->flags&FWPDF_COUNTDOWNINVALID) && !(dat->flags&FWPDF_PAUSED)) {
+ if (dat==NULL) return 0;
+ if (dat->countdown != 0 && !(dat->flags&FWPDF_COUNTDOWNINVALID) && !(dat->flags&FWPDF_PAUSED)) {
dat->countdown--;
PostMessage(dat->hwndProgress,PBM_STEPIT,0,0);
}
- if(IsWindowVisible(hwndFrame)) PostMessage(hwndFrame,M_UPDATE_COUNTDOWN,0,0);
- if(dat->countdown==0) {
+ if (IsWindowVisible(hwndFrame)) PostMessage(hwndFrame,M_UPDATE_COUNTDOWN,0,0);
+ if (dat->countdown==0) {
SendMessage(hwndFrame,M_CLOSE_COUNTDOWN,0,0);
ServiceShutdown(0,TRUE);
ServiceStopWatcher(0,0);
@@ -355,25 +355,25 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARA return 0;
case WM_SHOWWINDOW:
/* the text is kept unchanged while hidden */
- if((BOOL)wParam) SendMessage(hwndFrame,M_UPDATE_COUNTDOWN,0,0);
+ if ((BOOL)wParam) SendMessage(hwndFrame,M_UPDATE_COUNTDOWN,0,0);
break;
case M_UPDATE_COUNTDOWN:
- if(dat->flags&FWPDF_PAUSED && !(dat->flags&FWPDF_PAUSEDSHOWN)) {
+ if (dat->flags&FWPDF_PAUSED && !(dat->flags&FWPDF_PAUSEDSHOWN)) {
SetWindowText(dat->hwndTime,TranslateT("Paused"));
dat->flags|=FWPDF_PAUSEDSHOWN;
}
else {
TCHAR szOutput[256];
- if(dat->fTimeFlags&SDWTF_ST_TIME)
+ if (dat->fTimeFlags&SDWTF_ST_TIME)
GetFormatedDateTime(szOutput,SIZEOF(szOutput),dat->settingLastTime,TRUE);
else GetFormatedCountdown(szOutput,SIZEOF(szOutput),dat->countdown);
SetWindowText(dat->hwndTime,szOutput);
PostMessage(hwndFrame,M_CHECK_CLIPPED,0,0);
/* update tooltip text (if shown) */
- if(dat->hwndToolTip!=NULL && !(dat->flags&FWPDF_PAUSED)) {
+ if (dat->hwndToolTip != NULL && !(dat->flags&FWPDF_PAUSED)) {
TTTOOLINFO ti;
ti.cbSize=sizeof(ti);
- if(SendMessage(dat->hwndToolTip,TTM_GETCURRENTTOOL,0,(LPARAM)&ti) && (HWND)ti.uId!=dat->hwndIcon)
+ if (SendMessage(dat->hwndToolTip,TTM_GETCURRENTTOOL,0,(LPARAM)&ti) && (HWND)ti.uId != dat->hwndIcon)
SendMessage(dat->hwndToolTip,TTM_UPDATE,0,0);
} else dat->flags&=~FWPDF_PAUSEDSHOWN;
}
@@ -390,7 +390,7 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARA SendMessage(dat->hwndProgress,PBM_SETMARQUEE,TRUE,10); /* marquee for rest of time */
return 0;
case M_PAUSE_COUNTDOWN:
- if(dat->flags&FWPDF_PAUSED) {
+ if (dat->flags&FWPDF_PAUSED) {
/* unpause */
dat->flags&=~(FWPDF_PAUSED|FWPDF_PAUSEDSHOWN);
SendMessage(hwndFrame,M_SET_COUNTDOWN,0,0);
@@ -406,17 +406,17 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARA case WM_CONTEXTMENU:
{ HMENU hContextMenu;
POINT pt;
- if(dat->flags&FWPDF_COUNTDOWNINVALID) return 0;
+ if (dat->flags&FWPDF_COUNTDOWNINVALID) return 0;
POINTSTOPOINT(pt,MAKEPOINTS(lParam));
- if(pt.x==-1 && pt.y==-1) { /* invoked by keyboard */
+ if (pt.x==-1 && pt.y==-1) { /* invoked by keyboard */
RECT rc;
/* position in middle above rect */
- if(!GetWindowRect(hwndFrame, &rc)) return 0;
+ if (!GetWindowRect(hwndFrame, &rc)) return 0;
pt.x=rc.left+((int)(rc.right-rc.left)/2);
pt.y=rc.top+((int)(rc.bottom-rc.top)/2);
}
hContextMenu=CreatePopupMenu();
- if(hContextMenu!=NULL) {
+ if (hContextMenu != NULL) {
AppendMenu(hContextMenu,MF_STRING,MENUITEM_PAUSECOUNTDOWN,(dat->flags&FWPDF_PAUSED)?TranslateT("&Unpause Countdown"):TranslateT("&Pause Countdown"));
SetMenuDefaultItem(hContextMenu,MENUITEM_PAUSECOUNTDOWN,FALSE);
AppendMenu(hContextMenu,MF_STRING,MENUITEM_STOPCOUNTDOWN,TranslateT("&Cancel Countdown"));
@@ -426,14 +426,14 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARA return 0;
}
case WM_LBUTTONDBLCLK:
- if(!(dat->flags&FWPDF_COUNTDOWNINVALID))
+ if (!(dat->flags&FWPDF_COUNTDOWNINVALID))
SendMessage(hwndFrame,M_PAUSE_COUNTDOWN,0,0);
return 0;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case MENUITEM_STOPCOUNTDOWN:
/* close only countdown window when other watcher types running */
- if(dat->fTimeFlags&~(SDWTF_SPECIFICTIME|SDWTF_ST_MASK))
+ if (dat->fTimeFlags&~(SDWTF_SPECIFICTIME|SDWTF_ST_MASK))
CloseCountdownFrame(); /* something else is running */
else ServiceStopWatcher(0,0); /* calls CloseCountdownFrame() */
return 0;
@@ -449,16 +449,16 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARA HFONT hFontPrev=NULL;
TCHAR szOutput[256];
dat->flags&=~FWPDF_TIMEISCLIPPED;
- if(GetWindowText(dat->hwndTime,szOutput,SIZEOF(szOutput)-1))
- if(GetClientRect(dat->hwndTime,&rc)) {
+ if (GetWindowText(dat->hwndTime,szOutput,SIZEOF(szOutput)-1))
+ if (GetClientRect(dat->hwndTime,&rc)) {
hdc=GetDC(dat->hwndTime);
- if(hdc!=NULL) {
- if(dat->hFont!=NULL)
+ if (hdc != NULL) {
+ if (dat->hFont != NULL)
hFontPrev = (HFONT)SelectObject(hdc,dat->hFont);
- if(GetTextExtentPoint32(hdc,szOutput,lstrlen(szOutput),&size))
- if(size.cx>=(rc.right-rc.left))
+ if (GetTextExtentPoint32(hdc,szOutput,lstrlen(szOutput),&size))
+ if (size.cx>=(rc.right-rc.left))
dat->flags&=FWPDF_TIMEISCLIPPED;
- if(dat->hFont!=NULL)
+ if (dat->hFont != NULL)
SelectObject(hdc,hFontPrev);
ReleaseDC(dat->hwndTime,hdc);
}
@@ -466,12 +466,12 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARA return 0;
}
case WM_NOTIFY:
- if(((NMHDR*)lParam)->hwndFrom==dat->hwndToolTip)
+ if (((NMHDR*)lParam)->hwndFrom==dat->hwndToolTip)
switch(((NMHDR*)lParam)->code) {
case TTN_SHOW: /* 'in-place' tooltip on dat->hwndTime */
- if(dat->flags&FWPDF_TIMEISCLIPPED && (HWND)wParam==dat->hwndTime) {
+ if (dat->flags&FWPDF_TIMEISCLIPPED && (HWND)wParam==dat->hwndTime) {
RECT rc;
- if(GetWindowRect(dat->hwndTime,&rc)) {
+ if (GetWindowRect(dat->hwndTime,&rc)) {
SetWindowLongPtr(dat->hwndToolTip, GWL_STYLE, GetWindowLongPtr(dat->hwndToolTip, GWL_STYLE) | TTS_NOANIMATE);
SetWindowLongPtr(dat->hwndToolTip, GWL_EXSTYLE, GetWindowLongPtr(dat->hwndToolTip, GWL_EXSTYLE) | WS_EX_TRANSPARENT);
SendMessage(dat->hwndToolTip,TTM_ADJUSTRECT,TRUE,(LPARAM)&rc);
@@ -489,15 +489,15 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARA return 0;
case TTN_NEEDTEXT:
{ NMTTDISPINFO *ttdi=(NMTTDISPINFO*)lParam;
- if(dat->flags&FWPDF_TIMEISCLIPPED && (HWND)wParam==dat->hwndTime) {
- if(GetWindowText(dat->hwndTime,ttdi->szText,SIZEOF(ttdi->szText)-1))
+ if (dat->flags&FWPDF_TIMEISCLIPPED && (HWND)wParam==dat->hwndTime) {
+ if (GetWindowText(dat->hwndTime,ttdi->szText,SIZEOF(ttdi->szText)-1))
ttdi->lpszText=ttdi->szText;
}
- else if((HWND)wParam==dat->hwndIcon)
+ else if ((HWND)wParam==dat->hwndIcon)
ttdi->lpszText=TranslateT("Automatic Shutdown");
else {
TCHAR szTime[SIZEOF(ttdi->szText)];
- if(dat->fTimeFlags&SDWTF_ST_TIME)
+ if (dat->fTimeFlags&SDWTF_ST_TIME)
GetFormatedDateTime(szTime,SIZEOF(szTime),dat->settingLastTime,FALSE);
else GetFormatedCountdown(szTime,SIZEOF(szTime),dat->countdown);
mir_sntprintf(ttdi->szText,SIZEOF(ttdi->szText),_T("%s %s"),(dat->fTimeFlags&SDWTF_ST_TIME)?TranslateT("Shutdown at:"):TranslateT("Time left:"),szTime);
@@ -526,9 +526,9 @@ void ShowCountdownFrame(WORD fTimeFlags) NULL,
hInst,
&fTimeFlags);
- if(hwndCountdownFrame==NULL) return;
+ if (hwndCountdownFrame==NULL) return;
- if(ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
+ if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
CLISTFrame clf = { sizeof(clf) };
clf.hIcon=Skin_GetIcon("AutoShutdown_Active"); /* CListFrames does not make a copy */
clf.align=alBottom;
@@ -538,7 +538,7 @@ void ShowCountdownFrame(WORD fTimeFlags) clf.TBname=Translate("Automatic Shutdown");
clf.hWnd=hwndCountdownFrame;
hFrame=(WORD)CallService(MS_CLIST_FRAMES_ADDFRAME,(WPARAM)&clf,0);
- if(hFrame) {
+ if (hFrame) {
ShowWindow(hwndCountdownFrame,SW_SHOW);
CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_TBTIPNAME,hFrame),(LPARAM)clf.name);
/* HACKS TO FIX CLUI FRAMES:
@@ -548,7 +548,7 @@ void ShowCountdownFrame(WORD fTimeFlags) /* workaround #2: drawing glitch after adding a frame (frame positioned wrongly when hidden) */
CallService(MS_CLIST_FRAMES_UPDATEFRAME,hFrame,FU_FMPOS|FU_FMREDRAW);
/* workaround #3: MS_CLIST_FRAMES_SETFRAMEOPTIONS does cause redrawing problems */
- if(!(CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS,MAKEWPARAM(FO_FLAGS,hFrame),0)&F_VISIBLE))
+ if (!(CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS,MAKEWPARAM(FO_FLAGS,hFrame),0)&F_VISIBLE))
CallService(MS_CLIST_FRAMES_SHFRAME,hFrame,0);
/* workaround #4: MS_CLIST_FRAMES_SHFRAME does cause redrawing problems when frame was hidden */
RedrawWindow(hwndCountdownFrame,NULL,NULL,RDW_INVALIDATE|RDW_ALLCHILDREN|RDW_ERASE);
@@ -560,9 +560,9 @@ void ShowCountdownFrame(WORD fTimeFlags) void CloseCountdownFrame(void)
{
- if(hwndCountdownFrame!=NULL) {
+ if (hwndCountdownFrame != NULL) {
SendMessage(hwndCountdownFrame,M_CLOSE_COUNTDOWN,0,0);
- if(hFrame) {
+ if (hFrame) {
/* HACKS TO FIX CLUIFrames:
* workaround #6: MS_CLIST_FRAMES_REMOVEFRAME does not finish with
* destroy cycle (clist_modern, clist_nicer crashes) */
@@ -584,14 +584,14 @@ void CloseCountdownFrame(void) static int FrameModulesLoaded(WPARAM wParam,LPARAM lParam)
{
- if(ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
+ if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
LOGFONT lf;
/* built-in font module is not available before this hook */
COLORREF clr = GetDefaultColor(FRAMEELEMENT_TEXT);
FontService_RegisterFont("AutoShutdown","CountdownFont",LPGENT("Automatic Shutdown"),LPGENT("Countdown on Frame"),LPGENT("Automatic Shutdown"),LPGENT("Background"),0,FALSE,GetDefaultFont(&lf),clr);
clr=GetDefaultColor(FRAMEELEMENT_BKGRND);
FontService_RegisterColor("AutoShutdown","BkgColor",LPGENT("Automatic Shutdown"),LPGENT("Background"),clr);
- if( !IsThemeActive()) {
+ if ( !IsThemeActive()) {
/* progressbar color can only be changed with classic theme */
clr=GetDefaultColor(FRAMEELEMENT_BAR);
FontService_RegisterColor("AutoShutdown","ProgressColor",TranslateT("Automatic Shutdown"),TranslateT("Progress Bar"),clr);
@@ -610,7 +610,7 @@ int InitFrame(void) wcx.hInstance =hInst;
wcx.hCursor =(HCURSOR)LoadImage(NULL,IDC_ARROW,IMAGE_CURSOR,0,0,LR_SHARED);
wcx.lpszClassName =COUNTDOWNFRAME_CLASS;
- if(!RegisterClassEx(&wcx)) return 1;
+ if (!RegisterClassEx(&wcx)) return 1;
hwndCountdownFrame=NULL;
hHookModulesLoaded=HookEvent(ME_SYSTEM_MODULESLOADED,FrameModulesLoaded);
diff --git a/plugins/AutoShutdown/src/main.cpp b/plugins/AutoShutdown/src/main.cpp index 636fc3e0fd..5341f7d7d0 100644 --- a/plugins/AutoShutdown/src/main.cpp +++ b/plugins/AutoShutdown/src/main.cpp @@ -74,9 +74,9 @@ extern "C" __declspec(dllexport) int Load(void) INITCOMMONCONTROLSEX icc;
icc.dwSize=sizeof(icc);
icc.dwICC=ICC_DATE_CLASSES|ICC_UPDOWN_CLASS|ICC_PROGRESS_CLASS;
- if(!InitCommonControlsEx(&icc)) return 1;
+ if (!InitCommonControlsEx(&icc)) return 1;
- if(InitFrame()) return 1; /* before icons */
+ if (InitFrame()) return 1; /* before icons */
/* shared */
Icon_Register(hInst, "Automatic Shutdown", iconList, SIZEOF(iconList));
diff --git a/plugins/AutoShutdown/src/options.cpp b/plugins/AutoShutdown/src/options.cpp index 2c3ce593df..4cadbe61c4 100644 --- a/plugins/AutoShutdown/src/options.cpp +++ b/plugins/AutoShutdown/src/options.cpp @@ -34,35 +34,39 @@ static HANDLE hHookModulesLoaded; static INT_PTR CALLBACK ShutdownOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
{
switch(msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- { WORD setting=db_get_w(NULL,"AutoShutdown","ConfirmDlgCountdown",SETTING_CONFIRMDLGCOUNTDOWN_DEFAULT);
- if(setting<3) setting=SETTING_CONFIRMDLGCOUNTDOWN_DEFAULT;
- SendDlgItemMessage(hwndDlg,IDC_SPIN_CONFIRMDLGCOUNTDOWN,UDM_SETRANGE,0,MAKELPARAM(999,3));
- SendDlgItemMessage(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN,EM_SETLIMITTEXT,3,0);
- SendDlgItemMessage(hwndDlg,IDC_SPIN_CONFIRMDLGCOUNTDOWN,UDM_SETPOS,0,MAKELPARAM(setting,0));
- SetDlgItemInt(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN,setting,FALSE);
- }
- CheckDlgButton(hwndDlg,IDC_CHECK_SMARTOFFLINECHECK,db_get_b(NULL,"AutoShutdown","SmartOfflineCheck",SETTING_SMARTOFFLINECHECK_DEFAULT)!=0);
- CheckDlgButton(hwndDlg,IDC_CHECK_REMEMBERONRESTART,db_get_b(NULL,"AutoShutdown","RememberOnRestart",SETTING_REMEMBERONRESTART_DEFAULT)!=0);
- CheckDlgButton(hwndDlg,IDC_CHECK_SHOWCONFIRMDLG,db_get_b(NULL,"AutoShutdown","ShowConfirmDlg",SETTING_SHOWCONFIRMDLG_DEFAULT)!=0);
- { BOOL enabled=ServiceIsTypeEnabled(SDSDT_SHUTDOWN,0);
- if(enabled) {
- if(ServiceExists(MS_SYSINFO_HDDTEMP)) {
- EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_HDDOVERHEAT),TRUE);
- CheckDlgButton(hwndDlg,IDC_CHECK_HDDOVERHEAT,db_get_b(NULL,"AutoShutdown","HddOverheatShutdown",SETTING_HDDOVERHEATSHUTDOWN_DEFAULT)!=0);
- }
- if(ServiceExists(MS_WEATHER_UPDATE)) {
- EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_WEATHER),TRUE);
- CheckDlgButton(hwndDlg,IDC_CHECK_WEATHER,db_get_b(NULL,"AutoShutdown","WeatherShutdown",SETTING_WEATHERSHUTDOWN_DEFAULT)!=0);
- }
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ {
+ WORD setting=db_get_w(NULL,"AutoShutdown","ConfirmDlgCountdown",SETTING_CONFIRMDLGCOUNTDOWN_DEFAULT);
+ if (setting<3) setting=SETTING_CONFIRMDLGCOUNTDOWN_DEFAULT;
+ SendDlgItemMessage(hwndDlg,IDC_SPIN_CONFIRMDLGCOUNTDOWN,UDM_SETRANGE,0,MAKELPARAM(999,3));
+ SendDlgItemMessage(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN,EM_SETLIMITTEXT,3,0);
+ SendDlgItemMessage(hwndDlg,IDC_SPIN_CONFIRMDLGCOUNTDOWN,UDM_SETPOS,0,MAKELPARAM(setting,0));
+ SetDlgItemInt(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN,setting,FALSE);
+ }
+ CheckDlgButton(hwndDlg,IDC_CHECK_SMARTOFFLINECHECK,db_get_b(NULL,"AutoShutdown","SmartOfflineCheck",SETTING_SMARTOFFLINECHECK_DEFAULT) != 0);
+ CheckDlgButton(hwndDlg,IDC_CHECK_REMEMBERONRESTART,db_get_b(NULL,"AutoShutdown","RememberOnRestart",SETTING_REMEMBERONRESTART_DEFAULT) != 0);
+ CheckDlgButton(hwndDlg,IDC_CHECK_SHOWCONFIRMDLG,db_get_b(NULL,"AutoShutdown","ShowConfirmDlg",SETTING_SHOWCONFIRMDLG_DEFAULT) != 0);
+ {
+ BOOL enabled = ServiceIsTypeEnabled(SDSDT_SHUTDOWN,0);
+ if (enabled) {
+ if (ServiceExists(MS_SYSINFO_HDDTEMP)) {
+ EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_HDDOVERHEAT),TRUE);
+ CheckDlgButton(hwndDlg,IDC_CHECK_HDDOVERHEAT,db_get_b(NULL,"AutoShutdown","HddOverheatShutdown",SETTING_HDDOVERHEATSHUTDOWN_DEFAULT) != 0);
+ }
+ if (ServiceExists(MS_WEATHER_UPDATE)) {
+ EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_WEATHER),TRUE);
+ CheckDlgButton(hwndDlg,IDC_CHECK_WEATHER,db_get_b(NULL,"AutoShutdown","WeatherShutdown",SETTING_WEATHERSHUTDOWN_DEFAULT) != 0);
}
}
- SendMessage(hwndDlg,M_ENABLE_SUBCTLS,0,0);
- return TRUE; /* default focus */
- case M_ENABLE_SUBCTLS:
- { BOOL checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_SHOWCONFIRMDLG)!=0;
- if(checked!=IsWindowEnabled(GetDlgItem(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN))) {
+ }
+ SendMessage(hwndDlg,M_ENABLE_SUBCTLS,0,0);
+ return TRUE; /* default focus */
+
+ case M_ENABLE_SUBCTLS:
+ {
+ BOOL checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_SHOWCONFIRMDLG) != 0;
+ if (checked != IsWindowEnabled(GetDlgItem(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN))) {
EnableWindow(GetDlgItem(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN),checked);
EnableWindow(GetDlgItem(hwndDlg,IDC_SPIN_CONFIRMDLGCOUNTDOWN),checked);
EnableWindow(GetDlgItem(hwndDlg,IDC_TEXT_COUNTDOWNSTARTS),checked);
@@ -70,35 +74,37 @@ static INT_PTR CALLBACK ShutdownOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,L }
return TRUE;
}
- case WM_COMMAND:
- switch(LOWORD(wParam)) {
- case IDC_EDIT_CONFIRMDLGCOUNTDOWN:
- if(HIWORD(wParam)==EN_KILLFOCUS)
- if((int)GetDlgItemInt(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN,NULL,TRUE)<3) {
- SendDlgItemMessage(hwndDlg,IDC_SPIN_CONFIRMDLGCOUNTDOWN,UDM_SETPOS,0,MAKELPARAM(3,0));
- SetDlgItemInt(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN,3,FALSE);
- }
- if(HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus())
- return TRUE; /* no apply */
- break;
- }
- PostMessage(hwndDlg,M_ENABLE_SUBCTLS,0,0);
- PostMessage(GetParent(hwndDlg),PSM_CHANGED,0,0); /* enable apply */
- return FALSE;
- case WM_NOTIFY:
- switch(((NMHDR*)lParam)->code) {
- case PSN_APPLY:
- db_set_b(NULL,"AutoShutdown","ShowConfirmDlg",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SHOWCONFIRMDLG)!=0));
- db_set_w(NULL,"AutoShutdown","ConfirmDlgCountdown",(WORD)GetDlgItemInt(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN,NULL,FALSE));
- db_set_b(NULL,"AutoShutdown","RememberOnRestart",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_CHECK_REMEMBERONRESTART)!=0));
- db_set_b(NULL,"AutoShutdown","SmartOfflineCheck",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SMARTOFFLINECHECK)!=0));
- if(IsWindowEnabled(GetDlgItem(hwndDlg,IDC_CHECK_WEATHER)))
- db_set_b(NULL,"AutoShutdown","WeatherShutdown",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_CHECK_WEATHER)!=0));
- if(IsWindowEnabled(GetDlgItem(hwndDlg,IDC_CHECK_HDDOVERHEAT)))
- db_set_b(NULL,"AutoShutdown","HddOverheatShutdown",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_CHECK_HDDOVERHEAT)!=0));
- return TRUE;
- }
- break;
+
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDC_EDIT_CONFIRMDLGCOUNTDOWN:
+ if (HIWORD(wParam)==EN_KILLFOCUS)
+ if ((int)GetDlgItemInt(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN,NULL,TRUE)<3) {
+ SendDlgItemMessage(hwndDlg,IDC_SPIN_CONFIRMDLGCOUNTDOWN,UDM_SETPOS,0,MAKELPARAM(3,0));
+ SetDlgItemInt(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN,3,FALSE);
+ }
+ if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())
+ return TRUE; /* no apply */
+ break;
+ }
+ PostMessage(hwndDlg,M_ENABLE_SUBCTLS,0,0);
+ PostMessage(GetParent(hwndDlg),PSM_CHANGED,0,0); /* enable apply */
+ return FALSE;
+
+ case WM_NOTIFY:
+ switch(((NMHDR*)lParam)->code) {
+ case PSN_APPLY:
+ db_set_b(NULL,"AutoShutdown","ShowConfirmDlg",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SHOWCONFIRMDLG) != 0));
+ db_set_w(NULL,"AutoShutdown","ConfirmDlgCountdown",(WORD)GetDlgItemInt(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN,NULL,FALSE));
+ db_set_b(NULL,"AutoShutdown","RememberOnRestart",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_CHECK_REMEMBERONRESTART) != 0));
+ db_set_b(NULL,"AutoShutdown","SmartOfflineCheck",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SMARTOFFLINECHECK) != 0));
+ if (IsWindowEnabled(GetDlgItem(hwndDlg,IDC_CHECK_WEATHER)))
+ db_set_b(NULL,"AutoShutdown","WeatherShutdown",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_CHECK_WEATHER) != 0));
+ if (IsWindowEnabled(GetDlgItem(hwndDlg,IDC_CHECK_HDDOVERHEAT)))
+ db_set_b(NULL,"AutoShutdown","HddOverheatShutdown",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_CHECK_HDDOVERHEAT) != 0));
+ return TRUE;
+ }
+ break;
}
return FALSE;
}
diff --git a/plugins/AutoShutdown/src/settingsdlg.cpp b/plugins/AutoShutdown/src/settingsdlg.cpp index 6e527eac22..f5a31ace20 100644 --- a/plugins/AutoShutdown/src/settingsdlg.cpp +++ b/plugins/AutoShutdown/src/settingsdlg.cpp @@ -36,14 +36,14 @@ const TCHAR *unitNames[]={LPGENT("Second(s)"), LPGENT("Minute(s)"), LPGENT("Hour static void EnableDlgItem(HWND hwndDlg,int idCtrl,BOOL fEnable)
{
hwndDlg=GetDlgItem(hwndDlg,idCtrl);
- if(hwndDlg!=NULL && IsWindowEnabled(hwndDlg)!=fEnable)
+ if (hwndDlg != NULL && IsWindowEnabled(hwndDlg) != fEnable)
EnableWindow(hwndDlg,fEnable);
}
static BOOL CALLBACK DisplayCpuUsageProc(BYTE nCpuUsage,LPARAM lParam)
{
/* dialog closed? */
- if(!IsWindow((HWND)lParam)) return FALSE; /* stop poll thread */
+ 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);
@@ -54,9 +54,9 @@ static bool AnyProtoHasCaps(DWORD caps1) {
int nProtoCount;
PROTOACCOUNT **protos;
- if(!ProtoEnumAccounts(&nProtoCount, &protos))
+ if (!ProtoEnumAccounts(&nProtoCount, &protos))
for(int i=0;i<nProtoCount;++i)
- if(CallProtoService(protos[i]->szModuleName,PS_GETCAPS,(WPARAM)PFLAGNUM_1,0)&caps1)
+ if (CallProtoService(protos[i]->szModuleName,PS_GETCAPS,(WPARAM)PFLAGNUM_1,0)&caps1)
return true; /* CALLSERVICE_NOTFOUND also handled gracefully */
return false;
}
@@ -77,7 +77,7 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR {
HFONT hBoldFont;
LOGFONT lf;
- if(GetObject((HFONT)SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_GETFONT,0,0),sizeof(lf),&lf)) {
+ if (GetObject((HFONT)SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_GETFONT,0,0),sizeof(lf),&lf)) {
lf.lfWeight=FW_BOLD;
hBoldFont=CreateFontIndirect(&lf);
} else hBoldFont=NULL;
@@ -87,17 +87,17 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR {
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);
- CheckDlgButton(hwndDlg,IDC_CHECK_FILETRANSFER,(watcherType&SDWTF_FILETRANSFER)!=0);
- CheckDlgButton(hwndDlg,IDC_CHECK_IDLE,(watcherType&SDWTF_IDLE)!=0);
- CheckDlgButton(hwndDlg,IDC_CHECK_STATUS,(watcherType&SDWTF_STATUS)!=0);
- CheckDlgButton(hwndDlg,IDC_CHECK_CPUUSAGE,(watcherType&SDWTF_CPUUSAGE)!=0);
+ CheckDlgButton(hwndDlg,IDC_CHECK_SPECIFICTIME,(watcherType&SDWTF_SPECIFICTIME) != 0);
+ CheckDlgButton(hwndDlg,IDC_CHECK_MESSAGE,(watcherType&SDWTF_MESSAGE) != 0);
+ CheckDlgButton(hwndDlg,IDC_CHECK_FILETRANSFER,(watcherType&SDWTF_FILETRANSFER) != 0);
+ CheckDlgButton(hwndDlg,IDC_CHECK_IDLE,(watcherType&SDWTF_IDLE) != 0);
+ CheckDlgButton(hwndDlg,IDC_CHECK_STATUS,(watcherType&SDWTF_STATUS) != 0);
+ CheckDlgButton(hwndDlg,IDC_CHECK_CPUUSAGE,(watcherType&SDWTF_CPUUSAGE) != 0);
}
/* read-in countdown val */
{
SYSTEMTIME st;
- if(!TimeStampToSystemTime((time_t)db_get_dw(NULL,"AutoShutdown","TimeStamp",SETTING_TIMESTAMP_DEFAULT),&st))
+ if (!TimeStampToSystemTime((time_t)db_get_dw(NULL,"AutoShutdown","TimeStamp",SETTING_TIMESTAMP_DEFAULT),&st))
GetLocalTime(&st);
DateTime_SetSystemtime(GetDlgItem(hwndDlg,IDC_TIME_TIMESTAMP),GDT_VALID,&st);
DateTime_SetSystemtime(GetDlgItem(hwndDlg,IDC_DATE_TIMESTAMP),GDT_VALID,&st);
@@ -105,7 +105,7 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR }
{
DWORD setting=db_get_dw(NULL,"AutoShutdown","Countdown",SETTING_COUNTDOWN_DEFAULT);
- if(setting<1) setting=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);
SendDlgItemMessage(hwndDlg,IDC_SPIN_COUNTDOWN,UDM_SETPOS,0,MAKELPARAM(setting,0));
@@ -118,19 +118,19 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR SendMessage(hwndCombo,CB_INITSTORAGE,SIZEOF(unitNames),SIZEOF(unitNames)*16); /* approx. */
for(int i=0;i<SIZEOF(unitNames);++i) {
int index=SendMessage(hwndCombo,CB_ADDSTRING,0,(LPARAM)TranslateTS(unitNames[i]));
- if(index!=LB_ERR) {
+ if (index != LB_ERR) {
SendMessage(hwndCombo,CB_SETITEMDATA,index,(LPARAM)unitValues[i]);
- if(i==0 || unitValues[i]==lastUnit) SendMessage(hwndCombo,CB_SETCURSEL,index,0);
+ if (i==0 || unitValues[i]==lastUnit) SendMessage(hwndCombo,CB_SETCURSEL,index,0);
}
}
}
{
DBVARIANT dbv;
- if(!db_get_ts(NULL,"AutoShutdown","Message",&dbv)) {
+ if (!db_get_ts(NULL,"AutoShutdown","Message",&dbv)) {
SetDlgItemText(hwndDlg,IDC_EDIT_MESSAGE,dbv.ptszVal);
mir_free(dbv.ptszVal);
}
- if(ServiceExists(MS_AUTOREPLACER_ADDWINHANDLE))
+ if (ServiceExists(MS_AUTOREPLACER_ADDWINHANDLE))
CallService(MS_AUTOREPLACER_ADDWINHANDLE,0,(LPARAM)GetDlgItem(hwndDlg,IDC_EDIT_MESSAGE));
}
/* cpuusage threshold */
@@ -149,29 +149,29 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR SendMessage(hwndCombo,CB_SETEXTENDEDUI,TRUE,0);
SendMessage(hwndCombo,CB_INITSTORAGE,SDSDT_MAX,SDSDT_MAX*32);
for(BYTE shutdownType=1;shutdownType<=SDSDT_MAX;++shutdownType)
- if(ServiceIsTypeEnabled(shutdownType,0)) {
+ if (ServiceIsTypeEnabled(shutdownType,0)) {
TCHAR *pszText=(TCHAR*)ServiceGetTypeDescription(shutdownType,GSTDF_TCHAR); /* never fails */
int index=SendMessage(hwndCombo,CB_ADDSTRING,0,(LPARAM)pszText);
- if(index!=LB_ERR) {
+ if (index != LB_ERR) {
SendMessage(hwndCombo,CB_SETITEMDATA,index,(LPARAM)shutdownType);
- if(shutdownType==1 || shutdownType==lastShutdownType) SendMessage(hwndCombo,CB_SETCURSEL,(WPARAM)index,0);
+ if (shutdownType==1 || shutdownType==lastShutdownType) SendMessage(hwndCombo,CB_SETCURSEL,(WPARAM)index,0);
}
}
SendMessage(hwndDlg,M_UPDATE_SHUTDOWNDESC,0,(LPARAM)hwndCombo);
}
/* check if proto is installed that supports instant messages and check if a message dialog plugin is installed */
- if(!AnyProtoHasCaps(PF1_IMRECV) || !ServiceExists(MS_MSG_SENDMESSAGE)) { /* no srmessage present? */
+ if (!AnyProtoHasCaps(PF1_IMRECV) || !ServiceExists(MS_MSG_SENDMESSAGE)) { /* no srmessage present? */
CheckDlgButton(hwndDlg,IDC_CHECK_MESSAGE,FALSE);
EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_MESSAGE),FALSE);
EnableWindow(GetDlgItem(hwndDlg,IDC_EDIT_MESSAGE),FALSE);
}
/* check if proto is installed that supports file transfers and check if a file transfer dialog is available */
- if((!AnyProtoHasCaps(PF1_FILESEND) && !AnyProtoHasCaps(PF1_FILERECV)) || !ServiceExists(MS_FILE_SENDFILE)) { /* no srfile present? */
+ if ((!AnyProtoHasCaps(PF1_FILESEND) && !AnyProtoHasCaps(PF1_FILERECV)) || !ServiceExists(MS_FILE_SENDFILE)) { /* no srfile present? */
CheckDlgButton(hwndDlg,IDC_CHECK_FILETRANSFER,FALSE);
EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_FILETRANSFER),FALSE);
}
/* check if cpu usage can be detected */
- if(!PollCpuUsage(DisplayCpuUsageProc,(LPARAM)GetDlgItem(hwndDlg,IDC_TEXT_CURRENTCPU),1800)) {
+ if (!PollCpuUsage(DisplayCpuUsageProc,(LPARAM)GetDlgItem(hwndDlg,IDC_TEXT_CURRENTCPU),1800)) {
CheckDlgButton(hwndDlg,IDC_CHECK_CPUUSAGE,FALSE);
EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_CPUUSAGE),FALSE);
}
@@ -181,13 +181,13 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR }
case WM_DESTROY:
{
- if(ServiceExists(MS_AUTOREPLACER_ADDWINHANDLE))
+ if (ServiceExists(MS_AUTOREPLACER_ADDWINHANDLE))
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);
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);
+ if (hFont != NULL) DeleteObject(hFont);
hwndSettingsDlg=NULL;
}
return TRUE;
@@ -209,9 +209,9 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR case M_ENABLE_SUBCTLS:
{
- BOOL checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_MESSAGE)!=0;
+ BOOL checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_MESSAGE) != 0;
EnableDlgItem(hwndDlg,IDC_EDIT_MESSAGE,checked);
- checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_SPECIFICTIME)!=0;
+ checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_SPECIFICTIME) != 0;
EnableDlgItem(hwndDlg,IDC_RADIO_STTIME,checked);
EnableDlgItem(hwndDlg,IDC_RADIO_STCOUNTDOWN,checked);
checked=(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SPECIFICTIME) && IsDlgButtonChecked(hwndDlg,IDC_RADIO_STTIME));
@@ -221,9 +221,9 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR EnableDlgItem(hwndDlg,IDC_EDIT_COUNTDOWN,checked);
EnableDlgItem(hwndDlg,IDC_SPIN_COUNTDOWN,checked);
EnableDlgItem(hwndDlg,IDC_COMBO_COUNTDOWNUNIT,checked);
- checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_IDLE)!=0;
+ checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_IDLE) != 0;
EnableDlgItem(hwndDlg,IDC_URL_IDLE,checked);
- checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_CPUUSAGE)!=0;
+ checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_CPUUSAGE) != 0;
EnableDlgItem(hwndDlg,IDC_EDIT_CPUUSAGE,checked);
EnableDlgItem(hwndDlg,IDC_SPIN_CPUUSAGE,checked);
EnableDlgItem(hwndDlg,IDC_TEXT_PERCENT,checked);
@@ -256,16 +256,16 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR st.wMonth=stBuf.wMonth;
st.wYear=stBuf.wYear;
GetLocalTime(&stBuf);
- if(SystemTimeToTimeStamp(&st,×tamp)) {
+ if (SystemTimeToTimeStamp(&st,×tamp)) {
/* set to current date if earlier */
- if(timestamp<time(NULL)) {
+ if (timestamp<time(NULL)) {
st.wDay=stBuf.wDay;
st.wDayOfWeek=stBuf.wDayOfWeek;
st.wMonth=stBuf.wMonth;
st.wYear=stBuf.wYear;
- if(SystemTimeToTimeStamp(&st,×tamp)) {
+ if (SystemTimeToTimeStamp(&st,×tamp)) {
/* step one day up if still earlier */
- if(timestamp<time(NULL)) {
+ if (timestamp<time(NULL)) {
timestamp+=24*60*60;
TimeStampToSystemTime(timestamp,&st);
}
@@ -305,8 +305,8 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR return TRUE;
case IDC_EDIT_COUNTDOWN:
- if(HIWORD(wParam)==EN_KILLFOCUS) {
- if((int)GetDlgItemInt(hwndDlg,IDC_EDIT_COUNTDOWN,NULL,TRUE)<1) {
+ if (HIWORD(wParam)==EN_KILLFOCUS) {
+ if ((int)GetDlgItemInt(hwndDlg,IDC_EDIT_COUNTDOWN,NULL,TRUE)<1) {
SendDlgItemMessage(hwndDlg,IDC_SPIN_COUNTDOWN,UDM_SETPOS,0,MAKELPARAM(1,0));
SetDlgItemInt(hwndDlg,IDC_EDIT_COUNTDOWN,1,FALSE);
}
@@ -315,10 +315,10 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR break;
case IDC_EDIT_CPUUSAGE:
- if(HIWORD(wParam)==EN_KILLFOCUS) {
+ if (HIWORD(wParam)==EN_KILLFOCUS) {
WORD val=(WORD)GetDlgItemInt(hwndDlg,IDC_EDIT_CPUUSAGE,NULL,FALSE);
- if(val<1) val=1;
- else if(val>100) val=100;
+ if (val<1) val=1;
+ else if (val>100) val=100;
SendDlgItemMessage(hwndDlg,IDC_SPIN_CPUUSAGE,UDM_SETPOS,0,MAKELPARAM(val,0));
SetDlgItemInt(hwndDlg,IDC_EDIT_CPUUSAGE,val,FALSE);
return TRUE;
@@ -337,7 +337,7 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR }
case IDC_COMBO_SHUTDOWNTYPE:
- if(HIWORD(wParam)==CBN_SELCHANGE)
+ if (HIWORD(wParam)==CBN_SELCHANGE)
SendMessage(hwndDlg,M_UPDATE_SHUTDOWNDESC,0,lParam);
return TRUE;
@@ -348,7 +348,7 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR HWND hwndEdit=GetDlgItem(hwndDlg,IDC_EDIT_MESSAGE);
int len=GetWindowTextLength(hwndEdit)+1;
TCHAR *pszText=(TCHAR*)mir_alloc(len*sizeof(TCHAR));
- if(pszText!=NULL && GetWindowText(hwndEdit,pszText,len+1)) {
+ if (pszText != NULL && GetWindowText(hwndEdit,pszText,len+1)) {
TrimString(pszText);
db_set_ts(NULL,"AutoShutdown","Message",pszText);
}
@@ -359,28 +359,28 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR SYSTEMTIME st;
time_t timestamp;
DateTime_GetSystemtime(GetDlgItem(hwndDlg,IDC_TIME_TIMESTAMP),&st); /* time gets synchronized */
- if(!SystemTimeToTimeStamp(&st,×tamp))
+ if (!SystemTimeToTimeStamp(&st,×tamp))
timestamp=time(NULL);
db_set_dw(NULL,"AutoShutdown","TimeStamp",(DWORD)timestamp);
}
/* shutdown type */
{
int index = SendDlgItemMessage(hwndDlg,IDC_COMBO_SHUTDOWNTYPE,CB_GETCURSEL,0,0);
- if(index!=LB_ERR) db_set_b(NULL,"AutoShutdown","ShutdownType",(BYTE)SendDlgItemMessage(hwndDlg,IDC_COMBO_SHUTDOWNTYPE,CB_GETITEMDATA,(WPARAM)index,0));
+ if (index != LB_ERR) db_set_b(NULL,"AutoShutdown","ShutdownType",(BYTE)SendDlgItemMessage(hwndDlg,IDC_COMBO_SHUTDOWNTYPE,CB_GETITEMDATA,(WPARAM)index,0));
index=SendDlgItemMessage(hwndDlg,IDC_COMBO_COUNTDOWNUNIT,CB_GETCURSEL,0,0);
- if(index!=LB_ERR) db_set_dw(NULL,"AutoShutdown","CountdownUnit",(DWORD)SendDlgItemMessage(hwndDlg,IDC_COMBO_COUNTDOWNUNIT,CB_GETITEMDATA,(WPARAM)index,0));
+ if (index != LB_ERR) db_set_dw(NULL,"AutoShutdown","CountdownUnit",(DWORD)SendDlgItemMessage(hwndDlg,IDC_COMBO_COUNTDOWNUNIT,CB_GETITEMDATA,(WPARAM)index,0));
db_set_dw(NULL,"AutoShutdown","Countdown",(DWORD)GetDlgItemInt(hwndDlg,IDC_EDIT_COUNTDOWN,NULL,FALSE));
db_set_b(NULL,"AutoShutdown","CpuUsageThreshold",(BYTE)GetDlgItemInt(hwndDlg,IDC_EDIT_CPUUSAGE,NULL,FALSE));
}
/* watcher type */
{
WORD watcherType = (WORD)(IsDlgButtonChecked(hwndDlg,IDC_RADIO_STTIME)?SDWTF_ST_TIME:SDWTF_ST_COUNTDOWN);
- if(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SPECIFICTIME)) watcherType|=SDWTF_SPECIFICTIME;
- if(IsDlgButtonChecked(hwndDlg,IDC_CHECK_MESSAGE)) watcherType|=SDWTF_MESSAGE;
- if(IsDlgButtonChecked(hwndDlg,IDC_CHECK_FILETRANSFER)) watcherType|=SDWTF_FILETRANSFER;
- if(IsDlgButtonChecked(hwndDlg,IDC_CHECK_IDLE)) watcherType|=SDWTF_IDLE;
- if(IsDlgButtonChecked(hwndDlg,IDC_CHECK_STATUS)) watcherType|=SDWTF_STATUS;
- if(IsDlgButtonChecked(hwndDlg,IDC_CHECK_CPUUSAGE)) watcherType|=SDWTF_CPUUSAGE;
+ if (IsDlgButtonChecked(hwndDlg,IDC_CHECK_SPECIFICTIME)) watcherType|=SDWTF_SPECIFICTIME;
+ if (IsDlgButtonChecked(hwndDlg,IDC_CHECK_MESSAGE)) watcherType|=SDWTF_MESSAGE;
+ if (IsDlgButtonChecked(hwndDlg,IDC_CHECK_FILETRANSFER)) watcherType|=SDWTF_FILETRANSFER;
+ if (IsDlgButtonChecked(hwndDlg,IDC_CHECK_IDLE)) watcherType|=SDWTF_IDLE;
+ if (IsDlgButtonChecked(hwndDlg,IDC_CHECK_STATUS)) watcherType|=SDWTF_STATUS;
+ if (IsDlgButtonChecked(hwndDlg,IDC_CHECK_CPUUSAGE)) watcherType|=SDWTF_CPUUSAGE;
db_set_w(NULL,"AutoShutdown","WatcherFlags",watcherType);
ServiceStartWatcher(0,watcherType);
}
@@ -403,7 +403,7 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR static INT_PTR ServiceShowSettingsDialog(WPARAM wParam,LPARAM lParam)
{
- if(hwndSettingsDlg!=NULL) { /* already opened, bring to front */
+ if (hwndSettingsDlg != NULL) { /* already opened, bring to front */
SetForegroundWindow(hwndSettingsDlg);
return 0;
}
@@ -430,7 +430,7 @@ int ToolbarLoaded(WPARAM,LPARAM) void SetShutdownToolbarButton(bool fActive)
{
- if(hToolbarButton)
+ if (hToolbarButton)
CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hToolbarButton,fActive?TTBST_PUSHED:TTBST_RELEASED);
}
@@ -443,7 +443,7 @@ void SetShutdownMenuItem(bool fActive) /* main menu */
CLISTMENUITEM mi = { sizeof(mi) };
mi.position = 2001090000;
- if(fActive)
+ if (fActive)
{
mi.icolibItem = iconList[1].hIcolib;
mi.ptszName = LPGENT("Stop automatic &shutdown");
@@ -463,7 +463,7 @@ void SetShutdownMenuItem(bool fActive) /* tray menu */
mi.position = 899999;
- if(hTrayMenuItem != NULL) {
+ if (hTrayMenuItem != NULL) {
mi.flags |= CMIM_NAME | CMIM_ICON;
Menu_ModifyItem(hTrayMenuItem, &mi);
}
@@ -473,7 +473,7 @@ void SetShutdownMenuItem(bool fActive) static INT_PTR MenuItemCommand(WPARAM,LPARAM)
{
/* toggle between StopWatcher and ShowSettingsDdialog */
- if(ServiceIsWatcherEnabled(0,0))
+ if (ServiceIsWatcherEnabled(0,0))
ServiceStopWatcher(0,0);
else
ServiceShowSettingsDialog(0,0);
diff --git a/plugins/AutoShutdown/src/shutdownsvc.cpp b/plugins/AutoShutdown/src/shutdownsvc.cpp index c3f0a740ee..fb351ebef5 100644 --- a/plugins/AutoShutdown/src/shutdownsvc.cpp +++ b/plugins/AutoShutdown/src/shutdownsvc.cpp @@ -24,22 +24,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /* Shutdown Dialog */
static HWND hwndShutdownDlg;
extern HINSTANCE hInst;
-/* Services */
+
+/* Events */
static HANDLE hEventOkToShutdown,hEventShutdown;
-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).")};
-
+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)
{
@@ -47,10 +48,10 @@ static BOOL WinNT_SetPrivilege(TCHAR *pszPrivName,BOOL bEnable) HANDLE hToken;
TOKEN_PRIVILEGES tkp;
/* get a token for this process */
- if(OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&hToken)) {
+ if (OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&hToken)) {
tkp.PrivilegeCount=1; /* one privilege is to set */
/* get the LUID for the shutdown privilege */
- if(LookupPrivilegeValue(NULL,pszPrivName,&tkp.Privileges[0].Luid)) {
+ if (LookupPrivilegeValue(NULL,pszPrivName,&tkp.Privileges[0].Luid)) {
tkp.Privileges[0].Attributes=bEnable?SE_PRIVILEGE_ENABLED:0;
/* get the shutdown privilege for this process */
bReturn=AdjustTokenPrivileges(hToken,FALSE,&tkp,0,(PTOKEN_PRIVILEGES)NULL,0);
@@ -65,19 +66,6 @@ static void BroadcastEndSession(DWORD dwRecipients,LPARAM lParam) BroadcastSystemMessage(BSF_FORCEIFHUNG,&dwRecipients,WM_ENDSESSION,TRUE,lParam);
}
-static BOOL WinNT_IsWorkStationLocked(void)
-{
- HDESK hDesk;
- TCHAR szName[8];
- DWORD cbName;
- BOOL bLocked;
- hDesk=OpenInputDesktop(0,FALSE,DESKTOP_READOBJECTS);
- if(hDesk==NULL) return TRUE;
- bLocked=(!GetUserObjectInformation(hDesk,UOI_NAME,szName,SIZEOF(szName),&cbName) || lstrcmpi(szName,_T("default"))!=0);
- CloseDesktop(hDesk);
- return bLocked;
-}
-
/************************* Workers ************************************/
static BOOL IsShutdownTypeEnabled(BYTE shutdownType)
{
@@ -86,17 +74,17 @@ static BOOL IsShutdownTypeEnabled(BYTE shutdownType) case SDSDT_HIBERNATE:
case SDSDT_STANDBY:
{ HMODULE hPowerDLL=LoadLibraryA("POWRPROF"); /* all ascii */
- if(hPowerDLL!=NULL) {
+ if (hPowerDLL != NULL) {
BOOLEAN (STDAPICALLTYPE *pfnIsPwrModeAllowed)(void);
*(PROC*)&pfnIsPwrModeAllowed=GetProcAddress(hPowerDLL,(shutdownType==SDSDT_HIBERNATE)?"IsPwrHibernateAllowed":"IsPwrSuspendAllowed");
- if(pfnIsPwrModeAllowed) bReturn=pfnIsPwrModeAllowed()!=0;
+ if (pfnIsPwrModeAllowed) bReturn=pfnIsPwrModeAllowed() != 0;
FreeLibrary(hPowerDLL);
}
}
/* test privilege */
- if(bReturn) {
+ if (bReturn) {
bReturn=WinNT_SetPrivilege(SE_SHUTDOWN_NAME,TRUE);
- if(bReturn) WinNT_SetPrivilege(SE_SHUTDOWN_NAME,FALSE);
+ if (bReturn) WinNT_SetPrivilege(SE_SHUTDOWN_NAME,FALSE);
}
break;
case SDSDT_LOGOFF:
@@ -104,10 +92,10 @@ static BOOL IsShutdownTypeEnabled(BYTE shutdownType) DWORD dwSetting,dwSize;
/* NoLogOff is BINARY on Win9x/ME and DWORD on Win2000+ */
bReturn=TRUE;
- if(RegOpenKeyEx(HKEY_CURRENT_USER,_T("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer"),0,KEY_QUERY_VALUE,&hKey)==ERROR_SUCCESS) {
+ if (RegOpenKeyEx(HKEY_CURRENT_USER,_T("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer"),0,KEY_QUERY_VALUE,&hKey)==ERROR_SUCCESS) {
dwSize=sizeof(dwSetting);
- if(RegQueryValueEx(hKey, _T("NoLogOff"), 0, NULL, (LPBYTE)&dwSetting, &dwSize) == ERROR_SUCCESS)
- if(dwSetting) bReturn=FALSE;
+ if (RegQueryValueEx(hKey, _T("NoLogOff"), 0, NULL, (LPBYTE)&dwSetting, &dwSize) == ERROR_SUCCESS)
+ if (dwSetting) bReturn=FALSE;
RegCloseKey(hKey);
}
}
@@ -118,10 +106,10 @@ static BOOL IsShutdownTypeEnabled(BYTE shutdownType) DWORD dwSize,dwSetting;
/* DisableLockWorkstation is DWORD on Win2000+ */
bReturn=TRUE;
- if(RegOpenKeyEx(HKEY_CURRENT_USER,_T("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"),0,KEY_QUERY_VALUE,&hKey)==ERROR_SUCCESS) {
+ if (RegOpenKeyEx(HKEY_CURRENT_USER,_T("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"),0,KEY_QUERY_VALUE,&hKey)==ERROR_SUCCESS) {
dwSize=sizeof(dwSetting);
- if(!RegQueryValueEx(hKey, _T("DisableLockWorkstation"), 0, NULL, (LPBYTE)&dwSetting, &dwSize))
- if(dwSetting)
+ if (!RegQueryValueEx(hKey, _T("DisableLockWorkstation"), 0, NULL, (LPBYTE)&dwSetting, &dwSize))
+ if (dwSetting)
bReturn=FALSE;
RegCloseKey(hKey);
}
@@ -129,7 +117,7 @@ static BOOL IsShutdownTypeEnabled(BYTE shutdownType) break;
case SDSDT_CLOSERASCONNECTIONS:
/* check if RAS installed/available */
- bReturn=SearchPath(NULL,_T("RASAPI32"),_T(".DLL"),0,NULL,NULL)!=0;
+ bReturn=SearchPath(NULL,_T("RASAPI32"),_T(".DLL"),0,NULL,NULL) != 0;
break;
case SDSDT_SETMIRANDAOFFLINE:
case SDSDT_CLOSEMIRANDA:
@@ -139,7 +127,7 @@ static BOOL IsShutdownTypeEnabled(BYTE shutdownType) case SDSDT_SHUTDOWN:
/* test privileges */
bReturn=WinNT_SetPrivilege(SE_SHUTDOWN_NAME,TRUE);
- if(bReturn)
+ if (bReturn)
WinNT_SetPrivilege(SE_SHUTDOWN_NAME,FALSE);
break;
}
@@ -148,165 +136,179 @@ static BOOL IsShutdownTypeEnabled(BYTE shutdownType) static DWORD ShutdownNow(BYTE shutdownType)
{
- DWORD dwErrCode=ERROR_SUCCESS;
+ DWORD dwErrCode = ERROR_SUCCESS;
switch(shutdownType) {
- case SDSDT_CLOSEMIRANDA:
- if(!Miranda_Terminated()) {
- /* waiting for short until ready (but not too long...) */
- DWORD dwLastTickCount=GetTickCount();
- while(!CallService(MS_SYSTEM_OKTOEXIT,0,0)) {
- /* infinite loop protection (max 5 sec) */
- if(GetTickCount()-dwLastTickCount>=5000) { /* wraparound works */
- OutputDebugStringA("Timeout (5 sec)\n"); /* tell others, all ascii */
- break;
- }
- SleepEx(1000,TRUE);
- if(Miranda_Terminated()) break; /* someone else did it */
- OutputDebugStringA("Not ready to exit. Waiting...\n"); /* tell others, all ascii */
+ case SDSDT_CLOSEMIRANDA:
+ if (!Miranda_Terminated()) {
+ /* waiting for short until ready (but not too long...) */
+ DWORD dwLastTickCount=GetTickCount();
+ while(!CallService(MS_SYSTEM_OKTOEXIT,0,0)) {
+ /* infinite loop protection (max 5 sec) */
+ if (GetTickCount()-dwLastTickCount>=5000) { /* wraparound works */
+ OutputDebugStringA("Timeout (5 sec)\n"); /* tell others, all ascii */
+ break;
}
- /* shutdown service must be called from main thread anyway */
- if(!DestroyWindow((HWND)CallService(MS_CLUI_GETHWND,0,0)))
- dwErrCode=GetLastError();
+ SleepEx(1000,TRUE);
+ if (Miranda_Terminated()) break; /* someone else did it */
+ OutputDebugStringA("Not ready to exit. Waiting...\n"); /* tell others, all ascii */
}
- break;
- case SDSDT_SETMIRANDAOFFLINE:
- /* set global status mode to offline (is remembered by Miranda on exit) */
- CallService(MS_CLIST_SETSTATUSMODE,(WPARAM)ID_STATUS_OFFLINE,0);
- break;
- case SDSDT_STANDBY:
- case SDSDT_HIBERNATE:
- WinNT_SetPrivilege(SE_SHUTDOWN_NAME,TRUE);
- if(!SetSystemPowerState(shutdownType==SDSDT_STANDBY,TRUE))
+ /* shutdown service must be called from main thread anyway */
+ if (!DestroyWindow((HWND)CallService(MS_CLUI_GETHWND,0,0)))
dwErrCode=GetLastError();
- WinNT_SetPrivilege(SE_SHUTDOWN_NAME,FALSE);
- break;
- case SDSDT_LOCKWORKSTATION:
- {
- if(!WinNT_IsWorkStationLocked())
- dwErrCode=GetLastError();
- }
- break;
- case SDSDT_CLOSERASCONNECTIONS:
- ShutdownNow(SDSDT_SETMIRANDAOFFLINE); /* set Miranda offline */
- /* hang up all ras connections */
- { HMODULE hRasApiDLL=LoadLibrary(_T("RASAPI32")); /* all ascii */
- if(hRasApiDLL!=NULL) {
- DWORD (APIENTRY *pfnRasEnumConnections)(RASCONN*,DWORD*,DWORD*);
- DWORD (APIENTRY *pfnRasHangUp)(HRASCONN);
- DWORD (APIENTRY *pfnRasGetConnectStatus)(HRASCONN,RASCONNSTATUS*);
- *(PROC*)&pfnRasEnumConnections=GetProcAddress(hRasApiDLL,"RasEnumConnectionsW");
- *(PROC*)&pfnRasHangUp=GetProcAddress(hRasApiDLL,"RasHangUpW");
- *(PROC*)&pfnRasGetConnectStatus=GetProcAddress(hRasApiDLL,"RasGetConnectStatusW");
- if(pfnRasEnumConnections && pfnRasGetConnectStatus && pfnRasHangUp) {
- RASCONN *paConn;
- RASCONN *paConnBuf;
- DWORD dwConnSize,dwConnItems,dwRetries;
- RASCONNSTATUS rcs;
- DWORD dw,dwLastTickCount;
-
- dwConnSize=sizeof(RASCONN);
- dwConnItems=0;
- paConn=(RASCONN*)mir_alloc(dwConnSize);
- dwErrCode=ERROR_NOT_ENOUGH_MEMORY;
- if(paConn!=NULL)
- for(dwRetries=5;dwRetries!=0;dwRetries--) { /* prevent infinite loop (rare) */
- ZeroMemory(paConn,dwConnSize);
- paConn[0].dwSize=sizeof(RASCONN);
- dwErrCode=pfnRasEnumConnections(paConn,&dwConnSize,&dwConnItems);
- if(dwErrCode!=ERROR_BUFFER_TOO_SMALL) break;
- paConnBuf=(RASCONN*)mir_realloc(paConn,dwConnSize);
- if(paConnBuf!=NULL) {
- mir_free(paConn);
- paConn=NULL;
- dwErrCode=ERROR_NOT_ENOUGH_MEMORY;
- break;
- }
- paConn=paConnBuf;
+ }
+ break;
+
+ case SDSDT_SETMIRANDAOFFLINE:
+ /* set global status mode to offline (is remembered by Miranda on exit) */
+ CallService(MS_CLIST_SETSTATUSMODE,(WPARAM)ID_STATUS_OFFLINE,0);
+ break;
+
+ case SDSDT_STANDBY:
+ case SDSDT_HIBERNATE:
+ WinNT_SetPrivilege(SE_SHUTDOWN_NAME,TRUE);
+ if (!SetSystemPowerState(shutdownType == SDSDT_STANDBY, TRUE))
+ dwErrCode = GetLastError();
+ WinNT_SetPrivilege(SE_SHUTDOWN_NAME,FALSE);
+ break;
+
+ case SDSDT_LOCKWORKSTATION:
+ if ( !IsWorkstationLocked())
+ dwErrCode = GetLastError();
+ break;
+
+ case SDSDT_CLOSERASCONNECTIONS:
+ ShutdownNow(SDSDT_SETMIRANDAOFFLINE); /* set Miranda offline */
+ /* hang up all ras connections */
+ {
+ HMODULE hRasApiDLL=LoadLibrary(_T("RASAPI32")); /* all ascii */
+ if (hRasApiDLL != NULL) {
+ DWORD (APIENTRY *pfnRasEnumConnections)(RASCONN*,DWORD*,DWORD*);
+ DWORD (APIENTRY *pfnRasHangUp)(HRASCONN);
+ DWORD (APIENTRY *pfnRasGetConnectStatus)(HRASCONN,RASCONNSTATUS*);
+ *(PROC*)&pfnRasEnumConnections=GetProcAddress(hRasApiDLL,"RasEnumConnectionsW");
+ *(PROC*)&pfnRasHangUp=GetProcAddress(hRasApiDLL,"RasHangUpW");
+ *(PROC*)&pfnRasGetConnectStatus=GetProcAddress(hRasApiDLL,"RasGetConnectStatusW");
+ if (pfnRasEnumConnections && pfnRasGetConnectStatus && pfnRasHangUp) {
+ RASCONN *paConn;
+ RASCONN *paConnBuf;
+ DWORD dwConnSize,dwConnItems,dwRetries;
+ RASCONNSTATUS rcs;
+ DWORD dw,dwLastTickCount;
+
+ dwConnSize=sizeof(RASCONN);
+ dwConnItems=0;
+ paConn=(RASCONN*)mir_alloc(dwConnSize);
+ dwErrCode=ERROR_NOT_ENOUGH_MEMORY;
+ if (paConn != NULL) {
+ for(dwRetries=5; dwRetries != 0; dwRetries--) { /* prevent infinite loop (rare) */
+ ZeroMemory(paConn, dwConnSize);
+ paConn[0].dwSize = sizeof(RASCONN);
+ dwErrCode = pfnRasEnumConnections(paConn,&dwConnSize,&dwConnItems);
+ if (dwErrCode != ERROR_BUFFER_TOO_SMALL) break;
+ paConnBuf=(RASCONN*)mir_realloc(paConn,dwConnSize);
+ if (paConnBuf != NULL) {
+ mir_free(paConn);
+ paConn = NULL;
+ dwErrCode = ERROR_NOT_ENOUGH_MEMORY;
+ break;
}
- if(dwErrCode==ERROR_SUCCESS || dwErrCode==ERROR_BUFFER_TOO_SMALL) {
+ paConn=paConnBuf;
+ }
+ if (dwErrCode==ERROR_SUCCESS || dwErrCode==ERROR_BUFFER_TOO_SMALL) {
for(dw=0;dw<dwConnItems;++dw) {
- if(dwErrCode) {
- if(pfnRasHangUp(paConn[dw].hrasconn))
+ if (dwErrCode) {
+ if (pfnRasHangUp(paConn[dw].hrasconn))
paConn[dw].hrasconn=NULL; /* do not wait for on error */
- } else {
+ }
+ else {
dwErrCode=pfnRasHangUp(paConn[dw].hrasconn);
- if(!dwErrCode) paConn[dw].hrasconn=NULL; /* do not wait for on error */
+ if (!dwErrCode) paConn[dw].hrasconn=NULL; /* do not wait for on error */
}
}
/* RAS does not allow to quit directly after HangUp (see docs) */
- dwLastTickCount=GetTickCount();
+ dwLastTickCount = GetTickCount();
ZeroMemory(&rcs,sizeof(RASCONNSTATUS));
- rcs.dwSize=sizeof(RASCONNSTATUS);
- for(dw=0;dw<dwConnItems;++dw)
- if(paConn[dw].hrasconn!=NULL)
- while(pfnRasGetConnectStatus(paConn[dw].hrasconn, &rcs)!=ERROR_INVALID_HANDLE) {
+ rcs.dwSize = sizeof(RASCONNSTATUS);
+ for(dw=0; dw < dwConnItems; ++dw) {
+ if (paConn[dw].hrasconn != NULL) {
+ while(pfnRasGetConnectStatus(paConn[dw].hrasconn, &rcs) != ERROR_INVALID_HANDLE) {
Sleep(0); /* give rest of time silce to other threads with equal priority */
/* infinite loop protection (3000ms defined in docs) */
- dwRetries=GetTickCount();
- if(dwRetries-dwLastTickCount>3000) break; /* wraparound works */
+ dwRetries = GetTickCount();
+ if (dwRetries - dwLastTickCount>3000)
+ break; /* wraparound works */
}
+ }
+ }
}
mir_free(paConn); /* does NULL check */
- } else dwErrCode=GetLastError();
- FreeLibrary(hRasApiDLL);
- } else dwErrCode=GetLastError();
+ }
+ }
+ else dwErrCode = GetLastError();
+ FreeLibrary(hRasApiDLL);
}
- /* set Miranda to offline again, to remain offline with reconnection plugins */
- ShutdownNow(SDSDT_SETMIRANDAOFFLINE);
+ else dwErrCode = GetLastError();
+ }
+ /* set Miranda to offline again, to remain offline with reconnection plugins */
+ ShutdownNow(SDSDT_SETMIRANDAOFFLINE);
+ break;
+
+ case SDSDT_REBOOT:
+ case SDSDT_SHUTDOWN:
+ if (GetSystemMetrics(SM_SHUTTINGDOWN)) { /* Win2000+, 0 on error */
+ dwErrCode=ERROR_SHUTDOWN_IN_PROGRESS;
break;
- case SDSDT_REBOOT:
- case SDSDT_SHUTDOWN:
- if(GetSystemMetrics(SM_SHUTTINGDOWN)) { /* Win2000+, 0 on error */
- dwErrCode=ERROR_SHUTDOWN_IN_PROGRESS;
- break;
- }
- /* WinNT4/2000/XP */
- {
- WinNT_SetPrivilege(SE_SHUTDOWN_NAME,TRUE);
+ }
+ /* WinNT4/2000/XP */
+ {
+ WinNT_SetPrivilege(SE_SHUTDOWN_NAME,TRUE);
- /* does not send out WM_ENDSESSION messages, so we do it manually to
- * give the applications the chance to save their data */
- WinNT_SetPrivilege(SE_TCB_NAME,TRUE); /* for BSM_ALLDESKTOPS */
- BroadcastEndSession(BSM_APPLICATIONS|BSM_ALLDESKTOPS,ENDSESSION_CLOSEAPP); /* app should close itself */
- WinNT_SetPrivilege(SE_TCB_NAME,FALSE);
+ /* does not send out WM_ENDSESSION messages, so we do it manually to
+ * give the applications the chance to save their data */
+ WinNT_SetPrivilege(SE_TCB_NAME,TRUE); /* for BSM_ALLDESKTOPS */
+ BroadcastEndSession(BSM_APPLICATIONS|BSM_ALLDESKTOPS,ENDSESSION_CLOSEAPP); /* app should close itself */
+ WinNT_SetPrivilege(SE_TCB_NAME,FALSE);
- if(!InitiateSystemShutdownEx(NULL,TranslateT("AutoShutdown"),0,TRUE,shutdownType==SDSDT_REBOOT,SHTDN_REASON_MAJOR_OTHER|SHTDN_REASON_MINOR_OTHER|SHTDN_REASON_FLAG_PLANNED))
- dwErrCode=GetLastError();
+ if (!InitiateSystemShutdownEx(NULL,TranslateT("AutoShutdown"),0,TRUE,shutdownType==SDSDT_REBOOT,SHTDN_REASON_MAJOR_OTHER|SHTDN_REASON_MINOR_OTHER|SHTDN_REASON_FLAG_PLANNED))
+ dwErrCode=GetLastError();
- /* cleanly close Miranda */
- if(!dwErrCode) ShutdownNow(SDSDT_CLOSEMIRANDA);
- break;
+ /* cleanly close Miranda */
+ if (!dwErrCode) ShutdownNow(SDSDT_CLOSEMIRANDA);
+ break;
+ }
+ /* fall through for Win9x */
+ case SDSDT_LOGOFF:
+ {
+ UINT flags;
+ switch(shutdownType) {
+ case SDSDT_LOGOFF: flags=EWX_LOGOFF; break;
+ case SDSDT_REBOOT: flags=EWX_REBOOT; break;
+ default: flags=EWX_SHUTDOWN|EWX_POWEROFF;
}
- /* fall through for Win9x */
- case SDSDT_LOGOFF:
- { UINT flags;
- switch(shutdownType) {
- case SDSDT_LOGOFF: flags=EWX_LOGOFF; break;
- case SDSDT_REBOOT: flags=EWX_REBOOT; break;
- default: flags=EWX_SHUTDOWN|EWX_POWEROFF;
- }
- if(shutdownType==SDSDT_LOGOFF && !WinNT_IsWorkStationLocked())
- flags|=EWX_FORCEIFHUNG; /* only considered for WM_ENDSESSION messages */
- else flags|=EWX_FORCE; /* must be used when workstation locked */
-
- if(flags&EWX_FORCE) {
- /* EWX_FORCE does not send out WM_ENDSESSION messages, so we do it
- * manually to give the applications the chance to save their data */
- BroadcastEndSession(BSM_APPLICATIONS,(shutdownType==SDSDT_LOGOFF)?ENDSESSION_LOGOFF:0);
-
- /* Windows Me/98/95 (msdn): Because of the design of the shell,
- * calling ExitWindowsEx with EWX_FORCE fails to completely log off
- * the user (the system terminates the applications and displays the
- * Enter Windows Password dialog box, however, the user's desktop remains.)
- * To log off the user forcibly, terminate the Explorer process before calling
- * ExitWindowsEx with EWX_LOGOFF and EWX_FORCE. */
- }
- if(!ExitWindowsEx(flags,SHTDN_REASON_MAJOR_OTHER|SHTDN_REASON_MINOR_OTHER|SHTDN_REASON_FLAG_PLANNED))
- dwErrCode=GetLastError();
- /* cleanly close Miranda */
- if(!dwErrCode) ShutdownNow(SDSDT_CLOSEMIRANDA);
+ if (shutdownType == SDSDT_LOGOFF && !IsWorkstationLocked())
+ flags |= EWX_FORCEIFHUNG; /* only considered for WM_ENDSESSION messages */
+ else
+ flags|= EWX_FORCE; /* must be used when workstation locked */
+
+ if (flags & EWX_FORCE) {
+ /* EWX_FORCE does not send out WM_ENDSESSION messages, so we do it
+ * manually to give the applications the chance to save their data */
+ BroadcastEndSession(BSM_APPLICATIONS,(shutdownType==SDSDT_LOGOFF)?ENDSESSION_LOGOFF:0);
+
+ /* Windows Me/98/95 (msdn): Because of the design of the shell,
+ * calling ExitWindowsEx with EWX_FORCE fails to completely log off
+ * the user (the system terminates the applications and displays the
+ * Enter Windows Password dialog box, however, the user's desktop remains.)
+ * To log off the user forcibly, terminate the Explorer process before calling
+ * ExitWindowsEx with EWX_LOGOFF and EWX_FORCE. */
}
- break;
+ if (!ExitWindowsEx(flags,SHTDN_REASON_MAJOR_OTHER|SHTDN_REASON_MINOR_OTHER|SHTDN_REASON_FLAG_PLANNED))
+ dwErrCode = GetLastError();
+ /* cleanly close Miranda */
+ if (!dwErrCode)
+ ShutdownNow(SDSDT_CLOSEMIRANDA);
+ }
+ break;
}
return dwErrCode;
}
@@ -321,40 +323,43 @@ static INT_PTR CALLBACK ShutdownDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR WORD countdown=(WORD)GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TEXT_HEADER), GWLP_USERDATA);
switch(msg) {
- case WM_INITDIALOG:
- hwndShutdownDlg=hwndDlg;
- SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG)lParam);
- TranslateDialogDefault(hwndDlg);
-
- if(lParam==SDSDT_SHUTDOWN || lParam==SDSDT_REBOOT || lParam==SDSDT_LOGOFF)
- ShowWindow(GetDlgItem(hwndDlg,IDC_TEXT_UNSAVEDWARNING),SW_SHOW);
- SendDlgItemMessage(hwndDlg,IDC_ICON_HEADER,STM_SETIMAGE,IMAGE_ICON,(LPARAM)Skin_GetIcon("AutoShutdown_Header"));
- { HFONT hBoldFont;
- LOGFONT lf;
- if(GetObject((HFONT)SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_GETFONT,0,0),sizeof(lf),&lf)) {
- lf.lfWeight=FW_BOLD;
- hBoldFont=CreateFontIndirect(&lf);
- }
- else hBoldFont=NULL;
- SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_SETFONT,(WPARAM)hBoldFont,FALSE);
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TEXT_HEADER), GWLP_USERDATA, (LONG)hBoldFont);
- }
- { WORD countdown=db_get_w(NULL,"AutoShutdown","ConfirmDlgCountdown",SETTING_CONFIRMDLGCOUNTDOWN_DEFAULT);
- if(countdown<3) countdown=SETTING_CONFIRMDLGCOUNTDOWN_DEFAULT;
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TEXT_HEADER), GWLP_USERDATA, countdown);
- SendMessage(hwndDlg,M_UPDATE_COUNTDOWN,0,countdown);
+ case WM_INITDIALOG:
+ hwndShutdownDlg=hwndDlg;
+ SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG)lParam);
+ TranslateDialogDefault(hwndDlg);
+
+ if (lParam==SDSDT_SHUTDOWN || lParam==SDSDT_REBOOT || lParam==SDSDT_LOGOFF)
+ ShowWindow(GetDlgItem(hwndDlg,IDC_TEXT_UNSAVEDWARNING),SW_SHOW);
+ SendDlgItemMessage(hwndDlg,IDC_ICON_HEADER,STM_SETIMAGE,IMAGE_ICON,(LPARAM)Skin_GetIcon("AutoShutdown_Header"));
+ {
+ HFONT hBoldFont;
+ LOGFONT lf;
+ if (GetObject((HFONT)SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_GETFONT,0,0),sizeof(lf),&lf)) {
+ lf.lfWeight=FW_BOLD;
+ hBoldFont=CreateFontIndirect(&lf);
}
- SkinPlaySound("AutoShutdown_Countdown");
- if(!SetTimer(hwndDlg,1,1000,NULL)) PostMessage(hwndDlg,M_START_SHUTDOWN,0,0);
- Utils_RestoreWindowPositionNoSize(hwndDlg,NULL,"AutoShutdown","ConfirmDlg_");
+ else hBoldFont=NULL;
+ SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_SETFONT,(WPARAM)hBoldFont,FALSE);
+ SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TEXT_HEADER), GWLP_USERDATA, (LONG)hBoldFont);
+ }
+ {
+ WORD countdown=db_get_w(NULL,"AutoShutdown","ConfirmDlgCountdown",SETTING_CONFIRMDLGCOUNTDOWN_DEFAULT);
+ if (countdown<3) countdown=SETTING_CONFIRMDLGCOUNTDOWN_DEFAULT;
+ SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TEXT_HEADER), GWLP_USERDATA, countdown);
+ SendMessage(hwndDlg,M_UPDATE_COUNTDOWN,0,countdown);
+ }
+ SkinPlaySound("AutoShutdown_Countdown");
+ if (!SetTimer(hwndDlg,1,1000,NULL)) PostMessage(hwndDlg,M_START_SHUTDOWN,0,0);
+ Utils_RestoreWindowPositionNoSize(hwndDlg,NULL,"AutoShutdown","ConfirmDlg_");
+
+ /* disallow foreground window changes (WinMe/2000+) */
+ SetForegroundWindow(hwndDlg);
+ LockSetForegroundWindow(LSFW_LOCK);
- /* disallow foreground window changes (WinMe/2000+) */
- SetForegroundWindow(hwndDlg);
- LockSetForegroundWindow(LSFW_LOCK);
+ SendMessage(hwndDlg,WM_NEXTDLGCTL,(WPARAM)GetDlgItem(hwndDlg,IDCANCEL),TRUE);
+ return FALSE; /* focus set on cancel */
- SendMessage(hwndDlg,WM_NEXTDLGCTL,(WPARAM)GetDlgItem(hwndDlg,IDCANCEL),TRUE);
- return FALSE; /* focus set on cancel */
- case WM_DESTROY:
+ case WM_DESTROY:
{
hwndShutdownDlg=NULL;
ShowWindow(hwndDlg,SW_HIDE);
@@ -364,61 +369,66 @@ static INT_PTR CALLBACK ShutdownDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR 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;
+ if (hFont != NULL) DeleteObject(hFont);
}
- case M_START_SHUTDOWN:
- if(IsWindowEnabled(GetDlgItem(hwndDlg,IDC_BUTTON_SHUTDOWNNOW))) {
- DWORD dwErrCode;
- EnableWindow(GetDlgItem(hwndDlg,IDC_BUTTON_SHUTDOWNNOW),FALSE);
- ShowWindow(hwndDlg,SW_HIDE); /* get rid of the dialog immediately */
- dwErrCode=ShutdownNow(shutdownType);
- if(dwErrCode!=ERROR_SUCCESS) {
- char *pszErr;
- pszErr=GetWinErrorDescription(dwErrCode);
- ShowInfoMessage(NIIF_ERROR,Translate("Automatic Shutdown Error"),Translate("The shutdown process failed!\nReason: %s"),(pszErr!=NULL)?pszErr:Translate("Unknown"));
- if(pszErr!=NULL) LocalFree(pszErr);
- }
- DestroyWindow(hwndDlg);
- }
- return TRUE;
- case WM_TIMER:
- if(countdown) {
- --countdown;
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TEXT_HEADER), GWLP_USERDATA, countdown);
- if(countdown==27 || countdown==24 || countdown==21 || countdown==19 ||
- countdown==17 || countdown==15 || countdown==13 || countdown==11 ||
- countdown<=10)
- SkinPlaySound("AutoShutdown_Countdown");
+ return TRUE;
+
+ case M_START_SHUTDOWN:
+ if (IsWindowEnabled(GetDlgItem(hwndDlg,IDC_BUTTON_SHUTDOWNNOW))) {
+ DWORD dwErrCode;
+ EnableWindow(GetDlgItem(hwndDlg,IDC_BUTTON_SHUTDOWNNOW),FALSE);
+ ShowWindow(hwndDlg,SW_HIDE); /* get rid of the dialog immediately */
+ dwErrCode=ShutdownNow(shutdownType);
+ if (dwErrCode != ERROR_SUCCESS) {
+ char *pszErr;
+ pszErr=GetWinErrorDescription(dwErrCode);
+ ShowInfoMessage(NIIF_ERROR,Translate("Automatic Shutdown Error"),Translate("The shutdown process failed!\nReason: %s"),(pszErr != NULL)?pszErr:Translate("Unknown"));
+ if (pszErr != NULL) LocalFree(pszErr);
}
- else KillTimer(hwndDlg,wParam); /* countdown finished */
- PostMessage(hwndDlg,M_UPDATE_COUNTDOWN,0,countdown);
- return TRUE;
- case M_UPDATE_COUNTDOWN: /* lParam=(WORD)countdown */
+ DestroyWindow(hwndDlg);
+ }
+ return TRUE;
+
+ case WM_TIMER:
+ if (countdown) {
+ --countdown;
+ SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TEXT_HEADER), GWLP_USERDATA, countdown);
+ if (countdown==27 || countdown==24 || countdown==21 || countdown==19 ||
+ countdown==17 || countdown==15 || countdown==13 || countdown==11 ||
+ countdown<=10)
+ SkinPlaySound("AutoShutdown_Countdown");
+ }
+ else KillTimer(hwndDlg,wParam); /* countdown finished */
+ PostMessage(hwndDlg,M_UPDATE_COUNTDOWN,0,countdown);
+ return TRUE;
+
+ case M_UPDATE_COUNTDOWN: /* lParam=(WORD)countdown */
{
TCHAR szText[256];
mir_sntprintf(szText,SIZEOF(szText),TranslateTS(desc[shutdownType-1]),lParam);
SetDlgItemText(hwndDlg,IDC_TEXT_HEADER,szText);
/* countdown finished */
- if(!lParam) PostMessage(hwndDlg,M_START_SHUTDOWN,0,0);
- return TRUE;
+ if (!lParam)
+ PostMessage(hwndDlg,M_START_SHUTDOWN,0,0);
}
- case WM_COMMAND:
- switch(LOWORD(wParam)) {
- case IDC_BUTTON_SHUTDOWNNOW:
- KillTimer(hwndDlg,1);
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TEXT_HEADER), GWLP_USERDATA, 0);
- SendMessage(hwndDlg,M_UPDATE_COUNTDOWN,0,(LONG)0);
- PostMessage(hwndDlg,M_START_SHUTDOWN,0,0);
- return TRUE;
- case IDCANCEL: /* WM_CLOSE */
- if(countdown) {
- KillTimer(hwndDlg,1);
- DestroyWindow(hwndDlg);
- }
- return TRUE;
+ return TRUE;
+
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDC_BUTTON_SHUTDOWNNOW:
+ KillTimer(hwndDlg,1);
+ SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TEXT_HEADER), GWLP_USERDATA, 0);
+ SendMessage(hwndDlg,M_UPDATE_COUNTDOWN,0,(LONG)0);
+ PostMessage(hwndDlg,M_START_SHUTDOWN,0,0);
+ return TRUE;
+ case IDCANCEL: /* WM_CLOSE */
+ if (countdown) {
+ KillTimer(hwndDlg,1);
+ DestroyWindow(hwndDlg);
}
- break;
+ return TRUE;
+ }
+ break;
}
return FALSE;
}
@@ -428,32 +438,32 @@ static INT_PTR CALLBACK ShutdownDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR INT_PTR ServiceShutdown(WPARAM wParam,LPARAM lParam)
{
/* passing 0 as wParam is only to be used internally, undocumented */
- if(!wParam) wParam=db_get_b(NULL,"AutoShutdown","ShutdownType",SETTING_SHUTDOWNTYPE_DEFAULT);
- if(!IsShutdownTypeEnabled((BYTE)wParam)) return 1; /* does shutdownType range check */
- if((BOOL)lParam && hwndShutdownDlg!=NULL) return 2;
+ if (!wParam) wParam=db_get_b(NULL,"AutoShutdown","ShutdownType",SETTING_SHUTDOWNTYPE_DEFAULT);
+ if (!IsShutdownTypeEnabled((BYTE)wParam)) return 1; /* does shutdownType range check */
+ if ((BOOL)lParam && hwndShutdownDlg != NULL) return 2;
/* ask others if allowed */
- if(NotifyEventHooks(hEventOkToShutdown,wParam,lParam)) {
+ if (NotifyEventHooks(hEventOkToShutdown,wParam,lParam)) {
OutputDebugStringA("automatic shutdown denied by event hook\n"); /* all ascii */
return 3;
}
/* tell others */
NotifyEventHooks(hEventShutdown,wParam,lParam);
/* show dialog */
- if(lParam && db_get_b(NULL,"AutoShutdown","ShowConfirmDlg",SETTING_SHOWCONFIRMDLG_DEFAULT))
- if(CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SHUTDOWNNOW), NULL, ShutdownDlgProc, (LPARAM)(BYTE)wParam) != NULL)
+ if (lParam && db_get_b(NULL,"AutoShutdown","ShowConfirmDlg",SETTING_SHOWCONFIRMDLG_DEFAULT))
+ if (CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SHUTDOWNNOW), NULL, ShutdownDlgProc, (LPARAM)(BYTE)wParam) != NULL)
return 0;
/* show error */
- { DWORD dwErrCode;
- dwErrCode=ShutdownNow((BYTE)wParam);
- if(dwErrCode!=ERROR_SUCCESS) {
- char *pszErr;
- pszErr=GetWinErrorDescription(dwErrCode);
- ShowInfoMessage(NIIF_ERROR,Translate("Automatic Shutdown Error"),Translate("Inititiating the shutdown process failed!\nReason: %s"),(pszErr!=NULL)?pszErr:Translate("Unknown"));
- if(pszErr!=NULL) LocalFree(pszErr);
- return 4;
- }
+
+ DWORD dwErrCode = ShutdownNow((BYTE)wParam);
+ if (dwErrCode != ERROR_SUCCESS) {
+ char *pszErr = GetWinErrorDescription(dwErrCode);
+ ShowInfoMessage(NIIF_ERROR,Translate("Automatic Shutdown Error"),Translate("Inititiating the shutdown process failed!\nReason: %s"),(pszErr != NULL)?pszErr:Translate("Unknown"));
+ if (pszErr != NULL)
+ LocalFree(pszErr);
+ return 4;
}
+
return 0;
}
@@ -462,33 +472,38 @@ INT_PTR ServiceIsTypeEnabled(WPARAM wParam,LPARAM) return IsShutdownTypeEnabled((BYTE)wParam); /* does shutdownType range check */
}
+const TCHAR *apszShort[] = {
+ LPGENT("Close Miranda NG"),LPGENT("Set Miranda NG offline"),LPGENT("Log off user"),
+ LPGENT("Restart computer"),LPGENT("Shutdown computer"),LPGENT("Standby mode"),LPGENT("Hibernate mode"),
+ LPGENT("Lock workstation"),LPGENT("Hang up dialup connections"),LPGENT("Close Miranda NG"),
+ LPGENT("Set Miranda NG offline"),LPGENT("Log off user"),LPGENT("Restart computer"),LPGENT("Shutdown computer"),
+ LPGENT("Standby mode"),LPGENT("Hibernate mode"),LPGENT("Lock workstation"),LPGENT("Hang up dialup connections")
+};
+
+const TCHAR *apszLong[] = {
+ LPGENT("Sets all Miranda NG protocols to offline and closes Miranda NG."),
+ LPGENT("Sets all Miranda NG protocols to offline."),
+ LPGENT("Logs the current Windows user off so that another user can log in."),
+ LPGENT("Shuts down Windows and then restarts Windows."),
+ LPGENT("Closes all running programs and shuts down Windows to a point at which it is safe to turn off the power."),
+ LPGENT("Saves the current Windows session in memory and sets the system to suspend mode."),
+ LPGENT("Saves the current Windows session on harddisc, so that the power can be turned off."),
+ LPGENT("Locks the computer. To unlock the computer, you must log in."),
+ LPGENT("Sets all protocols to offline and closes all RAS connections.")
+};
+
INT_PTR ServiceGetTypeDescription(WPARAM wParam,LPARAM lParam)
{
- TCHAR *pszDesc;
- const TCHAR *apszShort[]={LPGENT("Close Miranda NG"),LPGENT("Set Miranda NG offline"),LPGENT("Log off user"),
- LPGENT("Restart computer"),LPGENT("Shutdown computer"),LPGENT("Standby mode"),LPGENT("Hibernate mode"),
- LPGENT("Lock workstation"),LPGENT("Hang up dialup connections"),LPGENT("Close Miranda NG"),
- LPGENT("Set Miranda NG offline"),LPGENT("Log off user"),LPGENT("Restart computer"),LPGENT("Shutdown computer"),
- LPGENT("Standby mode"),LPGENT("Hibernate mode"),LPGENT("Lock workstation"),LPGENT("Hang up dialup connections")};
- const TCHAR *apszLong[]={LPGENT("Sets all Miranda NG protocols to offline and closes Miranda NG."),
- LPGENT("Sets all Miranda NG protocols to offline."),
- LPGENT("Logs the current Windows user off so that another user can log in."),
- LPGENT("Shuts down Windows and then restarts Windows."),
- LPGENT("Closes all running programs and shuts down Windows to a point at which it is safe to turn off the power."),
- LPGENT("Saves the current Windows session in memory and sets the system to suspend mode."),
- LPGENT("Saves the current Windows session on harddisc, so that the power can be turned off."),
- LPGENT("Locks the computer. To unlock the computer, you must log in."),
- LPGENT("Sets all protocols to offline and closes all RAS connections.")};
/* shutdownType range check */
- if(!wParam || (BYTE)wParam>SDSDT_MAX) return 0;
+ if (!wParam || (BYTE)wParam>SDSDT_MAX) return 0;
/* select description */
- pszDesc=(TCHAR*)((lParam&GSTDF_LONGDESC)?apszLong:apszShort)[wParam-1];
- if(!(lParam&GSTDF_UNTRANSLATED)) pszDesc=TranslateTS(pszDesc);
+ TCHAR *pszDesc=(TCHAR*)((lParam&GSTDF_LONGDESC)?apszLong:apszShort)[wParam-1];
+ if (!(lParam&GSTDF_UNTRANSLATED)) pszDesc=TranslateTS(pszDesc);
/* convert as needed */
- if(!(lParam&GSTDF_UNICODE)) {
+ if (!(lParam&GSTDF_UNICODE)) {
static char szConvBuf[128];
char *buf=u2a(pszDesc);
- if(buf==NULL) return 0;
+ if (buf==NULL) return 0;
lstrcpynA(szConvBuf,buf,sizeof(szConvBuf));
mir_free(buf);
return (INT_PTR)szConvBuf;
@@ -503,22 +518,24 @@ void InitShutdownSvc(void) /* Shutdown Dialog */
hwndShutdownDlg=NULL;
SkinAddNewSoundExT("AutoShutdown_Countdown",LPGENT("Alerts"),LPGENT("Automatic Shutdown Countdown"));
+
+ /* Events */
+ hEventOkToShutdown = CreateHookableEvent(ME_AUTOSHUTDOWN_OKTOSHUTDOWN);
+ hEventShutdown = CreateHookableEvent(ME_AUTOSHUTDOWN_SHUTDOWN);
+
/* Services */
- hEventOkToShutdown=CreateHookableEvent(ME_AUTOSHUTDOWN_OKTOSHUTDOWN);
- hEventShutdown=CreateHookableEvent(ME_AUTOSHUTDOWN_SHUTDOWN);
- hServiceShutdown = CreateServiceFunction(MS_AUTOSHUTDOWN_SHUTDOWN, ServiceShutdown);
- hServiceIsTypeEnabled = CreateServiceFunction(MS_AUTOSHUTDOWN_ISTYPEENABLED, ServiceIsTypeEnabled);
- hServiceGetTypeDesc = CreateServiceFunction(MS_AUTOSHUTDOWN_GETTYPEDESCRIPTION, ServiceGetTypeDescription);
+ CreateServiceFunction(MS_AUTOSHUTDOWN_SHUTDOWN, ServiceShutdown);
+ CreateServiceFunction(MS_AUTOSHUTDOWN_ISTYPEENABLED, ServiceIsTypeEnabled);
+ CreateServiceFunction(MS_AUTOSHUTDOWN_GETTYPEDESCRIPTION, ServiceGetTypeDescription);
}
void UninitShutdownSvc(void)
{
/* Shutdown Dialog */
- if(hwndShutdownDlg!=NULL) DestroyWindow(hwndShutdownDlg);
+ if (hwndShutdownDlg != NULL)
+ DestroyWindow(hwndShutdownDlg);
+
/* Services */
- DestroyServiceFunction(hServiceShutdown);
- DestroyServiceFunction(hServiceIsTypeEnabled);
- DestroyServiceFunction(hServiceGetTypeDesc);
DestroyHookableEvent(hEventOkToShutdown);
DestroyHookableEvent(hEventShutdown);
}
diff --git a/plugins/AutoShutdown/src/utils.cpp b/plugins/AutoShutdown/src/utils.cpp index b510fbd17c..75c65dc345 100644 --- a/plugins/AutoShutdown/src/utils.cpp +++ b/plugins/AutoShutdown/src/utils.cpp @@ -30,15 +30,15 @@ char* u2a(const WCHAR *pszUnicode) char *psz;
DWORD flags;
- if(pszUnicode==NULL) return NULL;
+ if (pszUnicode==NULL) return NULL;
codepage=CallService(MS_LANGPACK_GETCODEPAGE,0,0);
/* without WC_COMPOSITECHECK some characters might get out strange (see MS blog) */
cch=WideCharToMultiByte(codepage,flags=WC_COMPOSITECHECK,pszUnicode,-1,NULL,0,NULL,NULL);
- if(!cch) cch=WideCharToMultiByte(codepage,flags=0,pszUnicode,-1,NULL,0,NULL,NULL);
- if(!cch) return NULL;
+ if (!cch) cch=WideCharToMultiByte(codepage,flags=0,pszUnicode,-1,NULL,0,NULL,NULL);
+ if (!cch) return NULL;
psz=(char*)mir_alloc(cch);
- if(psz!=NULL && !WideCharToMultiByte(codepage,flags,pszUnicode,-1,psz,cch,NULL,NULL)){
+ if (psz != NULL && !WideCharToMultiByte(codepage,flags,pszUnicode,-1,psz,cch,NULL,NULL)){
mir_free(psz);
return NULL;
}
@@ -83,7 +83,7 @@ void ShowInfoMessage(BYTE flags,const char *pszTitle,const char *pszTextFmt,...) mir_vsnprintf(szText,SIZEOF(szText),pszTextFmt,va);
va_end(va);
- if(ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) {
+ if (ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) {
MIRANDASYSTRAYNOTIFY msn;
msn.cbSize=sizeof(msn);
msn.szProto=NULL;
@@ -91,12 +91,12 @@ void ShowInfoMessage(BYTE flags,const char *pszTitle,const char *pszTextFmt,...) msn.szInfo=(char*)szText;
msn.uTimeout=30000; /* max timeout */
msn.dwInfoFlags=flags;
- if(!CallServiceSync(MS_CLIST_SYSTRAY_NOTIFY,0,(LPARAM)&msn))
+ if (!CallServiceSync(MS_CLIST_SYSTRAY_NOTIFY,0,(LPARAM)&msn))
return; /* success */
}
mbp=(MSGBOXPARAMSA*)mir_calloc(sizeof(*mbp));
- if(mbp==NULL) return;
+ if (mbp==NULL) return;
mbp->cbSize=sizeof(*mbp);
mbp->lpszCaption=mir_strdup(pszTitle);
mbp->lpszText=mir_strdup(szText);
@@ -115,8 +115,8 @@ char* GetWinErrorDescription(DWORD dwLastError) {
char *buf=NULL;
DWORD flags=FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM;
- if(!FormatMessageA(flags,NULL,dwLastError,LANGIDFROMLCID((LCID)CallService(MS_LANGPACK_GETLOCALE,0,0)),(char*)&buf,0,NULL))
- if(GetLastError()==ERROR_RESOURCE_LANG_NOT_FOUND)
+ if (!FormatMessageA(flags,NULL,dwLastError,LANGIDFROMLCID((LCID)CallService(MS_LANGPACK_GETLOCALE,0,0)),(char*)&buf,0,NULL))
+ if (GetLastError()==ERROR_RESOURCE_LANG_NOT_FOUND)
FormatMessageA(flags,NULL,dwLastError,0,(char*)&buf,0,NULL);
return buf;
}
@@ -136,7 +136,7 @@ BOOL SystemTimeToTimeStamp(SYSTEMTIME *st,time_t *timestamp) ts.tm_year = st->wYear-1900; /* current year minus 1900 */
ts.tm_yday=0; /* 0-365 (Jan1=0) */
*timestamp = mktime(&ts);
- return (*timestamp!=-1);
+ return (*timestamp != -1);
}
BOOL TimeStampToSystemTime(time_t timestamp,SYSTEMTIME *st)
@@ -162,22 +162,22 @@ BOOL GetFormatedCountdown(TCHAR *pszOut,int nSize,time_t countdown) static BOOL fInited=FALSE;
static int (WINAPI *pfnGetDurationFormat)(LCID,DWORD,const SYSTEMTIME*,double,WCHAR*,WCHAR*,int);
/* Init */
- if(!fInited && IsWinVerVistaPlus()) {
+ if (!fInited && IsWinVerVistaPlus()) {
*(PROC*)&pfnGetDurationFormat=GetProcAddress(GetModuleHandleA("KERNEL32"),"GetDurationFormat");
fInited=TRUE;
}
/* WinVista */
- if(pfnGetDurationFormat!=NULL) {
+ if (pfnGetDurationFormat != NULL) {
SYSTEMTIME st;
LCID locale;
locale=(LCID)CallService(MS_LANGPACK_GETLOCALE,0,0);
- if(TimeStampToSystemTime(countdown,&st))
- if(pfnGetDurationFormat(locale,0,&st,0,NULL,pszOut,nSize))
+ if (TimeStampToSystemTime(countdown,&st))
+ if (pfnGetDurationFormat(locale,0,&st,0,NULL,pszOut,nSize))
return TRUE;
return FALSE;
} else
/* Win9x/NT/XP */
- return StrFromTimeInterval(pszOut,nSize,(countdown>(MAXDWORD/1000))?MAXDWORD:(countdown*1000),10)!=0;
+ return StrFromTimeInterval(pszOut,nSize,(countdown>(MAXDWORD/1000))?MAXDWORD:(countdown*1000),10) != 0;
return FALSE;
}
@@ -189,13 +189,13 @@ BOOL GetFormatedDateTime(TCHAR *pszOut,int nSize,time_t timestamp,BOOL fShowDate GetLocalTime(&stNow);
TimeStampToSystemTime(timestamp,&st);
/* today: no need to show the date */
- if(!fShowDateEvenToday && st.wDay==stNow.wDay && st.wMonth==stNow.wMonth && st.wYear==stNow.wYear)
- return GetTimeFormat(locale,((st.wSecond==0)?TIME_NOSECONDS:0)|TIME_FORCE24HOURFORMAT,&st,NULL,pszOut,nSize)!=0;
+ if (!fShowDateEvenToday && st.wDay==stNow.wDay && st.wMonth==stNow.wMonth && st.wYear==stNow.wYear)
+ return GetTimeFormat(locale,((st.wSecond==0)?TIME_NOSECONDS:0)|TIME_FORCE24HOURFORMAT,&st,NULL,pszOut,nSize) != 0;
/* show both date and time */
{ TCHAR szDate[128],szTime[128];
- if(!GetTimeFormat(locale,((st.wSecond==0)?TIME_NOSECONDS:0)|TIME_FORCE24HOURFORMAT,&st,NULL,szTime,SIZEOF(szTime)))
+ if (!GetTimeFormat(locale,((st.wSecond==0)?TIME_NOSECONDS:0)|TIME_FORCE24HOURFORMAT,&st,NULL,szTime,SIZEOF(szTime)))
return FALSE;
- if(!GetDateFormat(locale,DATE_SHORTDATE,&st,NULL,szDate,SIZEOF(szDate)))
+ if (!GetDateFormat(locale,DATE_SHORTDATE,&st,NULL,szDate,SIZEOF(szDate)))
return FALSE;
mir_sntprintf(pszOut,nSize,_T("%s %s"),szTime,szDate);
return TRUE;
@@ -216,16 +216,16 @@ int FontService_RegisterFont(const char *pszDbModule,const char *pszDbName,const lstrcpyn(fid.backgroundGroup,pszBackgroundGroup,SIZEOF(fid.backgroundGroup)); /* buffer safe */
lstrcpyn(fid.backgroundName,pszBackgroundName,SIZEOF(fid.backgroundName)); /* buffer safe */
fid.flags=FIDF_ALLOWREREGISTER;
- if(bAllowEffects) fid.flags|=FIDF_ALLOWEFFECTS;
+ if (bAllowEffects) fid.flags|=FIDF_ALLOWEFFECTS;
fid.order=position;
- if(plfDefault!=NULL) {
+ if (plfDefault != NULL) {
fid.flags|=FIDF_DEFAULTVALID;
fid.deffontsettings.colour=clrDefault;
fid.deffontsettings.size=(char)plfDefault->lfHeight;
- if(plfDefault->lfItalic) fid.deffontsettings.style|=DBFONTF_ITALIC;
- if(plfDefault->lfWeight!=FW_NORMAL) fid.deffontsettings.style|=DBFONTF_BOLD;
- if(plfDefault->lfUnderline) fid.deffontsettings.style|=DBFONTF_UNDERLINE;
- if(plfDefault->lfStrikeOut) fid.deffontsettings.style|=DBFONTF_STRIKEOUT;
+ if (plfDefault->lfItalic) fid.deffontsettings.style|=DBFONTF_ITALIC;
+ if (plfDefault->lfWeight != FW_NORMAL) fid.deffontsettings.style|=DBFONTF_BOLD;
+ if (plfDefault->lfUnderline) fid.deffontsettings.style|=DBFONTF_UNDERLINE;
+ if (plfDefault->lfStrikeOut) fid.deffontsettings.style|=DBFONTF_STRIKEOUT;
fid.deffontsettings.charset=plfDefault->lfCharSet;
lstrcpyn(fid.deffontsettings.szFace,plfDefault->lfFaceName,SIZEOF(fid.deffontsettings.szFace)); /* buffer safe */
}
diff --git a/plugins/AutoShutdown/src/watcher.cpp b/plugins/AutoShutdown/src/watcher.cpp index b4d9d89a05..71ea713e9a 100644 --- a/plugins/AutoShutdown/src/watcher.cpp +++ b/plugins/AutoShutdown/src/watcher.cpp @@ -48,16 +48,16 @@ static void __stdcall MainThreadMapping(void *param) HANDLE *phDoneEvent = (HANDLE*)param;
ServiceShutdown(0,TRUE); /* ensure main thread (for cpu usage shutdown) */
ServiceStopWatcher(0,0);
- if(*phDoneEvent!=NULL) SetEvent(*phDoneEvent);
+ if (*phDoneEvent != NULL) SetEvent(*phDoneEvent);
}
static void __inline ShutdownAndStopWatcher(void)
{
HANDLE hDoneEvent;
hDoneEvent=CreateEvent(NULL,FALSE,FALSE,NULL);
- if(CallFunctionAsync(MainThreadMapping, &hDoneEvent))
- if(hDoneEvent!=NULL) WaitForSingleObject(hDoneEvent,INFINITE);
- if(hDoneEvent!=NULL) CloseHandle(hDoneEvent);
+ if (CallFunctionAsync(MainThreadMapping, &hDoneEvent))
+ if (hDoneEvent != NULL) WaitForSingleObject(hDoneEvent,INFINITE);
+ if (hDoneEvent != NULL) CloseHandle(hDoneEvent);
}
/************************* Msg Shutdown *******************************/
@@ -65,28 +65,28 @@ static void __inline ShutdownAndStopWatcher(void) // ppBlob might get reallocated, must have been allocated using mir_alloc()
static TCHAR* GetMessageText(BYTE **ppBlob,DWORD *pcbBlob)
{
- DWORD cb;
(*ppBlob)[*pcbBlob]=0;
- cb=lstrlenA((char*)*ppBlob);
+ DWORD cb = lstrlenA((char*)*ppBlob);
/* use Unicode data if present */
- if(*pcbBlob>(cb+3)) {
+ if (*pcbBlob>(cb+3)) {
(*ppBlob)[*pcbBlob-1]=0;
return (WCHAR*)&(*ppBlob)[cb];
}
/* no Unicode data present, convert from ANSI */
- { int len;
- BYTE *buf;
- len=MultiByteToWideChar(CP_ACP,0,(char*)*ppBlob,-1,NULL,0);
- if(!len) return NULL;
- buf=(BYTE*)mir_realloc(*ppBlob,(*pcbBlob)+(len*sizeof(WCHAR)));
- if(buf==NULL) return NULL;
- *pcbBlob+=len*sizeof(WCHAR);
- *ppBlob=buf;
- buf=&(*ppBlob)[cb];
- MultiByteToWideChar(CP_ACP,0,(char*)*ppBlob,-1,(WCHAR*)buf,len);
- ((WCHAR*)buf)[len-1]=0;
- return (WCHAR*)buf;
- }
+ int len = MultiByteToWideChar(CP_ACP,0,(char*)*ppBlob,-1,NULL,0);
+ if (!len)
+ return NULL;
+
+ BYTE *buf=(BYTE*)mir_realloc(*ppBlob,(*pcbBlob)+(len*sizeof(WCHAR)));
+ if (buf == NULL)
+ return NULL;
+
+ *pcbBlob += len*sizeof(WCHAR);
+ *ppBlob = buf;
+ buf = &(*ppBlob)[cb];
+ MultiByteToWideChar(CP_ACP,0,(char*)*ppBlob,-1,(WCHAR*)buf,len);
+ ((WCHAR*)buf)[len-1] = 0;
+ return (WCHAR*)buf;
}
static int MsgEventAdded(WPARAM wParam,LPARAM lParam)
@@ -100,12 +100,12 @@ static int MsgEventAdded(WPARAM wParam,LPARAM lParam) if (dbe.pBlob == NULL)
return 0;
if (!db_event_get(hDbEvent, &dbe))
- if(dbe.eventType == EVENTTYPE_MESSAGE && !(dbe.flags & DBEF_SENT)) {
+ if (dbe.eventType == EVENTTYPE_MESSAGE && !(dbe.flags & DBEF_SENT)) {
DBVARIANT dbv;
- if(!db_get_ts(NULL,"AutoShutdown","Message",&dbv)) {
+ if (!db_get_ts(NULL,"AutoShutdown","Message",&dbv)) {
TrimString(dbv.ptszVal);
TCHAR *pszMsg = GetMessageText(&dbe.pBlob,&dbe.cbBlob);
- if(pszMsg!=NULL && _tcsstr(pszMsg,dbv.ptszVal)!=NULL)
+ if (pszMsg != NULL && _tcsstr(pszMsg,dbv.ptszVal) != NULL)
ShutdownAndStopWatcher(); /* msg with specified text recvd */
mir_free(dbv.ptszVal); /* does NULL check */
}
@@ -123,44 +123,44 @@ static int nTransfersCount; static int ProtoAck(WPARAM wParam,LPARAM lParam)
{
ACKDATA *ack=(ACKDATA*)lParam;
- if(ack->type==ACKTYPE_FILE)
- switch(ack->result) {
- case ACKRESULT_DATA:
- { int i;
- for(i=0;i<nTransfersCount;++i)
- if(transfers[i]==ack->hProcess)
- break; /* already in list */
- /* insert into list */
- { HANDLE *buf=(HANDLE*)mir_realloc(transfers,(nTransfersCount+1)*sizeof(HANDLE)); if(buf!=NULL) {
- transfers=buf;
- transfers[nTransfersCount]=ack->hProcess;
- ++nTransfersCount;
- }
- }
- break;
+ if (ack->type != ACKTYPE_FILE)
+ return 0;
+
+ switch(ack->result) {
+ case ACKRESULT_DATA:
+ {
+ for(int i=0; i < nTransfersCount; ++i)
+ if (transfers[i]==ack->hProcess)
+ break; /* already in list */
+ /* insert into list */
+ HANDLE *buf = (HANDLE*)mir_realloc(transfers,(nTransfersCount+1)*sizeof(HANDLE));
+ if (buf != NULL) {
+ transfers = buf;
+ transfers[nTransfersCount] = ack->hProcess;
+ ++nTransfersCount;
}
- case ACKRESULT_SUCCESS:
- case ACKRESULT_FAILED:
- case ACKRESULT_DENIED:
- { int i;
- for(i=0;i<nTransfersCount;++i)
- if(transfers[i]==ack->hProcess) {
- /* remove from list */
- HANDLE *buf;
- if(i<(nTransfersCount-1))
- MoveMemory(&transfers[i],&transfers[i+1],(nTransfersCount-i-1)*sizeof(HANDLE));
- --nTransfersCount;
- buf=(HANDLE*)mir_realloc(transfers,nTransfersCount*sizeof(HANDLE));
- if(buf!=NULL) transfers=buf;
- else if(!nTransfersCount) transfers=NULL;
- /* stop watcher */
- if(!nTransfersCount && (currentWatcherType&SDWTF_FILETRANSFER))
- ShutdownAndStopWatcher();
- break;
- }
+ break;
+ }
+ case ACKRESULT_SUCCESS:
+ case ACKRESULT_FAILED:
+ case ACKRESULT_DENIED:
+ for(int i=0;i<nTransfersCount;++i) {
+ if (transfers[i]==ack->hProcess) {
+ /* remove from list */
+ if (i<(nTransfersCount-1))
+ MoveMemory(&transfers[i],&transfers[i+1],(nTransfersCount-i-1)*sizeof(HANDLE));
+ --nTransfersCount;
+ HANDLE *buf = (HANDLE*)mir_realloc(transfers,nTransfersCount*sizeof(HANDLE));
+ if (buf != NULL) transfers=buf;
+ else if (!nTransfersCount) transfers=NULL;
+ /* stop watcher */
+ if (!nTransfersCount && (currentWatcherType&SDWTF_FILETRANSFER))
+ ShutdownAndStopWatcher();
break;
}
}
+ break;
+ }
return 0;
}
@@ -168,7 +168,7 @@ static int ProtoAck(WPARAM wParam,LPARAM lParam) static int IdleChanged(WPARAM,LPARAM lParam)
{
- if(currentWatcherType&SDWTF_IDLE && lParam&IDF_ISIDLE)
+ if (currentWatcherType&SDWTF_IDLE && lParam&IDF_ISIDLE)
ShutdownAndStopWatcher();
return 0;
}
@@ -181,12 +181,12 @@ static BOOL CheckAllContactsOffline(void) fSmartCheck=db_get_b(NULL,"AutoShutdown","SmartOfflineCheck",SETTING_SMARTOFFLINECHECK_DEFAULT);
for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *pszProto = GetContactProto(hContact);
- if(pszProto != NULL && CallProtoService(pszProto,PS_GETSTATUS,0,0)!=ID_STATUS_OFFLINE) {
- if(db_get_b(hContact,pszProto,"ChatRoom",0)) continue;
- if(db_get_w(hContact,pszProto,"Status",0)!=ID_STATUS_OFFLINE) {
- if(fSmartCheck) {
- if(db_get_b(hContact,"CList","Hidden",0)) continue;
- if(db_get_b(hContact,"CList","NotOnList",0)) continue;
+ if (pszProto != NULL && CallProtoService(pszProto,PS_GETSTATUS,0,0) != ID_STATUS_OFFLINE) {
+ if (db_get_b(hContact,pszProto,"ChatRoom",0)) continue;
+ if (db_get_w(hContact,pszProto,"Status",0) != ID_STATUS_OFFLINE) {
+ if (fSmartCheck) {
+ if (db_get_b(hContact,"CList","Hidden",0)) continue;
+ if (db_get_b(hContact,"CList","NotOnList",0)) continue;
}
fAllOffline=FALSE;
break;
@@ -198,12 +198,12 @@ static BOOL CheckAllContactsOffline(void) static int StatusSettingChanged(WPARAM wParam,LPARAM lParam)
{
- if(currentWatcherType&SDWTF_STATUS) {
+ if (currentWatcherType&SDWTF_STATUS) {
DBCONTACTWRITESETTING *dbcws=(DBCONTACTWRITESETTING*)lParam;
- if((HANDLE)wParam!=NULL && dbcws->value.wVal==ID_STATUS_OFFLINE && !lstrcmpA(dbcws->szSetting,"Status")) {
+ if ((HANDLE)wParam != NULL && dbcws->value.wVal==ID_STATUS_OFFLINE && !lstrcmpA(dbcws->szSetting,"Status")) {
char *pszProto = GetContactProto((HANDLE)wParam);
- if(pszProto!=NULL && !lstrcmpA(dbcws->szModule,pszProto))
- if(CheckAllContactsOffline())
+ if (pszProto != NULL && !lstrcmpA(dbcws->szModule,pszProto))
+ if (CheckAllContactsOffline())
ShutdownAndStopWatcher();
}
}
@@ -218,14 +218,14 @@ static BOOL CALLBACK CpuUsageWatcherProc(BYTE nCpuUsage,LPARAM lParam) {
static BYTE nTimesBelow=0; /* only one watcher thread */
/* terminated? */
- if(idCpuUsageThread!=GetCurrentThreadId()) {
+ if (idCpuUsageThread != GetCurrentThreadId()) {
nTimesBelow=0;
return FALSE; /* stop poll thread */
}
/* ignore random peaks */
- if(nCpuUsage<(BYTE)lParam) ++nTimesBelow;
+ if (nCpuUsage<(BYTE)lParam) ++nTimesBelow;
else nTimesBelow=0;
- if(nTimesBelow==3) {
+ if (nTimesBelow==3) {
nTimesBelow=0;
ShutdownAndStopWatcher();
return FALSE; /* stop poll thread */
@@ -238,8 +238,8 @@ static BOOL CALLBACK CpuUsageWatcherProc(BYTE nCpuUsage,LPARAM lParam) static int WeatherUpdated(WPARAM wParam,LPARAM lParam)
{
char *pszProto = GetContactProto((HANDLE)wParam);
- if((BOOL)lParam && pszProto!=NULL && CallProtoService(pszProto,PS_GETSTATUS,0,0)==THUNDER)
- if(db_get_b(NULL,"AutoShutdown","WeatherShutdown",SETTING_WEATHERSHUTDOWN_DEFAULT))
+ if ((BOOL)lParam && pszProto != NULL && CallProtoService(pszProto,PS_GETSTATUS,0,0)==THUNDER)
+ if (db_get_b(NULL,"AutoShutdown","WeatherShutdown",SETTING_WEATHERSHUTDOWN_DEFAULT))
ServiceShutdown(SDSDT_SHUTDOWN,TRUE);
return 0;
}
@@ -248,7 +248,7 @@ static int WeatherUpdated(WPARAM wParam,LPARAM lParam) static int HddOverheat(WPARAM wParam,LPARAM lParam)
{
- if(db_get_b(NULL,"AutoShutdown","HddOverheatShutdown",SETTING_HDDOVERHEATSHUTDOWN_DEFAULT))
+ if (db_get_b(NULL,"AutoShutdown","HddOverheatShutdown",SETTING_HDDOVERHEATSHUTDOWN_DEFAULT))
ServiceShutdown(SDSDT_SHUTDOWN,TRUE);
return 0;
}
@@ -258,21 +258,21 @@ 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)
+ if (lParam==0)
lParam=(LPARAM)db_get_w(NULL,"AutoShutdown","WatcherFlags",0);
/* invalid flags or empty? */
- if(!(lParam&SDWTF_MASK))
+ if (!(lParam&SDWTF_MASK))
return 1;
/* no specific time choice? */
- if(lParam&SDWTF_SPECIFICTIME && !(lParam&SDWTF_ST_MASK))
+ if (lParam&SDWTF_SPECIFICTIME && !(lParam&SDWTF_ST_MASK))
return 2;
- if(currentWatcherType==(WORD)lParam)
+ if (currentWatcherType==(WORD)lParam)
return 3;
- if(currentWatcherType!=0) {
+ if (currentWatcherType != 0) {
/* Time Shutdown */
CloseCountdownFrame(); /* fails if not opened */
/* Cpu Shutdown */
@@ -284,26 +284,26 @@ INT_PTR ServiceStartWatcher(WPARAM wParam,LPARAM lParam) NotifyEventHooks(hEventWatcherChanged,TRUE,0);
/* Time Shutdown */
- if(currentWatcherType&SDWTF_SPECIFICTIME)
+ if (currentWatcherType&SDWTF_SPECIFICTIME)
ShowCountdownFrame(currentWatcherType); /* after modules loaded */
/* Cpu Shutdown */
- if(currentWatcherType&SDWTF_CPUUSAGE)
+ if (currentWatcherType&SDWTF_CPUUSAGE)
idCpuUsageThread=PollCpuUsage(CpuUsageWatcherProc,(LPARAM)DBGetContactSettingRangedByte(NULL,"AutoShutdown","CpuUsageThreshold",SETTING_CPUUSAGETHRESHOLD_DEFAULT,1,100),1500);
/* Transfer Shutdown */
- if(currentWatcherType&SDWTF_FILETRANSFER && !nTransfersCount)
+ if (currentWatcherType&SDWTF_FILETRANSFER && !nTransfersCount)
ShutdownAndStopWatcher();
/* Status Shutdown */
- if(currentWatcherType&SDWTF_STATUS && CheckAllContactsOffline())
+ if (currentWatcherType&SDWTF_STATUS && CheckAllContactsOffline())
ShutdownAndStopWatcher();
return 0;
}
INT_PTR ServiceStopWatcher(WPARAM,LPARAM)
{
- if(currentWatcherType==0) return 1;
+ if (currentWatcherType==0) return 1;
/* Time Shutdown */
- if(currentWatcherType&SDWTF_SPECIFICTIME)
+ if (currentWatcherType&SDWTF_SPECIFICTIME)
CloseCountdownFrame();
/* Cpu Shutdown */
idCpuUsageThread=0;
@@ -317,7 +317,7 @@ INT_PTR ServiceStopWatcher(WPARAM,LPARAM) INT_PTR ServiceIsWatcherEnabled(WPARAM,LPARAM)
{
- return currentWatcherType!=0;
+ return currentWatcherType != 0;
}
/************************* Misc ***********************************/
@@ -325,14 +325,14 @@ INT_PTR ServiceIsWatcherEnabled(WPARAM,LPARAM) void WatcherModulesLoaded(void)
{
/* Weather Shutdown */
- if(ServiceExists(MS_WEATHER_UPDATE))
+ if (ServiceExists(MS_WEATHER_UPDATE))
hHookWeatherUpdated=HookEvent(ME_WEATHER_UPDATED,WeatherUpdated);
/* Overheat Shutdown */
- if(ServiceExists(MS_SYSINFO_HDDTEMP))
+ if (ServiceExists(MS_SYSINFO_HDDTEMP))
hHookHddOverheat=HookEvent(ME_SYSINFO_HDDOVERHEAT,HddOverheat);
/* restore watcher if it was running on last exit */
- if(db_get_b(NULL,"AutoShutdown","RememberOnRestart",0)==SDROR_RUNNING) {
+ if (db_get_b(NULL,"AutoShutdown","RememberOnRestart",0)==SDROR_RUNNING) {
db_set_b(NULL,"AutoShutdown","RememberOnRestart",1);
ServiceStartWatcher(0,0); /* after modules loaded */
}
@@ -366,8 +366,8 @@ void InitWatcher(void) void UninitWatcher(void)
{
/* remember watcher if running */
- if(!ServiceStopWatcher(0,0))
- if(db_get_b(NULL,"AutoShutdown","RememberOnRestart",SETTING_REMEMBERONRESTART_DEFAULT))
+ if (!ServiceStopWatcher(0,0))
+ if (db_get_b(NULL,"AutoShutdown","RememberOnRestart",SETTING_REMEMBERONRESTART_DEFAULT))
db_set_b(NULL,"AutoShutdown","RememberOnRestart",SDROR_RUNNING);
/* Message Shutdown */
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index 7730df32b6..e17eb4fbce 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -543,7 +543,7 @@ void MirandaImport(HWND hdlg) if (nImportOption == IMPORT_ALL || (nCustomOptions & 2046)) { // 2 - 1024 types
AddMessage( LPGENT("Importing history."));
HANDLE hContact = srcDb->FindFirstContact();
- for(int i=1; hContact != NULL; i++) {
+ for (int i=1; hContact != NULL; i++) {
ImportHistory(hContact, NULL, NULL);
SetProgress(100 * i / nNumberOfContacts);
diff --git a/plugins/Import/src/miranda.cpp b/plugins/Import/src/miranda.cpp index fc9a654165..e2da3df048 100644 --- a/plugins/Import/src/miranda.cpp +++ b/plugins/Import/src/miranda.cpp @@ -84,16 +84,14 @@ INT_PTR CALLBACK MirandaPageProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lPa case WM_INITDIALOG:
TranslateDialogDefault(hdlg);
{
- TCHAR *pfd, *pfd1, *pfd2, *pfn;
-
REPLACEVARSDATA dat = {0};
dat.cbSize = sizeof(dat);
dat.dwFlags = RVF_TCHAR;
- pfd = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)_T("%miranda_path%\\Profiles"), (LPARAM)&dat);
- pfd1 = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)_T("%miranda_path%"), (LPARAM)&dat);
- pfd2 = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)_T("%miranda_profile%"), (LPARAM)&dat);
- pfn = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)_T("%miranda_profilename%"), (LPARAM)&dat);
+ TCHAR *pfd = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)_T("%miranda_path%\\Profiles"), (LPARAM)&dat);
+ TCHAR *pfd1 = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)_T("%miranda_path%"), (LPARAM)&dat);
+ TCHAR *pfd2 = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)_T("%miranda_profile%"), (LPARAM)&dat);
+ TCHAR *pfn = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)_T("%miranda_profilename%"), (LPARAM)&dat);
SearchForLists(hdlg, pfd2, pfn);
SearchForLists(hdlg, pfd1, NULL);
@@ -104,8 +102,8 @@ INT_PTR CALLBACK MirandaPageProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lPa mir_free(pfd2);
mir_free(pfd1);
mir_free(pfd);
- return TRUE;
}
+ return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
@@ -116,9 +114,8 @@ INT_PTR CALLBACK MirandaPageProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lPa case IDOK:
{
TCHAR filename[MAX_PATH];
-
GetDlgItemText(hdlg, IDC_FILENAME, filename, SIZEOF(filename));
- if (_taccess(filename, 4)) {
+ if ( _taccess(filename, 4)) {
MessageBox(hdlg, TranslateT("The given file does not exist. Please check that you have entered the name correctly."), TranslateT("Miranda Import"), MB_OK);
break;
}
@@ -140,40 +137,36 @@ INT_PTR CALLBACK MirandaPageProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lPa break;
case IDC_OTHER:
- {
- OPENFILENAME ofn;
- TCHAR str[MAX_PATH], text[256];
- TCHAR *pfd;
-
- pfd = Utils_ReplaceVarsT(_T("%miranda_profile%"));
-
- GetDlgItemText(hdlg, IDC_FILENAME, str, SIZEOF(str));
- ZeroMemory(&ofn, sizeof(ofn));
- ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
- ofn.hwndOwner = hdlg;
- mir_sntprintf(text, SIZEOF(text), _T("%s (*.dat, *.bak)%c*.dat;*.bak%c%s (*.*)%c*.*%c%c"), TranslateT("Miranda NG database"), 0, 0, TranslateT("All Files"), 0, 0, 0);
- ofn.lpstrFilter = text;
- ofn.lpstrDefExt = _T("dat");
- ofn.lpstrFile = str;
- ofn.Flags = OFN_FILEMUSTEXIST | OFN_EXPLORER | OFN_NOCHANGEDIR | OFN_DONTADDTORECENT;
- ofn.nMaxFile = SIZEOF(str);
- ofn.lpstrInitialDir = pfd;
- if (GetOpenFileName(&ofn))
- SetDlgItemText(hdlg, IDC_FILENAME, str);
-
- mir_free(pfd);
- break;
- }
+ OPENFILENAME ofn;
+ TCHAR str[MAX_PATH], text[256];
+ TCHAR *pfd;
+
+ pfd = Utils_ReplaceVarsT(_T("%miranda_profile%"));
+
+ GetDlgItemText(hdlg, IDC_FILENAME, str, SIZEOF(str));
+ ZeroMemory(&ofn, sizeof(ofn));
+ ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
+ ofn.hwndOwner = hdlg;
+ mir_sntprintf(text, SIZEOF(text), _T("%s (*.dat, *.bak)%c*.dat;*.bak%c%s (*.*)%c*.*%c%c"), TranslateT("Miranda NG database"), 0, 0, TranslateT("All Files"), 0, 0, 0);
+ ofn.lpstrFilter = text;
+ ofn.lpstrDefExt = _T("dat");
+ ofn.lpstrFile = str;
+ ofn.Flags = OFN_FILEMUSTEXIST | OFN_EXPLORER | OFN_NOCHANGEDIR | OFN_DONTADDTORECENT;
+ ofn.nMaxFile = SIZEOF(str);
+ ofn.lpstrInitialDir = pfd;
+ if (GetOpenFileName(&ofn))
+ SetDlgItemText(hdlg, IDC_FILENAME, str);
+
+ mir_free(pfd);
+ break;
}
break;
- case WM_DESTROY:
- {
- int i;
- for(i=SendDlgItemMessage(hdlg,IDC_LIST,LB_GETCOUNT,0,0)-1;i>=0;i--)
- mir_free((char*)SendDlgItemMessage(hdlg,IDC_LIST,LB_GETITEMDATA,i,0));
- break;
- } }
+ case WM_DESTROY:
+ for (int i = SendDlgItemMessage(hdlg,IDC_LIST,LB_GETCOUNT,0,0)-1; i >= 0; i--)
+ mir_free((char*)SendDlgItemMessage(hdlg, IDC_LIST, LB_GETITEMDATA, i, 0));
+ break;
+ }
return FALSE;
}
@@ -199,7 +192,7 @@ INT_PTR CALLBACK MirandaOptionsPageProc(HWND hdlg,UINT message,WPARAM wParam,LPA break;
case IDOK:
- if (IsDlgButtonChecked(hdlg,IDC_RADIO_ALL)) {
+ if ( IsDlgButtonChecked(hdlg,IDC_RADIO_ALL)) {
nImportOption = IMPORT_ALL;
nCustomOptions = 0;//IOPT_MSGSENT|IOPT_MSGRECV|IOPT_URLSENT|IOPT_URLRECV;
DoImport = MirandaImport;
@@ -207,7 +200,7 @@ INT_PTR CALLBACK MirandaOptionsPageProc(HWND hdlg,UINT message,WPARAM wParam,LPA break;
}
- if (IsDlgButtonChecked(hdlg,IDC_RADIO_CONTACTS)) {
+ if ( IsDlgButtonChecked(hdlg,IDC_RADIO_CONTACTS)) {
nImportOption = IMPORT_CONTACTS;
nCustomOptions = 0;
DoImport = MirandaImport;
@@ -327,21 +320,17 @@ INT_PTR CALLBACK MirandaAdvOptionsPageProc(HWND hdlg,UINT message,WPARAM wParam, case IDC_ALL:
case IDC_INCOMING:
case IDC_OUTGOING:
- {
- int i;
+ if (LOWORD(wParam) == IDC_ALL)
+ for (int i = 0; i < sizeof(SysControls)/sizeof(SysControls[0]); i++)
+ CheckDlgButton(hdlg,SysControls[i], !IsDlgButtonChecked(hdlg,SysControls[i]));
- if (LOWORD(wParam) == IDC_ALL)
- for (i = 0; i < sizeof(SysControls)/sizeof(SysControls[0]); i++)
- CheckDlgButton(hdlg,SysControls[i], !IsDlgButtonChecked(hdlg,SysControls[i]));
+ if (LOWORD(wParam) != IDC_OUTGOING)
+ for (int i = 0; i < sizeof(InControls)/sizeof(InControls[0]); i++)
+ CheckDlgButton(hdlg,InControls[i], !IsDlgButtonChecked(hdlg,InControls[i]));
- if (LOWORD(wParam) != IDC_OUTGOING)
- for (i = 0; i < sizeof(InControls)/sizeof(InControls[0]); i++)
- CheckDlgButton(hdlg,InControls[i], !IsDlgButtonChecked(hdlg,InControls[i]));
-
- if (LOWORD(wParam) != IDC_INCOMING)
- for (i = 0; i < sizeof(OutControls)/sizeof(OutControls[0]); i++)
- CheckDlgButton(hdlg,OutControls[i], !IsDlgButtonChecked(hdlg,OutControls[i]));
- }
+ if (LOWORD(wParam) != IDC_INCOMING)
+ for (int i = 0; i < sizeof(OutControls)/sizeof(OutControls[0]); i++)
+ CheckDlgButton(hdlg,OutControls[i], !IsDlgButtonChecked(hdlg,OutControls[i]));
break;
case IDC_MSG:
diff --git a/plugins/KeyboardNotify/src/ignore.cpp b/plugins/KeyboardNotify/src/ignore.cpp index 645ea4b192..6ce81f49cb 100644 --- a/plugins/KeyboardNotify/src/ignore.cpp +++ b/plugins/KeyboardNotify/src/ignore.cpp @@ -59,7 +59,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt hChildItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
if(hChildItem)
SetListGroupIcons(hwndList, hChildItem, hItem, childCount);
- for(i=0; i < SIZEOF(iconOn); i++)
+ for (i=0; i < SIZEOF(iconOn); i++)
if(iconOn[i] && SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i) == 0)
iconOn[i] = 0;
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem);
@@ -70,7 +70,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt else
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem);
while(hItem) {
- for(i=0; i < SIZEOF(iconOn); i++) {
+ for (i=0; i < SIZEOF(iconOn); i++) {
iImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i);
if(iconOn[i] && iImage == 0)
iconOn[i] = 0;
@@ -80,7 +80,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem);
}
//set icons
- for(i=0; i < SIZEOF(iconOn); i++) {
+ for (i=0; i < SIZEOF(iconOn); i++) {
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hParentItem, MAKELPARAM(i, childCount[i]?(iconOn[i]?i+3:0):EMPTY_EXTRA_ICON));
if(groupChildCount)
groupChildCount[i] += childCount[i];
@@ -129,7 +129,7 @@ static void ResetListOptions(HWND hwndList) SendMessage(hwndList, CLM_SETLEFTMARGIN, 4, 0);
SendMessage(hwndList, CLM_SETINDENT, 10, 0);
SendMessage(hwndList, CLM_SETHIDEEMPTYGROUPS, 1, 0);
- for(i=0; i <= FONTID_MAX; i++)
+ for (i=0; i <= FONTID_MAX; i++)
SendMessage(hwndList, CLM_SETTEXTCOLOR, i, GetSysColor(COLOR_WINDOWTEXT));
}
@@ -162,7 +162,7 @@ static void InitialiseItem(HWND hwndList, HANDLE hContact, HANDLE hItem, DWORD p int i;
mask = GetMask(hContact);
- for(i=0; i < IGNOREEVENT_MAX; i++)
+ for (i=0; i < IGNOREEVENT_MAX; i++)
if(ignoreIdToPf1[i] == 0xFFFFFFFF || protoCaps & ignoreIdToPf1[i])
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(i, mask&(1<<i)?i+3:0));
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(IGNOREEVENT_MAX, 1));
@@ -174,7 +174,7 @@ static void SaveItemMask(HWND hwndList, HANDLE hContact, HANDLE hItem, const cha DWORD mask;
int i, iImage;
- for(i=0, mask=0; i < IGNOREEVENT_MAX; i++) {
+ for (i=0, mask=0; i < IGNOREEVENT_MAX; i++) {
iImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(i, 0));
if(iImage && iImage != EMPTY_EXTRA_ICON)
mask |= 1<<i;
@@ -219,7 +219,7 @@ INT_PTR CALLBACK DlgProcIgnoreOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPA ImageList_AddIcon(hIml, LoadSkinnedIcon(SKINICON_EVENT_FILE));
ImageList_AddIcon(hIml, LoadSkinnedIcon(SKINICON_OTHER_MIRANDA));
SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hIml);
- for(i=0; i < SIZEOF(hIcons); i++)
+ for (i=0; i < SIZEOF(hIcons); i++)
hIcons[i] = ImageList_GetIcon(hIml, 1+i, ILD_NORMAL);
}
SendDlgItemMessage(hwndDlg, IDC_ALLICON, STM_SETICON, (WPARAM)hIcons[0], 0);
@@ -284,11 +284,11 @@ INT_PTR CALLBACK DlgProcIgnoreOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPA if (!(hitFlags & CLCHT_ONITEMEXTRA))
break;
if(nm->iColumn == IGNOREEVENT_MAX) { //ignore all
- for(iImage=0; iImage < IGNOREEVENT_MAX; iImage++)
+ for (iImage=0; iImage < IGNOREEVENT_MAX; iImage++)
SetIconsForColumn(GetDlgItem(hwndDlg, IDC_LIST), hItem, hItemAll, iImage, iImage+3);
}
else if(nm->iColumn == IGNOREEVENT_MAX+1) { //ignore none
- for(iImage=0; iImage < IGNOREEVENT_MAX; iImage++)
+ for (iImage=0; iImage < IGNOREEVENT_MAX; iImage++)
SetIconsForColumn(GetDlgItem(hwndDlg, IDC_LIST), hItem, hItemAll, iImage, 0);
}
else {
@@ -326,7 +326,7 @@ INT_PTR CALLBACK DlgProcIgnoreOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPA case WM_DESTROY:
{ int i;
HIMAGELIST hIml;
- for(i=0; i < SIZEOF(hIcons); i++)
+ for (i=0; i < SIZEOF(hIcons); i++)
DestroyIcon(hIcons[i]);
hIml = (HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGELIST, 0, 0);
ImageList_Destroy(hIml);
diff --git a/plugins/KeyboardNotify/src/main.cpp b/plugins/KeyboardNotify/src/main.cpp index 860b03ae92..bf5a170972 100644 --- a/plugins/KeyboardNotify/src/main.cpp +++ b/plugins/KeyboardNotify/src/main.cpp @@ -26,10 +26,6 @@ #define NCONVERS_BLINKID ((HANDLE)123456) //nconvers' random identifier used to flash an icon for "incoming message" on contact list
-#ifndef SPI_GETSCREENSAVERRUNNING
-#define SPI_GETSCREENSAVERRUNNING 114
-#endif
-
#ifndef WM_XBUTTONDBLCLK
#define WM_XBUTTONDBLCLK 0x020D
#endif
@@ -109,7 +105,6 @@ BOOL bReminderDisabled = FALSE; char *szMetaProto = NULL;
BYTE bMetaProtoEnabled = 0;
-
PLUGININFOEX pluginInfo={
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
@@ -124,8 +119,6 @@ PLUGININFOEX pluginInfo={ {0x119d7288, 0x2050, 0x448d, {0x99, 0x00, 0xd8, 0x6a, 0xc7, 0x04, 0x26, 0xbf}}
};
-
-
int InitializeOptions(WPARAM,LPARAM);
void LoadSettings(void);
int HookWindowsHooks(void);
@@ -137,7 +130,6 @@ static LRESULT CALLBACK MirandaKeyBoardHookFunction(int, WPARAM, LPARAM); static LRESULT CALLBACK MirandaWndProcHookFunction(int, WPARAM, LPARAM);
BOOL CheckMsgWnd(HANDLE, BOOL *);
-
BOOL isMetaContactsSubContact(HANDLE hMetaContact, HANDLE hContact)
{
char *szProto = GetContactProto(hMetaContact);
@@ -149,7 +141,6 @@ BOOL isMetaContactsSubContact(HANDLE hMetaContact, HANDLE hContact) return FALSE;
}
-
BOOL checkOpenWindow(HANDLE hContact)
{
BOOL found, focus;
@@ -172,76 +163,27 @@ BOOL checkOpenWindow(HANDLE hContact) return FALSE;
}
-BOOL isScreenSaverRunning()
-{
- BOOL screenSaverIsRunning=FALSE;
-
- SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, &screenSaverIsRunning, FALSE);
- return screenSaverIsRunning;
-}
-
-
-/* this function is from the original idle module */
-BOOL isWorkstationLocked()
-{
- HDESK hd;
- char buf[MAX_PATH];
-
- hd = OpenInputDesktop(0, FALSE, MAXIMUM_ALLOWED); /* if it fails then the workstation is prolly locked anyway */
- if (hd == NULL) return TRUE;
- GetUserObjectInformation(hd, UOI_NAME, buf, sizeof(buf), NULL); /* if we got it (hmm,) get a name */
- CloseDesktop(hd);
- return strcmp(buf, "Winlogon")==0;
-}
-
-
-BOOL isFullScreen()
-{
- int w = GetSystemMetrics(SM_CXSCREEN);
- int h = GetSystemMetrics(SM_CYSCREEN);
-
- HWND hWnd = 0;
- while (hWnd = FindWindowEx(NULL, hWnd, NULL, NULL)) {
- RECT WindowRect;
-
- if (!(GetWindowLongPtr(hWnd, GWL_EXSTYLE) & WS_EX_TOPMOST))
- continue;
-
- GetWindowRect(hWnd, &WindowRect);
- if ((w != (WindowRect.right - WindowRect.left)) || (h != (WindowRect.bottom - WindowRect.top)))
- continue;
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-
BOOL checkNotifyOptions()
{
- BOOL fullScreenMode, screenSaverIsRunning, workstationIsLocked, processesRunning;
-
- screenSaverIsRunning = isScreenSaverRunning();
+ BOOL screenSaverIsRunning = IsScreenSaverRunning();
if (screenSaverIsRunning && bScreenSaverRunning)
- return TRUE;
+ return TRUE;
- workstationIsLocked = isWorkstationLocked();
+ BOOL workstationIsLocked = IsWorkstationLocked();
if (workstationIsLocked && bWorkstationLocked)
- return TRUE;
+ return TRUE;
- fullScreenMode = isFullScreen() && !screenSaverIsRunning;
+ BOOL fullScreenMode = IsFullScreen() && !screenSaverIsRunning;
if (fullScreenMode && bFullScreenMode)
- return TRUE;
+ return TRUE;
- processesRunning = areThereProcessesRunning();
+ BOOL processesRunning = areThereProcessesRunning();
if (processesRunning && bProcessesAreRunning)
- return TRUE;
+ return TRUE;
return (!fullScreenMode && !screenSaverIsRunning && !workstationIsLocked && !processesRunning && bWorkstationActive);
}
-
BOOL isStatusEnabled(int status)
{
switch (status) {
@@ -259,13 +201,11 @@ BOOL isStatusEnabled(int status) }
}
-
BOOL checkGlobalStatus()
{
return isStatusEnabled(CallService(MS_CLIST_GETSTATUSMODE, 0, 0));
}
-
BOOL checkGlobalXstatus()
{
int protosSupporting=0, status=0;
@@ -288,19 +228,15 @@ BOOL checkGlobalXstatus() return protosSupporting == 0;
}
-
DBEVENTINFO createMsgEventInfo(HANDLE hContact)
{
DBEVENTINFO einfo = {0};
-
einfo.cbSize = sizeof(einfo);
einfo.eventType = EVENTTYPE_MESSAGE;
einfo.szModule = GetContactProto(hContact);
-
return einfo;
}
-
DBEVENTINFO readEventInfo(HANDLE hDbEvent, HANDLE hContact)
{
if (hDbEvent == NCONVERS_BLINKID) // we need to handle nconvers' blink event
@@ -311,26 +247,23 @@ DBEVENTINFO readEventInfo(HANDLE hDbEvent, HANDLE hContact) return einfo;
}
-
BOOL checkIgnore(HANDLE hContact, WORD eventType)
{
return !IsIgnored(hContact, eventType);
}
-
BOOL checkProtocol(char *szProto)
{
if (!szProto)
return FALSE;
- for(int i=0; i < ProtoList.protoCount; i++)
+ for (int i=0; i < ProtoList.protoCount; i++)
if (ProtoList.protoInfo[i].szProto && !strcmp(ProtoList.protoInfo[i].szProto, szProto))
return ProtoList.protoInfo[i].enabled;
return FALSE;
}
-
BOOL metaCheckProtocol(char *szProto, HANDLE hContact, WORD eventType)
{
HANDLE hSubContact=NULL;
@@ -366,7 +299,6 @@ BOOL checkUnopenEvents() return FALSE;
}
-
static void FlashThreadFunction()
{
BOOL bEvent = FALSE;
@@ -485,7 +417,7 @@ BOOL checkXstatus(char *szProto) if (!szProto)
return checkGlobalXstatus();
- for(int i=0; i < ProtoList.protoCount; i++)
+ for (int i=0; i < ProtoList.protoCount; i++)
if (ProtoList.protoInfo[i].szProto && !strcmp(ProtoList.protoInfo[i].szProto, szProto)) {
if (!ProtoList.protoInfo[i].xstatus.count) return TRUE;
@@ -643,7 +575,7 @@ void createProcessList(void) ProcessList.count = 0;
ProcessList.szFileName = (TCHAR **)malloc(count * sizeof(TCHAR *));
if (ProcessList.szFileName) {
- for(i=0; i < count; i++)
+ for (i=0; i < count; i++)
if (db_get_ts(NULL, KEYBDMODULE, fmtDBSettingName("process%d", i), &dbv))
ProcessList.szFileName[i] = NULL;
else {
@@ -665,7 +597,7 @@ void destroyProcessList(void) count = ProcessList.count;
ProcessList.count = 0;
- for(i=0; i < count; i++)
+ for (i=0; i < count; i++)
if (ProcessList.szFileName[i])
free(ProcessList.szFileName[i]);
@@ -723,11 +655,11 @@ void LoadSettings(void) db_set_b(NULL, KEYBDMODULE, "testnum", DEF_SETTING_TESTNUM);
if (db_get_b(NULL, KEYBDMODULE, "testsecs", -1) == -1)
db_set_b(NULL, KEYBDMODULE, "testsecs", DEF_SETTING_TESTSECS);
- for(int i=0; i < ProtoList.protoCount; i++)
+ for (int i=0; i < ProtoList.protoCount; i++)
if (ProtoList.protoInfo[i].visible) {
unsigned int j;
ProtoList.protoInfo[i].enabled = db_get_b(NULL, KEYBDMODULE, ProtoList.protoInfo[i].szProto, DEF_SETTING_PROTOCOL);
- for(j=0; j < ProtoList.protoInfo[i].xstatus.count; j++)
+ for (j=0; j < ProtoList.protoInfo[i].xstatus.count; j++)
ProtoList.protoInfo[i].xstatus.enabled[j] = db_get_b(NULL, KEYBDMODULE, fmtDBSettingName("%sxstatus%d", ProtoList.protoInfo[i].szProto, j), DEF_SETTING_XSTATUS);
}
@@ -773,7 +705,7 @@ void updateXstatusProto(PROTOCOL_INFO *protoInfo) if (!protoInfo->xstatus.enabled)
protoInfo->xstatus.count = 0;
else
- for(unsigned i=0; i < protoInfo->xstatus.count; i++)
+ for (unsigned i=0; i < protoInfo->xstatus.count; i++)
protoInfo->xstatus.enabled[i] = FALSE;
}
@@ -792,7 +724,7 @@ void createProtocolList(void) return;
}
- for(int i=0; i < ProtoList.protoCount; i++) {
+ for (int i=0; i < ProtoList.protoCount; i++) {
ProtoList.protoInfo[i].xstatus.count = 0;
ProtoList.protoInfo[i].xstatus.enabled = NULL;
ProtoList.protoInfo[i].szProto = (char *)malloc(strlen(proto[i]->szModuleName) + 1);
@@ -899,7 +831,7 @@ extern "C" __declspec(dllexport) int Load(void) void destroyProtocolList(void)
{
- for(int i=0; i < ProtoList.protoCount; i++) {
+ for (int i=0; i < ProtoList.protoCount; i++) {
if (ProtoList.protoInfo[i].szProto)
free(ProtoList.protoInfo[i].szProto);
if (ProtoList.protoInfo[i].xstatus.enabled)
diff --git a/plugins/KeyboardNotify/src/options.cpp b/plugins/KeyboardNotify/src/options.cpp index d4d5d031bb..0f853b03e9 100644 --- a/plugins/KeyboardNotify/src/options.cpp +++ b/plugins/KeyboardNotify/src/options.cpp @@ -224,7 +224,7 @@ INT_PTR CALLBACK DlgProcProtoOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR lvItem.cchTextMax = 256;
lvItem.iItem = 0;
lvItem.iSubItem = 0;
- for(int i=0; i < ProtoList.protoCount; i++) {
+ for (int i=0; i < ProtoList.protoCount; i++) {
int count; PROTOACCOUNT** protos;
ProtoEnumAccounts( &count, &protos );
if(ProtoList.protoInfo[i].visible) {
@@ -519,7 +519,7 @@ INT_PTR CALLBACK DlgProcBasicOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (XstatusListAux)
for (int i = 0; i < ProtoList.protoCount; i++)
- for(int j = 0; j < (int)XstatusListAux[i].count; j++)
+ for (int j = 0; j < (int)XstatusListAux[i].count; j++)
db_set_b(NULL, KEYBDMODULE, fmtDBSettingName("%sxstatus%d", ProtoList.protoInfo[i].szProto, j), (BYTE)XstatusListAux[i].enabled[j]);
LoadSettings();
@@ -1211,7 +1211,7 @@ void createProcessListAux(void) void destroyProcessListAux(void)
{
- for(int i = 0; i < ProcessListAux.count; i++)
+ for (int i = 0; i < ProcessListAux.count; i++)
if (ProcessListAux.szFileName[i])
free(ProcessListAux.szFileName[i]);
@@ -1307,7 +1307,7 @@ void createXstatusListAux(void) if (!XstatusListAux[i].enabled)
XstatusListAux[i].count = 0;
else
- for(int j = 0; j < (int)XstatusListAux[i].count; j++)
+ for (int j = 0; j < (int)XstatusListAux[i].count; j++)
XstatusListAux[i].enabled[j] = ProtoList.protoInfo[i].xstatus.enabled[j];
}
}
@@ -1318,7 +1318,7 @@ void createXstatusListAux(void) void destroyXstatusListAux(void)
{
if (XstatusListAux) {
- for(int i = 0; i < ProtoList.protoCount; i++)
+ for (int i = 0; i < ProtoList.protoCount; i++)
if (XstatusListAux[i].enabled)
free(XstatusListAux[i].enabled);
free(XstatusListAux);
@@ -1382,7 +1382,7 @@ INT_PTR CALLBACK DlgProcXstatusList(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA tvis.item.iImage = tvis.item.iSelectedImage = ImageList_AddIcon(hImageList, hIconAux=(HICON)CallProtoService(ProtoList.protoInfo[i].szProto, PS_LOADICON, PLI_PROTOCOL, 0));
if (hIconAux) DestroyIcon(hIconAux);
hParent = TreeView_InsertItem(hwndTree, &tvis);
- for(j = 0; j < XstatusListAux[i].count; j++) {
+ for (j = 0; j < XstatusListAux[i].count; j++) {
tvis.hParent = hParent;
tvis.item.mask = TVIF_TEXT|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
if (!j){
diff --git a/plugins/Scriver/src/msgwindow.cpp b/plugins/Scriver/src/msgwindow.cpp index abe6b0ac84..89df28fcc6 100644 --- a/plugins/Scriver/src/msgwindow.cpp +++ b/plugins/Scriver/src/msgwindow.cpp @@ -1136,7 +1136,7 @@ static void DrawTab(ParentWindowData *dat, HWND hwnd, WPARAM wParam, LPARAM lPar TCITEM tci;
LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT) lParam;
int iTabIndex = lpDIS->itemID;
- tcdat = (TabCtrlData *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ tcdat = (TabCtrlData*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (iTabIndex >= 0) {
HANDLE hTheme = NULL;
int tstate;
@@ -1247,30 +1247,29 @@ static void DrawTab(ParentWindowData *dat, HWND hwnd, WPARAM wParam, LPARAM lPar LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- TabCtrlData *dat;
- dat = (TabCtrlData *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ TabCtrlData *dat = (TabCtrlData*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+
switch(msg) {
- case EM_SUBCLASSED:
- dat = (TabCtrlData *) mir_alloc(sizeof(TabCtrlData));
- SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) dat);
- dat->bDragging = FALSE;
- dat->bDragged = FALSE;
- dat->srcTab = -1;
- dat->destTab = -1;
- return 0;
- case WM_MBUTTONDOWN:
+ case EM_SUBCLASSED:
+ dat = (TabCtrlData*)mir_alloc(sizeof(TabCtrlData));
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) dat);
+ dat->bDragging = FALSE;
+ dat->bDragged = FALSE;
+ dat->srcTab = -1;
+ dat->destTab = -1;
+ return 0;
+
+ case WM_MBUTTONDOWN:
{
- TCITEM tci;
- int tabId;
- MessageWindowTabData *mwtd;
TCHITTESTINFO thinfo;
thinfo.pt.x = LOWORD(lParam);
thinfo.pt.y = HIWORD(lParam);
- tabId = TabCtrl_HitTest(hwnd, &thinfo);
+ int tabId = TabCtrl_HitTest(hwnd, &thinfo);
if (tabId >= 0) {
+ TCITEM tci;
tci.mask = TCIF_PARAM;
TabCtrl_GetItem(hwnd, tabId, &tci);
- mwtd = (MessageWindowTabData *) tci.lParam;
+ MessageWindowTabData *mwtd = (MessageWindowTabData *) tci.lParam;
if (mwtd != NULL) {
SendMessage(mwtd->hwnd, WM_CLOSE, 0, 0);
dat->srcTab = -1;
@@ -1278,13 +1277,12 @@ LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) }
return 0;
}
- case WM_LBUTTONDBLCLK:
+ case WM_LBUTTONDBLCLK:
{
TCHITTESTINFO thinfo;
- int tabId;
thinfo.pt.x = LOWORD(lParam);
thinfo.pt.y = HIWORD(lParam);
- tabId = TabCtrl_HitTest(hwnd, &thinfo);
+ int tabId = TabCtrl_HitTest(hwnd, &thinfo);
if (tabId >=0 && tabId == dat->srcTab) {
SendMessage(GetChildFromTab(hwnd, tabId)->hwnd, WM_CLOSE, 0, 0);
dat->srcTab = -1;
@@ -1292,284 +1290,277 @@ LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) dat->destTab = -1;
}
break;
- case WM_LBUTTONDOWN:
- if (!dat->bDragging) {
- TCHITTESTINFO thinfo;
- FILETIME ft;
- thinfo.pt.x = LOWORD(lParam);
- thinfo.pt.y = HIWORD(lParam);
- dat->srcTab = TabCtrl_HitTest(hwnd, &thinfo);
- GetSystemTimeAsFileTime(&ft);
- if (dat->srcTab >=0 ) {
- dat->bDragging = TRUE;
- dat->bDragged = FALSE;
- dat->clickLParam = lParam;
- dat->clickWParam = wParam;
- dat->lastClickTime = ft.dwLowDateTime;
- dat->mouseLBDownPos.x = thinfo.pt.x;
- dat->mouseLBDownPos.y = thinfo.pt.y;
- SetCapture(hwnd);
+ case WM_LBUTTONDOWN:
+ if (!dat->bDragging) {
+ TCHITTESTINFO thinfo;
+ thinfo.pt.x = LOWORD(lParam);
+ thinfo.pt.y = HIWORD(lParam);
+ dat->srcTab = TabCtrl_HitTest(hwnd, &thinfo);
+
+ FILETIME ft;
+ GetSystemTimeAsFileTime(&ft);
+ if (dat->srcTab >= 0) {
+ dat->bDragging = TRUE;
+ dat->bDragged = FALSE;
+ dat->clickLParam = lParam;
+ dat->clickWParam = wParam;
+ dat->lastClickTime = ft.dwLowDateTime;
+ dat->mouseLBDownPos.x = thinfo.pt.x;
+ dat->mouseLBDownPos.y = thinfo.pt.y;
+ SetCapture(hwnd);
+ }
+ return 0;
+ }
+ break;
+ case WM_CAPTURECHANGED:
+ case WM_LBUTTONUP:
+ if (dat->bDragging) {
+ TCHITTESTINFO thinfo;
+ thinfo.pt.x = LOWORD(lParam);
+ thinfo.pt.y = HIWORD(lParam);
+ if (dat->bDragged) {
+ ImageList_DragLeave(GetDesktopWindow());
+ ImageList_EndDrag();
+ ImageList_Destroy(dat->hDragImageList);
+ SetCursor(LoadCursor(NULL, IDC_ARROW));
+ dat->destTab = TabCtrl_HitTest(hwnd, &thinfo);
+ if (thinfo.flags != TCHT_NOWHERE && dat->destTab != dat->srcTab) {
+ NMHDR nmh;
+ TCHAR sBuffer[501];
+ TCITEM item;
+ int curSel;
+ curSel = TabCtrl_GetCurSel(hwnd);
+ item.mask = TCIF_IMAGE | TCIF_PARAM | TCIF_TEXT;
+ item.pszText = sBuffer;
+ item.cchTextMax = SIZEOF(sBuffer);
+ TabCtrl_GetItem(hwnd, dat->srcTab, &item);
+ sBuffer[SIZEOF(sBuffer)-1] = '\0';
+
+ if (curSel == dat->srcTab)
+ curSel = dat->destTab;
+ else if (curSel > dat->srcTab && curSel <= dat->destTab)
+ curSel--;
+ else if (curSel < dat->srcTab && curSel >= dat->destTab)
+ curSel++;
+
+ TabCtrl_DeleteItem(hwnd, dat->srcTab);
+ TabCtrl_InsertItem(hwnd, dat->destTab, &item );
+ TabCtrl_SetCurSel(hwnd, curSel);
+ dat->destTab = -1;
+ nmh.hwndFrom = hwnd;
+ nmh.idFrom = GetDlgCtrlID(hwnd);
+ nmh.code = TCN_SELCHANGE;
+ SendMessage(GetParent(hwnd), WM_NOTIFY, nmh.idFrom, (LPARAM)&nmh);
+ UpdateWindow(hwnd);
+ }
+ else if (thinfo.flags == TCHT_NOWHERE) {
+ TCITEM tci;
+ POINT pt;
+ NewMessageWindowLParam newData = { 0 };
+ dat->destTab = -1;
+ tci.mask = TCIF_PARAM;
+ TabCtrl_GetItem(hwnd, dat->srcTab, &tci);
+ MessageWindowTabData *mwtd = (MessageWindowTabData *) tci.lParam;
+ if (mwtd != NULL) {
+ HWND hChild = mwtd->hwnd;
+ HANDLE hContact = mwtd->hContact;
+ GetCursorPos(&pt);
+ HWND hParent = WindowFromPoint(pt);
+ while (GetParent(hParent) != NULL)
+ hParent = GetParent(hParent);
+
+ hParent = WindowList_Find(g_dat.hParentWindowList, hParent);
+ if ((hParent != NULL && hParent != GetParent(hwnd)) || (hParent == NULL && mwtd->parent->childrenCount > 1 && (GetKeyState(VK_CONTROL) & 0x8000))) {
+ if (hParent == NULL) {
+ RECT rc, rcDesktop;
+ newData.hContact = hContact;
+ hParent = (HWND)CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSGWIN), NULL, DlgProcParentWindow, (LPARAM)& newData);
+ GetWindowRect(hParent, &rc);
+ rc.right = (rc.right - rc.left);
+ rc.bottom = (rc.bottom - rc.top);
+ rc.left = pt.x - rc.right / 2;
+ rc.top = pt.y - rc.bottom / 2;
+ HMONITOR hMonitor = MonitorFromRect(&rc, MONITOR_DEFAULTTONEAREST);
+ MONITORINFO mi;
+ mi.cbSize = sizeof(mi);
+ GetMonitorInfo(hMonitor, &mi);
+ rcDesktop = mi.rcWork;
+ if (rc.left < rcDesktop.left)
+ rc.left = rcDesktop.left;
+ if (rc.top < rcDesktop.top)
+ rc.top = rcDesktop.top;
+ MoveWindow(hParent, rc.left, rc.top, rc.right, rc.bottom, FALSE);
+ }
+ NotifyLocalWinEvent(hContact, hChild, MSG_WINDOW_EVT_CLOSING);
+ NotifyLocalWinEvent(hContact, hChild, MSG_WINDOW_EVT_CLOSE);
+ SetParent(hChild, hParent);
+ SendMessage(GetParent(hwnd), CM_REMOVECHILD, 0, (LPARAM)hChild);
+ SendMessage(hChild, DM_SETPARENT, 0, (LPARAM)hParent);
+ SendMessage(hParent, CM_ADDCHILD, (WPARAM)hChild, (LPARAM)hContact);
+ SendMessage(hChild, DM_UPDATETABCONTROL, 0, 0);
+ SendMessage(hParent, CM_ACTIVATECHILD, 0, (LPARAM)hChild);
+ NotifyLocalWinEvent(hContact, hChild, MSG_WINDOW_EVT_OPENING);
+ NotifyLocalWinEvent(hContact, hChild, MSG_WINDOW_EVT_OPEN);
+ ShowWindow(hParent, SW_SHOWNA);
+ EnableWindow(hParent, TRUE);
+ }
+ }
+ }
+ else {
+ dat->destTab = -1;
+ RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
}
- return 0;
}
- break;
- case WM_CAPTURECHANGED:
- case WM_LBUTTONUP:
+ else if (dat->srcTab >= 0 && g_dat.flags2 & SMF2_TABCLOSEBUTTON) {
+ IMAGEINFO info;
+ POINT pt;
+ RECT rect;
+ int atTop = (GetWindowLongPtr(hwnd, GWL_STYLE) & TCS_BOTTOM) == 0;
+ TabCtrl_GetItemRect(hwnd, dat->srcTab, &rect);
+ pt.x = LOWORD(lParam);
+ pt.y = HIWORD(lParam);
+ ImageList_GetImageInfo(g_dat.hButtonIconList, 0, &info);
+ rect.left = rect.right - (info.rcImage.right - info.rcImage.left) - 6;
+ if (!atTop)
+ rect.top = rect.bottom - (info.rcImage.bottom - info.rcImage.top);
+
+ if (pt.x >= rect.left && pt.x < rect.left + (info.rcImage.right - info.rcImage.left) && pt.y >= rect.top && pt.y < rect.top + (info.rcImage.bottom - info.rcImage.top)) {
+ HBITMAP hOldBitmap, hBmp;
+ HDC hdc = GetDC(NULL);
+ HDC hdcMem = CreateCompatibleDC(hdc);
+ pt.x -= rect.left;
+ pt.y -= rect.top;
+ hBmp = CreateCompatibleBitmap(hdc, info.rcImage.right - info.rcImage.left + 1, info.rcImage.bottom - info.rcImage.top + 1);
+ hOldBitmap = (HBITMAP)SelectObject(hdcMem, hBmp);
+ SetPixel(hdcMem, pt.x, pt.y, 0x000000);
+ ImageList_DrawEx(g_dat.hButtonIconList, 0, hdcMem, 0, 0, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
+ COLORREF color1 = GetPixel(hdcMem, pt.x, pt.y);
+ SetPixel(hdcMem, pt.x, pt.y, 0xFFFFFF);
+ ImageList_DrawEx(g_dat.hButtonIconList, 0, hdcMem, 0, 0, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
+ COLORREF color2 = GetPixel(hdcMem, pt.x, pt.y);
+ SelectObject(hdcMem, hOldBitmap);
+ DeleteDC(hdcMem);
+ DeleteObject(hBmp);
+ ReleaseDC(NULL, hdc);
+ if (color1 != 0x000000 || color2 != 0xFFFFFF) {
+ SendMessage(GetChildFromTab(hwnd, dat->srcTab)->hwnd, WM_CLOSE, 0, 0);
+ dat->srcTab = -1;
+ }
+ }
+ else SendMessage(hwnd, WM_LBUTTONDOWN, dat->clickWParam, dat->clickLParam);
+ }
+ else SendMessage(hwnd, WM_LBUTTONDOWN, dat->clickWParam, dat->clickLParam);
+
+ dat->bDragged = FALSE;
+ dat->bDragging = FALSE;
+ dat->destTab = -1;
+ ReleaseCapture();
+ }
+ break;
+ case WM_MOUSEMOVE:
+ if (wParam & MK_LBUTTON) {
if (dat->bDragging) {
+ FILETIME ft;
TCHITTESTINFO thinfo;
+ GetSystemTimeAsFileTime(&ft);
thinfo.pt.x = LOWORD(lParam);
thinfo.pt.y = HIWORD(lParam);
- if (dat->bDragged) {
- ImageList_DragLeave(GetDesktopWindow());
- ImageList_EndDrag();
- ImageList_Destroy(dat->hDragImageList);
- SetCursor(LoadCursor(NULL, IDC_ARROW));
- dat->destTab = TabCtrl_HitTest(hwnd, &thinfo);
- if (thinfo.flags != TCHT_NOWHERE && dat->destTab != dat->srcTab) {
- NMHDR nmh;
- TCHAR sBuffer[501];
- TCITEM item;
- int curSel;
- curSel = TabCtrl_GetCurSel(hwnd);
- item.mask = TCIF_IMAGE | TCIF_PARAM | TCIF_TEXT;
- item.pszText = sBuffer;
- item.cchTextMax = SIZEOF(sBuffer);
- TabCtrl_GetItem(hwnd, dat->srcTab, &item);
- sBuffer[SIZEOF(sBuffer)-1] = '\0';
- if (curSel == dat->srcTab) {
- curSel = dat->destTab;
- } else {
- if (curSel > dat->srcTab && curSel <= dat->destTab) {
- curSel--;
- } else if (curSel < dat->srcTab && curSel >= dat->destTab) {
- curSel++;
- }
- }
- TabCtrl_DeleteItem(hwnd, dat->srcTab);
- TabCtrl_InsertItem(hwnd, dat->destTab, &item );
- TabCtrl_SetCurSel(hwnd, curSel);
- dat->destTab = -1;
- nmh.hwndFrom = hwnd;
- nmh.idFrom = GetDlgCtrlID(hwnd);
- nmh.code = TCN_SELCHANGE;
- SendMessage(GetParent(hwnd), WM_NOTIFY, nmh.idFrom, (LPARAM)&nmh);
- UpdateWindow(hwnd);
- } else if (thinfo.flags == TCHT_NOWHERE) {
- MessageWindowTabData *mwtd;
- TCITEM tci;
- POINT pt;
- NewMessageWindowLParam newData = { 0 };
- dat->destTab = -1;
- tci.mask = TCIF_PARAM;
- TabCtrl_GetItem(hwnd, dat->srcTab, &tci);
- mwtd = (MessageWindowTabData *) tci.lParam;
- if (mwtd != NULL) {
- HWND hChild = mwtd->hwnd;
- HANDLE hContact = mwtd->hContact;
- HWND hParent;
- GetCursorPos(&pt);
- hParent = WindowFromPoint(pt);
- while (GetParent(hParent) != NULL) {
- hParent = GetParent(hParent);
- }
- hParent = WindowList_Find(g_dat.hParentWindowList, hParent);
- if ((hParent != NULL && hParent != GetParent(hwnd)) || (hParent == NULL && mwtd->parent->childrenCount > 1 && (GetKeyState(VK_CONTROL) & 0x8000))) {
- if (hParent == NULL) {
- MONITORINFO mi;
- HMONITOR hMonitor;
- RECT rc, rcDesktop;
- newData.hContact = hContact;
- hParent = (HWND)CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSGWIN), NULL, DlgProcParentWindow, (LPARAM)& newData);
- GetWindowRect(hParent, &rc);
- rc.right = (rc.right - rc.left);
- rc.bottom = (rc.bottom - rc.top);
- rc.left = pt.x - rc.right / 2;
- rc.top = pt.y - rc.bottom / 2;
- hMonitor = MonitorFromRect(&rc, MONITOR_DEFAULTTONEAREST);
- mi.cbSize = sizeof(mi);
- GetMonitorInfo(hMonitor, &mi);
- rcDesktop = mi.rcWork;
- if (rc.left < rcDesktop.left) {
- rc.left = rcDesktop.left;
- }
- if (rc.top < rcDesktop.top) {
- rc.top = rcDesktop.top;
- }
- MoveWindow(hParent, rc.left, rc.top, rc.right, rc.bottom, FALSE);
-
- }
- NotifyLocalWinEvent(hContact, hChild, MSG_WINDOW_EVT_CLOSING);
- NotifyLocalWinEvent(hContact, hChild, MSG_WINDOW_EVT_CLOSE);
- SetParent(hChild, hParent);
- SendMessage(GetParent(hwnd), CM_REMOVECHILD, 0, (LPARAM)hChild);
- SendMessage(hChild, DM_SETPARENT, 0, (LPARAM)hParent);
- SendMessage(hParent, CM_ADDCHILD, (WPARAM)hChild, (LPARAM)hContact);
- SendMessage(hChild, DM_UPDATETABCONTROL, 0, 0);
- SendMessage(hParent, CM_ACTIVATECHILD, 0, (LPARAM)hChild);
- NotifyLocalWinEvent(hContact, hChild, MSG_WINDOW_EVT_OPENING);
- NotifyLocalWinEvent(hContact, hChild, MSG_WINDOW_EVT_OPEN);
- ShowWindow(hParent, SW_SHOWNA);
- EnableWindow(hParent, TRUE);
- }
- }
- } else {
- dat->destTab = -1;
- RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
- }
- } else if (dat->srcTab >= 0 && g_dat.flags2 & SMF2_TABCLOSEBUTTON) {
- IMAGEINFO info;
+ if (!dat->bDragged) {
+ if ((abs(thinfo.pt.x-dat->mouseLBDownPos.x)<3 && abs(thinfo.pt.y-dat->mouseLBDownPos.y)<3)
+ || (ft.dwLowDateTime - dat->lastClickTime) < 10*1000*150)
+ break;
+ }
+ if (!dat->bDragged) {
POINT pt;
RECT rect;
- int atTop = (GetWindowLongPtr(hwnd, GWL_STYLE) & TCS_BOTTOM) == 0;
+ RECT rect2;
+ HBRUSH hBrush = CreateSolidBrush(RGB(255,0,254));
+ GetCursorPos(&pt);
TabCtrl_GetItemRect(hwnd, dat->srcTab, &rect);
- pt.x = LOWORD(lParam);
- pt.y = HIWORD(lParam);
- ImageList_GetImageInfo(g_dat.hButtonIconList, 0, &info);
- rect.left = rect.right - (info.rcImage.right - info.rcImage.left) - 6;
- if (!atTop) {
- rect.top = rect.bottom - (info.rcImage.bottom - info.rcImage.top);
- }
- if (pt.x >= rect.left && pt.x < rect.left + (info.rcImage.right - info.rcImage.left) && pt.y >= rect.top && pt.y < rect.top + (info.rcImage.bottom - info.rcImage.top)) {
- HBITMAP hOldBitmap, hBmp;
- COLORREF color1, color2;
- HDC hdc = GetDC(NULL);
- HDC hdcMem = CreateCompatibleDC(hdc);
- pt.x -= rect.left;
- pt.y -= rect.top;
- hBmp = CreateCompatibleBitmap(hdc, info.rcImage.right - info.rcImage.left + 1, info.rcImage.bottom - info.rcImage.top + 1);
- hOldBitmap = (HBITMAP)SelectObject(hdcMem, hBmp);
- SetPixel(hdcMem, pt.x, pt.y, 0x000000);
- ImageList_DrawEx(g_dat.hButtonIconList, 0, hdcMem, 0, 0, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
- color1 = GetPixel(hdcMem, pt.x, pt.y);
- SetPixel(hdcMem, pt.x, pt.y, 0xFFFFFF);
- ImageList_DrawEx(g_dat.hButtonIconList, 0, hdcMem, 0, 0, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
- color2 = GetPixel(hdcMem, pt.x, pt.y);
- SelectObject(hdcMem, hOldBitmap);
- DeleteDC(hdcMem);
- DeleteObject(hBmp);
- ReleaseDC(NULL, hdc);
- if (color1 != 0x000000 || color2 != 0xFFFFFF) {
- SendMessage(GetChildFromTab(hwnd, dat->srcTab)->hwnd, WM_CLOSE, 0, 0);
- dat->srcTab = -1;
- }
- } else {
- SendMessage(hwnd, WM_LBUTTONDOWN, dat->clickWParam, dat->clickLParam);
- }
- } else {
- SendMessage(hwnd, WM_LBUTTONDOWN, dat->clickWParam, dat->clickLParam);
+ rect.right -= rect.left-1;
+ rect.bottom -= rect.top-1;
+ rect2.left = 0; rect2.right = rect.right; rect2.top = 0; rect2.bottom = rect.bottom;
+ dat->hDragImageList = ImageList_Create(rect.right, rect.bottom, ILC_COLOR | ILC_MASK, 0, 1);
+ HDC hDC = GetDC(hwnd);
+ HDC hMemDC = CreateCompatibleDC(hDC);
+ HBITMAP hBitmap = CreateCompatibleBitmap(hDC, rect.right, rect.bottom);
+ HBITMAP hOldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap);
+ FillRect(hMemDC, &rect2, hBrush);
+ SetWindowOrgEx (hMemDC, rect.left, rect.top, NULL);
+ SendMessage(hwnd, WM_PRINTCLIENT, (WPARAM)hMemDC, PRF_CLIENT);
+ SelectObject(hMemDC, hOldBitmap);
+ ImageList_AddMasked(dat->hDragImageList, hBitmap, RGB(255,0,254));
+ DeleteObject(hBitmap);
+ DeleteObject(hBrush);
+ ReleaseDC(hwnd, hDC);
+ DeleteDC(hMemDC);
+ ImageList_BeginDrag(dat->hDragImageList, 0, dat->mouseLBDownPos.x - rect.left, dat->mouseLBDownPos.y - rect.top);
+ ImageList_DragEnter(GetDesktopWindow(), pt.x, pt.y);
+ SetCursor(hDragCursor);
+ dat->mouseLBDownPos.x = thinfo.pt.x;
+ dat->mouseLBDownPos.y = thinfo.pt.y;
}
- dat->bDragged = FALSE;
- dat->bDragging = FALSE;
- dat->destTab = -1;
- ReleaseCapture();
- }
- break;
- case WM_MOUSEMOVE:
- if (wParam & MK_LBUTTON) {
- if (dat->bDragging) {
- FILETIME ft;
+ else {
TCHITTESTINFO thinfo;
- GetSystemTimeAsFileTime(&ft);
- thinfo.pt.x = LOWORD(lParam);
- thinfo.pt.y = HIWORD(lParam);
- if (!dat->bDragged) {
- if ((abs(thinfo.pt.x-dat->mouseLBDownPos.x)<3 && abs(thinfo.pt.y-dat->mouseLBDownPos.y)<3)
- || (ft.dwLowDateTime - dat->lastClickTime) < 10*1000*150)
- break;
- }
- if (!dat->bDragged) {
- POINT pt;
- RECT rect;
- RECT rect2;
- HDC hDC, hMemDC;
- HBITMAP hBitmap, hOldBitmap;
- HBRUSH hBrush = CreateSolidBrush(RGB(255,0,254));
- GetCursorPos(&pt);
- TabCtrl_GetItemRect(hwnd, dat->srcTab, &rect);
- rect.right -= rect.left-1;
- rect.bottom -= rect.top-1;
- rect2.left = 0; rect2.right = rect.right; rect2.top = 0; rect2.bottom = rect.bottom;
- dat->hDragImageList = ImageList_Create(rect.right, rect.bottom, ILC_COLOR | ILC_MASK, 0, 1);
- hDC = GetDC(hwnd);
- hMemDC = CreateCompatibleDC(hDC);
- hBitmap = CreateCompatibleBitmap(hDC, rect.right, rect.bottom);
- hOldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap);
- FillRect(hMemDC, &rect2, hBrush);
- SetWindowOrgEx (hMemDC, rect.left, rect.top, NULL);
- SendMessage(hwnd, WM_PRINTCLIENT, (WPARAM)hMemDC, PRF_CLIENT);
- SelectObject(hMemDC, hOldBitmap);
- ImageList_AddMasked(dat->hDragImageList, hBitmap, RGB(255,0,254));
- DeleteObject(hBitmap);
- DeleteObject(hBrush);
- ReleaseDC(hwnd, hDC);
- DeleteDC(hMemDC);
- ImageList_BeginDrag(dat->hDragImageList, 0, dat->mouseLBDownPos.x - rect.left, dat->mouseLBDownPos.y - rect.top);
+ POINT pt;
+ GetCursorPos(&pt);
+ thinfo.pt = pt;
+ ScreenToClient(hwnd, &thinfo.pt);
+ int newDest = TabCtrl_HitTest(hwnd, &thinfo);
+ if (thinfo.flags == TCHT_NOWHERE)
+ newDest = -1;
+
+ if (newDest != dat->destTab) {
+ dat->destTab = newDest;
+ ImageList_DragLeave(GetDesktopWindow());
+ RedrawWindow(hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW);
ImageList_DragEnter(GetDesktopWindow(), pt.x, pt.y);
- SetCursor(hDragCursor);
- dat->mouseLBDownPos.x = thinfo.pt.x;
- dat->mouseLBDownPos.y = thinfo.pt.y;
- } else {
- TCHITTESTINFO thinfo;
- POINT pt;
- int newDest;
- GetCursorPos(&pt);
- thinfo.pt = pt;
- ScreenToClient(hwnd, &thinfo.pt);
- newDest = TabCtrl_HitTest(hwnd, &thinfo);
- if (thinfo.flags == TCHT_NOWHERE) {
- newDest = -1;
- }
- if (newDest != dat->destTab) {
- dat->destTab = newDest;
- ImageList_DragLeave(GetDesktopWindow());
- RedrawWindow(hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW);
- ImageList_DragEnter(GetDesktopWindow(), pt.x, pt.y);
- } else {
- ImageList_DragMove(pt.x, pt.y);
- }
}
- dat->bDragged = TRUE;
- return 0;
+ else ImageList_DragMove(pt.x, pt.y);
}
+ dat->bDragged = TRUE;
+ return 0;
}
- break;
- case EM_UNSUBCLASSED:
- mir_free(dat);
- return 0;
+ }
+ break;
+
+ case EM_UNSUBCLASSED:
+ mir_free(dat);
+ return 0;
}
return mir_callNextSubclass(hwnd, TabCtrlProc, msg, wParam, lParam);
}
-int ScriverRestoreWindowPosition(HWND hwnd,HANDLE hContact,const char *szModule,const char *szNamePrefix, int flags, int showCmd)
+int ScriverRestoreWindowPosition(HWND hwnd, HANDLE hContact, const char *szModule,const char *szNamePrefix, int flags, int showCmd)
{
RECT rcDesktop;
WINDOWPLACEMENT wp;
+ wp.length = sizeof(wp);
+ GetWindowPlacement(hwnd, &wp);
+
char szSettingName[64];
- int x,y;
- MONITORINFO mi;
- HMONITOR hMonitor;
-// SystemParametersInfo(SPI_GETWORKAREA, 0, &rcDesktop, 0);
- wp.length=sizeof(wp);
- GetWindowPlacement(hwnd,&wp);
mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sx", szNamePrefix);
- x=db_get_dw(hContact,szModule,szSettingName,-1);
+ int x = db_get_dw(hContact,szModule,szSettingName,-1);
mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sy", szNamePrefix);
- y=(int)db_get_dw(hContact,szModule,szSettingName,-1);
- if (x==-1) return 1;
- if (flags&RWPF_NOSIZE) {
+ int y = db_get_dw(hContact,szModule,szSettingName,-1);
+ if (x == -1)
+ return 1;
+
+ if (flags & RWPF_NOSIZE)
OffsetRect(&wp.rcNormalPosition,x-wp.rcNormalPosition.left,y-wp.rcNormalPosition.top);
- } else {
- wp.rcNormalPosition.left=x;
- wp.rcNormalPosition.top=y;
+ else {
+ wp.rcNormalPosition.left = x;
+ wp.rcNormalPosition.top = y;
mir_snprintf(szSettingName, SIZEOF(szSettingName), "%swidth", szNamePrefix);
- wp.rcNormalPosition.right=wp.rcNormalPosition.left+db_get_dw(hContact,szModule,szSettingName,-1);
+ wp.rcNormalPosition.right = wp.rcNormalPosition.left + db_get_dw(hContact,szModule,szSettingName,-1);
mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sheight", szNamePrefix);
- wp.rcNormalPosition.bottom=wp.rcNormalPosition.top+db_get_dw(hContact,szModule,szSettingName,-1);
+ wp.rcNormalPosition.bottom = wp.rcNormalPosition.top + db_get_dw(hContact,szModule,szSettingName,-1);
}
- wp.flags=0;
+ wp.flags = 0;
wp.showCmd = showCmd;
- hMonitor = MonitorFromRect(&wp.rcNormalPosition, MONITOR_DEFAULTTONEAREST);
+ HMONITOR hMonitor = MonitorFromRect(&wp.rcNormalPosition, MONITOR_DEFAULTTONEAREST);
+ MONITORINFO mi;
mi.cbSize = sizeof(mi);
GetMonitorInfo(hMonitor, &mi);
rcDesktop = mi.rcWork;
@@ -1586,22 +1577,22 @@ HWND GetParentWindow(HANDLE hContact, BOOL bChat) { if (g_dat.flags2 & SMF2_USETABS) {
if (!bChat || !(g_dat.flags2 & SMF2_SEPARATECHATSCONTAINERS)) {
if (g_dat.lastParent != NULL) {
- int tabsNum = (int) SendMessage(g_dat.lastParent->hwnd, CM_GETCHILDCOUNT, 0, 0);
- if (!(g_dat.flags2 & SMF2_LIMITTABS) || tabsNum < g_dat.limitTabsNum) {
+ int tabsNum = (int)SendMessage(g_dat.lastParent->hwnd, CM_GETCHILDCOUNT, 0, 0);
+ if (!(g_dat.flags2 & SMF2_LIMITTABS) || tabsNum < g_dat.limitTabsNum)
return g_dat.lastParent->hwnd;
- }
}
- } else {
+ }
+ else {
if (g_dat.lastChatParent != NULL) {
- int tabsNum = (int) SendMessage(g_dat.lastChatParent->hwnd, CM_GETCHILDCOUNT, 0, 0);
+ int tabsNum = (int)SendMessage(g_dat.lastChatParent->hwnd, CM_GETCHILDCOUNT, 0, 0);
if (!(g_dat.flags2 & SMF2_LIMITCHATSTABS) || tabsNum < g_dat.limitChatsTabsNum) {
return g_dat.lastChatParent->hwnd;
}
}
}
}
- if (!(g_dat.flags2 & SMF2_SEPARATECHATSCONTAINERS)) {
- newData.isChat =FALSE;
- }
+ if ( !(g_dat.flags2 & SMF2_SEPARATECHATSCONTAINERS))
+ newData.isChat = FALSE;
+
return CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSGWIN), NULL, DlgProcParentWindow, (LPARAM)& newData);
}
diff --git a/plugins/SimpleStatusMsg/src/main.cpp b/plugins/SimpleStatusMsg/src/main.cpp index caa4505ea2..ef0abee184 100644 --- a/plugins/SimpleStatusMsg/src/main.cpp +++ b/plugins/SimpleStatusMsg/src/main.cpp @@ -1004,25 +1004,21 @@ INT_PTR ShowStatusMessageDialog(WPARAM wParam, LPARAM lParam) static int ChangeStatusMessage(WPARAM wParam, LPARAM lParam)
{
+ if (Miranda_Terminated())
+ return 0;
+
int iStatus = (int)wParam;
char *szProto = (char*)lParam;
- int iDlgFlags;
- BOOL bShowDlg, bOnStartup = FALSE, bGlobalStartupStatus = TRUE, bScreenSaverRunning = FALSE;
- char szSetting[80];
-
- if (Miranda_Terminated()) return 0;
// TODO this could be done better
- if (szProto && !strcmp(szProto, "SimpleStatusMsgGlobalStartupStatus"))
- {
+ BOOL bOnStartup = FALSE, bGlobalStartupStatus = TRUE;
+ if (szProto && !strcmp(szProto, "SimpleStatusMsgGlobalStartupStatus")) {
szProto = NULL;
bOnStartup = TRUE;
}
- if (accounts->statusMsgCount == 1 && !szProto)
- {
- for (int i = 0; i < accounts->count; ++i)
- {
+ if (accounts->statusMsgCount == 1 && !szProto) {
+ for (int i = 0; i < accounts->count; ++i) {
if (!IsAccountEnabled(accounts->pa[i]))
continue;
@@ -1033,8 +1029,7 @@ static int ChangeStatusMessage(WPARAM wParam, LPARAM lParam) continue;
szProto = accounts->pa[i]->szModuleName;
- if (bOnStartup && iStatus == ID_STATUS_CURRENT)
- {
+ if (bOnStartup && iStatus == ID_STATUS_CURRENT) {
iStatus = GetStartupStatus(accounts->pa[i]->szModuleName);
bGlobalStartupStatus = FALSE;
}
@@ -1042,13 +1037,14 @@ static int ChangeStatusMessage(WPARAM wParam, LPARAM lParam) }
}
+ char szSetting[80];
mir_snprintf(szSetting, SIZEOF(szSetting), "%sFlags", szProto ? szProto : "");
- iDlgFlags = db_get_b(NULL, "SimpleStatusMsg", (char *)StatusModeToDbSetting(iStatus, szSetting), STATUS_DEFAULT);
- bShowDlg = iDlgFlags & STATUS_SHOW_DLG || bOnStartup;
- SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, &bScreenSaverRunning, 0);
+ int iDlgFlags = db_get_b(NULL, "SimpleStatusMsg", (char *)StatusModeToDbSetting(iStatus, szSetting), STATUS_DEFAULT);
- if (szProto)
- {
+ BOOL bShowDlg = iDlgFlags & STATUS_SHOW_DLG || bOnStartup;
+ BOOL bScreenSaverRunning = IsScreenSaverRunning();
+
+ if (szProto) {
struct MsgBoxInitData *box_data;
int status_modes = 0, status_modes_msg = 0, iProtoFlags;
@@ -1057,10 +1053,8 @@ static int ChangeStatusMessage(WPARAM wParam, LPARAM lParam) return 0;
status_modes_msg = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0);
- if (!(Proto_Status2Flag(iStatus) & status_modes_msg) || !(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND))
- {
- if (bOnStartup && GetCurrentStatus(szProto) != iStatus)
- {
+ if (!(Proto_Status2Flag(iStatus) & status_modes_msg) || !(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)) {
+ if (bOnStartup && GetCurrentStatus(szProto) != iStatus) {
CallProtoService(szProto, PS_SETSTATUS, iStatus, 0);
#ifdef _DEBUG
log2file("ChangeStatusMessage(): Set %s status for %s.", StatusModeToDbSetting(iStatus, ""), szProto);
@@ -1071,13 +1065,11 @@ static int ChangeStatusMessage(WPARAM wParam, LPARAM lParam) mir_snprintf(szSetting, SIZEOF(szSetting), "Proto%sFlags", szProto);
iProtoFlags = db_get_b(NULL, "SimpleStatusMsg", szSetting, PROTO_DEFAULT);
- if (iProtoFlags & PROTO_NO_MSG || iProtoFlags & PROTO_THIS_MSG)
- {
+ if (iProtoFlags & PROTO_NO_MSG || iProtoFlags & PROTO_THIS_MSG) {
if (HasProtoStaticStatusMsg(szProto, iStatus, iStatus))
return 1;
}
- else if (iProtoFlags & PROTO_NOCHANGE && !bOnStartup)
- {
+ else if (iProtoFlags & PROTO_NOCHANGE && !bOnStartup) {
DBVARIANT dbv;
TCHAR *msg = NULL;
@@ -1097,8 +1089,7 @@ static int ChangeStatusMessage(WPARAM wParam, LPARAM lParam) return 1;
}
- if (!bShowDlg || bScreenSaverRunning)
- {
+ if (!bShowDlg || bScreenSaverRunning) {
TCHAR *msg = GetAwayMessageFormat(iStatus, szProto);
#ifdef _DEBUG
log2file("ChangeStatusMessage(): Set %s status and \"%S\" status message for %s.", StatusModeToDbSetting(iStatus, ""), msg, szProto);
@@ -1128,21 +1119,15 @@ static int ChangeStatusMessage(WPARAM wParam, LPARAM lParam) DestroyWindow(hwndSAMsgDialog);
hwndSAMsgDialog = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_AWAYMSGBOX), NULL, AwayMsgBoxDlgProc, (LPARAM)box_data);
}
- else
- {
- struct MsgBoxInitData *box_data;
- int iProtoFlags;
-
+ else {
// iStatus == ID_STATUS_CURRENT only when bOnStartup == TRUE
if (iStatus == ID_STATUS_OFFLINE || (!(accounts->statusMsgFlags & Proto_Status2Flag(iStatus)) && iStatus != ID_STATUS_CURRENT))
return 0;
- iProtoFlags = db_get_b(NULL, "SimpleStatusMsg", "ProtoFlags", PROTO_DEFAULT);
- if (!bShowDlg || bScreenSaverRunning || (iProtoFlags & PROTO_NOCHANGE && !bOnStartup))
- {
+ int iProtoFlags = db_get_b(NULL, "SimpleStatusMsg", "ProtoFlags", PROTO_DEFAULT);
+ if (!bShowDlg || bScreenSaverRunning || (iProtoFlags & PROTO_NOCHANGE && !bOnStartup)) {
TCHAR *msg = NULL;
- for (int i = 0; i < accounts->count; ++i)
- {
+ for (int i = 0; i < accounts->count; ++i) {
if (!IsAccountEnabled(accounts->pa[i]))
continue;
@@ -1156,8 +1141,7 @@ static int ChangeStatusMessage(WPARAM wParam, LPARAM lParam) !(CallProtoService(accounts->pa[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND))
continue;
- if (iProtoFlags & PROTO_NOCHANGE)
- {
+ if (iProtoFlags & PROTO_NOCHANGE) {
DBVARIANT dbv;
mir_snprintf(szSetting, SIZEOF(szSetting), "FCur%sMsg", accounts->pa[i]->szModuleName);
if (!db_get_ts(NULL, "SimpleStatusMsg", szSetting, &dbv))
@@ -1179,7 +1163,7 @@ static int ChangeStatusMessage(WPARAM wParam, LPARAM lParam) return 1;
}
- box_data = (struct MsgBoxInitData *)mir_alloc(sizeof(struct MsgBoxInitData));
+ MsgBoxInitData *box_data = (MsgBoxInitData*)mir_alloc( sizeof(MsgBoxInitData));
box_data->m_szProto = NULL;
box_data->m_iStatus = iStatus;
box_data->m_iStatusModes = accounts->statusFlags;
@@ -1263,27 +1247,9 @@ static INT_PTR SetOutToLunchStatus(WPARAM wParam, LPARAM lParam) static int ProcessProtoAck(WPARAM wParam,LPARAM lParam)
{
ACKDATA *ack = (ACKDATA *)lParam;
-
if (!ack || !ack->szModule)
return 0;
- if (ack->type == ACKTYPE_AWAYMSG && ack->result == ACKRESULT_SENTREQUEST && !ack->lParam)
- {
- TCHAR *tszMsg = GetAwayMessage(CallProtoService((char *)ack->szModule, PS_GETSTATUS, 0, 0), (char *)ack->szModule, TRUE, NULL);
-
- {
- char *szMsg = mir_u2a(tszMsg);
- CallContactService(ack->hContact, PSS_AWAYMSG, (WPARAM)(HANDLE)ack->hProcess, (LPARAM)szMsg);
- if (szMsg) mir_free(szMsg);
- }
-
-#ifdef _DEBUG
- log2file("ProcessProtoAck(): Send away message \"%S\" reply.", tszMsg);
-#endif
- if (tszMsg) mir_free(tszMsg);
- return 0;
- }
-
if (ack->type != ACKTYPE_STATUS || ack->result != ACKRESULT_SUCCESS || ack->hContact != NULL)
return 0;
diff --git a/plugins/StatusPlugins/AdvancedAutoAway/advancedautoaway.cpp b/plugins/StatusPlugins/AdvancedAutoAway/advancedautoaway.cpp index 7e372640ab..5a3a801732 100644 --- a/plugins/StatusPlugins/AdvancedAutoAway/advancedautoaway.cpp +++ b/plugins/StatusPlugins/AdvancedAutoAway/advancedautoaway.cpp @@ -88,7 +88,6 @@ static LRESULT CALLBACK MouseHookFunction(int code, WPARAM wParam, LPARAM lParam static LRESULT CALLBACK KeyBoardHookFunction(int code, WPARAM wParam, LPARAM lParam);
static LRESULT CALLBACK MirandaMouseHookFunction(int code, WPARAM wParam, LPARAM lParam);
static LRESULT CALLBACK MirandaKeyBoardHookFunction(int code, WPARAM wParam, LPARAM lParam);
-static BOOL IsSaverRunning();
BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved);
static VOID CALLBACK AutoAwayTimer(HWND hwnd,UINT message,UINT_PTR idEvent,DWORD dwTime);
@@ -280,8 +279,8 @@ static VOID CALLBACK AutoAwayTimer(HWND hwnd,UINT message,UINT_PTR idEvent,DWORD int sts2Time = aas.naTime * SECS_PER_MINUTE;
int sts1setTime = aas.sts1setTimer==0?0:(GetTickCount() - aas.sts1setTimer)/1000;
int currentMode = CallProtoService(aas.szName,PS_GETSTATUS,0, 0);
- if ( aas.optionFlags & FLAG_ONSAVER )
- SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, &screenSaver, FALSE);
+ if (aas.optionFlags & FLAG_ONSAVER)
+ screenSaver = IsScreenSaverRunning();
if (aas.optionFlags & FLAG_ONLOCK)
locked = IsWorkstationLocked();
diff --git a/protocols/Gadu-Gadu/src/gg.h b/protocols/Gadu-Gadu/src/gg.h index 8c77df9033..48dca26c90 100644 --- a/protocols/Gadu-Gadu/src/gg.h +++ b/protocols/Gadu-Gadu/src/gg.h @@ -310,11 +310,6 @@ extern LIST<GGPROTO> g_Instances; extern PLUGININFOEX pluginInfo;
extern IconItem iconList[];
-// Screen saver
-#ifndef SPI_GETSCREENSAVERRUNNING
-#define SPI_GETSCREENSAVERRUNNING 114
-#endif
-
/////////////////////////////////////////////////
// Methods
diff --git a/protocols/JabberG/src/jabber.h b/protocols/JabberG/src/jabber.h index e482113872..697c8b5c2e 100644 --- a/protocols/JabberG/src/jabber.h +++ b/protocols/JabberG/src/jabber.h @@ -241,11 +241,6 @@ protected: // Font for groupchat log dialog
#define JABBER_GCLOG_NUM_FONT 6 // 6 fonts (0:send, 1:msg, 2:time, 3:nick, 4:sys, 5:/me)
-// Old SDK don't have this
-#ifndef SPI_GETSCREENSAVERRUNNING
-#define SPI_GETSCREENSAVERRUNNING 114
-#endif
-
// Icon list
enum {
JABBER_IDI_GCOWNER = 0,
diff --git a/src/core/stdaway/sendmsg.cpp b/src/core/stdaway/sendmsg.cpp index b981615f65..79bc374a97 100644 --- a/src/core/stdaway/sendmsg.cpp +++ b/src/core/stdaway/sendmsg.cpp @@ -315,11 +315,11 @@ static INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wPa static int StatusModeChange(WPARAM wParam, LPARAM lParam)
{
- BOOL bScreenSaverRunning = FALSE;
int statusMode = (int)wParam;
char *szProto = (char*)lParam;
- if (protoModeMsgFlags == 0) return 0;
+ if (protoModeMsgFlags == 0)
+ return 0;
// If its a global change check the complete PFLAGNUM_3 flags to see if a popup might be needed
if ( !szProto)
@@ -335,7 +335,7 @@ static int StatusModeChange(WPARAM wParam, LPARAM lParam) return 0;
}
- SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, &bScreenSaverRunning, FALSE);
+ BOOL bScreenSaverRunning = IsScreenSaverRunning();
if (GetStatusModeByte(statusMode, "Ignore"))
ChangeAllProtoMessages(szProto, statusMode, NULL);
diff --git a/src/mir_core/winver.cpp b/src/mir_core/winver.cpp index 03a6e62a28..96f2ddb26b 100644 --- a/src/mir_core/winver.cpp +++ b/src/mir_core/winver.cpp @@ -64,8 +64,7 @@ MIR_CORE_DLL(BOOL) IsFullScreen() ClientToScreen(hWnd, (LPPOINT)&rect);
ClientToScreen(hWnd, (LPPOINT)&rect.right);
- if (EqualRect(&rect, &rectw) && IntersectRect(&recti, &rect, &rcScreen) &&
- EqualRect(&recti, &rcScreen))
+ if (EqualRect(&rect, &rectw) && IntersectRect(&recti, &rect, &rcScreen) && EqualRect(&recti, &rcScreen))
return true;
}
}
@@ -79,8 +78,11 @@ MIR_CORE_DLL(BOOL) IsWorkstationLocked(void) if (hDesk == NULL)
return true;
+ TCHAR tszName[100];
+ DWORD cbName;
+ BOOL bLocked = (!GetUserObjectInformation(hDesk, UOI_NAME, tszName, SIZEOF(tszName), &cbName) || lstrcmpi(tszName,_T("default")) != 0);
CloseDesktop(hDesk);
- return false;
+ return bLocked;
}
MIR_CORE_DLL(BOOL) IsScreenSaverRunning(void)
|