summaryrefslogtreecommitdiff
path: root/plugins/AutoShutdown/src/utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/AutoShutdown/src/utils.cpp')
-rw-r--r--plugins/AutoShutdown/src/utils.cpp50
1 files changed, 25 insertions, 25 deletions
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 */
}