From 46a53191c1ad11a41c948594e972568e62d155b4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 6 Jun 2012 13:58:20 +0000 Subject: minor code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@332 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/addcontact/addcontact.cpp | 2 +- src/modules/button/button.cpp | 2 +- src/modules/clist/clc.cpp | 2 +- src/modules/clist/clistevents.cpp | 6 +- src/modules/clist/clistmenus.cpp | 2 +- src/modules/clist/clisttray.cpp | 8 +- src/modules/clist/clui.cpp | 4 +- src/modules/clist/genmenuopt.cpp | 2 +- src/modules/clist/keyboard.cpp | 4 +- src/modules/contacts/contacts.cpp | 36 ++-- src/modules/database/database.cpp | 4 +- src/modules/database/dbini.cpp | 46 ++-- src/modules/database/profilemanager.cpp | 4 +- src/modules/findadd/findadd.cpp | 154 ++++++------- src/modules/findadd/searchresults.cpp | 44 ++-- src/modules/fonts/FontOptions.cpp | 22 +- src/modules/fonts/services.cpp | 8 +- src/modules/history/history.cpp | 18 +- src/modules/icolib/extracticon.cpp | 4 +- src/modules/icolib/skin2icons.cpp | 14 +- src/modules/ignore/ignore.cpp | 106 ++++----- src/modules/keybindings/keybindings.cpp | 28 +-- src/modules/langpack/langpack.cpp | 20 +- src/modules/langpack/lpservices.cpp | 4 +- src/modules/netlib/netlib.cpp | 82 +++---- src/modules/netlib/netlibautoproxy.cpp | 2 +- src/modules/netlib/netlibbind.cpp | 4 +- src/modules/netlib/netlibhttp.cpp | 18 +- src/modules/netlib/netlibhttpproxy.cpp | 2 +- src/modules/netlib/netliblog.cpp | 24 +-- src/modules/netlib/netlibopenconn.cpp | 16 +- src/modules/netlib/netlibopts.cpp | 88 ++++---- src/modules/netlib/netlibpktrecver.cpp | 16 +- src/modules/netlib/netlibssl.cpp | 2 +- src/modules/netlib/netlibupnp.cpp | 4 +- src/modules/options/options.cpp | 80 +++---- src/modules/plugins/newplugins.cpp | 372 ++++++++++++++------------------ src/modules/protocols/protoaccs.cpp | 2 +- src/modules/protocols/protochains.cpp | 34 +-- src/modules/protocols/protocols.cpp | 6 +- src/modules/protocols/protodir.cpp | 6 +- src/modules/protocols/protoopts.cpp | 7 +- src/modules/skin/sounds.cpp | 20 +- src/modules/srawaymsg/awaymsg.cpp | 2 +- src/modules/srawaymsg/sendmsg.cpp | 2 +- src/modules/sremail/email.cpp | 4 +- src/modules/srfile/file.cpp | 24 +-- src/modules/srfile/fileexistsdlg.cpp | 28 +-- src/modules/srfile/fileopts.cpp | 22 +- src/modules/srfile/filerecvdlg.cpp | 38 ++-- src/modules/srfile/filesenddlg.cpp | 28 +-- src/modules/srfile/filexferdlg.cpp | 66 +++--- src/modules/srfile/ftmanager.cpp | 2 +- src/modules/srurl/url.cpp | 6 +- src/modules/srurl/urldialogs.cpp | 74 +++---- src/modules/userinfo/contactinfo.cpp | 126 +++++------ src/modules/userinfo/stdinfo.cpp | 74 +++---- src/modules/userinfo/userinfo.cpp | 70 +++--- src/modules/useronline/useronline.cpp | 10 +- src/modules/utils/colourpicker.cpp | 4 +- src/modules/utils/hyperlink.cpp | 64 +++--- src/modules/utils/openurl.cpp | 46 ++-- src/modules/utils/path.cpp | 4 +- src/modules/utils/resizer.cpp | 44 ++-- src/modules/utils/timezones.cpp | 4 +- src/modules/utils/utils.cpp | 24 +-- src/modules/utils/windowlist.cpp | 16 +- src/modules/visibility/visibility.cpp | 48 ++--- src/modules/xml/xmlParser.cpp | 18 +- 69 files changed, 1067 insertions(+), 1110 deletions(-) (limited to 'src/modules') diff --git a/src/modules/addcontact/addcontact.cpp b/src/modules/addcontact/addcontact.cpp index 9491599846..b21e6aa77f 100644 --- a/src/modules/addcontact/addcontact.cpp +++ b/src/modules/addcontact/addcontact.cpp @@ -93,7 +93,7 @@ INT_PTR CALLBACK AddContactDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lpara char idstr[4]; int id; _itoa(groupId,idstr,10); - if(DBGetContactSettingTString(NULL,"CListGroups",idstr,&dbv)) break; + if (DBGetContactSettingTString(NULL,"CListGroups",idstr,&dbv)) break; id = SendDlgItemMessage(hdlg,IDC_GROUP,CB_ADDSTRING,0,(LPARAM)(dbv.ptszVal+1)); SendDlgItemMessage(hdlg,IDC_GROUP,CB_SETITEMDATA ,id,groupId+1); DBFreeVariant(&dbv); diff --git a/src/modules/button/button.cpp b/src/modules/button/button.cpp index b65796f13e..66aafc243c 100644 --- a/src/modules/button/button.cpp +++ b/src/modules/button/button.cpp @@ -601,7 +601,7 @@ static LRESULT CALLBACK MButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, L POINT pt; GetWindowRect(hwndDlg,&rc); GetCursorPos(&pt); - if(!PtInRect(&rc,pt)) { // mouse must be gone, trigger mouse leave + if (!PtInRect(&rc,pt)) { // mouse must be gone, trigger mouse leave PostMessage(hwndDlg,WM_MOUSELEAVE,0,0L); KillTimer(hwndDlg,BUTTON_POLLID); } } diff --git a/src/modules/clist/clc.cpp b/src/modules/clist/clc.cpp index 4b3e8dbd11..f260a8c452 100644 --- a/src/modules/clist/clc.cpp +++ b/src/modules/clist/clc.cpp @@ -498,7 +498,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, cli.pfnAddContactToTree(hwnd, dat, (HANDLE) wParam, 1, 1); if (cli.pfnFindItem(hwnd, dat, (HANDLE) wParam, &contact, NULL, NULL)) { CopyMemory(contact->iExtraImage, iExtraImage, SIZEOF(iExtraImage)); - if(flags & CONTACTF_CHECKED) + if (flags & CONTACTF_CHECKED) contact->flags |= CONTACTF_CHECKED; } nm.hdr.code = CLN_CONTACTMOVED; diff --git a/src/modules/clist/clistevents.cpp b/src/modules/clist/clistevents.cpp index 4958934c9828..6b95a648bb 100644 --- a/src/modules/clist/clistevents.cpp +++ b/src/modules/clist/clistevents.cpp @@ -303,7 +303,7 @@ int fnEventsProcessTrayDoubleClick(int index) break; } if (szProto) { - for(i=0; icle.hContact) eventProto=(char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)cli.events.items[i]->cle.hContact, 0); @@ -319,7 +319,7 @@ int fnEventsProcessTrayDoubleClick(int index) //lets process backward try to find first event without desired proto in tray int j; if (click_in_first_icon) - for(i=0; icle.hContact) eventProto=(char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)cli.events.items[i]->cle.hContact, 0); @@ -356,7 +356,7 @@ static int RemoveEventsForContact(WPARAM wParam, LPARAM) int j, hit; /* - the for(;;) loop is used here since the cli.events.count can not be relied upon to take us + the for (;;) loop is used here since the cli.events.count can not be relied upon to take us thru the cli.events.items[] array without suffering from shortsightedness about how many unseen events remain, e.g. three events, we remove the first, we're left with 2, the event loop exits at 2 and we never see the real new 2. diff --git a/src/modules/clist/clistmenus.cpp b/src/modules/clist/clistmenus.cpp index 15e8ebc1b2..1d9f8275d7 100644 --- a/src/modules/clist/clistmenus.cpp +++ b/src/modules/clist/clistmenus.cpp @@ -644,7 +644,7 @@ INT_PTR StatusMenuExecService(WPARAM wParam, LPARAM) else { int MenusProtoCount = 0; - for( int i=0; i < accounts.getCount(); i++ ) + for ( int i=0; i < accounts.getCount(); i++ ) if ( cli.pfnGetProtocolVisibility( accounts[i]->szModuleName )) MenusProtoCount++; diff --git a/src/modules/clist/clisttray.cpp b/src/modules/clist/clisttray.cpp index c708d3f1a8..717d5beae1 100644 --- a/src/modules/clist/clisttray.cpp +++ b/src/modules/clist/clisttray.cpp @@ -45,7 +45,7 @@ static CRITICAL_SECTION trayLockCS; #define lock cli.pfnLockTray() #define ulock cli.pfnUnlockTray() -#define initcheck if(!fTrayInited) return +#define initcheck if (!fTrayInited) return static BOOL fTrayInited=FALSE; @@ -412,7 +412,7 @@ int fnTrayIconUpdate(HICON hNewIcon, const TCHAR *szNewTip, const char *szPrefer cli.pfnTrayIconMakeTooltip(szNewTip, cli.trayIcon[i].szProto); mir_free( cli.trayIcon[i].ptszToolTip ); cli.trayIcon[i].ptszToolTip = mir_tstrdup( cli.szTip ); - if(!mToolTipTrayTips) + if (!mToolTipTrayTips) lstrcpyn(nid.szTip, cli.szTip, SIZEOF(nid.szTip)); Shell_NotifyIcon(NIM_MODIFY, &nid); @@ -427,7 +427,7 @@ int fnTrayIconUpdate(HICON hNewIcon, const TCHAR *szNewTip, const char *szPrefer DWORD time1=DBGetContactSettingWord(NULL,"CList","CycleTime",SETTING_CYCLETIME_DEFAULT)*200; DWORD time2=DBGetContactSettingWord(NULL,"CList","IconFlashTime",550)+1000; DWORD time=max(max(2000,time1),time2); - if(RefreshTimerId) {KillTimer(NULL,RefreshTimerId); RefreshTimerId=0;} + if (RefreshTimerId) {KillTimer(NULL,RefreshTimerId); RefreshTimerId=0;} RefreshTimerId=SetTimer(NULL,0,time,RefreshTimerProc); // if unknown base was changed - than show preffered proto icon for 2 sec and reset it to original one after timeout } { ulock; return i; } @@ -454,7 +454,7 @@ int fnTrayIconSetBaseInfo(HICON hIcon, const char *szPreferredProto) ulock; return i; } if ((cli.pfnGetProtocolVisibility(szPreferredProto)) - && (GetAverageMode()==-1) + && (GetAverageMode() == -1) && (DBGetContactSettingByte(NULL,"CList","TrayIcon",SETTING_TRAYICON_DEFAULT)==SETTING_TRAYICON_MULTI) && !(DBGetContactSettingByte(NULL,"CList","AlwaysMulti",SETTING_ALWAYSMULTI_DEFAULT))) goto LBL_Error; diff --git a/src/modules/clist/clui.cpp b/src/modules/clist/clui.cpp index 07a4270aa7..f82872711d 100644 --- a/src/modules/clist/clui.cpp +++ b/src/modules/clist/clui.cpp @@ -635,7 +635,7 @@ LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM return DefWindowProc(hwnd, msg, wParam, lParam); case WM_SETCURSOR: - if(cluiopt.transparent) { + if (cluiopt.transparent) { if (!transparentFocus && GetForegroundWindow()!=hwnd && setLayeredWindowAttributes) { setLayeredWindowAttributes(hwnd, RGB(0,0,0), (BYTE)cluiopt.alpha, LWA_ALPHA); transparentFocus=1; @@ -968,7 +968,7 @@ LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM return FALSE; case WM_MENUSELECT: - if(lParam && (HMENU)lParam == cli.hMenuMain) { + if (lParam && (HMENU)lParam == cli.hMenuMain) { int pos = LOWORD(wParam); POINT pt; GetCursorPos(&pt); diff --git a/src/modules/clist/genmenuopt.cpp b/src/modules/clist/genmenuopt.cpp index eb413f94ac..0d8a883702 100644 --- a/src/modules/clist/genmenuopt.cpp +++ b/src/modules/clist/genmenuopt.cpp @@ -367,7 +367,7 @@ static HTREEITEM MoveItemAbove(HWND hTreeWnd, HTREEITEM hItem, HTREEITEM hInsert tvis.item.cchTextMax = sizeof( name ); tvis.item.hItem = hItem; tvis.item.iImage = tvis.item.iSelectedImage = (( MenuItemOptData* )tvi.lParam)->show; - if(!SendMessage(hTreeWnd, TVM_GETITEM, 0, (LPARAM)&tvis.item)) + if (!SendMessage(hTreeWnd, TVM_GETITEM, 0, (LPARAM)&tvis.item)) return NULL; if (!TreeView_DeleteItem(hTreeWnd,hItem)) return NULL; diff --git a/src/modules/clist/keyboard.cpp b/src/modules/clist/keyboard.cpp index b03c7bac03..75c2630a33 100644 --- a/src/modules/clist/keyboard.cpp +++ b/src/modules/clist/keyboard.cpp @@ -33,7 +33,7 @@ static INT_PTR hkHideShow(WPARAM, LPARAM) INT_PTR hkSearch(WPARAM wParam,LPARAM lParam) { DBVARIANT dbv={0}; - if(!DBGetContactSettingString(NULL,"CList","SearchUrl",&dbv)) { + if (!DBGetContactSettingString(NULL,"CList","SearchUrl",&dbv)) { CallService(MS_UTILS_OPENURL,DBGetContactSettingByte(NULL,"CList","HKSearchNewWnd",0),(LPARAM)dbv.pszVal); DBFreeVariant(&dbv); } @@ -42,7 +42,7 @@ INT_PTR hkSearch(WPARAM wParam,LPARAM lParam) */ static INT_PTR hkRead(WPARAM, LPARAM) { - if(cli.pfnEventsProcessTrayDoubleClick(0)==0) return TRUE; + if (cli.pfnEventsProcessTrayDoubleClick(0)==0) return TRUE; SetForegroundWindow(cli.hwndContactList); SetFocus(cli.hwndContactList); return 0; diff --git a/src/modules/contacts/contacts.cpp b/src/modules/contacts/contacts.cpp index 002c58dc6d..043e316512 100644 --- a/src/modules/contacts/contacts.cpp +++ b/src/modules/contacts/contacts.cpp @@ -146,8 +146,8 @@ static INT_PTR GetContactInfo(WPARAM, LPARAM lParam) { int i,countryCount; struct CountryListEntry *countries; CallService(MS_UTILS_GETCOUNTRYLIST,(WPARAM)&countryCount,(LPARAM)&countries); - for(i=0;idwFlag & CNF_UNICODE ) { int cbLen = MultiByteToWideChar( CP_ACP, 0, ( LPCSTR )countries[i].szName, -1, NULL, 0 ); @@ -169,9 +169,9 @@ static INT_PTR GetContactInfo(WPARAM, LPARAM lParam) { break; case CNF_FIRSTLAST: - if( !GetDatabaseString( ci, "FirstName", &dbv )) { + if ( !GetDatabaseString( ci, "FirstName", &dbv )) { DBVARIANT dbv2; - if(!GetDatabaseString(ci,"LastName",&dbv2)) { + if (!GetDatabaseString(ci,"LastName",&dbv2)) { ci->type = CNFT_ASCIIZ; if ( ci->dwFlag & CNF_UNICODE ) { size_t len = wcslen(dbv.pwszVal) + wcslen(dbv2.pwszVal) + 2; @@ -219,7 +219,7 @@ static INT_PTR GetContactInfo(WPARAM, LPARAM lParam) { case CNF_DISPLAY: { int i; - for( i=0; i < NAMEORDERCOUNT; i++ ) { + for ( i=0; i < NAMEORDERCOUNT; i++ ) { switch(nameOrder[i]) { case 0: // custom name { @@ -283,9 +283,9 @@ static INT_PTR GetContactInfo(WPARAM, LPARAM lParam) { break; } case 6: // first + last name - if(!GetDatabaseString(ci,"FirstName",&dbv)) { + if (!GetDatabaseString(ci,"FirstName",&dbv)) { DBVARIANT dbv2; - if(!GetDatabaseString(ci,"LastName",&dbv2)) { + if (!GetDatabaseString(ci,"LastName",&dbv2)) { ci->type = CNFT_ASCIIZ; if ( ci->dwFlag & CNF_UNICODE ) { @@ -371,7 +371,7 @@ static INT_PTR CALLBACK ContactOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM lPara tvis.hParent = NULL; tvis.hInsertAfter = TVI_LAST; tvis.item.mask = TVIF_TEXT|TVIF_PARAM; - for(i=0; i < SIZEOF(nameOrderDescr); i++ ) { + for (i=0; i < SIZEOF(nameOrderDescr); i++ ) { tvis.item.lParam = nameOrder[i]; tvis.item.pszText = TranslateTS( nameOrderDescr[ nameOrder[i]] ); TreeView_InsertItem( GetDlgItem(hwndDlg,IDC_NAMEORDER), &tvis ); @@ -416,27 +416,27 @@ static INT_PTR CALLBACK ContactOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM lPara } break; case WM_MOUSEMOVE: - if(!dat->dragging) break; + if (!dat->dragging) break; { TVHITTESTINFO hti; hti.pt.x=(short)LOWORD(lParam); hti.pt.y=(short)HIWORD(lParam); ClientToScreen(hwndDlg,&hti.pt); ScreenToClient(GetDlgItem(hwndDlg,IDC_NAMEORDER),&hti.pt); TreeView_HitTest(GetDlgItem(hwndDlg,IDC_NAMEORDER),&hti); - if(hti.flags&(TVHT_ONITEM|TVHT_ONITEMRIGHT)) { + if (hti.flags&(TVHT_ONITEM|TVHT_ONITEMRIGHT)) { hti.pt.y-=TreeView_GetItemHeight(GetDlgItem(hwndDlg,IDC_NAMEORDER))/2; TreeView_HitTest(GetDlgItem(hwndDlg,IDC_NAMEORDER),&hti); TreeView_SetInsertMark(GetDlgItem(hwndDlg,IDC_NAMEORDER),hti.hItem,1); } else { - if(hti.flags&TVHT_ABOVE) SendDlgItemMessage(hwndDlg,IDC_NAMEORDER,WM_VSCROLL,MAKEWPARAM(SB_LINEUP,0),0); - if(hti.flags&TVHT_BELOW) SendDlgItemMessage(hwndDlg,IDC_NAMEORDER,WM_VSCROLL,MAKEWPARAM(SB_LINEDOWN,0),0); + if (hti.flags&TVHT_ABOVE) SendDlgItemMessage(hwndDlg,IDC_NAMEORDER,WM_VSCROLL,MAKEWPARAM(SB_LINEUP,0),0); + if (hti.flags&TVHT_BELOW) SendDlgItemMessage(hwndDlg,IDC_NAMEORDER,WM_VSCROLL,MAKEWPARAM(SB_LINEDOWN,0),0); TreeView_SetInsertMark(GetDlgItem(hwndDlg,IDC_NAMEORDER),NULL,0); } } break; case WM_LBUTTONUP: - if(!dat->dragging) break; + if (!dat->dragging) break; TreeView_SetInsertMark(GetDlgItem(hwndDlg,IDC_NAMEORDER),NULL,0); dat->dragging=0; ReleaseCapture(); @@ -448,12 +448,12 @@ static INT_PTR CALLBACK ContactOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM lPara ScreenToClient(GetDlgItem(hwndDlg,IDC_NAMEORDER),&hti.pt); hti.pt.y-=TreeView_GetItemHeight(GetDlgItem(hwndDlg,IDC_NAMEORDER))/2; TreeView_HitTest(GetDlgItem(hwndDlg,IDC_NAMEORDER),&hti); - if(dat->hDragItem==hti.hItem) break; + if (dat->hDragItem==hti.hItem) break; tvi.mask=TVIF_HANDLE|TVIF_PARAM; tvi.hItem=hti.hItem; TreeView_GetItem(GetDlgItem(hwndDlg,IDC_NAMEORDER),&tvi); - if(tvi.lParam == SIZEOF(nameOrderDescr)-1) break; - if(hti.flags&(TVHT_ONITEM|TVHT_ONITEMRIGHT)) { + if (tvi.lParam == SIZEOF(nameOrderDescr)-1) break; + if (hti.flags&(TVHT_ONITEM|TVHT_ONITEMRIGHT)) { TVINSERTSTRUCT tvis; TCHAR name[128]; tvis.item.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT|TVIF_PARAM; @@ -498,10 +498,10 @@ int LoadContactsModule(void) { BYTE i; DBVARIANT dbv; - for(i=0; iszName); SetDlgItemTextA(hwndDlg,IDC_SETTINGNAME,szSettingName); SetDlgItemTextA(hwndDlg,IDC_NEWVALUE,warnInfo->szValue); - if(IsInSpaceSeparatedList(warnInfo->szSection,warnInfo->szSafeSections)) + if (IsInSpaceSeparatedList(warnInfo->szSection,warnInfo->szSafeSections)) pszSecurityInfo=LPGENT("This change is known to be safe."); - else if(IsInSpaceSeparatedList(warnInfo->szSection,warnInfo->szUnsafeSections)) + else if (IsInSpaceSeparatedList(warnInfo->szSection,warnInfo->szUnsafeSections)) pszSecurityInfo=LPGENT("This change is known to be potentially hazardous."); else pszSecurityInfo=LPGENT("This change is not known to be safe."); @@ -212,10 +212,10 @@ static void ProcessIniFile(TCHAR* szIniPath, char *szSafeSections, char *szUnsaf while (lineLength && (BYTE)(szLine[lineLength-1])<=' ') szLine[--lineLength]='\0'; - if (szLine[0]==';' || szLine[0]<=' ') + if (szLine[0] == ';' || szLine[0]<=' ') continue; - if (szLine[0]=='[') { + if (szLine[0] == '[') { char *szEnd = strchr(szLine+1,']'); if (szEnd == NULL) continue; @@ -266,7 +266,7 @@ static void ProcessIniFile(TCHAR* szIniPath, char *szSafeSections, char *szUnsaf continue; } - if(szSection[0]=='\0') + if (szSection[0] == '\0') continue; char *szValue=strchr(szLine,'='); @@ -286,11 +286,11 @@ static void ProcessIniFile(TCHAR* szIniPath, char *szSafeSections, char *szUnsaf warnInfo.szValue=szValue; warnInfo.warnNoMore=0; warnInfo.cancel=0; - if(warnThisSection && IDNO==DialogBoxParam(hMirandaInst,MAKEINTRESOURCE(IDD_WARNINICHANGE),NULL,WarnIniChangeDlgProc,(LPARAM)&warnInfo)) + if (warnThisSection && IDNO==DialogBoxParam(hMirandaInst,MAKEINTRESOURCE(IDD_WARNINICHANGE),NULL,WarnIniChangeDlgProc,(LPARAM)&warnInfo)) continue; - if(warnInfo.cancel) + if (warnInfo.cancel) break; - if(warnInfo.warnNoMore) + if (warnInfo.warnNoMore) warnThisSection=0; } @@ -321,8 +321,8 @@ static void ProcessIniFile(TCHAR* szIniPath, char *szSafeSections, char *szUnsaf case 'g': case 'G': { char *pstr; - for(pstr=szValue+1;*pstr;pstr++) { - if(*pstr=='\\') { + for (pstr=szValue+1;*pstr;pstr++) { + if (*pstr=='\\') { switch(pstr[1]) { case 'n': *pstr='\n'; break; case 't': *pstr='\t'; break; @@ -345,9 +345,9 @@ static void ProcessIniFile(TCHAR* szIniPath, char *szSafeSections, char *szUnsaf DBCONTACTWRITESETTING cws; buf=(PBYTE)mir_alloc(lstrlenA(szValue+1)); - for(len=0,pszValue=szValue+1;;len++) { + for (len=0,pszValue=szValue+1;;len++) { buf[len]=(BYTE)strtol(pszValue,&pszEnd,0x10); - if(pszValue==pszEnd) break; + if (pszValue==pszEnd) break; pszValue=pszEnd; } cws.szModule=szSection; @@ -376,7 +376,7 @@ static void DoAutoExec(void) int secur; GetPrivateProfileString(_T("AutoExec"),_T("Use"),_T("prompt"),szUse,SIZEOF(szUse),mirandabootini); - if(!lstrcmpi(szUse,_T("no"))) return; + if (!lstrcmpi(szUse,_T("no"))) return; GetPrivateProfileString(_T("AutoExec"),_T("Safe"),_T("CLC Icons CLUI CList SkinSounds"),buf,SIZEOF(buf),mirandabootini); szSafeSections = mir_t2a(buf); GetPrivateProfileString(_T("AutoExec"),_T("Unsafe"),_T("ICQ MSN"),buf,SIZEOF(buf),mirandabootini); @@ -418,22 +418,22 @@ static void DoAutoExec(void) bool secFN = lstrcmpi(fd.cFileName,szOverrideSecurityFilename) == 0; mir_sntprintf(szIniPath, SIZEOF(szIniPath), _T("%s%s"), szFindPath, fd.cFileName); - if(!lstrcmpi(szUse,_T("prompt")) && !secFN) { + if (!lstrcmpi(szUse,_T("prompt")) && !secFN) { int result=DialogBoxParam(hMirandaInst,MAKEINTRESOURCE(IDD_INSTALLINI),NULL,InstallIniDlgProc,(LPARAM)szIniPath); - if(result==IDC_NOTOALL) break; - if(result==IDCANCEL) continue; + if (result==IDC_NOTOALL) break; + if (result==IDCANCEL) continue; } ProcessIniFile(szIniPath, szSafeSections, szUnsafeSections, secur, secFN); - if(secFN) + if (secFN) DeleteFile(szIniPath); else { TCHAR szOnCompletion[8]; GetPrivateProfileString(_T("AutoExec"),_T("OnCompletion"),_T("recycle"),szOnCompletion,SIZEOF(szOnCompletion),mirandabootini); - if(!lstrcmpi(szOnCompletion,_T("delete"))) + if (!lstrcmpi(szOnCompletion,_T("delete"))) DeleteFile(szIniPath); - else if(!lstrcmpi(szOnCompletion,_T("recycle"))) { + else if (!lstrcmpi(szOnCompletion,_T("recycle"))) { SHFILEOPSTRUCT shfo={0}; shfo.wFunc=FO_DELETE; shfo.pFrom=szIniPath; @@ -441,7 +441,7 @@ static void DoAutoExec(void) shfo.fFlags=FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO; SHFileOperation(&shfo); } - else if(!lstrcmpi(szOnCompletion,_T("rename"))) { + else if (!lstrcmpi(szOnCompletion,_T("rename"))) { TCHAR szRenamePrefix[MAX_PATH]; TCHAR szNewPath[MAX_PATH]; GetPrivateProfileString(_T("AutoExec"),_T("RenamePrefix"),_T("done_"),szRenamePrefix,SIZEOF(szRenamePrefix),mirandabootini); @@ -450,7 +450,7 @@ static void DoAutoExec(void) lstrcat(szNewPath,fd.cFileName); MoveFile(szIniPath,szNewPath); } - else if(!lstrcmpi(szOnCompletion,_T("ask"))) + else if (!lstrcmpi(szOnCompletion,_T("ask"))) DialogBoxParam(hMirandaInst,MAKEINTRESOURCE(IDD_INIIMPORTDONE),NULL,IniImportDoneDlgProc,(LPARAM)szIniPath); } } while (FindNextFile(hFind, &fd)); diff --git a/src/modules/database/profilemanager.cpp b/src/modules/database/profilemanager.cpp index 67d100b3cd..87b1e505f6 100644 --- a/src/modules/database/profilemanager.cpp +++ b/src/modules/database/profilemanager.cpp @@ -570,7 +570,7 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, odp = ( OPTIONSDIALOGPAGE* )psh->ppsp; tci.mask = TCIF_TEXT; - for( i=0; i < dat->pageCount; i++ ) { + for ( i=0; i < dat->pageCount; i++ ) { dat->opd[i].pTemplate = (DLGTEMPLATE *)LockResource(LoadResource(odp[i].hInstance,FindResourceA(odp[i].hInstance,odp[i].pszTemplate,MAKEINTRESOURCEA(5)))); dat->opd[i].dlgProc = odp[i].pfnDlgProc; dat->opd[i].hInst = odp[i].hInstance; @@ -704,7 +704,7 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, pshn.hdr.idFrom=0; pshn.lParam=0; pshn.hdr.code=PSN_RESET; - for(i=0;ipageCount;i++) { + for (i=0;ipageCount;i++) { if (dat->opd[i].hwnd==NULL || !dat->opd[i].changed) continue; pshn.hdr.hwndFrom=dat->opd[i].hwnd; SendMessage(dat->opd[i].hwnd,WM_NOTIFY,0,(LPARAM)&pshn); diff --git a/src/modules/findadd/findadd.cpp b/src/modules/findadd/findadd.cpp index 527a3cda63..18d4c28670 100644 --- a/src/modules/findadd/findadd.cpp +++ b/src/modules/findadd/findadd.cpp @@ -52,30 +52,30 @@ static int FindAddDlgResizer(HWND,LPARAM lParam,UTILRESIZECONTROL *urc) return RD_ANCHORX_WIDTH|RD_ANCHORY_BOTTOM; case IDC_PROTOIDGROUP: //the resize is always processed in template order nextY=y=urc->rcItem.top; - if(dat->showProtoId) nextY=y+urc->rcItem.bottom-urc->rcItem.top+7; + if (dat->showProtoId) nextY=y+urc->rcItem.bottom-urc->rcItem.top+7; break; case IDC_EMAILGROUP: oldTop=urc->rcItem.top; y=nextY; - if(dat->showEmail) nextY=y+urc->rcItem.bottom-urc->rcItem.top+7; + if (dat->showEmail) nextY=y+urc->rcItem.bottom-urc->rcItem.top+7; OffsetRect(&urc->rcItem,0,y-oldTop); return RD_ANCHORX_LEFT|RD_ANCHORY_CUSTOM; case IDC_NAMEGROUP: oldTop=urc->rcItem.top; y=nextY; - if(dat->showName) nextY=y+urc->rcItem.bottom-urc->rcItem.top+7; + if (dat->showName) nextY=y+urc->rcItem.bottom-urc->rcItem.top+7; OffsetRect(&urc->rcItem,0,y-oldTop); return RD_ANCHORX_LEFT|RD_ANCHORY_CUSTOM; case IDC_ADVANCEDGROUP: oldTop=urc->rcItem.top; y=nextY; - if(dat->showAdvanced) nextY=y+urc->rcItem.bottom-urc->rcItem.top+7; + if (dat->showAdvanced) nextY=y+urc->rcItem.bottom-urc->rcItem.top+7; OffsetRect(&urc->rcItem,0,y-oldTop); return RD_ANCHORX_LEFT|RD_ANCHORY_CUSTOM; case IDC_TINYEXTENDEDGROUP: oldTop=urc->rcItem.top; y=nextY; - if(dat->showTiny) + if (dat->showTiny) { int height= urc->dlgNewSize.cy-y-(urc->dlgOriginalSize.cy-urc->rcItem.bottom); nextY=y+200; //min height for custom dialog @@ -191,14 +191,14 @@ static void ShowAdvancedSearchDlg(HWND hwndDlg,struct FindAddDlgData *dat) { char *szProto=(char*)SendDlgItemMessage(hwndDlg,IDC_PROTOLIST,CB_GETITEMDATA,SendDlgItemMessage(hwndDlg,IDC_PROTOLIST,CB_GETCURSEL,0,0),0); - if(szProto==NULL) return; - if(dat->hwndAdvSearch==NULL) { + if (szProto==NULL) return; + if (dat->hwndAdvSearch==NULL) { RECT rc; dat->hwndAdvSearch=(HWND)CallProtoService(szProto,PS_CREATEADVSEARCHUI,0,(LPARAM)hwndDlg); GetWindowRect(GetDlgItem(hwndDlg,IDC_RESULTS),&rc); SetWindowPos(dat->hwndAdvSearch,0,rc.left,rc.top,0,0,SWP_NOZORDER|SWP_NOSIZE); } - if(animateWindow) { + if (animateWindow) { animateWindow(dat->hwndAdvSearch,150,AW_ACTIVATE|AW_SLIDE|AW_HOR_POSITIVE); RedrawWindow(dat->hwndAdvSearch,NULL,NULL,RDW_INVALIDATE|RDW_UPDATENOW|RDW_ALLCHILDREN); } else ShowWindow(dat->hwndAdvSearch,SW_SHOW); @@ -223,8 +223,8 @@ static void ReposTinySearchDlg(HWND hwndDlg,struct FindAddDlgData *dat) static void ShowTinySearchDlg(HWND hwndDlg,struct FindAddDlgData *dat) { char *szProto=(char*)SendDlgItemMessage(hwndDlg,IDC_PROTOLIST,CB_GETITEMDATA,SendDlgItemMessage(hwndDlg,IDC_PROTOLIST,CB_GETCURSEL,0,0),0); - if(szProto==NULL) return; - if(dat->hwndTinySearch==NULL) { + if (szProto==NULL) return; + if (dat->hwndTinySearch==NULL) { dat->hwndTinySearch=(HWND)CallProtoService(szProto,PS_CREATEADVSEARCHUI,0,(LPARAM)/*GetDlgItem(*/hwndDlg/*,IDC_TINYEXTENDEDGROUP)*/); if (dat->hwndTinySearch) ReposTinySearchDlg(hwndDlg, dat); @@ -236,8 +236,8 @@ static void ShowTinySearchDlg(HWND hwndDlg,struct FindAddDlgData *dat) static void HideAdvancedSearchDlg(HWND hwndDlg,struct FindAddDlgData *dat) { - if(dat->hwndAdvSearch==NULL) return; - if(animateWindow && IsWinVerXPPlus()) //blending is quite slow on win2k + if (dat->hwndAdvSearch==NULL) return; + if (animateWindow && IsWinVerXPPlus()) //blending is quite slow on win2k animateWindow(dat->hwndAdvSearch,150,AW_HIDE|AW_BLEND); else ShowWindow(dat->hwndAdvSearch,SW_HIDE); CheckDlgButton(hwndDlg,IDC_ADVANCED,BST_UNCHECKED); @@ -253,7 +253,7 @@ static void CheckSearchTypeRadioButton(HWND hwndDlg,int idControl) { int i; static const int controls[]={IDC_BYPROTOID,IDC_BYEMAIL,IDC_BYNAME,IDC_BYADVANCED,IDC_BYCUSTOM}; - for( i=0; i < SIZEOF(controls); i++ ) + for ( i=0; i < SIZEOF(controls); i++ ) CheckDlgButton(hwndDlg,controls[i],idControl==controls[i]?BST_CHECKED:BST_UNCHECKED); } @@ -342,7 +342,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP if ( !DBGetContactSettingTString( NULL, "FindAdd", "LastSearched", &dbv )) szProto = dbv.ptszVal; - for( i=0, netProtoCount=0; i < accounts.getCount(); i++ ) { + for ( i=0, netProtoCount=0; i < accounts.getCount(); i++ ) { if (!Proto_IsAccountEnabled( accounts[i] )) continue; DWORD caps = (DWORD)CallProtoService( accounts[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0 ); if (caps & PF1_BASICSEARCH || caps & PF1_EXTSEARCH || caps & PF1_SEARCHBYEMAIL || caps & PF1_SEARCHBYNAME) @@ -354,7 +354,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP cbei.iItem=0; hdc=GetDC(hwndDlg); SelectObject(hdc,(HFONT)SendDlgItemMessage(hwndDlg,IDC_PROTOLIST,WM_GETFONT,0,0)); - if(netProtoCount>1) { + if (netProtoCount>1) { cbei.pszText=TranslateT("All Networks"); GetTextExtentPoint32(hdc,cbei.pszText,lstrlen(cbei.pszText),&textSize); if (textSize.cx>cbwidth) cbwidth = textSize.cx; @@ -363,7 +363,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP SendDlgItemMessage(hwndDlg,IDC_PROTOLIST,CBEM_INSERTITEM,0,(LPARAM)&cbei); cbei.iItem++; } - for( i=0; i < accounts.getCount(); i++ ) { + for ( i=0; i < accounts.getCount(); i++ ) { PROTOACCOUNT* pa = accounts[i]; if (!Proto_IsAccountEnabled(pa)) continue; DWORD caps=(DWORD)CallProtoService( pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0 ); @@ -405,7 +405,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP CallService(MS_UTILS_RESIZEDIALOG,0,(LPARAM)&urd); ReposTinySearchDlg(hwndDlg, dat); SendDlgItemMessage(hwndDlg,IDC_STATUSBAR,WM_SIZE,0,0); - if(dat->notSearchedYet) { + if (dat->notSearchedYet) { RECT rc; GetClientRect(hwndList,&rc); ListView_SetColumnWidth(hwndList,0,rc.right); @@ -453,22 +453,22 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP PROTOACCOUNT* pa = accounts[i]; if (!Proto_IsAccountEnabled(pa)) continue; protoCaps=(DWORD)CallProtoService(pa->szModuleName,PS_GETCAPS,PFLAGNUM_1,0); - if(protoCaps&PF1_SEARCHBYEMAIL) dat->showEmail=1; - if(protoCaps&PF1_SEARCHBYNAME) dat->showName=1; + if (protoCaps&PF1_SEARCHBYEMAIL) dat->showEmail=1; + if (protoCaps&PF1_SEARCHBYNAME) dat->showName=1; } } else { protoCaps=(DWORD)CallProtoService(szProto,PS_GETCAPS,PFLAGNUM_1,0); - if(protoCaps&PF1_BASICSEARCH) dat->showProtoId=1; - if(protoCaps&PF1_SEARCHBYEMAIL) dat->showEmail=1; - if(protoCaps&PF1_SEARCHBYNAME) dat->showName=1; - if(protoCaps&PF1_EXTSEARCH && !(protoCaps&PF1_EXTSEARCHUI)) dat->showTiny=1; - if(protoCaps&PF1_EXTSEARCHUI) dat->showAdvanced=1; - if(protoCaps&PF1_USERIDISEMAIL && dat->showProtoId) {dat->showProtoId=0; dat->showEmail=1;} - if(dat->showProtoId) { + if (protoCaps&PF1_BASICSEARCH) dat->showProtoId=1; + if (protoCaps&PF1_SEARCHBYEMAIL) dat->showEmail=1; + if (protoCaps&PF1_SEARCHBYNAME) dat->showName=1; + if (protoCaps&PF1_EXTSEARCH && !(protoCaps&PF1_EXTSEARCHUI)) dat->showTiny=1; + if (protoCaps&PF1_EXTSEARCHUI) dat->showAdvanced=1; + if (protoCaps&PF1_USERIDISEMAIL && dat->showProtoId) {dat->showProtoId=0; dat->showEmail=1;} + if (dat->showProtoId) { char *szUniqueId; szUniqueId=(char*)CallProtoService(szProto,PS_GETCAPS,PFLAG_UNIQUEIDTEXT,0); - if(szUniqueId) { + if (szUniqueId) { #if defined( _UNICODE ) TCHAR* p = mir_a2u(szUniqueId); SetDlgItemText(hwndDlg,IDC_BYPROTOID,p); @@ -478,7 +478,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP #endif } else SetDlgItemText(hwndDlg,IDC_BYPROTOID,TranslateT("Handle")); - if(protoCaps&PF1_NUMERICUSERID) SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_PROTOID),GWL_STYLE,GetWindowLongPtr(GetDlgItem(hwndDlg,IDC_PROTOID),GWL_STYLE)|ES_NUMBER); + if (protoCaps&PF1_NUMERICUSERID) SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_PROTOID),GWL_STYLE,GetWindowLongPtr(GetDlgItem(hwndDlg,IDC_PROTOID),GWL_STYLE)|ES_NUMBER); else SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_PROTOID),GWL_STYLE,GetWindowLongPtr(GetDlgItem(hwndDlg,IDC_PROTOID),GWL_STYLE)&~ES_NUMBER); } } @@ -507,22 +507,22 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP (dat->showTiny && IsDlgButtonChecked(hwndDlg,IDC_BYCUSTOM)) || (dat->showName && IsDlgButtonChecked(hwndDlg,IDC_BYNAME)) || (dat->showProtoId && IsDlgButtonChecked(hwndDlg,IDC_BYPROTOID)); - if(!checkmarkVisible) { - if(dat->showProtoId) CheckSearchTypeRadioButton(hwndDlg,IDC_BYPROTOID); - else if(dat->showEmail) CheckSearchTypeRadioButton(hwndDlg,IDC_BYEMAIL); - else if(dat->showName) CheckSearchTypeRadioButton(hwndDlg,IDC_BYNAME); - else if(dat->showAdvanced) CheckSearchTypeRadioButton(hwndDlg,IDC_BYADVANCED); - else if(dat->showTiny) CheckSearchTypeRadioButton(hwndDlg,IDC_BYCUSTOM); + if (!checkmarkVisible) { + if (dat->showProtoId) CheckSearchTypeRadioButton(hwndDlg,IDC_BYPROTOID); + else if (dat->showEmail) CheckSearchTypeRadioButton(hwndDlg,IDC_BYEMAIL); + else if (dat->showName) CheckSearchTypeRadioButton(hwndDlg,IDC_BYNAME); + else if (dat->showAdvanced) CheckSearchTypeRadioButton(hwndDlg,IDC_BYADVANCED); + else if (dat->showTiny) CheckSearchTypeRadioButton(hwndDlg,IDC_BYCUSTOM); } SendMessage(hwndDlg,WM_SIZE,0,0); SendMessage(hwndDlg,WM_GETMINMAXINFO,0,(LPARAM)&mmi); GetWindowRect(hwndDlg,&rc); - if(rc.bottom-rc.topCtlID==IDC_STATUSBAR && dis->itemID==1) { + if (dis->CtlID==IDC_STATUSBAR && dis->itemID==1) { RenderThrobber(dis->hDC,&dis->rcItem,&dat->throbbing,&dat->pivot); return TRUE; } @@ -547,7 +547,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP switch(((LPNMHDR)lParam)->code) { case LVN_ITEMCHANGED: { int count=ListView_GetSelectedCount(hwndList); - if(dat->notSearchedYet) count=0; + if (dat->notSearchedYet) count=0; EnableResultButtons(hwndDlg,count); break; } @@ -560,7 +560,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP hdi.fmt=HDF_LEFT|HDF_STRING; Header_SetItem(ListView_GetHeader(hwndList),dat->iLastColumnSortIndex,&hdi); - if(nmlv->iSubItem!=dat->iLastColumnSortIndex) + if (nmlv->iSubItem!=dat->iLastColumnSortIndex) { dat->bSortAscending=TRUE; dat->iLastColumnSortIndex=nmlv->iSubItem; @@ -580,13 +580,13 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_PROTOLIST: - if(HIWORD(wParam)==CBN_SELCHANGE) { + if (HIWORD(wParam)==CBN_SELCHANGE) { HideAdvancedSearchDlg(hwndDlg,dat); - if(dat->hwndAdvSearch) { + if (dat->hwndAdvSearch) { DestroyWindow(dat->hwndAdvSearch); dat->hwndAdvSearch=NULL; } - if(dat->hwndTinySearch) { + if (dat->hwndTinySearch) { DestroyWindow(dat->hwndTinySearch); dat->hwndTinySearch=NULL; } @@ -603,14 +603,14 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP HideAdvancedSearchDlg(hwndDlg,dat); break; case IDC_PROTOID: - if(HIWORD(wParam)==EN_CHANGE) { + if (HIWORD(wParam)==EN_CHANGE) { HideAdvancedSearchDlg(hwndDlg,dat); CheckSearchTypeRadioButton(hwndDlg,IDC_BYPROTOID); EnableWindow(GetDlgItem(hwndDlg,IDC_ADD),TRUE); } break; case IDC_EMAIL: - if(HIWORD(wParam)==EN_CHANGE) { + if (HIWORD(wParam)==EN_CHANGE) { HideAdvancedSearchDlg(hwndDlg,dat); CheckSearchTypeRadioButton(hwndDlg,IDC_BYEMAIL); } @@ -618,14 +618,14 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP case IDC_NAMENICK: case IDC_NAMEFIRST: case IDC_NAMELAST: - if(HIWORD(wParam)==EN_CHANGE) { + if (HIWORD(wParam)==EN_CHANGE) { HideAdvancedSearchDlg(hwndDlg,dat); CheckSearchTypeRadioButton(hwndDlg,IDC_BYNAME); } break; case IDC_ADVANCED: EnableWindow(GetDlgItem(hwndDlg,IDC_ADD), ListView_GetSelectedCount(hwndList) > 0); - if(IsDlgButtonChecked(hwndDlg,IDC_ADVANCED)) + if (IsDlgButtonChecked(hwndDlg,IDC_ADVANCED)) ShowAdvancedSearchDlg(hwndDlg,dat); else HideAdvancedSearchDlg(hwndDlg,dat); @@ -637,42 +637,42 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP case IDOK: { HideAdvancedSearchDlg(hwndDlg,dat); - if(dat->searchCount) { //cancel search + if (dat->searchCount) { //cancel search SetDlgItemText(hwndDlg,IDOK,TranslateT("&Search")); - if(dat->hResultHook) {UnhookEvent(dat->hResultHook); dat->hResultHook=NULL;} - if(dat->search) {mir_free(dat->search); dat->search=NULL;} + if (dat->hResultHook) {UnhookEvent(dat->hResultHook); dat->hResultHook=NULL;} + if (dat->search) {mir_free(dat->search); dat->search=NULL;} dat->searchCount=0; StopThrobber(hwndDlg,dat); SetStatusBarSearchInfo(GetDlgItem(hwndDlg,IDC_STATUSBAR),dat); break; } char *szProto=(char*)SendDlgItemMessage(hwndDlg,IDC_PROTOLIST,CB_GETITEMDATA,SendDlgItemMessage(hwndDlg,IDC_PROTOLIST,CB_GETCURSEL,0,0),0); - if(dat->search) {mir_free(dat->search); dat->search=NULL;} + if (dat->search) {mir_free(dat->search); dat->search=NULL;} dat->searchCount=0; dat->hResultHook=HookEventMessage(ME_PROTO_ACK,hwndDlg,HM_SEARCHACK); if (IsDlgButtonChecked(hwndDlg,IDC_BYCUSTOM)) { BeginSearch(hwndDlg,dat,szProto,PS_SEARCHBYADVANCED,PF1_EXTSEARCHUI,dat->hwndTinySearch); } - else if(IsDlgButtonChecked(hwndDlg,IDC_BYPROTOID)) { + else if (IsDlgButtonChecked(hwndDlg,IDC_BYPROTOID)) { TCHAR str[256]; GetDlgItemText(hwndDlg,IDC_PROTOID,str,SIZEOF(str)); rtrim(str); - if(str[0]==0) + if (str[0]==0) MessageBox(hwndDlg,sttErrMsg,sttErrTitle,MB_OK); else BeginSearch(hwndDlg,dat,szProto,PS_BASICSEARCHT,PF1_BASICSEARCH,str); } - else if(IsDlgButtonChecked(hwndDlg,IDC_BYEMAIL)) { + else if (IsDlgButtonChecked(hwndDlg,IDC_BYEMAIL)) { TCHAR str[256]; GetDlgItemText(hwndDlg,IDC_EMAIL,str,SIZEOF(str)); rtrim(str); - if(str[0]==0) + if (str[0]==0) MessageBox(hwndDlg,sttErrMsg,sttErrTitle,MB_OK); else BeginSearch(hwndDlg,dat,szProto,PS_SEARCHBYEMAILT,PF1_SEARCHBYEMAIL,str); } - else if(IsDlgButtonChecked(hwndDlg,IDC_BYNAME)) { + else if (IsDlgButtonChecked(hwndDlg,IDC_BYNAME)) { TCHAR nick[256],first[256],last[256]; PROTOSEARCHBYNAME psbn; GetDlgItemText(hwndDlg,IDC_NAMENICK,nick,SIZEOF(nick)); @@ -681,20 +681,20 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP psbn.pszFirstName = first; psbn.pszLastName = last; psbn.pszNick = nick; - if(nick[0]==0 && first[0]==0 && last[0]==0) + if (nick[0]==0 && first[0]==0 && last[0]==0) MessageBox(hwndDlg,sttErrMsg,sttErrTitle,MB_OK); else BeginSearch(hwndDlg,dat,szProto,PS_SEARCHBYNAMET,PF1_SEARCHBYNAME,&psbn); } - else if(IsDlgButtonChecked(hwndDlg,IDC_BYADVANCED)) { - if(dat->hwndAdvSearch==NULL) + else if (IsDlgButtonChecked(hwndDlg,IDC_BYADVANCED)) { + if (dat->hwndAdvSearch==NULL) MessageBox(hwndDlg,sttErrMsg,sttErrTitle,MB_OK); else BeginSearch(hwndDlg,dat,szProto,PS_SEARCHBYADVANCED,PF1_EXTSEARCHUI,dat->hwndAdvSearch); } - if(dat->searchCount==0) { - if(dat->hResultHook) {UnhookEvent(dat->hResultHook); dat->hResultHook=NULL;} + if (dat->searchCount==0) { + if (dat->hResultHook) {UnhookEvent(dat->hResultHook); dat->hResultHook=NULL;} break; } @@ -764,9 +764,9 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP ScreenToClient(hwndDlg,&pt); switch(GetDlgCtrlID(ChildWindowFromPoint(hwndDlg,pt))) { case IDC_RESULTS: - if(dat->notSearchedYet) return TRUE; + if (dat->notSearchedYet) return TRUE; ScreenToClient(hwndList,&lvhti.pt); - if(ListView_HitTest(hwndList,&lvhti)==-1) break; + if (ListView_HitTest(hwndList,&lvhti) == -1) break; ShowMoreOptionsMenu(hwndDlg,(short)LOWORD(lParam),(short)HIWORD(lParam)); return TRUE; } @@ -776,14 +776,14 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP { ACKDATA *ack=(ACKDATA*)lParam; int i; - if(ack->type!=ACKTYPE_SEARCH) break; - for(i=0;isearchCount;i++) - if(dat->search[i].hProcess==ack->hProcess && dat->search[i].hProcess != NULL && !lstrcmpA(dat->search[i].szProto,ack->szModule)) break; - if(i==dat->searchCount) break; - if(ack->result==ACKRESULT_SUCCESS || ack->result==ACKRESULT_FAILED) { + if (ack->type!=ACKTYPE_SEARCH) break; + for (i=0;isearchCount;i++) + if (dat->search[i].hProcess==ack->hProcess && dat->search[i].hProcess != NULL && !lstrcmpA(dat->search[i].szProto,ack->szModule)) break; + if (i==dat->searchCount) break; + if (ack->result==ACKRESULT_SUCCESS || ack->result==ACKRESULT_FAILED) { dat->searchCount--; memmove(dat->search+i,dat->search+i+1,sizeof(struct ProtoSearchInfo)*(dat->searchCount-i)); - if(dat->searchCount==0) { + if (dat->searchCount==0) { mir_free(dat->search); dat->search=NULL; UnhookEvent(dat->hResultHook); @@ -794,7 +794,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP ListView_SortItemsEx(hwndList, SearchResultsCompareFunc, (LPARAM)hwndDlg); SetStatusBarSearchInfo(GetDlgItem(hwndDlg,IDC_STATUSBAR),dat); } - else if(ack->result==ACKRESULT_SEARCHRESULT && ack->lParam) { + else if (ack->result==ACKRESULT_SEARCHRESULT && ack->lParam) { PROTOSEARCHRESULT *psr; CUSTOMSEARCHRESULTS * csr=(CUSTOMSEARCHRESULTS*)ack->lParam; @@ -876,7 +876,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP } break; } - else if(ack->result==ACKRESULT_DATA) { + else if (ack->result==ACKRESULT_DATA) { LVITEM lvi={0}; int i,col; PROTOSEARCHRESULT *psr=(PROTOSEARCHRESULT*)ack->lParam; @@ -897,11 +897,11 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP lvi.mask = LVIF_PARAM|LVIF_IMAGE; lvi.lParam=(LPARAM)lsr; - for(i = SendDlgItemMessage(hwndDlg,IDC_PROTOLIST,CB_GETCOUNT,0,0); i--; ) + for (i = SendDlgItemMessage(hwndDlg,IDC_PROTOLIST,CB_GETCOUNT,0,0); i--; ) { szComboProto=(char*)SendDlgItemMessage(hwndDlg,IDC_PROTOLIST,CB_GETITEMDATA,i,0); - if(szComboProto==NULL) continue; - if(!lstrcmpA(szComboProto,ack->szModule)) { + if (szComboProto==NULL) continue; + if (!lstrcmpA(szComboProto,ack->szModule)) { cbei.mask=CBEIF_IMAGE; cbei.iItem=i; SendDlgItemMessage(hwndDlg,IDC_PROTOLIST,CBEM_GETITEM,0,(LPARAM)&cbei); @@ -933,15 +933,15 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP DBWriteContactSettingTString(NULL, "FindAdd", "LastSearched", szProto?szProto:_T("")); } SaveColumnSizes(hwndList); - if(dat->hResultHook!=NULL) UnhookEvent(dat->hResultHook); + if (dat->hResultHook!=NULL) UnhookEvent(dat->hResultHook); FreeSearchResults(hwndList); ImageList_Destroy(dat->himlComboIcons); mir_free(dat->search); - if(dat->hwndAdvSearch) { + if (dat->hwndAdvSearch) { DestroyWindow(dat->hwndAdvSearch); dat->hwndAdvSearch=NULL; } - if(dat->hwndTinySearch) { + if (dat->hwndTinySearch) { DestroyWindow(dat->hwndTinySearch); dat->hwndTinySearch=NULL; } @@ -958,7 +958,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP static INT_PTR FindAddCommand(WPARAM, LPARAM) { - if(IsWindow(hwndFindAdd)) { + if (IsWindow(hwndFindAdd)) { ShowWindow(hwndFindAdd,SW_SHOWNORMAL); SetForegroundWindow(hwndFindAdd); SetFocus(hwndFindAdd); diff --git a/src/modules/findadd/searchresults.cpp b/src/modules/findadd/searchresults.cpp index f3b3066999..868cd1f126 100644 --- a/src/modules/findadd/searchresults.cpp +++ b/src/modules/findadd/searchresults.cpp @@ -45,10 +45,10 @@ void SaveColumnSizes(HWND hwndResults) columnCount=Header_GetItemCount(ListView_GetHeader(hwndResults)); if (columnCount != NUM_COLUMNID) return; ListView_GetColumnOrderArray(hwndResults,columnCount,columnOrder); - for(i=0; i < NUM_COLUMNID; i++) { + for (i=0; i < NUM_COLUMNID; i++) { mir_snprintf(szSetting, SIZEOF(szSetting), "ColOrder%d", i); DBWriteContactSettingByte(NULL,"FindAdd",szSetting,(BYTE)columnOrder[i]); - if(i>=columnCount) continue; + if (i>=columnCount) continue; mir_snprintf(szSetting, SIZEOF(szSetting), "ColWidth%d", i); DBWriteContactSettingWord(NULL,"FindAdd",szSetting,(WORD)ListView_GetColumnWidth(hwndResults,i)); } @@ -73,16 +73,16 @@ void LoadColumnSizes(HWND hwndResults,const char *szProto) columnCount = NUM_COLUMNID; colOrdersValid = true; - for(i=0; i < NUM_COLUMNID; i++) + for (i=0; i < NUM_COLUMNID; i++) { LVCOLUMN lvc; - if( i < columnCount ) + if ( i < columnCount ) { int bNeedsFree = FALSE; lvc.mask = LVCF_TEXT | LVCF_WIDTH; - if( szColumnNames[i] != NULL ) + if ( szColumnNames[i] != NULL ) lvc.pszText = TranslateTS( szColumnNames[i] ); - else if( i == COLUMNID_HANDLE ) + else if ( i == COLUMNID_HANDLE ) { if (szProto) { @@ -179,11 +179,11 @@ void FreeSearchResults(HWND hwndResults) { LV_ITEM lvi; struct ListSearchResult *lsr; - for(lvi.iItem=ListView_GetItemCount(hwndResults)-1;lvi.iItem>=0;lvi.iItem--) { + for (lvi.iItem=ListView_GetItemCount(hwndResults)-1;lvi.iItem>=0;lvi.iItem--) { lvi.mask=LVIF_PARAM; ListView_GetItem(hwndResults,&lvi); lsr=(struct ListSearchResult*)lvi.lParam; - if(lsr==NULL) continue; + if (lsr==NULL) continue; mir_free(lsr->psr.id); mir_free(lsr->psr.email); mir_free(lsr->psr.nick); @@ -217,19 +217,19 @@ int BeginSearch(HWND,struct FindAddDlgData *dat,const char *szProto,const char * int failures = 0; dat->searchCount = 0; dat->search = (struct ProtoSearchInfo*)mir_calloc(sizeof(struct ProtoSearchInfo) * accounts.getCount()); - for( i=0; i < accounts.getCount();i++) { + for ( i=0; i < accounts.getCount();i++) { PROTOACCOUNT* pa = accounts[i]; if (!Proto_IsAccountEnabled(pa)) continue; DWORD caps=(DWORD)CallProtoService(pa->szModuleName,PS_GETCAPS,PFLAGNUM_1,0); - if(!(caps&requiredCapability)) continue; + if (!(caps&requiredCapability)) continue; dat->search[dat->searchCount].hProcess = (HANDLE)CallProtoService(pa->szModuleName,szSearchService,0,(LPARAM)pvSearchParams); dat->search[dat->searchCount].szProto = pa->szModuleName; if ( dat->search[dat->searchCount].hProcess == NULL ) failures++; else dat->searchCount++; } - if(failures) { + if (failures) { //infuriatingly vague error message. fixme. - if(dat->searchCount==0) { + if (dat->searchCount==0) { forkthread(BeginSearchFailed,0,NULL); mir_free(dat->search); dat->search=NULL; @@ -241,7 +241,7 @@ int BeginSearch(HWND,struct FindAddDlgData *dat,const char *szProto,const char * dat->searchCount=1; dat->search[0].hProcess=(HANDLE)CallProtoService(szProto,szSearchService,0,(LPARAM)pvSearchParams); dat->search[0].szProto=szProto; - if(dat->search[0].hProcess==NULL) { + if (dat->search[0].hProcess==NULL) { //infuriatingly vague error message. fixme. PROTOACCOUNT* pa = Proto_GetAccount(szProto); forkthread(BeginSearchFailed, 0, mir_tstrdup(pa->tszAccountName)); @@ -263,7 +263,7 @@ void SetStatusBarSearchInfo(HWND hwndStatus,struct FindAddDlgData *dat) int i; lstrcpy( str, TranslateT("Searching")); - for( i=0; i < dat->searchCount; i++ ) { + for ( i=0; i < dat->searchCount; i++ ) { PROTOACCOUNT* pa = Proto_GetAccount( dat->search[i].szProto ); if ( !pa ) continue; @@ -292,18 +292,18 @@ void SetStatusBarResultInfo(HWND hwndDlg) TCHAR str[256]; total=ListView_GetItemCount(hwndResults); - for(lvi.iItem=total-1;lvi.iItem>=0;lvi.iItem--) { + for (lvi.iItem=total-1;lvi.iItem>=0;lvi.iItem--) { lvi.mask=LVIF_PARAM; ListView_GetItem(hwndResults,&lvi); lsr=(struct ListSearchResult*)lvi.lParam; - if(lsr==NULL) continue; - for(i=0;iszProto) { + if (lsr==NULL) continue; + for (i=0;iszProto) { subtotal[i].count++; break; } } - if(i==subtotalCount) { + if (i==subtotalCount) { subtotal=(struct ProtoResultsSummary*)mir_realloc(subtotal,sizeof(struct ProtoResultsSummary)*(subtotalCount+1)); subtotal[subtotalCount].szProto=lsr->szProto; subtotal[subtotalCount++].count=1; @@ -316,12 +316,12 @@ void SetStatusBarResultInfo(HWND hwndDlg) return; if ( subtotalCount == 1 ) { - if(total==1) mir_sntprintf( str, SIZEOF(str), TranslateT("1 %s user found"), pa->tszAccountName ); + if (total==1) mir_sntprintf( str, SIZEOF(str), TranslateT("1 %s user found"), pa->tszAccountName ); else mir_sntprintf( str, SIZEOF(str), TranslateT("%d %s users found"), total, pa->tszAccountName ); } else { mir_sntprintf( str, SIZEOF(str), TranslateT("%d users found ("),total); - for( i=0; i < subtotalCount; i++ ) { + for ( i=0; i < subtotalCount; i++ ) { if ( i ) { if (( pa = Proto_GetAccount( subtotal[i].szProto )) == NULL ) return; @@ -356,7 +356,7 @@ void ShowMoreOptionsMenu(HWND hwndDlg,int x,int y) dat=(struct FindAddDlgData*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA); { LVITEM lvi; - if(ListView_GetSelectedCount(GetDlgItem(hwndDlg,IDC_RESULTS))!=1) return; + if (ListView_GetSelectedCount(GetDlgItem(hwndDlg,IDC_RESULTS))!=1) return; lvi.mask=LVIF_PARAM; lvi.iItem=ListView_GetNextItem(GetDlgItem(hwndDlg,IDC_RESULTS),-1,LVNI_ALL|LVNI_SELECTED); ListView_GetItem(GetDlgItem(hwndDlg,IDC_RESULTS),&lvi); diff --git a/src/modules/fonts/FontOptions.cpp b/src/modules/fonts/FontOptions.cpp index 801f023141..b38936f8c6 100644 --- a/src/modules/fonts/FontOptions.cpp +++ b/src/modules/fonts/FontOptions.cpp @@ -140,7 +140,7 @@ BOOL ExportSettings(HWND hwndDlg, TCHAR *filename, OBJLIST& flist, OBJL char header[512], buff[1024], abuff[1024]; HANDLE fhand = CreateFile(filename, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0); - if(fhand == INVALID_HANDLE_VALUE) { + if (fhand == INVALID_HANDLE_VALUE) { MessageBox(hwndDlg, filename, TranslateT("Failed to create file"), MB_ICONWARNING | MB_OK); return FALSE; } @@ -191,7 +191,7 @@ BOOL ExportSettings(HWND hwndDlg, TCHAR *filename, OBJLIST& flist, OBJL strcat(buff, _itoa((BYTE)size.cy, abuff, 10)); } - else if(F.flags & FIDF_SAVEPOINTSIZE) { + else if (F.flags & FIDF_SAVEPOINTSIZE) { HDC hdc = GetDC(hwndDlg); strcat(buff, _itoa((BYTE)-MulDiv(F.value.size, 72, GetDeviceCaps(hdc, LOGPIXELSY)), abuff, 10)); ReleaseDC(hwndDlg, hdc); @@ -206,7 +206,7 @@ BOOL ExportSettings(HWND hwndDlg, TCHAR *filename, OBJLIST& flist, OBJL WriteLine(fhand, buff); mir_snprintf(buff, SIZEOF(buff), "%sCol=d%d", F.prefix, (DWORD)F.value.colour); WriteLine(fhand, buff); - if(F.flags & FIDF_NOAS) { + if (F.flags & FIDF_NOAS) { mir_snprintf(buff, SIZEOF(buff), "%sAs=w%d", F.prefix, (WORD)0x00FF); WriteLine(fhand, buff); } @@ -219,7 +219,7 @@ BOOL ExportSettings(HWND hwndDlg, TCHAR *filename, OBJLIST& flist, OBJL TColourID& C = clist[i]; mir_snprintf(buff, SIZEOF(buff), "\r\n[%s]", C.dbSettingsGroup ); - if(strcmp(buff, header) != 0) { + if (strcmp(buff, header) != 0) { strcpy(header, buff); WriteLine(fhand, buff); } @@ -232,7 +232,7 @@ BOOL ExportSettings(HWND hwndDlg, TCHAR *filename, OBJLIST& flist, OBJL TEffectID& E = elist[i]; mir_snprintf(buff, SIZEOF(buff), "\r\n[%s]", E.dbSettingsGroup ); - if(strcmp(buff, header) != 0) { + if (strcmp(buff, header) != 0) { strcpy(header, buff); WriteLine(fhand, buff); } @@ -265,7 +265,7 @@ UINT_PTR CALLBACK CFHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam TranslateDialogDefault(hdlg); ShowWindow(GetDlgItem(hdlg, 1095), SW_HIDE); - if(cf && (cf->lCustData & FIDF_DISABLESTYLES)) { + if (cf && (cf->lCustData & FIDF_DISABLESTYLES)) { EnableWindow(GetDlgItem(hdlg, 1137), FALSE); ShowWindow(GetDlgItem(hdlg, 1137), SW_HIDE); ShowWindow(GetDlgItem(hdlg, 1095), SW_SHOW); @@ -428,7 +428,7 @@ static void sttSaveCollapseState( HWND hwndTree ) tvi.stateMask = (DWORD)-1; TreeView_GetItem( hwndTree, &tvi ); - if( tvi.cChildren > 0 ) { + if ( tvi.cChildren > 0 ) { treeItem = (TreeItem *)tvi.lParam; if ( tvi.state & TVIS_EXPANDED ) DBWriteContactSettingByte(NULL, "FontServiceUI", treeItem->paramName, TVIS_EXPANDED ); @@ -437,11 +437,11 @@ static void sttSaveCollapseState( HWND hwndTree ) } ht = TreeView_GetChild( hwndTree, hti ); - if( ht == NULL ) { + if ( ht == NULL ) { ht = TreeView_GetNextSibling( hwndTree, hti ); while( ht == NULL ) { hti = TreeView_GetParent( hwndTree, hti ); - if( hti == NULL ) break; + if ( hti == NULL ) break; ht = TreeView_GetNextSibling( hwndTree, hti ); } } @@ -810,7 +810,7 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam, FONTEFFECT Effect; FONTEFFECT * pEffect = NULL; - if(dis->CtlID != IDC_FONTLIST) + if (dis->CtlID != IDC_FONTLIST) break; if (!itemData) return FALSE; @@ -1156,7 +1156,7 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam, FSUIListItemData *itemData = (FSUIListItemData *)SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETITEMDATA, selItems[i], 0); if (IsBadReadPtr(itemData, sizeof(FSUIListItemData))) continue; // prevent possible problems with corrupted itemData - if((itemData->font_id >= 0) && (font_id_list_w2[itemData->font_id].flags & FIDF_DEFAULTVALID)) { + if ((itemData->font_id >= 0) && (font_id_list_w2[itemData->font_id].flags & FIDF_DEFAULTVALID)) { font_id_list_w2[itemData->font_id].value = font_id_list_w2[itemData->font_id].deffontsettings; MEASUREITEMSTRUCT mis = { 0 }; diff --git a/src/modules/fonts/services.cpp b/src/modules/fonts/services.cpp index 2681855c90..09e465c59a 100644 --- a/src/modules/fonts/services.cpp +++ b/src/modules/fonts/services.cpp @@ -128,7 +128,7 @@ int GetFontSettingFromDB(char *settings_group, char *prefix, LOGFONT* lf, COLORR GetDefaultFontSetting(lf, colour); - if(flags & FIDF_APPENDNAME) mir_snprintf(idstr, SIZEOF(idstr), "%sName", prefix); + if (flags & FIDF_APPENDNAME) mir_snprintf(idstr, SIZEOF(idstr), "%sName", prefix); else mir_snprintf(idstr, SIZEOF(idstr), "%s", prefix); if ( !DBGetContactSettingTString(NULL, settings_group, idstr, &dbv )) { @@ -147,7 +147,7 @@ int GetFontSettingFromDB(char *settings_group, char *prefix, LOGFONT* lf, COLORR //wsprintf(idstr, "%sFlags", prefix); - //if(DBGetContactSettingDword(NULL, settings_group, idstr, 0) & FIDF_SAVEACTUALHEIGHT) { + //if (DBGetContactSettingDword(NULL, settings_group, idstr, 0) & FIDF_SAVEACTUALHEIGHT) { // HDC hdc = GetDC(0); // lf->lfHeight = -lf->lfHeight; // ReleaseDC(0, hdc); @@ -171,9 +171,9 @@ int GetFontSettingFromDB(char *settings_group, char *prefix, LOGFONT* lf, COLORR lf->lfQuality = DEFAULT_QUALITY; lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; - if(lf->lfHeight > 0) { + if (lf->lfHeight > 0) { HDC hdc = GetDC(0); - if(flags & FIDF_SAVEPOINTSIZE) { + if (flags & FIDF_SAVEPOINTSIZE) { lf->lfHeight = -MulDiv(lf->lfHeight,GetDeviceCaps(hdc, LOGPIXELSY), 72); } else { // assume SAVEACTUALHEIGHT TEXTMETRIC tm; diff --git a/src/modules/history/history.cpp b/src/modules/history/history.cpp index adc29f469c..dda1617443 100644 --- a/src/modules/history/history.cpp +++ b/src/modules/history/history.cpp @@ -212,14 +212,14 @@ static void FillHistoryThread(void* param) if ( !IsWindow( hInfo->hwnd )) break; newBlobSize=CallService(MS_DB_EVENT_GETBLOBSIZE,(WPARAM)hDbEvent,0); - if(newBlobSize>oldBlobSize) { + if (newBlobSize>oldBlobSize) { dbei.pBlob=(PBYTE)mir_realloc(dbei.pBlob,newBlobSize); oldBlobSize=newBlobSize; } dbei.cbBlob = oldBlobSize; CallService( MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei ); GetObjectSummary(&dbei,str,SIZEOF(str)); - if(str[0]) { + if (str[0]) { tmi.printTimeStamp(NULL, dbei.timestamp, _T("d t"), strdatetime, SIZEOF(strdatetime), 0); mir_sntprintf( eventText, SIZEOF(eventText), _T("%s: %s"), strdatetime, str ); i = SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)eventText ); @@ -337,7 +337,7 @@ static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LP DBEVENTINFO dbei; int sel; sel=SendDlgItemMessage(hwndDlg,IDC_LIST,LB_GETCURSEL,0,0); - if(sel==LB_ERR) { EnableWindow(GetDlgItem(hwndDlg,IDC_DELETEHISTORY),FALSE); break; } + if (sel==LB_ERR) { EnableWindow(GetDlgItem(hwndDlg,IDC_DELETEHISTORY),FALSE); break; } EnableWindow(GetDlgItem(hwndDlg,IDC_DELETEHISTORY),TRUE); contactName = cli.pfnGetContactDisplayName( hContact, 0 ); hDbEvent=(HANDLE)SendDlgItemMessage(hwndDlg,IDC_LIST,LB_GETITEMDATA,sel,0); @@ -375,24 +375,24 @@ static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LP dbei.cbSize=sizeof(dbei); dbei.pBlob=NULL; oldBlobSize=0; - for(;;) { + for (;;) { hDbEvent = (HANDLE)SendDlgItemMessage(hwndDlg,IDC_LIST,LB_GETITEMDATA,++index,0); - if(hDbEvent == ( HANDLE )LB_ERR) { + if (hDbEvent == ( HANDLE )LB_ERR) { index = -1; continue; } - if(hDbEvent==hDbEventStart) break; + if (hDbEvent==hDbEventStart) break; newBlobSize=CallService(MS_DB_EVENT_GETBLOBSIZE,(WPARAM)hDbEvent,0); - if(newBlobSize>oldBlobSize) { + if (newBlobSize>oldBlobSize) { dbei.pBlob=(PBYTE)mir_realloc(dbei.pBlob,newBlobSize); oldBlobSize=newBlobSize; } dbei.cbBlob=oldBlobSize; CallService(MS_DB_EVENT_GET,(WPARAM)hDbEvent,(LPARAM)&dbei); GetObjectDescription(&dbei,str,SIZEOF(str)); - if(str[0]) { + if (str[0]) { CharUpperBuff(str,lstrlen(str)); - if( _tcsstr(str,(const TCHAR*)lParam)!=NULL) { + if ( _tcsstr(str,(const TCHAR*)lParam)!=NULL) { SendDlgItemMessage(hwndDlg,IDC_LIST,LB_SETCURSEL,index,0); SendMessage(hwndDlg,WM_COMMAND,MAKEWPARAM(IDC_LIST,LBN_SELCHANGE),0); break; diff --git a/src/modules/icolib/extracticon.cpp b/src/modules/icolib/extracticon.cpp index f1ce824575..fae0a073fd 100644 --- a/src/modules/icolib/extracticon.cpp +++ b/src/modules/icolib/extracticon.cpp @@ -103,7 +103,7 @@ IMAGE_RESOURCE_DIRECTORY_ENTRY* _FindResourceBase(void* prt, int resType, int* p count = pDir->NumberOfIdEntries + pDir->NumberOfNamedEntries; pRes = (IMAGE_RESOURCE_DIRECTORY_ENTRY*)(pDir+1); - for(i = 0; i < count; i++) + for (i = 0; i < count; i++) if (pRes[i].Name == (DWORD)resType) break; if (i == count) return NULL; @@ -134,7 +134,7 @@ void* _FindResource(IMAGE_DOS_HEADER* pDosHeader, void* prt, int resIndex, int r pRes = _FindResourceBase(prt, resType, &count); if (resIndex < 0) { - for(index = 0; index < count; index++) + for (index = 0; index < count; index++) if (pRes[index].Name == (DWORD)(-resIndex)) break; } diff --git a/src/modules/icolib/skin2icons.cpp b/src/modules/icolib/skin2icons.cpp index 8ebc39a334..ab7975399f 100644 --- a/src/modules/icolib/skin2icons.cpp +++ b/src/modules/icolib/skin2icons.cpp @@ -1446,7 +1446,7 @@ static void SaveCollapseState( HWND hwndTree ) tvi.stateMask = (DWORD)-1; TreeView_GetItem( hwndTree, &tvi ); - if( tvi.cChildren > 0 ) { + if ( tvi.cChildren > 0 ) { treeItem = (TreeItem *)tvi.lParam; if ( tvi.state & TVIS_EXPANDED ) DBWriteContactSettingByte(NULL, "SkinIconsUI", treeItem->paramName, TVIS_EXPANDED ); @@ -1455,11 +1455,11 @@ static void SaveCollapseState( HWND hwndTree ) } ht = TreeView_GetChild( hwndTree, hti ); - if( ht == NULL ) { + if ( ht == NULL ) { ht = TreeView_GetNextSibling( hwndTree, hti ); while( ht == NULL ) { hti = TreeView_GetParent( hwndTree, hti ); - if( hti == NULL ) break; + if ( hti == NULL ) break; ht = TreeView_GetNextSibling( hwndTree, hti ); } } @@ -1776,7 +1776,7 @@ INT_PTR CALLBACK DlgProcIcoLibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM break; case IDC_PREVIEW: - if(((LPNMHDR)lParam)->code == LVN_GETINFOTIP) + if (((LPNMHDR)lParam)->code == LVN_GETINFOTIP) { IconItem *item; NMLVGETINFOTIP *pInfoTip = (NMLVGETINFOTIP *)lParam; @@ -1785,11 +1785,11 @@ INT_PTR CALLBACK DlgProcIcoLibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lvi.iItem = pInfoTip->iItem; ListView_GetItem(pInfoTip->hdr.hwndFrom, &lvi); - if( lvi.lParam < iconList.getCount() ) { + if ( lvi.lParam < iconList.getCount() ) { item = iconList[lvi.lParam]; - if( item->temp_file ) + if ( item->temp_file ) _tcsncpy( pInfoTip->pszText, item->temp_file, pInfoTip->cchTextMax ); - else if( item->default_file ) + else if ( item->default_file ) mir_sntprintf( pInfoTip->pszText, pInfoTip->cchTextMax, _T("%s,%d"), item->default_file, item->default_indx ); } } diff --git a/src/modules/ignore/ignore.cpp b/src/modules/ignore/ignore.cpp index 0017ae7e15..d25576af61 100644 --- a/src/modules/ignore/ignore.cpp +++ b/src/modules/ignore/ignore.cpp @@ -30,10 +30,10 @@ static const DWORD ignoreIdToPf4[IGNOREEVENT_MAX]={0xFFFFFFFF,0xFFFFFFFF,0xFFFFF static DWORD GetMask(HANDLE hContact) { DWORD mask=DBGetContactSettingDword(hContact,"Ignore","Mask1",(DWORD)(-1)); - if(mask==(DWORD)(-1)) { - if(hContact==NULL) mask=0; + if (mask==(DWORD)(-1)) { + if (hContact==NULL) mask=0; else { - if(DBGetContactSettingByte(hContact,"CList","Hidden",0) || DBGetContactSettingByte(hContact,"CList","NotOnList",0)) + if (DBGetContactSettingByte(hContact,"CList","Hidden",0) || DBGetContactSettingByte(hContact,"CList","NotOnList",0)) mask=DBGetContactSettingDword(NULL,"Ignore","Mask1",0); else mask=DBGetContactSettingDword(NULL,"Ignore","Default1",0); @@ -52,30 +52,30 @@ static void SetListGroupIcons(HWND hwndList,HANDLE hFirstItem,HANDLE hParentItem typeOfFirst=SendMessage(hwndList,CLM_GETITEMTYPE,(WPARAM)hFirstItem,0); //check groups - if(typeOfFirst==CLCIT_GROUP) hItem=hFirstItem; + if (typeOfFirst==CLCIT_GROUP) hItem=hFirstItem; else hItem=(HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_NEXTGROUP,(LPARAM)hFirstItem); while(hItem) { hChildItem=(HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_CHILD,(LPARAM)hItem); - if(hChildItem) SetListGroupIcons(hwndList,hChildItem,hItem,childCount); - for(i=0; i < SIZEOF(iconOn); i++) - if(iconOn[i] && SendMessage(hwndList,CLM_GETEXTRAIMAGE,(WPARAM)hItem,i)==0) iconOn[i]=0; + if (hChildItem) SetListGroupIcons(hwndList,hChildItem,hItem,childCount); + 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); } //check contacts - if(typeOfFirst==CLCIT_CONTACT) hItem=hFirstItem; + if (typeOfFirst==CLCIT_CONTACT) hItem=hFirstItem; 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; - if(iImage!=0xFF) childCount[i]++; + if (iconOn[i] && iImage==0) iconOn[i]=0; + if (iImage!=0xFF) childCount[i]++; } 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):0xFF)); - if(groupChildCount) groupChildCount[i]+=childCount[i]; + if (groupChildCount) groupChildCount[i]+=childCount[i]; } SendMessage(hwndList,CLM_SETEXTRAIMAGE,(WPARAM)hParentItem,MAKELPARAM(IGNOREEVENT_MAX,1)); SendMessage(hwndList,CLM_SETEXTRAIMAGE,(WPARAM)hParentItem,MAKELPARAM(IGNOREEVENT_MAX+1,2)); @@ -88,19 +88,19 @@ static void SetAllChildIcons(HWND hwndList,HANDLE hFirstItem,int iColumn,int iIm typeOfFirst=SendMessage(hwndList,CLM_GETITEMTYPE,(WPARAM)hFirstItem,0); //check groups - if(typeOfFirst==CLCIT_GROUP) hItem=hFirstItem; + if (typeOfFirst==CLCIT_GROUP) hItem=hFirstItem; else hItem=(HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_NEXTGROUP,(LPARAM)hFirstItem); while(hItem) { hChildItem=(HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_CHILD,(LPARAM)hItem); - if(hChildItem) SetAllChildIcons(hwndList,hChildItem,iColumn,iImage); + if (hChildItem) SetAllChildIcons(hwndList,hChildItem,iColumn,iImage); hItem=(HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_NEXTGROUP,(LPARAM)hItem); } //check contacts - if(typeOfFirst==CLCIT_CONTACT) hItem=hFirstItem; + if (typeOfFirst==CLCIT_CONTACT) hItem=hFirstItem; else hItem=(HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_NEXTCONTACT,(LPARAM)hFirstItem); while(hItem) { iOldIcon=SendMessage(hwndList,CLM_GETEXTRAIMAGE,(WPARAM)hItem,iColumn); - if(iOldIcon!=0xFF && iOldIcon!=iImage) SendMessage(hwndList,CLM_SETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(iColumn,iImage)); + if (iOldIcon!=0xFF && iOldIcon!=iImage) SendMessage(hwndList,CLM_SETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(iColumn,iImage)); hItem=(HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_NEXTCONTACT,(LPARAM)hItem); } } @@ -115,7 +115,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)); } @@ -124,18 +124,18 @@ static void SetIconsForColumn(HWND hwndList,HANDLE hItem,HANDLE hItemAll,int iCo int itemType; itemType=SendMessage(hwndList,CLM_GETITEMTYPE,(WPARAM)hItem,0); - if(itemType==CLCIT_CONTACT) { + if (itemType==CLCIT_CONTACT) { int oldiImage = SendMessage(hwndList,CLM_GETEXTRAIMAGE,(WPARAM)hItem,iColumn); if (oldiImage!=0xFF&&oldiImage!=iImage) SendMessage(hwndList,CLM_SETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(iColumn,iImage)); } - else if(itemType==CLCIT_INFO) { - if(hItem==hItemAll) SetAllChildIcons(hwndList,hItem,iColumn,iImage); + else if (itemType==CLCIT_INFO) { + if (hItem==hItemAll) SetAllChildIcons(hwndList,hItem,iColumn,iImage); else SendMessage(hwndList,CLM_SETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(iColumn,iImage)); //hItemUnknown } - else if(itemType==CLCIT_GROUP) { + else if (itemType==CLCIT_GROUP) { hItem=(HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_CHILD,(LPARAM)hItem); - if(hItem) SetAllChildIcons(hwndList,hItem,iColumn,iImage); + if (hItem) SetAllChildIcons(hwndList,hItem,iColumn,iImage); } } @@ -145,8 +145,8 @@ static void InitialiseItem(HWND hwndList,HANDLE hContact,HANDLE hItem,DWORD prot int i; mask=GetMask(hContact); - for(i=0;iiColumn==-1) break; + if (nm->iColumn==-1) break; hItem=(HANDLE)SendDlgItemMessage(hwndDlg,IDC_LIST,CLM_HITTEST,(WPARAM)&hitFlags,MAKELPARAM(nm->pt.x,nm->pt.y)); - if(hItem==NULL) break; - if(!(hitFlags&CLCHT_ONITEMEXTRA)) break; - if(nm->iColumn==IGNOREEVENT_MAX) { //ignore all - for(iImage=0;iImageiColumn==IGNOREEVENT_MAX) { //ignore all + for (iImage=0;iImageiColumn==IGNOREEVENT_MAX+1) { //ignore none - for(iImage=0;iImageiColumn==IGNOREEVENT_MAX+1) { //ignore none + for (iImage=0;iImageiColumn,0)); - if(iImage==0) iImage=nm->iColumn+3; - else if(iImage!=0xFF) iImage=0; + if (iImage==0) iImage=nm->iColumn+3; + else if (iImage!=0xFF) iImage=0; SetIconsForColumn(GetDlgItem(hwndDlg,IDC_LIST),hItem,hItemAll,nm->iColumn,iImage); } SetListGroupIcons(GetDlgItem(hwndDlg,IDC_LIST),(HANDLE)SendDlgItemMessage(hwndDlg,IDC_LIST,CLM_GETNEXTITEM,CLGN_ROOT,0),hItemAll,NULL); @@ -308,8 +308,8 @@ static INT_PTR CALLBACK DlgProcIgnoreOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0); do { hItem=(HANDLE)SendDlgItemMessage(hwndDlg,IDC_LIST,CLM_FINDCONTACT,(WPARAM)hContact,0); - if(hItem) SaveItemMask(GetDlgItem(hwndDlg,IDC_LIST),hContact,hItem,"Mask1"); - if(SendDlgItemMessage(hwndDlg,IDC_LIST,CLM_GETCHECKMARK,(WPARAM)hItem,0)) + if (hItem) SaveItemMask(GetDlgItem(hwndDlg,IDC_LIST),hContact,hItem,"Mask1"); + if (SendDlgItemMessage(hwndDlg,IDC_LIST,CLM_GETCHECKMARK,(WPARAM)hItem,0)) DBDeleteContactSetting(hContact,"CList","Hidden"); else DBWriteContactSettingByte(hContact,"CList","Hidden",1); @@ -329,7 +329,7 @@ static INT_PTR CALLBACK DlgProcIgnoreOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM 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); @@ -360,15 +360,15 @@ static int IgnoreOptInitialise(WPARAM wParam, LPARAM) static INT_PTR IsIgnored(WPARAM wParam,LPARAM lParam) { DWORD mask=GetMask((HANDLE)wParam); - if(lParam<1 || lParam>IGNOREEVENT_MAX) return 1; + if (lParam<1 || lParam>IGNOREEVENT_MAX) return 1; return (mask>>(lParam-1))&1; } static INT_PTR Ignore(WPARAM wParam,LPARAM lParam) { DWORD mask=GetMask((HANDLE)wParam); - if((lParam<1 || lParam>IGNOREEVENT_MAX) && lParam!=IGNOREEVENT_ALL) return 1; - if(lParam==IGNOREEVENT_ALL) mask=(1<IGNOREEVENT_MAX) && lParam!=IGNOREEVENT_ALL) return 1; + if (lParam==IGNOREEVENT_ALL) mask=(1<IGNOREEVENT_MAX) && lParam!=IGNOREEVENT_ALL) return 1; - if(lParam==IGNOREEVENT_ALL) mask=0; + if ((lParam<1 || lParam>IGNOREEVENT_MAX) && lParam!=IGNOREEVENT_ALL) return 1; + if (lParam==IGNOREEVENT_ALL) mask=0; else mask&=~(1<<(lParam-1)); DBWriteContactSettingDword((HANDLE)wParam,"Ignore","Mask1",mask); return 0; @@ -392,25 +392,25 @@ static int IgnoreContactAdded(WPARAM wParam, LPARAM) static INT_PTR IgnoreRecvMessage(WPARAM wParam,LPARAM lParam) { - if(IsIgnored((WPARAM)((CCSDATA*)lParam)->hContact,IGNOREEVENT_MESSAGE)) return 1; + if (IsIgnored((WPARAM)((CCSDATA*)lParam)->hContact,IGNOREEVENT_MESSAGE)) return 1; return CallService(MS_PROTO_CHAINRECV,wParam,lParam); } static INT_PTR IgnoreRecvUrl(WPARAM wParam,LPARAM lParam) { - if(IsIgnored((WPARAM)((CCSDATA*)lParam)->hContact,IGNOREEVENT_URL)) return 1; + if (IsIgnored((WPARAM)((CCSDATA*)lParam)->hContact,IGNOREEVENT_URL)) return 1; return CallService(MS_PROTO_CHAINRECV,wParam,lParam); } static INT_PTR IgnoreRecvFile(WPARAM wParam,LPARAM lParam) { - if(IsIgnored((WPARAM)((CCSDATA*)lParam)->hContact,IGNOREEVENT_FILE)) return 1; + if (IsIgnored((WPARAM)((CCSDATA*)lParam)->hContact,IGNOREEVENT_FILE)) return 1; return CallService(MS_PROTO_CHAINRECV,wParam,lParam); } static INT_PTR IgnoreRecvAuth(WPARAM wParam,LPARAM lParam) { - if(IsIgnored((WPARAM)((CCSDATA*)lParam)->hContact,IGNOREEVENT_AUTHORIZATION)) return 1; + if (IsIgnored((WPARAM)((CCSDATA*)lParam)->hContact,IGNOREEVENT_AUTHORIZATION)) return 1; return CallService(MS_PROTO_CHAINRECV,wParam,lParam); } diff --git a/src/modules/keybindings/keybindings.cpp b/src/modules/keybindings/keybindings.cpp index ee208de504..1832eee568 100644 --- a/src/modules/keybindings/keybindings.cpp +++ b/src/modules/keybindings/keybindings.cpp @@ -95,9 +95,9 @@ static KeyBindingItem* findKeyBinding(char *actionGroup, DWORD key) KeyBindingItem *ptr = NULL; if (key != 0) { for (ptr = keyBindingList; ptr != NULL; ptr = ptr->next) - if (strcmp(ptr->actionGroupName, actionGroup) == 0) + if (strcmp(ptr->actionGroupName, actionGroup) == 0) for (i = 0; i < 5; i++) - if (ptr->key[i] == key) return ptr; + if (ptr->key[i] == key) return ptr; } return ptr; } @@ -108,9 +108,9 @@ static KeyBindingItem* findTempKeyBinding(char *actionGroup, DWORD key) KeyBindingItem *ptr = NULL; if (key != 0) { for (ptr = keyBindingList; ptr != NULL; ptr = ptr->next) - if (strcmp(ptr->actionGroupName, actionGroup) == 0) + if (strcmp(ptr->actionGroupName, actionGroup) == 0) for (i = 0; i < 5; i++) - if (ptr->tempKey[i] == key) return ptr; + if (ptr->tempKey[i] == key) return ptr; } return ptr; } @@ -121,9 +121,9 @@ static void removeTempKeyBinding(char *actionGroup, DWORD key) int i, j; if (key != 0) { for (ptr = keyBindingList; ptr != NULL; ptr = ptr->next) - if (strcmp(ptr->actionGroupName, actionGroup) == 0) + if (strcmp(ptr->actionGroupName, actionGroup) == 0) for (i = 0; i < 5; i++) - if (ptr->tempKey[i] == key) { + if (ptr->tempKey[i] == key) { for (j = i+1; j < 5; j++) ptr->tempKey[j-1] = ptr->tempKey[j]; ptr->tempKey[4] = 0; @@ -262,11 +262,11 @@ static void saveCollapseState( HWND hwndTree ) DBWriteContactSettingByte(NULL, "KeyBindingsUI", treeItem->paramName, 0 ); } ht = TreeView_GetChild( hwndTree, hti ); - if( ht == NULL ) { + if( ht == NULL ) { ht = TreeView_GetNextSibling( hwndTree, hti ); - while( ht == NULL ) { + while( ht == NULL ) { hti = TreeView_GetParent( hwndTree, hti ); - if( hti == NULL ) break; + if( hti == NULL ) break; ht = TreeView_GetNextSibling( hwndTree, hti ); } } hti = ht; @@ -372,7 +372,7 @@ static LRESULT CALLBACK KeyBindingsEditProc(HWND hwnd, UINT msg, WPARAM wParam, default: break; } - if (virtualKey == 0) { + if (virtualKey == 0) { modifiers = tempModifiers; refreshPreview(hwnd); } @@ -449,7 +449,7 @@ BOOL CALLBACK DlgProcKeyBindingsOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR int i; removeTempKeyBinding(currentTreeItem->keyBinding->actionGroupName, modifiers | virtualKey); for (i=0; i<5; i++) { - if (currentTreeItem->keyBinding->tempKey[i] == 0) { + if (currentTreeItem->keyBinding->tempKey[i] == 0) { currentTreeItem->keyBinding->tempKey[i] = modifiers | virtualKey; break; } @@ -497,14 +497,14 @@ BOOL CALLBACK DlgProcKeyBindingsOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case IDC_LIST: - if (HIWORD(wParam) == LBN_SELCHANGE) { + if (HIWORD(wParam) == LBN_SELCHANGE) { EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), TRUE); } break; } break; case WM_NOTIFY: - if (((LPNMHDR) lParam)->idFrom == IDC_CATEGORYLIST) + if (((LPNMHDR) lParam)->idFrom == IDC_CATEGORYLIST) { switch(((NMHDR*)lParam)->code) { case TVN_SELCHANGEDA: @@ -530,7 +530,7 @@ BOOL CALLBACK DlgProcKeyBindingsOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR } } } - if (((LPNMHDR) lParam)->idFrom == 0 && ((LPNMHDR) lParam)->code == PSN_APPLY ) { + if (((LPNMHDR) lParam)->idFrom == 0 && ((LPNMHDR) lParam)->code == PSN_APPLY ) { saveKeyBindings(); } break; diff --git a/src/modules/langpack/langpack.cpp b/src/modules/langpack/langpack.cpp index 96e2d44c02..bffe6898f7 100644 --- a/src/modules/langpack/langpack.cpp +++ b/src/modules/langpack/langpack.cpp @@ -82,7 +82,7 @@ void ConvertBackslashes(char *str, UINT fileCp) { char *pstr; for ( pstr = str; *pstr; pstr = CharNextExA( fileCp, pstr, 0 )) { - if( *pstr == '\\' ) { + if ( *pstr == '\\' ) { switch( pstr[1] ) { case 'n': *pstr = '\n'; break; case 't': *pstr = '\t'; break; @@ -237,7 +237,7 @@ static void LoadLangPackFile( FILE* fp, char* line, UINT fileCp ) fgets( line, SIZEOF(line), p ); UINT fileCp = CP_ACP; - if (strlen(line) >= 3 && line[0]=='\xef' && line[1]=='\xbb' && line[2]=='\xbf') + if (strlen(line) >= 3 && line[0] == '\xef' && line[1] == '\xbb' && line[2] == '\xbf') { fileCp = CP_UTF8; fseek(p, 3, SEEK_SET); @@ -342,7 +342,7 @@ static int LoadLangPack(const TCHAR *szLangPack) UINT fileCp = CP_ACP; size_t lineLen = strlen(line); - if (lineLen >= 3 && line[0]=='\xef' && line[1]=='\xbb' && line[2]=='\xbf') + if (lineLen >= 3 && line[0] == '\xef' && line[1] == '\xbb' && line[2] == '\xbf') { fileCp = CP_UTF8; memmove(line, line + 3, lineLen - 2); @@ -361,7 +361,7 @@ static int LoadLangPack(const TCHAR *szLangPack) break; lrtrim( line ); - if( IsEmpty( line ) || line[0]==';' || line[0]==0) + if ( IsEmpty( line ) || line[0] == ';' || line[0]==0) continue; if ( line[0] == '[' || line[0] == '#' ) @@ -374,11 +374,11 @@ static int LoadLangPack(const TCHAR *szLangPack) } *pszColon++ = 0; - if(!lstrcmpA(line,"Language")) {mir_snprintf(langPack.language,sizeof(langPack.language),"%s",pszColon); lrtrim(langPack.language);} - else if(!lstrcmpA(line,"Last-Modified-Using")) {mir_snprintf(langPack.lastModifiedUsing,sizeof(langPack.lastModifiedUsing),"%s",pszColon); lrtrim(langPack.lastModifiedUsing);} - else if(!lstrcmpA(line,"Authors")) {mir_snprintf(langPack.authors,sizeof(langPack.authors),"%s",pszColon); lrtrim(langPack.authors);} - else if(!lstrcmpA(line,"Author-email")) {mir_snprintf(langPack.authorEmail,sizeof(langPack.authorEmail),"%s",pszColon); lrtrim(langPack.authorEmail);} - else if(!lstrcmpA(line, "Locale")) { + if (!lstrcmpA(line,"Language")) {mir_snprintf(langPack.language,sizeof(langPack.language),"%s",pszColon); lrtrim(langPack.language);} + else if (!lstrcmpA(line,"Last-Modified-Using")) {mir_snprintf(langPack.lastModifiedUsing,sizeof(langPack.lastModifiedUsing),"%s",pszColon); lrtrim(langPack.lastModifiedUsing);} + else if (!lstrcmpA(line,"Authors")) {mir_snprintf(langPack.authors,sizeof(langPack.authors),"%s",pszColon); lrtrim(langPack.authors);} + else if (!lstrcmpA(line,"Author-email")) {mir_snprintf(langPack.authorEmail,sizeof(langPack.authorEmail),"%s",pszColon); lrtrim(langPack.authorEmail);} + else if (!lstrcmpA(line, "Locale")) { char szBuf[20], *stopped; lrtrim(pszColon + 1); @@ -529,7 +529,7 @@ int LoadLangPackModule(void) LoadLangPackServices(); pathToAbsoluteT(_T("langpack_*.txt"), szSearch, NULL); hFind = FindFirstFile( szSearch, &fd ); - if( hFind != INVALID_HANDLE_VALUE ) { + if ( hFind != INVALID_HANDLE_VALUE ) { pathToAbsoluteT(fd.cFileName, szSearch, NULL); FindClose(hFind); LoadLangPack(szSearch); diff --git a/src/modules/langpack/lpservices.cpp b/src/modules/langpack/lpservices.cpp index 48c0aea155..69d416330b 100644 --- a/src/modules/langpack/lpservices.cpp +++ b/src/modules/langpack/lpservices.cpp @@ -94,10 +94,10 @@ static BOOL CALLBACK TranslateDialogEnumProc(HWND hwnd,LPARAM lParam) LangPackMuuid* uuid = LangPackLookupUuid( lptd->flags ); GetClassName( hwnd, szClass, SIZEOF(szClass)); - if(!lstrcmpi(szClass,_T("static")) || !lstrcmpi(szClass,_T("hyperlink")) || !lstrcmpi(szClass,_T("button")) || !lstrcmpi(szClass,_T("MButtonClass")) || !lstrcmpi(szClass,_T("MHeaderbarCtrl"))) + if (!lstrcmpi(szClass,_T("static")) || !lstrcmpi(szClass,_T("hyperlink")) || !lstrcmpi(szClass,_T("button")) || !lstrcmpi(szClass,_T("MButtonClass")) || !lstrcmpi(szClass,_T("MHeaderbarCtrl"))) TranslateWindow( uuid, hwnd ); else if ( !lstrcmpi( szClass,_T("edit"))) { - if( lptd->flags & LPTDF_NOIGNOREEDIT || GetWindowLongPtr(hwnd,GWL_STYLE) & ES_READONLY ) + if ( lptd->flags & LPTDF_NOIGNOREEDIT || GetWindowLongPtr(hwnd,GWL_STYLE) & ES_READONLY ) TranslateWindow( uuid, hwnd ); } return TRUE; diff --git a/src/modules/netlib/netlib.cpp b/src/modules/netlib/netlib.cpp index 1a6a583679..ed084b523d 100644 --- a/src/modules/netlib/netlib.cpp +++ b/src/modules/netlib/netlib.cpp @@ -69,13 +69,13 @@ int NetlibEnterNestedCS(struct NetlibConnection *nlc,int which) DWORD dwCurrentThreadId=GetCurrentThreadId(); WaitForSingleObject(hConnectionHeaderMutex,INFINITE); - if(nlc==NULL || nlc->handleType!=NLH_CONNECTION) { + if (nlc==NULL || nlc->handleType!=NLH_CONNECTION) { ReleaseMutex(hConnectionHeaderMutex); SetLastError(ERROR_INVALID_PARAMETER); return 0; } nlncs = (which == NLNCS_SEND) ? &nlc->ncsSend : &nlc->ncsRecv; - if(nlncs->lockCount && nlncs->dwOwningThreadId==dwCurrentThreadId) { + if (nlncs->lockCount && nlncs->dwOwningThreadId==dwCurrentThreadId) { nlncs->lockCount++; ReleaseMutex(hConnectionHeaderMutex); return 1; @@ -86,14 +86,14 @@ int NetlibEnterNestedCS(struct NetlibConnection *nlc,int which) WaitForSingleObject(nlncs->hMutex,INFINITE); nlncs->dwOwningThreadId=dwCurrentThreadId; nlncs->lockCount=1; - if(InterlockedDecrement(&nlc->dontCloseNow)==0) + if (InterlockedDecrement(&nlc->dontCloseNow)==0) SetEvent(nlc->hOkToCloseEvent); return 1; } void NetlibLeaveNestedCS(struct NetlibNestedCriticalSection *nlncs) { - if(--nlncs->lockCount==0) { + if (--nlncs->lockCount==0) { nlncs->dwOwningThreadId=0; ReleaseMutex(nlncs->hMutex); } @@ -102,27 +102,27 @@ void NetlibLeaveNestedCS(struct NetlibNestedCriticalSection *nlncs) static INT_PTR GetNetlibUserSettingInt(const char *szUserModule,const char *szSetting,int defValue) { DBVARIANT dbv; - if(DBGetContactSetting(NULL,szUserModule,szSetting,&dbv) + if (DBGetContactSetting(NULL,szUserModule,szSetting,&dbv) && DBGetContactSetting(NULL,"Netlib",szSetting,&dbv)) return defValue; - if(dbv.type==DBVT_BYTE) return dbv.bVal; - if(dbv.type==DBVT_WORD) return dbv.wVal; + if (dbv.type==DBVT_BYTE) return dbv.bVal; + if (dbv.type==DBVT_WORD) return dbv.wVal; return dbv.dVal; } static char *GetNetlibUserSettingString(const char *szUserModule,const char *szSetting,int decode) { DBVARIANT dbv; - if(DBGetContactSettingString(NULL,szUserModule,szSetting,&dbv) + if (DBGetContactSettingString(NULL,szUserModule,szSetting,&dbv) && DBGetContactSettingString(NULL,"Netlib",szSetting,&dbv)) { return NULL; } else { char *szRet; - if(decode) CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM)dbv.pszVal); + if (decode) CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM)dbv.pszVal); szRet=mir_strdup(dbv.pszVal); DBFreeVariant(&dbv); - if(szRet==NULL) SetLastError(ERROR_OUTOFMEMORY); + if (szRet==NULL) SetLastError(ERROR_OUTOFMEMORY); return szRet; } } @@ -132,7 +132,7 @@ static INT_PTR NetlibRegisterUser(WPARAM,LPARAM lParam) NETLIBUSER *nlu=(NETLIBUSER*)lParam; struct NetlibUser *thisUser; - if(nlu==NULL || nlu->cbSize!=sizeof(NETLIBUSER) || nlu->szSettingsModule==NULL + if (nlu==NULL || nlu->cbSize!=sizeof(NETLIBUSER) || nlu->szSettingsModule==NULL || (!(nlu->flags&NUF_NOOPTIONS) && nlu->szDescriptiveName==NULL) || (nlu->flags&NUF_HTTPGATEWAY && (nlu->pfnHttpGatewayInit==NULL))) { SetLastError(ERROR_INVALID_PARAMETER); @@ -156,7 +156,7 @@ static INT_PTR NetlibRegisterUser(WPARAM,LPARAM lParam) if (nlu->szDescriptiveName) { thisUser->user.ptszDescriptiveName = (thisUser->user.flags&NUF_UNICODE ? mir_u2t((WCHAR*)nlu->ptszDescriptiveName) : mir_a2t(nlu->szDescriptiveName)); } - if((thisUser->user.szSettingsModule=mir_strdup(nlu->szSettingsModule))==NULL + if ((thisUser->user.szSettingsModule=mir_strdup(nlu->szSettingsModule))==NULL || (nlu->szDescriptiveName && thisUser->user.ptszDescriptiveName ==NULL) || (nlu->szHttpGatewayUserAgent && (thisUser->user.szHttpGatewayUserAgent=mir_strdup(nlu->szHttpGatewayUserAgent))==NULL)) { @@ -172,9 +172,9 @@ static INT_PTR NetlibRegisterUser(WPARAM,LPARAM lParam) thisUser->settings.cbSize=sizeof(NETLIBUSERSETTINGS); thisUser->settings.useProxy=GetNetlibUserSettingInt(thisUser->user.szSettingsModule,"NLUseProxy",0); thisUser->settings.proxyType=GetNetlibUserSettingInt(thisUser->user.szSettingsModule,"NLProxyType",PROXYTYPE_SOCKS5); - if(thisUser->user.flags&NUF_NOHTTPSOPTION && thisUser->settings.proxyType==PROXYTYPE_HTTPS) + if (thisUser->user.flags&NUF_NOHTTPSOPTION && thisUser->settings.proxyType==PROXYTYPE_HTTPS) thisUser->settings.proxyType=PROXYTYPE_HTTP; - if(!(thisUser->user.flags&(NUF_HTTPCONNS|NUF_HTTPGATEWAY)) && thisUser->settings.proxyType==PROXYTYPE_HTTP) { + if (!(thisUser->user.flags&(NUF_HTTPCONNS|NUF_HTTPGATEWAY)) && thisUser->settings.proxyType==PROXYTYPE_HTTP) { thisUser->settings.useProxy=0; thisUser->settings.proxyType=PROXYTYPE_SOCKS5; } @@ -204,7 +204,7 @@ static INT_PTR NetlibGetUserSettings(WPARAM wParam,LPARAM lParam) NETLIBUSERSETTINGS *nlus=(NETLIBUSERSETTINGS*)lParam; struct NetlibUser *nlu=(struct NetlibUser*)wParam; - if(GetNetlibHandleType(nlu)!=NLH_USER || nlus==NULL || nlus->cbSize!=sizeof(NETLIBUSERSETTINGS)) { + if (GetNetlibHandleType(nlu)!=NLH_USER || nlus==NULL || nlus->cbSize!=sizeof(NETLIBUSERSETTINGS)) { SetLastError(ERROR_INVALID_PARAMETER); return 0; } @@ -217,7 +217,7 @@ static INT_PTR NetlibSetUserSettings(WPARAM wParam,LPARAM lParam) NETLIBUSERSETTINGS *nlus=(NETLIBUSERSETTINGS*)lParam; struct NetlibUser *nlu=(struct NetlibUser*)wParam; - if(GetNetlibHandleType(nlu)!=NLH_USER || nlus==NULL || nlus->cbSize!=sizeof(NETLIBUSERSETTINGS)) { + if (GetNetlibHandleType(nlu)!=NLH_USER || nlus==NULL || nlus->cbSize!=sizeof(NETLIBUSERSETTINGS)) { SetLastError(ERROR_INVALID_PARAMETER); return 0; } @@ -274,7 +274,7 @@ INT_PTR NetlibCloseHandle(WPARAM wParam, LPARAM) } else { - if(nlc->s != INVALID_SOCKET) { + if (nlc->s != INVALID_SOCKET) { NetlibDoClose(nlc); } if (nlc->s2 != INVALID_SOCKET) closesocket(nlc->s2); @@ -287,7 +287,7 @@ INT_PTR NetlibCloseHandle(WPARAM wParam, LPARAM) waitHandles[2]=nlc->ncsRecv.hMutex; waitHandles[3]=nlc->ncsSend.hMutex; waitResult=WaitForMultipleObjects( SIZEOF(waitHandles),waitHandles,TRUE,INFINITE); - if(waitResult= WAIT_OBJECT_0 + SIZEOF(waitHandles)) { + if (waitResult= WAIT_OBJECT_0 + SIZEOF(waitHandles)) { ReleaseMutex(hConnectionHeaderMutex); SetLastError(ERROR_INVALID_PARAMETER); //already been closed return 0; @@ -415,11 +415,11 @@ INT_PTR NetlibHttpUrlEncode(WPARAM,LPARAM lParam) unsigned char *pszIn,*pszOut; int outputLen; - if(szInput==NULL) { + if (szInput==NULL) { SetLastError(ERROR_INVALID_PARAMETER); return (INT_PTR)(char*)NULL; } - for(outputLen=0,pszIn=szInput;*pszIn;pszIn++) { + for (outputLen=0,pszIn=szInput;*pszIn;pszIn++) { if ( (48 <= *pszIn && *pszIn <= 57) ||//0-9 (65 <= *pszIn && *pszIn <= 90) ||//ABC...XYZ (97 <= *pszIn && *pszIn <= 122) ||//abc...xyz @@ -427,16 +427,16 @@ INT_PTR NetlibHttpUrlEncode(WPARAM,LPARAM lParam) else outputLen+=3; } szOutput=(unsigned char*)HeapAlloc(GetProcessHeap(),0,outputLen+1); - if(szOutput==NULL) { + if (szOutput==NULL) { SetLastError(ERROR_OUTOFMEMORY); return (INT_PTR)(unsigned char*)NULL; } - for(pszOut=szOutput,pszIn=szInput;*pszIn;pszIn++) { + for (pszOut=szOutput,pszIn=szInput;*pszIn;pszIn++) { if ( (48 <= *pszIn && *pszIn <= 57) || (65 <= *pszIn && *pszIn <= 90) || (97 <= *pszIn && *pszIn <= 122) || *pszIn == '-' || *pszIn == '_' || *pszIn == '.') *pszOut++=*pszIn; - else if(*pszIn==' ') *pszOut++='+'; + else if (*pszIn==' ') *pszOut++='+'; else { *pszOut++='%'; *pszOut++=szHexDigits[*pszIn>>4]; @@ -455,18 +455,18 @@ INT_PTR NetlibBase64Encode(WPARAM, LPARAM lParam) char *pszOut; PBYTE pbIn; - if(nlb64==NULL || nlb64->pszEncoded==NULL || nlb64->pbDecoded==NULL) { + if (nlb64==NULL || nlb64->pszEncoded==NULL || nlb64->pbDecoded==NULL) { SetLastError(ERROR_INVALID_PARAMETER); return 0; } - if(nlb64->cchEncodedcbDecoded)) { + if (nlb64->cchEncodedcbDecoded)) { SetLastError(ERROR_BUFFER_OVERFLOW); return 0; } nlb64->cchEncoded=Netlib_GetBase64EncodedBufferSize(nlb64->cbDecoded); - for(iIn=0,pbIn=nlb64->pbDecoded,pszOut=nlb64->pszEncoded;iIncbDecoded;iIn+=3,pbIn+=3,pszOut+=4) { + for (iIn=0,pbIn=nlb64->pbDecoded,pszOut=nlb64->pszEncoded;iIncbDecoded;iIn+=3,pbIn+=3,pszOut+=4) { pszOut[0]=base64chars[pbIn[0]>>2]; - if(nlb64->cbDecoded-iIn==1) { + if (nlb64->cbDecoded-iIn==1) { pszOut[1]=base64chars[(pbIn[0]&3)<<4]; pszOut[2]='='; pszOut[3]='='; @@ -474,7 +474,7 @@ INT_PTR NetlibBase64Encode(WPARAM, LPARAM lParam) break; } pszOut[1]=base64chars[((pbIn[0]&3)<<4)|(pbIn[1]>>4)]; - if(nlb64->cbDecoded-iIn==2) { + if (nlb64->cbDecoded-iIn==2) { pszOut[2]=base64chars[(pbIn[1]&0xF)<<2]; pszOut[3]='='; pszOut+=4; @@ -489,12 +489,12 @@ INT_PTR NetlibBase64Encode(WPARAM, LPARAM lParam) static BYTE Base64CharToInt(char c) { - if(c>='A' && c<='Z') return c-'A'; - if(c>='a' && c<='z') return c-'a'+26; - if(c>='0' && c<='9') return c-'0'+52; - if(c=='+') return 62; - if(c=='/') return 63; - if(c=='=') return 64; + if (c>='A' && c<='Z') return c-'A'; + if (c>='a' && c<='z') return c-'a'+26; + if (c>='0' && c<='9') return c-'0'+52; + if (c=='+') return 62; + if (c=='/') return 63; + if (c=='=') return 64; return 255; } @@ -506,32 +506,32 @@ INT_PTR NetlibBase64Decode(WPARAM, LPARAM lParam) BYTE b1,b2,b3,b4; int iIn; - if(nlb64==NULL || nlb64->pszEncoded==NULL || nlb64->pbDecoded==NULL) { + if (nlb64==NULL || nlb64->pszEncoded==NULL || nlb64->pbDecoded==NULL) { SetLastError(ERROR_INVALID_PARAMETER); return 0; } - if(nlb64->cchEncoded&3) { + if (nlb64->cchEncoded&3) { SetLastError(ERROR_INVALID_DATA); return 0; } - if(nlb64->cbDecodedcchEncoded)) { + if (nlb64->cbDecodedcchEncoded)) { SetLastError(ERROR_BUFFER_OVERFLOW); return 0; } nlb64->cbDecoded=Netlib_GetBase64DecodedBufferSize(nlb64->cchEncoded); - for(iIn=0,pszIn=nlb64->pszEncoded,pbOut=nlb64->pbDecoded;iIncchEncoded;iIn+=4,pszIn+=4,pbOut+=3) { + for (iIn=0,pszIn=nlb64->pszEncoded,pbOut=nlb64->pbDecoded;iIncchEncoded;iIn+=4,pszIn+=4,pbOut+=3) { b1=Base64CharToInt(pszIn[0]); b2=Base64CharToInt(pszIn[1]); b3=Base64CharToInt(pszIn[2]); b4=Base64CharToInt(pszIn[3]); - if(b1==255 || b1==64 || b2==255 || b2==64 || b3==255 || b4==255) { + if (b1==255 || b1==64 || b2==255 || b2==64 || b3==255 || b4==255) { SetLastError(ERROR_INVALID_DATA); return 0; } pbOut[0]=(b1<<2)|(b2>>4); - if(b3==64) {nlb64->cbDecoded-=2; break;} + if (b3==64) {nlb64->cbDecoded-=2; break;} pbOut[1]=(b2<<4)|(b3>>2); - if(b4==64) {nlb64->cbDecoded--; break;} + if (b4==64) {nlb64->cbDecoded--; break;} pbOut[2]=b4|(b3<<6); } return 1; diff --git a/src/modules/netlib/netlibautoproxy.cpp b/src/modules/netlib/netlibautoproxy.cpp index 173faa138d..21f841ff3c 100644 --- a/src/modules/netlib/netlibautoproxy.cpp +++ b/src/modules/netlib/netlibautoproxy.cpp @@ -425,7 +425,7 @@ void NetlibLoadIeProxy(void) } char* szProxyBypass = szProxyBypassStr; - for(;;) + for (;;) { char *szProxyBypassEnd = strchr(szProxyBypass, ';'); if (szProxyBypassEnd) *szProxyBypassEnd = 0; diff --git a/src/modules/netlib/netlibbind.cpp b/src/modules/netlib/netlibbind.cpp index d1133f9514..3f28551434 100644 --- a/src/modules/netlib/netlibbind.cpp +++ b/src/modules/netlib/netlibbind.cpp @@ -53,13 +53,13 @@ bool BindSocketToPort(const char *szPorts, SOCKET s, SOCKET s6, int* portn) char *pszEnd; int portMin, portMax, port, portnum = 0; - for(psz=szPorts;*psz;) + for (psz=szPorts;*psz;) { while (*psz == ' ' || *psz == ',') psz++; portMin = strtol(psz, &pszEnd, 0); if (pszEnd == psz) break; while (*pszEnd == ' ') pszEnd++; - if(*pszEnd == '-') + if (*pszEnd == '-') { psz = pszEnd + 1; portMax = strtol(psz, &pszEnd, 0); diff --git a/src/modules/netlib/netlibhttp.cpp b/src/modules/netlib/netlibhttp.cpp index 8fba0eed1c..d0be2f35b2 100644 --- a/src/modules/netlib/netlibhttp.cpp +++ b/src/modules/netlib/netlibhttp.cpp @@ -100,7 +100,7 @@ static void AppendToCharBuffer(struct ResizableCharBuffer *rcb, const char *fmt, for (;;) { charsDone = mir_vsnprintf(rcb->sz + rcb->iEnd, rcb->cbAlloced-rcb->iEnd, fmt, va); - if(charsDone >= 0) break; + if (charsDone >= 0) break; rcb->cbAlloced += 512; rcb->sz = (char*)mir_realloc(rcb->sz, rcb->cbAlloced); } @@ -333,7 +333,7 @@ static int HttpPeekFirstResponseLine(NetlibConnection *nlc, DWORD dwTimeoutTime, char buffer[2048]; char *peol; - for(;;) + for (;;) { bytesPeeked = RecvWithTimeoutTime(nlc, dwTimeoutTime, buffer, SIZEOF(buffer) - 1, MSG_PEEK | recvFlags); @@ -402,7 +402,7 @@ static int SendHttpRequestAndData(struct NetlibConnection *nlc,struct ResizableC { bool sendData = (nlhr->requestType==REQUEST_POST || nlhr->requestType==REQUEST_PUT); - if(sendContentLengthHeader && sendData) + if (sendContentLengthHeader && sendData) AppendToCharBuffer(httpRequest,"Content-Length: %d\r\n\r\n", nlhr->dataLength); else AppendToCharBuffer(httpRequest,"\r\n"); @@ -822,10 +822,10 @@ INT_PTR NetlibHttpFreeRequestStruct(WPARAM, LPARAM lParam) SetLastError(ERROR_INVALID_PARAMETER); return 0; } - if(nlhr->headers) + if (nlhr->headers) { int i; - for(i=0; iheadersCount; i++) + for (i=0; iheadersCount; i++) { mir_free(nlhr->headers[i].szName); mir_free(nlhr->headers[i].szValue); @@ -850,7 +850,7 @@ INT_PTR NetlibHttpRecvHeaders(WPARAM wParam,LPARAM lParam) int headersCount = 0, bufferSize = 8192; bool headersCompleted = false; - if(!NetlibEnterNestedCS(nlc,NLNCS_RECV)) + if (!NetlibEnterNestedCS(nlc,NLNCS_RECV)) return 0; dwRequestTimeoutTime = GetTickCount() + HTTPRECVDATATIMEOUT; @@ -999,7 +999,7 @@ INT_PTR NetlibHttpTransaction(WPARAM wParam, LPARAM lParam) ++nlhrSend.headersCount; CallService(MS_SYSTEM_GETVERSIONTEXT,SIZEOF(szMirandaVer),(LPARAM)szMirandaVer); pspace=strchr(szMirandaVer,' '); - if(pspace) + if (pspace) { *pspace++ = '\0'; mir_snprintf(szUserAgent, SIZEOF(szUserAgent), "Miranda/%s (%s)", szMirandaVer, pspace); @@ -1217,7 +1217,7 @@ next: while (chunksz != 0) { - for(;;) + for (;;) { recvResult = RecvWithTimeoutTime(nlc, GetTickCount() + HTTPRECVDATATIMEOUT, nlhrReply->pData + nlhrReply->dataLength, @@ -1242,7 +1242,7 @@ next: { dataBufferAlloced += 2048; nlhrReply->pData = (char*)mir_realloc(nlhrReply->pData, dataBufferAlloced); - if(nlhrReply->pData == NULL) + if (nlhrReply->pData == NULL) { SetLastError(ERROR_OUTOFMEMORY); NetlibHttpFreeRequestStruct(0, (LPARAM)nlhrReply); diff --git a/src/modules/netlib/netlibhttpproxy.cpp b/src/modules/netlib/netlibhttpproxy.cpp index decef4e285..fa6c2368b5 100644 --- a/src/modules/netlib/netlibhttpproxy.cpp +++ b/src/modules/netlib/netlibhttpproxy.cpp @@ -461,7 +461,7 @@ int NetlibInitHttpConnection(struct NetlibConnection *nlc, struct NetlibUser *nl /* * Gena01 - Ok, we should be able to use just POST. Needed for Yahoo, NO GET requests */ - if(nlc->nlhpi.szHttpPostUrl == NULL) + if (nlc->nlhpi.szHttpPostUrl == NULL) { SetLastError(ERROR_BAD_FORMAT); return 0; diff --git a/src/modules/netlib/netliblog.cpp b/src/modules/netlib/netliblog.cpp index 4dced62c5c..d974406047 100644 --- a/src/modules/netlib/netliblog.cpp +++ b/src/modules/netlib/netliblog.cpp @@ -78,7 +78,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg,UINT message,WPARAM wPara CheckDlgButton(hwndDlg,IDC_TEXTDUMPS,logOptions.textDumps?BST_CHECKED:BST_UNCHECKED); CheckDlgButton(hwndDlg,IDC_AUTODETECTTEXT,logOptions.autoDetectText?BST_CHECKED:BST_UNCHECKED); { int i; - for( i=0; i < SIZEOF(szTimeFormats); i++ ) + for ( i=0; i < SIZEOF(szTimeFormats); i++ ) SendDlgItemMessage(hwndDlg,IDC_TIMEFORMAT,CB_ADDSTRING,0,(LPARAM)TranslateTS( szTimeFormats[i] )); } SendDlgItemMessage(hwndDlg,IDC_TIMEFORMAT,CB_SETCURSEL,logOptions.timeFormat,0); @@ -89,7 +89,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg,UINT message,WPARAM wPara SetDlgItemText(hwndDlg,IDC_PATH,logOptions.szFile); CheckDlgButton(hwndDlg,IDC_SHOWTHISDLGATSTART,DBGetContactSettingByte(NULL, "Netlib", "ShowLogOptsAtStart",0)?BST_CHECKED:BST_UNCHECKED); { DBVARIANT dbv; - if(!DBGetContactSettingString(NULL, "Netlib", "RunAtStart",&dbv)) { + if (!DBGetContactSettingString(NULL, "Netlib", "RunAtStart",&dbv)) { SetDlgItemTextA(hwndDlg,IDC_RUNATSTART,dbv.pszVal); DBFreeVariant(&dbv); } @@ -137,8 +137,8 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg,UINT message,WPARAM wPara break; */ case IDC_FILENAME: - if(HIWORD(wParam)!=EN_CHANGE) break; - if((HWND)lParam==GetFocus()) + if (HIWORD(wParam)!=EN_CHANGE) break; + if ((HWND)lParam==GetFocus()) CheckDlgButton(hwndDlg,IDC_TOFILE,BST_CHECKED); { @@ -178,11 +178,11 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg,UINT message,WPARAM wPara ofn.nMaxFile=SIZEOF(str)-2; ofn.nMaxFileTitle=MAX_PATH; if (LOWORD(wParam)==IDC_FILENAMEBROWSE) { - if(!GetSaveFileName(&ofn)) return 1; + if (!GetSaveFileName(&ofn)) return 1; } else { - if(!GetOpenFileName(&ofn)) return 1; + if (!GetOpenFileName(&ofn)) return 1; } - if(LOWORD(wParam)==IDC_RUNATSTARTBROWSE && _tcschr(str,' ')!=NULL) { + if (LOWORD(wParam)==IDC_RUNATSTARTBROWSE && _tcschr(str,' ')!=NULL) { MoveMemory(str+1,str,SIZEOF(str)-2); str[0]='"'; lstrcat(str,_T("\"")); @@ -196,7 +196,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg,UINT message,WPARAM wPara PROCESS_INFORMATION pi; GetDlgItemText(hwndDlg,IDC_RUNATSTART,str,MAX_PATH); si.cb=sizeof(si); - if(str[0]) CreateProcess(NULL,str,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi); + if (str[0]) CreateProcess(NULL,str,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi); } break; case IDC_SAVE: @@ -298,7 +298,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg,UINT message,WPARAM wPara void NetlibLogShowOptions(void) { - if(logOptions.hwndOpts==NULL) + if (logOptions.hwndOpts==NULL) logOptions.hwndOpts=CreateDialog(hMirandaInst,MAKEINTRESOURCE(IDD_NETLIBLOGOPTS),NULL,LogOptionsDlgProc); SetForegroundWindow(logOptions.hwndOpts); } @@ -362,14 +362,14 @@ static INT_PTR NetlibLog(WPARAM wParam, LPARAM lParam) szTime[0] = '\0'; break; } - if(logOptions.timeFormat || logOptions.showUser) + if (logOptions.timeFormat || logOptions.showUser) mir_snprintf(szHead, SIZEOF(szHead) - 1, "[%s%s%s] ", szTime, (logOptions.showUser && logOptions.timeFormat) ? " " : "", logOptions.showUser ? nlu->user.szSettingsModule : ""); else szHead[0]=0; - if(logOptions.toOutputDebugString) + if (logOptions.toOutputDebugString) { if (szHead[0]) OutputDebugStringA(szHead); @@ -488,7 +488,7 @@ void NetlibDumpData(struct NetlibConnection *nlc,PBYTE buf,int len,int sent,int if (logOptions.autoDetectText) { int i; - for(i = 0; i=0x80) { diff --git a/src/modules/netlib/netlibopenconn.cpp b/src/modules/netlib/netlibopenconn.cpp index 5ee3200308..086269c021 100644 --- a/src/modules/netlib/netlibopenconn.cpp +++ b/src/modules/netlib/netlibopenconn.cpp @@ -168,7 +168,7 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc,struct Netlib buf[0]=5; //yep, socks5 buf[1]=1; //one auth method buf[2]=nlu->settings.useProxyAuth?2:0; - if(NLSend(nlc,(char*)buf,3,MSG_DUMPPROXY)==SOCKET_ERROR) { + if (NLSend(nlc,(char*)buf,3,MSG_DUMPPROXY)==SOCKET_ERROR) { NetlibLogf(nlu,"%s %d: %s() failed (%u)",__FILE__,__LINE__,"NLSend",GetLastError()); return 0; } @@ -178,13 +178,13 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc,struct Netlib NetlibLogf(nlu,"%s %d: %s() failed (%u)",__FILE__,__LINE__,"RecvUntilTimeout",GetLastError()); return 0; } - if((buf[1]!=0 && buf[1]!=2)) { + if ((buf[1]!=0 && buf[1]!=2)) { SetLastError(ERROR_INVALID_ID_AUTHORITY); NetlibLogf(nlu,"%s %d: %s() failed (%u)",__FILE__,__LINE__,"NLRecv",GetLastError()); return 0; } - if(buf[1]==2) { //rfc1929 + if (buf[1]==2) { //rfc1929 int nUserLen,nPassLen; PBYTE pAuthBuf; @@ -196,7 +196,7 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc,struct Netlib memcpy(pAuthBuf+2,nlu->settings.szProxyAuthUser,nUserLen); pAuthBuf[2+nUserLen]=nPassLen; memcpy(pAuthBuf+3+nUserLen,nlu->settings.szProxyAuthPassword,nPassLen); - if(NLSend(nlc,(char*)pAuthBuf,3+nUserLen+nPassLen,MSG_DUMPPROXY)==SOCKET_ERROR) { + if (NLSend(nlc,(char*)pAuthBuf,3+nUserLen+nPassLen,MSG_DUMPPROXY)==SOCKET_ERROR) { NetlibLogf(nlu,"%s %d: %s() failed (%u)",__FILE__,__LINE__,"NLSend",GetLastError()); mir_free(pAuthBuf); return 0; @@ -207,7 +207,7 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc,struct Netlib NetlibLogf(nlu,"%s %d: %s() failed (%u)",__FILE__,__LINE__,"RecvUntilTimeout",GetLastError()); return 0; } - if(buf[1]) { + if (buf[1]) { SetLastError(ERROR_ACCESS_DENIED); NetlibLogf(nlu,"%s %d: %s() failed (%u)",__FILE__,__LINE__,"RecvUntilTimeout",GetLastError()); return 0; @@ -222,7 +222,7 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc,struct Netlib if (nlc->dnsThroughProxy) { hostIP = inet_addr(nloc->szHost); - if(hostIP == INADDR_NONE) + if (hostIP == INADDR_NONE) nHostLen = lstrlenA(nloc->szHost)+1; else nHostLen = 4; } @@ -237,7 +237,7 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc,struct Netlib pInit[0]=5; //SOCKS5 pInit[1]= nloc->flags & NLOCF_UDP ? 3 : 1; //connect or UDP pInit[2]=0; //reserved - if(hostIP==INADDR_NONE) { //DNS lookup through proxy + if (hostIP==INADDR_NONE) { //DNS lookup through proxy pInit[3]=3; pInit[4]=nHostLen-1; memcpy(pInit+5,nloc->szHost,nHostLen-1); @@ -247,7 +247,7 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc,struct Netlib *(PDWORD)(pInit+4)=hostIP; } *(PWORD)(pInit+4+nHostLen)=htons(nloc->wPort); - if(NLSend(nlc,(char*)pInit,6+nHostLen,MSG_DUMPPROXY)==SOCKET_ERROR) { + if (NLSend(nlc,(char*)pInit,6+nHostLen,MSG_DUMPPROXY)==SOCKET_ERROR) { NetlibLogf(nlu,"%s %d: %s() failed (%u)",__FILE__,__LINE__,"NLSend",GetLastError()); mir_free(pInit); return 0; diff --git a/src/modules/netlib/netlibopts.cpp b/src/modules/netlib/netlibopts.cpp index 7a74c8612f..0988f5d552 100644 --- a/src/modules/netlib/netlibopts.cpp +++ b/src/modules/netlib/netlibopts.cpp @@ -74,13 +74,13 @@ static const WORD oftenProxyPorts[]={1080,1080,1080,8080,8080,8080}; static void ShowMultipleControls(HWND hwndDlg,const UINT *controls,int cControls,int state) { int i; - for(i=0;iszIncomingPorts) dest->szIncomingPorts=mir_strdup(dest->szIncomingPorts); - if(dest->szOutgoingPorts) dest->szOutgoingPorts=mir_strdup(dest->szOutgoingPorts); - if(dest->szProxyAuthPassword) dest->szProxyAuthPassword=mir_strdup(dest->szProxyAuthPassword); - if(dest->szProxyAuthUser) dest->szProxyAuthUser=mir_strdup(dest->szProxyAuthUser); - if(dest->szProxyServer) dest->szProxyServer=mir_strdup(dest->szProxyServer); + if (dest->szIncomingPorts) dest->szIncomingPorts=mir_strdup(dest->szIncomingPorts); + if (dest->szOutgoingPorts) dest->szOutgoingPorts=mir_strdup(dest->szOutgoingPorts); + if (dest->szProxyAuthPassword) dest->szProxyAuthPassword=mir_strdup(dest->szProxyAuthPassword); + if (dest->szProxyAuthUser) dest->szProxyAuthUser=mir_strdup(dest->szProxyAuthUser); + if (dest->szProxyServer) dest->szProxyServer=mir_strdup(dest->szProxyServer); } static void CombineSettingsStrings(char **dest,char **source) { - if(*dest!=NULL && (*source==NULL || lstrcmpiA(*dest,*source))) {mir_free(*dest); *dest=NULL;} + if (*dest!=NULL && (*source==NULL || lstrcmpiA(*dest,*source))) {mir_free(*dest); *dest=NULL;} } static void CombineSettingsStructs(NETLIBUSERSETTINGS *dest,DWORD *destFlags,NETLIBUSERSETTINGS *source,DWORD sourceFlags) { - if(sourceFlags&NUF_OUTGOING) { - if(*destFlags&NUF_OUTGOING) { - if(dest->validateSSL!=source->validateSSL) dest->validateSSL=2; - if(dest->useProxy!=source->useProxy) dest->useProxy=2; - if(dest->proxyType!=source->proxyType) dest->proxyType=0; + if (sourceFlags&NUF_OUTGOING) { + if (*destFlags&NUF_OUTGOING) { + if (dest->validateSSL!=source->validateSSL) dest->validateSSL=2; + if (dest->useProxy!=source->useProxy) dest->useProxy=2; + if (dest->proxyType!=source->proxyType) dest->proxyType=0; CombineSettingsStrings(&dest->szProxyServer,&source->szProxyServer); - if(dest->wProxyPort!=source->wProxyPort) dest->wProxyPort=0; - if(dest->useProxyAuth!=source->useProxyAuth) dest->useProxyAuth=2; + if (dest->wProxyPort!=source->wProxyPort) dest->wProxyPort=0; + if (dest->useProxyAuth!=source->useProxyAuth) dest->useProxyAuth=2; CombineSettingsStrings(&dest->szProxyAuthUser,&source->szProxyAuthUser); CombineSettingsStrings(&dest->szProxyAuthPassword,&source->szProxyAuthPassword); - if(dest->dnsThroughProxy!=source->dnsThroughProxy) dest->dnsThroughProxy=2; - if(dest->specifyOutgoingPorts!=source->specifyOutgoingPorts) dest->specifyOutgoingPorts=2; + if (dest->dnsThroughProxy!=source->dnsThroughProxy) dest->dnsThroughProxy=2; + if (dest->specifyOutgoingPorts!=source->specifyOutgoingPorts) dest->specifyOutgoingPorts=2; CombineSettingsStrings(&dest->szOutgoingPorts,&source->szOutgoingPorts); } else { @@ -127,33 +127,33 @@ static void CombineSettingsStructs(NETLIBUSERSETTINGS *dest,DWORD *destFlags,NET dest->useProxy=source->useProxy; dest->proxyType=source->proxyType; dest->szProxyServer=source->szProxyServer; - if(dest->szProxyServer) dest->szProxyServer=mir_strdup(dest->szProxyServer); + if (dest->szProxyServer) dest->szProxyServer=mir_strdup(dest->szProxyServer); dest->wProxyPort=source->wProxyPort; dest->useProxyAuth=source->useProxyAuth; dest->szProxyAuthUser=source->szProxyAuthUser; - if(dest->szProxyAuthUser) dest->szProxyAuthUser=mir_strdup(dest->szProxyAuthUser); + if (dest->szProxyAuthUser) dest->szProxyAuthUser=mir_strdup(dest->szProxyAuthUser); dest->szProxyAuthPassword=source->szProxyAuthPassword; - if(dest->szProxyAuthPassword) dest->szProxyAuthPassword=mir_strdup(dest->szProxyAuthPassword); + if (dest->szProxyAuthPassword) dest->szProxyAuthPassword=mir_strdup(dest->szProxyAuthPassword); dest->dnsThroughProxy=source->dnsThroughProxy; dest->specifyOutgoingPorts=source->specifyOutgoingPorts; dest->szOutgoingPorts=source->szOutgoingPorts; if (dest->szOutgoingPorts) dest->szOutgoingPorts=mir_strdup(dest->szOutgoingPorts); } } - if(sourceFlags&NUF_INCOMING) { - if(*destFlags&NUF_INCOMING) { - if(dest->enableUPnP!=source->enableUPnP) dest->enableUPnP=2; - if(dest->specifyIncomingPorts!=source->specifyIncomingPorts) dest->specifyIncomingPorts=2; + if (sourceFlags&NUF_INCOMING) { + if (*destFlags&NUF_INCOMING) { + if (dest->enableUPnP!=source->enableUPnP) dest->enableUPnP=2; + if (dest->specifyIncomingPorts!=source->specifyIncomingPorts) dest->specifyIncomingPorts=2; CombineSettingsStrings(&dest->szIncomingPorts,&source->szIncomingPorts); } else { dest->enableUPnP=source->enableUPnP; dest->specifyIncomingPorts=source->specifyIncomingPorts; dest->szIncomingPorts=source->szIncomingPorts; - if(dest->szIncomingPorts) dest->szIncomingPorts=mir_strdup(dest->szIncomingPorts); + if (dest->szIncomingPorts) dest->szIncomingPorts=mir_strdup(dest->szIncomingPorts); } } - if((*destFlags&NUF_NOHTTPSOPTION)!=(sourceFlags&NUF_NOHTTPSOPTION)) + if ((*destFlags&NUF_NOHTTPSOPTION)!=(sourceFlags&NUF_NOHTTPSOPTION)) *destFlags=(*destFlags|sourceFlags)&~NUF_NOHTTPSOPTION; else *destFlags|=sourceFlags; } @@ -188,21 +188,21 @@ static void ChangeSettingStringByEdit(HWND hwndDlg,UINT ctrlId,int iUser,int mem if (!(tempSettings[i]->flags & NUF_NOOPTIONS)) { ppszNew=(char**)(((PBYTE)&tempSettings[i]->settings)+memberOffset); - if(*ppszNew) mir_free(*ppszNew); + if (*ppszNew) mir_free(*ppszNew); *ppszNew=mir_strdup(szNewValue); } mir_free(szNewValue); } else { ppszNew=(char**)(((PBYTE)&tempSettings[iUser]->settings)+memberOffset); - if(*ppszNew) mir_free(*ppszNew); + if (*ppszNew) mir_free(*ppszNew); *ppszNew=szNewValue; } } static void WriteSettingsStructToDb(const char *szSettingsModule,NETLIBUSERSETTINGS *settings,DWORD flags) { - if(flags&NUF_OUTGOING) { + if (flags&NUF_OUTGOING) { char szEncodedPassword[512]; DBWriteContactSettingByte(NULL,szSettingsModule,"NLValidateSSL",(BYTE)settings->validateSSL); DBWriteContactSettingByte(NULL,szSettingsModule,"NLUseProxy",(BYTE)settings->useProxy); @@ -218,7 +218,7 @@ static void WriteSettingsStructToDb(const char *szSettingsModule,NETLIBUSERSETTI DBWriteContactSettingByte(NULL,szSettingsModule,"NLSpecifyOutgoingPorts",(BYTE)settings->specifyOutgoingPorts); DBWriteContactSettingString(NULL,szSettingsModule,"NLOutgoingPorts",settings->szOutgoingPorts?settings->szOutgoingPorts:""); } - if(flags&NUF_INCOMING) { + if (flags&NUF_INCOMING) { DBWriteContactSettingByte(NULL,szSettingsModule,"NLEnableUPnP",(BYTE)settings->enableUPnP); DBWriteContactSettingByte(NULL,szSettingsModule,"NLSpecifyIncomingPorts",(BYTE)settings->specifyIncomingPorts); DBWriteContactSettingString(NULL,szSettingsModule,"NLIncomingPorts",settings->szIncomingPorts?settings->szIncomingPorts:""); @@ -252,13 +252,13 @@ void NetlibSaveUserSettingsStruct(const char *szSettingsModule,NETLIBUSERSETTING if (thisUser->user.flags & NUF_NOOPTIONS) continue; CombineSettingsStructs(&combinedSettings, &flags, &thisUser->settings, thisUser->user.flags); } - if(combinedSettings.validateSSL==2) combinedSettings.validateSSL=0; - if(combinedSettings.useProxy==2) combinedSettings.useProxy=0; - if(combinedSettings.proxyType==0) combinedSettings.proxyType=PROXYTYPE_SOCKS5; - if(combinedSettings.useProxyAuth==2) combinedSettings.useProxyAuth=0; - if(combinedSettings.dnsThroughProxy==2) combinedSettings.dnsThroughProxy=1; - if(combinedSettings.enableUPnP==2) combinedSettings.enableUPnP=1; - if(combinedSettings.specifyIncomingPorts==2) combinedSettings.specifyIncomingPorts=0; + if (combinedSettings.validateSSL==2) combinedSettings.validateSSL=0; + if (combinedSettings.useProxy==2) combinedSettings.useProxy=0; + if (combinedSettings.proxyType==0) combinedSettings.proxyType=PROXYTYPE_SOCKS5; + if (combinedSettings.useProxyAuth==2) combinedSettings.useProxyAuth=0; + if (combinedSettings.dnsThroughProxy==2) combinedSettings.dnsThroughProxy=1; + if (combinedSettings.enableUPnP==2) combinedSettings.enableUPnP=1; + if (combinedSettings.specifyIncomingPorts==2) combinedSettings.specifyIncomingPorts=0; WriteSettingsStructToDb("Netlib",&combinedSettings,flags); NetlibFreeUserSettingsStruct(&combinedSettings); LeaveCriticalSection(&csNetlibUser); @@ -408,7 +408,7 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, switch(LOWORD(wParam)) { case IDC_NETLIBUSERS: - if(HIWORD(wParam)==CBN_SELCHANGE) SendMessage(hwndDlg,M_REFRESHALL,0,0); + if (HIWORD(wParam)==CBN_SELCHANGE) SendMessage(hwndDlg,M_REFRESHALL,0,0); return 0; case IDC_LOGOPTIONS: @@ -462,11 +462,11 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, ChangeSettingIntByCheckbox(hwndDlg,LOWORD(wParam),iUser,offsetof(NETLIBUSERSETTINGS,validateSSL)); break; case IDC_PROXYHOST: - if(HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus()) return 0; + if (HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus()) return 0; ChangeSettingStringByEdit(hwndDlg,LOWORD(wParam),iUser,offsetof(NETLIBUSERSETTINGS,szProxyServer)); break; case IDC_PROXYPORT: - if(HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus()) return 0; + if (HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus()) return 0; { int newValue,i; newValue=GetDlgItemInt(hwndDlg,LOWORD(wParam),NULL,FALSE); if (iUser == -1) @@ -479,19 +479,19 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, } break; case IDC_PROXYUSER: - if(HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus()) return 0; + if (HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus()) return 0; ChangeSettingStringByEdit(hwndDlg,LOWORD(wParam),iUser,offsetof(NETLIBUSERSETTINGS,szProxyAuthUser)); break; case IDC_PROXYPASS: - if(HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus()) return 0; + if (HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus()) return 0; ChangeSettingStringByEdit(hwndDlg,LOWORD(wParam),iUser,offsetof(NETLIBUSERSETTINGS,szProxyAuthPassword)); break; case IDC_PORTSRANGE: - if(HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus()) return 0; + if (HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus()) return 0; ChangeSettingStringByEdit(hwndDlg,LOWORD(wParam),iUser,offsetof(NETLIBUSERSETTINGS,szIncomingPorts)); break; case IDC_PORTSRANGEO: - if(HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus()) return 0; + if (HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus()) return 0; ChangeSettingStringByEdit(hwndDlg,LOWORD(wParam),iUser,offsetof(NETLIBUSERSETTINGS,szOutgoingPorts)); break; } diff --git a/src/modules/netlib/netlibpktrecver.cpp b/src/modules/netlib/netlibpktrecver.cpp index 85f65aa617..91fc4ddbe9 100644 --- a/src/modules/netlib/netlibpktrecver.cpp +++ b/src/modules/netlib/netlibpktrecver.cpp @@ -28,12 +28,12 @@ INT_PTR NetlibPacketRecverCreate(WPARAM wParam,LPARAM lParam) struct NetlibConnection *nlc=(struct NetlibConnection*)wParam; struct NetlibPacketRecver *nlpr; - if(GetNetlibHandleType(nlc)!=NLH_CONNECTION || lParam==0) { + if (GetNetlibHandleType(nlc)!=NLH_CONNECTION || lParam==0) { SetLastError(ERROR_INVALID_PARAMETER); return (INT_PTR)(struct NetlibPacketRecver*)NULL; } nlpr=(struct NetlibPacketRecver*)mir_calloc(sizeof(struct NetlibPacketRecver)); - if(nlpr==NULL) { + if (nlpr==NULL) { SetLastError(ERROR_OUTOFMEMORY); return (INT_PTR)(struct NetlibPacketRecver*)NULL; } @@ -53,7 +53,7 @@ INT_PTR NetlibPacketRecverGetMore(WPARAM wParam,LPARAM lParam) NETLIBPACKETRECVER *nlprParam=(NETLIBPACKETRECVER*)lParam; INT_PTR recvResult; - if(GetNetlibHandleType(nlpr)!=NLH_PACKETRECVER || nlprParam==NULL || nlprParam->cbSize!=sizeof(NETLIBPACKETRECVER) || nlprParam->bytesUsed>nlpr->packetRecver.bytesAvailable) { + if (GetNetlibHandleType(nlpr)!=NLH_PACKETRECVER || nlprParam==NULL || nlprParam->cbSize!=sizeof(NETLIBPACKETRECVER) || nlprParam->bytesUsed>nlpr->packetRecver.bytesAvailable) { SetLastError(ERROR_INVALID_PARAMETER); return SOCKET_ERROR; } @@ -62,8 +62,8 @@ INT_PTR NetlibPacketRecverGetMore(WPARAM wParam,LPARAM lParam) return SOCKET_ERROR; } nlpr->packetRecver.dwTimeout=nlprParam->dwTimeout; - if(nlprParam->bytesUsed==0) { - if(nlpr->packetRecver.bytesAvailable==nlpr->packetRecver.bufferSize) { + if (nlprParam->bytesUsed==0) { + if (nlpr->packetRecver.bytesAvailable==nlpr->packetRecver.bufferSize) { nlpr->packetRecver.bytesAvailable=0; NetlibLogf(nlpr->nlc->nlu,"Packet recver: packet overflowed buffer, ditching"); } @@ -72,14 +72,14 @@ INT_PTR NetlibPacketRecverGetMore(WPARAM wParam,LPARAM lParam) MoveMemory(nlpr->packetRecver.buffer,nlpr->packetRecver.buffer+nlprParam->bytesUsed,nlpr->packetRecver.bytesAvailable-nlprParam->bytesUsed); nlpr->packetRecver.bytesAvailable-=nlprParam->bytesUsed; } - if(nlprParam->dwTimeout!=INFINITE) { - if(!si.pending(nlpr->nlc->hSsl) && WaitUntilReadable(nlpr->nlc->s,nlprParam->dwTimeout) <= 0) { + if (nlprParam->dwTimeout!=INFINITE) { + if (!si.pending(nlpr->nlc->hSsl) && WaitUntilReadable(nlpr->nlc->s,nlprParam->dwTimeout) <= 0) { *nlprParam=nlpr->packetRecver; return SOCKET_ERROR; } } recvResult=NLRecv(nlpr->nlc, (char*)nlpr->packetRecver.buffer+nlpr->packetRecver.bytesAvailable,nlpr->packetRecver.bufferSize-nlpr->packetRecver.bytesAvailable,0); - if(recvResult>0) nlpr->packetRecver.bytesAvailable+=recvResult; + if (recvResult>0) nlpr->packetRecver.bytesAvailable+=recvResult; *nlprParam=nlpr->packetRecver; return recvResult; } diff --git a/src/modules/netlib/netlibssl.cpp b/src/modules/netlib/netlibssl.cpp index 96a9a52348..d533bc1236 100644 --- a/src/modules/netlib/netlibssl.cpp +++ b/src/modules/netlib/netlibssl.cpp @@ -793,7 +793,7 @@ int NetlibSslRead(SslHandle *ssl, char *buf, int num, int peek) // Locate data and (optional) extra buffers. pDataBuffer = NULL; pExtraBuffer = NULL; - for(i = 1; i < 4; i++) + for (i = 1; i < 4; i++) { if (pDataBuffer == NULL && Buffers[i].BufferType == SECBUFFER_DATA) pDataBuffer = &Buffers[i]; diff --git a/src/modules/netlib/netlibupnp.cpp b/src/modules/netlib/netlibupnp.cpp index 080fed019d..639cade4de 100644 --- a/src/modules/netlib/netlibupnp.cpp +++ b/src/modules/netlib/netlibupnp.cpp @@ -381,7 +381,7 @@ retrycon: LongLog(szData); sz = 0; - for(;;) + for (;;) { int bytesRecv; @@ -632,7 +632,7 @@ static void discoverUPnP(void) buf = (char*)mir_alloc(1500); - for(i = 3; --i && szUrl[0] == 0;) + for (i = 3; --i && szUrl[0] == 0;) { for (j = 0; j < nip; ++j) { diff --git a/src/modules/options/options.cpp b/src/modules/options/options.cpp index d8d09f8967..699a9d5f91 100644 --- a/src/modules/options/options.cpp +++ b/src/modules/options/options.cpp @@ -107,7 +107,7 @@ static HTREEITEM FindNamedTreeItemAtRoot(HWND hwndTree, const TCHAR* name) tvi.hItem = TreeView_GetRoot( hwndTree ); while( tvi.hItem != NULL ) { SendMessage( hwndTree, TVM_GETITEM, 0, (LPARAM)&tvi ); - if( !_tcsicmp( str,name )) + if ( !_tcsicmp( str,name )) return tvi.hItem; tvi.hItem = TreeView_GetNextSibling( hwndTree, tvi.hItem ); @@ -126,7 +126,7 @@ static HTREEITEM FindNamedTreeItemAtChildren(HWND hwndTree, HTREEITEM hItem, con tvi.hItem = TreeView_GetChild( hwndTree, hItem ); while( tvi.hItem != NULL ) { SendMessage( hwndTree, TVM_GETITEM, 0, (LPARAM)&tvi ); - if( !_tcsicmp( str,name )) + if ( !_tcsicmp( str,name )) return tvi.hItem; tvi.hItem = TreeView_GetNextSibling( hwndTree, tvi.hItem ); @@ -139,7 +139,7 @@ static BOOL CALLBACK BoldGroupTitlesEnumChildren(HWND hwnd,LPARAM lParam) TCHAR szClass[64]; GetClassName(hwnd,szClass,SIZEOF(szClass)); - if(!lstrcmp(szClass,_T("Button")) && (GetWindowLongPtr(hwnd,GWL_STYLE)&0x0F)==BS_GROUPBOX) + if (!lstrcmp(szClass,_T("Button")) && (GetWindowLongPtr(hwnd,GWL_STYLE)&0x0F)==BS_GROUPBOX) SendMessage(hwnd,WM_SETFONT,lParam,0); return TRUE; } @@ -788,9 +788,9 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPAR mir_sntprintf(fullTitle,sz,(dat->opd[i].pszGroup && dat->opd[i].pszTitle)?_T("%s - %s"):_T("%s%s"),dat->opd[i].pszGroup?dat->opd[i].pszGroup:_T(""),dat->opd[i].pszTitle?dat->opd[i].pszTitle:_T("") ); } useTitle=fullTitle?fullTitle:dat->opd[i].pszTitle; - if(dat->opd[i].pszGroup != NULL && FilterInst==NULL) { + if (dat->opd[i].pszGroup != NULL && FilterInst==NULL) { tvis.hParent = FindNamedTreeItemAtRoot(hwndTree, dat->opd[i].pszGroup); - if(tvis.hParent == NULL) { + if (tvis.hParent == NULL) { tvis.item.lParam = -1; tvis.item.pszText = dat->opd[i].pszGroup; tvis.hParent = TreeView_InsertItem(hwndTree, &tvis); @@ -799,7 +799,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPAR else { TVITEM tvi; tvi.hItem = FindNamedTreeItemAtRoot(hwndTree,useTitle); - if( tvi.hItem != NULL ) { + if ( tvi.hItem != NULL ) { if ( i == dat->currentPage ) dat->hCurrentPage=tvi.hItem; tvi.mask = TVIF_PARAM; TreeView_GetItem(hwndTree,&tvi); @@ -815,7 +815,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPAR hItem = FindNamedTreeItemAtRoot(hwndTree,useTitle); else hItem = FindNamedTreeItemAtChildren(hwndTree,tvis.hParent,useTitle); - if( hItem != NULL ) { + if ( hItem != NULL ) { if ( i == dat->currentPage ) { TVITEM tvi; tvi.hItem=hItem; @@ -849,7 +849,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPAR } tvi.hItem = TreeView_GetNextSibling( hwndTree, tvi.hItem ); } - if(dat->hCurrentPage==NULL) { + if (dat->hCurrentPage==NULL) { dat->hCurrentPage=TreeView_GetRoot(hwndTree); dat->currentPage=-1; } @@ -858,7 +858,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPAR if ( oldWnd ) { if ( dat->currentPage == (-1) || oldWnd != dat->opd[dat->currentPage].hwnd ) { ShowWindow( oldWnd, SW_HIDE); - if ( oldTab && ( dat->currentPage ==-1 || !dat->opd[dat->currentPage].insideTab ) ) + if ( oldTab && ( dat->currentPage == -1 || !dat->opd[dat->currentPage].insideTab ) ) ShowWindow( oldTab, SW_HIDE ); } } @@ -876,7 +876,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPAR case PSM_CHANGED: EnableWindow(GetDlgItem(hdlg,IDC_APPLY),TRUE); - if(dat->currentPage != (-1)) dat->opd[dat->currentPage].changed=1; + if (dat->currentPage != (-1)) dat->opd[dat->currentPage].changed=1; return TRUE; case PSM_ISEXPERT: @@ -898,12 +898,12 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPAR case TCN_SELCHANGING: case TVN_SELCHANGING: { PSHNOTIFY pshn; - if(dat->currentPage==-1 || dat->opd[dat->currentPage].hwnd==NULL) break; + if (dat->currentPage==-1 || dat->opd[dat->currentPage].hwnd==NULL) break; pshn.hdr.code=PSN_KILLACTIVE; pshn.hdr.hwndFrom=dat->opd[dat->currentPage].hwnd; pshn.hdr.idFrom=0; pshn.lParam=0; - if(SendMessage(dat->opd[dat->currentPage].hwnd,WM_NOTIFY,0,(LPARAM)&pshn)) { + if (SendMessage(dat->opd[dat->currentPage].hwnd,WM_NOTIFY,0,(LPARAM)&pshn)) { SetWindowLongPtr(hdlg,DWLP_MSGRESULT,TRUE); return TRUE; } @@ -913,11 +913,11 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPAR case TVN_SELCHANGED: { BOOL tabChange = (wParam == IDC_TAB); ShowWindow(GetDlgItem(hdlg,IDC_STNOPAGE),SW_HIDE); - if(dat->currentPage!=-1 && dat->opd[dat->currentPage].hwnd!=NULL) ShowWindow(dat->opd[dat->currentPage].hwnd,SW_HIDE); + if (dat->currentPage!=-1 && dat->opd[dat->currentPage].hwnd!=NULL) ShowWindow(dat->opd[dat->currentPage].hwnd,SW_HIDE); if (!tabChange) { TVITEM tvi; tvi.hItem=dat->hCurrentPage=TreeView_GetSelection(hwndTree); - if(tvi.hItem==NULL) break; + if (tvi.hItem==NULL) break; tvi.mask=TVIF_HANDLE|TVIF_PARAM; TreeView_GetItem(hwndTree,&tvi); dat->currentPage=tvi.lParam; @@ -943,32 +943,32 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPAR int w,h; dat->opd[dat->currentPage].hwnd=CreateDialogIndirectParamA(dat->opd[dat->currentPage].hInst,dat->opd[dat->currentPage].pTemplate,hdlg,dat->opd[dat->currentPage].dlgProc,dat->opd[dat->currentPage].dwInitParam); - if(dat->opd[dat->currentPage].flags&ODPF_BOLDGROUPS) + if (dat->opd[dat->currentPage].flags&ODPF_BOLDGROUPS) EnumChildWindows(dat->opd[dat->currentPage].hwnd,BoldGroupTitlesEnumChildren,(LPARAM)dat->hBoldFont); GetClientRect(dat->opd[dat->currentPage].hwnd,&rcPage); dat->opd[dat->currentPage].expertWidth=rcPage.right; dat->opd[dat->currentPage].expertHeight=rcPage.bottom; GetWindowRect(dat->opd[dat->currentPage].hwnd,&rc); - if(dat->opd[dat->currentPage].simpleBottomControlId) { + if (dat->opd[dat->currentPage].simpleBottomControlId) { GetWindowRect(GetDlgItem(dat->opd[dat->currentPage].hwnd,dat->opd[dat->currentPage].simpleBottomControlId),&rcControl); dat->opd[dat->currentPage].simpleHeight=rcControl.bottom-rc.top; } else dat->opd[dat->currentPage].simpleHeight=dat->opd[dat->currentPage].expertHeight; - if(dat->opd[dat->currentPage].simpleRightControlId) { + if (dat->opd[dat->currentPage].simpleRightControlId) { GetWindowRect(GetDlgItem(dat->opd[dat->currentPage].hwnd,dat->opd[dat->currentPage].simpleRightControlId),&rcControl); dat->opd[dat->currentPage].simpleWidth=rcControl.right-rc.left; } else dat->opd[dat->currentPage].simpleWidth=dat->opd[dat->currentPage].expertWidth; - if(IsDlgButtonChecked(hdlg,IDC_EXPERT)) { + if (IsDlgButtonChecked(hdlg,IDC_EXPERT)) { w=dat->opd[dat->currentPage].expertWidth; h=dat->opd[dat->currentPage].expertHeight; } else { int i; - for(i=0;iopd[dat->currentPage].nExpertOnlyControls;i++) + for (i=0;iopd[dat->currentPage].nExpertOnlyControls;i++) ShowWindow(GetDlgItem(dat->opd[dat->currentPage].hwnd,dat->opd[dat->currentPage].expertOnlyControls[i]),SW_HIDE); w=dat->opd[dat->currentPage].simpleWidth; h=dat->opd[dat->currentPage].simpleHeight; @@ -1026,7 +1026,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPAR { int pageWidth, pageHeight; - if(IsDlgButtonChecked(hdlg,IDC_EXPERT)) { + if (IsDlgButtonChecked(hdlg,IDC_EXPERT)) { pageWidth=dat->opd[dat->currentPage].expertWidth; pageHeight=dat->opd[dat->currentPage].expertHeight; } @@ -1068,7 +1068,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPAR } ShowWindow(dat->opd[dat->currentPage].hwnd,SW_SHOW); - if(((LPNMTREEVIEW)lParam)->action==TVC_BYMOUSE) PostMessage(hdlg,DM_FOCUSPAGE,0,0); + if (((LPNMTREEVIEW)lParam)->action==TVC_BYMOUSE) PostMessage(hdlg,DM_FOCUSPAGE,0,0); else SetFocus(hwndTree); } else ShowWindow(GetDlgItem(hdlg,IDC_STNOPAGE),SW_SHOW); @@ -1112,25 +1112,25 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPAR pshn.hdr.idFrom=0; pshn.lParam=expert; pshn.hdr.code=PSN_EXPERTCHANGED; - for(i=0;ipageCount;i++) { - if(dat->opd[i].hwnd==NULL) continue; + for (i=0;ipageCount;i++) { + if (dat->opd[i].hwnd==NULL) continue; if (!CheckPageShow( hdlg, dat, i ) ) continue; //if (( dat->opd[i].flags & ODPF_SIMPLEONLY ) && expert) continue; //if (( dat->opd[i].flags & ODPF_EXPERTONLY ) && !expert) continue; pshn.hdr.hwndFrom=dat->opd[i].hwnd; SendMessage(dat->opd[i].hwnd,WM_NOTIFY,0,(LPARAM)&pshn); - for(j=0;jopd[i].nExpertOnlyControls;j++) + for (j=0;jopd[i].nExpertOnlyControls;j++) ShowWindow(GetDlgItem(dat->opd[i].hwnd,dat->opd[i].expertOnlyControls[j]),expert?SW_SHOW:SW_HIDE); dat->opd[i].insideTab = IsInsideTab( hdlg, dat, i ); GetWindowRect(dat->opd[i].hwnd,&rcPage); - if(dat->opd[i].simpleBottomControlId) newh=expert?dat->opd[i].expertHeight:dat->opd[i].simpleHeight; + if (dat->opd[i].simpleBottomControlId) newh=expert?dat->opd[i].expertHeight:dat->opd[i].simpleHeight; else newh=rcPage.bottom-rcPage.top; - if(dat->opd[i].simpleRightControlId) neww=expert?dat->opd[i].expertWidth:dat->opd[i].simpleWidth; + if (dat->opd[i].simpleRightControlId) neww=expert?dat->opd[i].expertWidth:dat->opd[i].simpleWidth; else neww=rcPage.right-rcPage.left; - if(i==dat->currentPage) { + if (i==dat->currentPage) { POINT ptStart,ptEnd,ptNow; DWORD thisTick,startTick; RECT rc; @@ -1147,13 +1147,13 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPAR ptEnd.x=(dat->rcDisplay.left+dat->rcDisplay.right-neww)>>1; ptEnd.y=(dat->rcDisplay.top+dat->rcDisplay.bottom-newh)>>1; } - if(abs(ptEnd.x-ptStart.x)>5 || abs(ptEnd.y-ptStart.y)>5) { + if (abs(ptEnd.x-ptStart.x)>5 || abs(ptEnd.y-ptStart.y)>5) { startTick=GetTickCount(); SetWindowPos(dat->opd[i].hwnd,HWND_TOP,0,0,min(neww,rcPage.right),min(newh,rcPage.bottom),SWP_NOMOVE); UpdateWindow(dat->opd[i].hwnd); - for(;;) { + for (;;) { thisTick=GetTickCount(); - if(thisTick>startTick+100) break; + if (thisTick>startTick+100) break; ptNow.x=ptStart.x+(ptEnd.x-ptStart.x)*(int)(thisTick-startTick)/100; ptNow.y=ptStart.y+(ptEnd.y-ptStart.y)*(int)(thisTick-startTick)/100; SetWindowPos(dat->opd[i].hwnd,0,ptNow.x,ptNow.y,0,0,SWP_NOZORDER|SWP_NOSIZE); @@ -1183,8 +1183,8 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPAR pshn.hdr.idFrom=0; pshn.lParam=0; pshn.hdr.code=PSN_RESET; - for(i=0;ipageCount;i++) { - if(dat->opd[i].hwnd==NULL || !dat->opd[i].changed) continue; + for (i=0;ipageCount;i++) { + if (dat->opd[i].hwnd==NULL || !dat->opd[i].changed) continue; pshn.hdr.hwndFrom=dat->opd[i].hwnd; SendMessage(dat->opd[i].hwnd,WM_NOTIFY,0,(LPARAM)&pshn); } @@ -1202,24 +1202,24 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPAR EnableWindow(GetDlgItem(hdlg,IDC_APPLY),FALSE); SetFocus(hwndTree); - if(dat->currentPage!=(-1)) { + if (dat->currentPage!=(-1)) { pshn.hdr.idFrom=0; pshn.lParam=0; pshn.hdr.code=PSN_KILLACTIVE; pshn.hdr.hwndFrom=dat->opd[dat->currentPage].hwnd; - if(SendMessage(dat->opd[dat->currentPage].hwnd,WM_NOTIFY,0,(LPARAM)&pshn)) + if (SendMessage(dat->opd[dat->currentPage].hwnd,WM_NOTIFY,0,(LPARAM)&pshn)) break; } pshn.hdr.code=PSN_APPLY; - for(i=0;ipageCount;i++) { - if(dat->opd[i].hwnd==NULL || !dat->opd[i].changed) continue; + for (i=0;ipageCount;i++) { + if (dat->opd[i].hwnd==NULL || !dat->opd[i].changed) continue; dat->opd[i].changed=0; pshn.hdr.hwndFrom=dat->opd[i].hwnd; - if(SendMessage(dat->opd[i].hwnd,WM_NOTIFY,0,(LPARAM)&pshn)==PSNRET_INVALID_NOCHANGEPAGE) { + if (SendMessage(dat->opd[i].hwnd,WM_NOTIFY,0,(LPARAM)&pshn)==PSNRET_INVALID_NOCHANGEPAGE) { dat->hCurrentPage=dat->opd[i].hTreeItem; TreeView_SelectItem(hwndTree,dat->hCurrentPage); - if(dat->currentPage!=(-1)) ShowWindow(dat->opd[dat->currentPage].hwnd,SW_HIDE); + if (dat->currentPage!=(-1)) ShowWindow(dat->opd[dat->currentPage].hwnd,SW_HIDE); dat->currentPage=i; if (dat->currentPage != (-1)) ShowWindow(dat->opd[dat->currentPage].hwnd,SW_SHOW); return 0; @@ -1410,8 +1410,8 @@ static INT_PTR AddOptionsPage(WPARAM wParam,LPARAM lParam) { OPTIONSDIALOGPAGE *odp=(OPTIONSDIALOGPAGE*)lParam, *dst; struct OptionsPageInit *opi=(struct OptionsPageInit*)wParam; - if(odp==NULL||opi==NULL) return 1; - if(odp->cbSize!=sizeof(OPTIONSDIALOGPAGE) + if (odp==NULL||opi==NULL) return 1; + if (odp->cbSize!=sizeof(OPTIONSDIALOGPAGE) && odp->cbSize != OPTIONPAGE_OLD_SIZE && odp->cbSize != OPTIONPAGE_OLD_SIZE2 && odp->cbSize != OPTIONPAGE_OLD_SIZE3) diff --git a/src/modules/plugins/newplugins.cpp b/src/modules/plugins/newplugins.cpp index 9b880d8ef2..46430ad9ce 100644 --- a/src/modules/plugins/newplugins.cpp +++ b/src/modules/plugins/newplugins.cpp @@ -2,7 +2,7 @@ Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2010 Miranda ICQ/IM project, +Copyright 2000-2010 Miranda ICQ/IM project, all portions of this codebase are copyrighted to the people listed in contributors.txt. @@ -11,7 +11,7 @@ modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. -This program is distributed in the hope that it will be useful, +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -62,15 +62,20 @@ typedef struct { // can all be NULL #define PCLASS_CLIST 0x80 // a CList implementation #define PCLASS_SERVICE 0x100 // has Service Mode implementation -typedef struct pluginEntry { +struct pluginEntry +{ TCHAR pluginname[64]; unsigned int pclass; // PCLASS_* BASIC_PLUGIN_INFO bpi; - struct pluginEntry * nextclass; -} pluginEntry; + pluginEntry* nextclass; +}; static int sttComparePlugins( const pluginEntry* p1, const pluginEntry* p2 ) -{ return ( int )( p1->bpi.hInst - p2->bpi.hInst ); +{ + if (p1->bpi.hInst == p2->bpi.hInst) + return 0; + + return ( p1->bpi.hInst < p2->bpi.hInst ) ? -1 : 1; } static int sttComparePluginsByName( const pluginEntry* p1, const pluginEntry* p2 ) @@ -79,7 +84,7 @@ static int sttComparePluginsByName( const pluginEntry* p1, const pluginEntry* p2 LIST pluginList( 10, sttComparePluginsByName ), pluginListAddr( 10, sttComparePlugins ); -///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////// #define MAX_MIR_VER ULONG_MAX @@ -89,29 +94,9 @@ struct PluginUUIDList { } static const pluginBannedList[] = { - {{0x7f65393b, 0x7771, 0x4f3f, { 0xa9, 0xeb, 0x5d, 0xba, 0xf2, 0xb3, 0x61, 0xf1 }}, MAX_MIR_VER}, // png2dib - {{0xe00f1643, 0x263c, 0x4599, { 0xb8, 0x4b, 0x5, 0x3e, 0x5c, 0x51, 0x1d, 0x28 }}, MAX_MIR_VER}, // loadavatars (unicode) - {{0xc9e01eb0, 0xa119, 0x42d2, { 0xb3, 0x40, 0xe8, 0x67, 0x8f, 0x5f, 0xea, 0xd9 }}, MAX_MIR_VER}, // loadavatars (ansi) - {{0xb4ef58c4, 0x4458, 0x4e47, { 0xa7, 0x67, 0x5c, 0xae, 0xe5, 0xe7, 0xc, 0x81 }}, MAX_MIR_VER}, // 0.7.x AIM Protocol - {{0xb529402b, 0x53ba, 0x4c81, { 0x9e, 0x27, 0xd4, 0x31, 0xeb, 0xe8, 0xec, 0x36 }}, MAX_MIR_VER}, // 0.7.x IRC Protocol - {{0x847bb03c, 0x408c, 0x4f9b, { 0xaa, 0x5a, 0xf5, 0xc0, 0xb7, 0xb5, 0x60, 0x1e }}, MAX_MIR_VER}, // 0.7.x ICQ Protocol - {{0x1ee5af12, 0x26b0, 0x4290, { 0x8f, 0x97, 0x16, 0x77, 0xcb, 0xe, 0xfd, 0x2b }}, MAX_MIR_VER}, // 0.7.x Jabber Protocol (Unicode) - {{0xf7f5861d, 0x988d, 0x479d, { 0xa5, 0xbb, 0x80, 0xc7, 0xfa, 0x8a, 0xd0, 0xef }}, MAX_MIR_VER}, // 0.7.x Jabber Protocol (Ansi) - {{0xdc39da8a, 0x8385, 0x4cd9, { 0xb2, 0x98, 0x80, 0x67, 0x7b, 0x8f, 0xe6, 0xe4 }}, MAX_MIR_VER}, // 0.7.x MSN Protocol (Unicode) - {{0x29aa3a80, 0x3368, 0x4b78, { 0x82, 0xc1, 0xdf, 0xc7, 0x29, 0x6a, 0x58, 0x99 }}, MAX_MIR_VER}, // 0.7.x MSN Protocol (Ansi) - {{0xa6648b6c, 0x6fb8, 0x4551, { 0xb4, 0xe7, 0x1, 0x36, 0xf9, 0x16, 0xd4, 0x85 }}, MAX_MIR_VER}, // 0.7.x Yahoo Protocol - {{0x6ca5f042, 0x7a7f, 0x47cc, { 0xa7, 0x15, 0xfc, 0x8c, 0x46, 0xfb, 0xf4, 0x34 }}, PLUGIN_MAKE_VERSION(3, 0, 4, 0)}, // 0.8.x TabSRMM (Unicode) - {{0x5889a3ef, 0x7c95, 0x4249, { 0x98, 0xbb, 0x34, 0xe9, 0x5, 0x3a, 0x6e, 0xa0 }}, PLUGIN_MAKE_VERSION(3, 0, 4, 0)}, // 0.8.x TabSRMM (ANSI) - {{0x84636f78, 0x2057, 0x4302, { 0x8a, 0x65, 0x23, 0xa1, 0x6d, 0x46, 0x84, 0x4c }}, PLUGIN_MAKE_VERSION(2, 9, 0, 4)}, // 0.8.x Scriver (Unicode) - {{0x1e91b6c9, 0xe040, 0x4a6f, { 0xab, 0x56, 0xdf, 0x76, 0x98, 0xfa, 0xcb, 0xf1 }}, PLUGIN_MAKE_VERSION(2, 9, 0, 4)}, // 0.8.x Scriver (ANSI) - {{0x240a91dc, 0x9464, 0x457a, { 0x97, 0x87, 0xff, 0x1e, 0xa8, 0x8e, 0x77, 0xe3 }}, PLUGIN_MAKE_VERSION(0, 9, 0, 0)}, // 0.8.x CList Classic (Unicode) - {{0x552cf71a, 0x249f, 0x4650, { 0xbb, 0x2b, 0x7c, 0xdb, 0x1f, 0xe7, 0xd1, 0x78 }}, PLUGIN_MAKE_VERSION(0, 9, 0, 0)}, // 0.8.x CList Classic (ANSI) - {{0x8f79b4ee, 0xeb48, 0x4a03, { 0x87, 0x3e, 0x27, 0xbe, 0x6b, 0x7e, 0x9a, 0x25 }}, PLUGIN_MAKE_VERSION(0, 9, 1, 0)}, // 0.8.x Clist Nicer (Unicode) - {{0x5a070cec, 0xb2ab, 0x4bbe, { 0x8e, 0x48, 0x9c, 0x8d, 0xcd, 0xda, 0x14, 0xc3 }}, PLUGIN_MAKE_VERSION(0, 9, 1, 0)}, // 0.8.x Clist Nicer (ANSI) - {{0x43909b6, 0xaad8, 0x4d82, { 0x8e, 0xb5, 0x9f, 0x64, 0xcf, 0xe8, 0x67, 0xcd }}, PLUGIN_MAKE_VERSION(0, 9, 0, 8)}, // 0.8.x Clist Modern (Unicode) - {{0xf6588c56, 0x15dc, 0x4cd7, { 0x8c, 0xf9, 0x48, 0xab, 0x6c, 0x5f, 0xd2, 0xf }}, PLUGIN_MAKE_VERSION(0, 9, 0, 8)}, // 0.8.x Clist Modern (ANSI) - {{0x2a417ab9, 0x16f2, 0x472d, { 0x9a, 0xe3, 0x41, 0x51, 0x3, 0xc7, 0x8a, 0x64 }}, PLUGIN_MAKE_VERSION(0, 9, 0, 0)}, // 0.8.x Clist MW (Unicode) - {{0x7ab05d31, 0x9972, 0x4406, { 0x82, 0x3e, 0xe, 0xd7, 0x45, 0xef, 0x7c, 0x56 }}, PLUGIN_MAKE_VERSION(0, 9, 0, 0)} // 0.8.x Clist MW (ANSI) + {{0x7f65393b, 0x7771, 0x4f3f, { 0xa9, 0xeb, 0x5d, 0xba, 0xf2, 0xb3, 0x61, 0xf1 }}, MAX_MIR_VER}, // png2dib + {{0xe00f1643, 0x263c, 0x4599, { 0xb8, 0x4b, 0x05, 0x3e, 0x5c, 0x51, 0x1d, 0x28 }}, MAX_MIR_VER}, // loadavatars (unicode) + {{0xc9e01eb0, 0xa119, 0x42d2, { 0xb3, 0x40, 0xe8, 0x67, 0x8f, 0x5f, 0xea, 0xd9 }}, MAX_MIR_VER}, // loadavatars (ansi) }; const int pluginBannedListCount = SIZEOF(pluginBannedList); @@ -139,7 +124,7 @@ int CallHookSubscribers( HANDLE hEvent, WPARAM wParam, LPARAM lParam ); int LoadDatabaseModule(void); -char * GetPluginNameByInstance( HINSTANCE hInstance ) +char* GetPluginNameByInstance( HINSTANCE hInstance ) { int i = 0; if ( pluginList.getCount() == 0) return NULL; @@ -177,7 +162,7 @@ HINSTANCE GetInstByAddress( void* codePtr ) static int uuidToString(const MUUID uuid, char *szStr, int cbLen) { if (cbLen<1||!szStr) return 0; - mir_snprintf(szStr, cbLen, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", + mir_snprintf(szStr, cbLen, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", uuid.a, uuid.b, uuid.c, uuid.d[0], uuid.d[1], uuid.d[2], uuid.d[3], uuid.d[4], uuid.d[5], uuid.d[6], uuid.d[7]); return 1; } @@ -194,7 +179,7 @@ static int validInterfaceList(Miranda_Plugin_Interfaces ifaceProc) { MUUID *piface = ( ifaceProc ) ? ifaceProc() : NULL; int i = 0/*, j*/; - + if (!piface) return 0; if (equalUUID(miid_last, piface[0])) @@ -202,17 +187,18 @@ static int validInterfaceList(Miranda_Plugin_Interfaces ifaceProc) return 1; } -static int isPluginBanned(MUUID u1, DWORD dwVersion) { - int i; +static int isPluginBanned(MUUID u1, DWORD dwVersion) +{ + int i; - for (i=0; icbSize != sizeof(PLUGIN_DB_ENUM) || de->pfnEnumCallback == NULL ) return 1; - while ( x != NULL ) - { + while ( x != NULL ) { int rc = de->pfnEnumCallback(StrConvA(x->pluginname), x->bpi.dblink, de->lParam); - if (rc == DBPE_DONE) - { + if (rc == DBPE_DONE) { // this db has been picked, get rid of all the others pluginEntry * y = pluginListDb, * n; - while ( y != NULL ) - { + while ( y != NULL ) { n = y->nextclass; if ( x != y ) Plugin_Uninit(y); @@ -504,12 +484,10 @@ static BOOL scanPluginsDir (WIN32_FIND_DATA * fd, TCHAR * path, WPARAM, LPARAM) pluginEntry* p = (pluginEntry*)HeapAlloc(hPluginListHeap, HEAP_NO_SERIALIZE | HEAP_ZERO_MEMORY, sizeof(pluginEntry)); _tcsncpy(p->pluginname, fd->cFileName, SIZEOF(p->pluginname)); // plugin name suggests its a db module, load it right now - if ( isdb ) - { + if ( isdb ) { TCHAR buf[MAX_PATH]; mir_sntprintf(buf, SIZEOF(buf), _T("%s\\Plugins\\%s"), path, fd->cFileName); - if (checkAPI(buf, &bpi, mirandaVersion, CHECKAPI_DB, NULL)) - { + if (checkAPI(buf, &bpi, mirandaVersion, CHECKAPI_DB, NULL)) { // db plugin is valid p->pclass |= (PCLASS_DB | PCLASS_BASICAPI); // copy the dblink stuff @@ -522,35 +500,29 @@ static BOOL scanPluginsDir (WIN32_FIND_DATA * fd, TCHAR * path, WPARAM, LPARAM) // didn't have basic APIs or DB exports - failed. p->pclass |= PCLASS_FAILED; } - else if (validguess_clist_name(fd->cFileName)) - { + else if (validguess_clist_name(fd->cFileName)) { // keep a note of this plugin for later if ( pluginListUI != NULL ) p->nextclass=pluginListUI; pluginListUI=p; p->pclass |= PCLASS_CLIST; } - else if (validguess_servicemode_name(fd->cFileName)) - { + else if (validguess_servicemode_name(fd->cFileName)) { TCHAR buf[MAX_PATH]; mir_sntprintf(buf, SIZEOF(buf), _T("%s\\Plugins\\%s"), path, fd->cFileName); - if (checkAPI(buf, &bpi, mirandaVersion, CHECKAPI_NONE, NULL)) - { + if (checkAPI(buf, &bpi, mirandaVersion, CHECKAPI_NONE, NULL)) { p->pclass |= (PCLASS_OK | PCLASS_BASICAPI); p->bpi = bpi; - if (bpi.Interfaces) - { + if (bpi.Interfaces) { int i = 0; MUUID *piface = bpi.Interfaces(); - while (!equalUUID(miid_last, piface[i])) - { + while (!equalUUID(miid_last, piface[i])) { if (!equalUUID(miid_servicemode, piface[i++])) continue; p->pclass |= (PCLASS_SERVICE); if ( pluginListSM != NULL ) p->nextclass = pluginListSM; pluginListSM=p; - if (pluginList_crshdmp == NULL && lstrcmpi(fd->cFileName, _T("svc_crshdmp.dll")) == 0) - { - pluginList_crshdmp = p; + if (pluginList_crshdmp == NULL && lstrcmpi(fd->cFileName, _T("svc_crshdmp.dll")) == 0) { + pluginList_crshdmp = p; p->pclass |= PCLASS_LAST; } break; @@ -571,7 +543,7 @@ static BOOL scanPluginsDir (WIN32_FIND_DATA * fd, TCHAR * path, WPARAM, LPARAM) static void SetPluginOnWhiteList(TCHAR * pluginname, int allow) { - DBWriteContactSettingByte(NULL, PLUGINDISABLELIST, StrConvA(pluginname), allow == 0); + DBWriteContactSettingByte(NULL, PLUGINDISABLELIST, StrConvA(pluginname), allow == 0); } // returns 1 if the plugin should be enabled within this profile, filename is always lower case @@ -580,12 +552,10 @@ static int isPluginOnWhiteList(TCHAR * pluginname) char* pluginnameA = _strlwr(mir_t2a(pluginname)); int rc = DBGetContactSettingByte(NULL, PLUGINDISABLELIST, pluginnameA, 0); mir_free(pluginnameA); - if ( rc != 0 && askAboutIgnoredPlugins ) - { + if ( rc != 0 && askAboutIgnoredPlugins ) { TCHAR buf[256]; mir_sntprintf(buf, SIZEOF(buf), TranslateT("'%s' is disabled, re-enable?"), pluginname); - if (MessageBox(NULL, buf, TranslateT("Re-enable Miranda plugin?"), MB_YESNO | MB_ICONQUESTION) == IDYES) - { + if (MessageBox(NULL, buf, TranslateT("Re-enable Miranda plugin?"), MB_YESNO | MB_ICONQUESTION) == IDYES) { SetPluginOnWhiteList(pluginname, 1); rc = 0; } @@ -598,8 +568,7 @@ static pluginEntry* getCListModule(TCHAR * exe, TCHAR * slice, int useWhiteList) { pluginEntry * p = pluginListUI; BASIC_PLUGIN_INFO bpi; - while ( p != NULL ) - { + while ( p != NULL ) { mir_sntprintf(slice, &exe[MAX_PATH] - slice, _T("\\Plugins\\%s"), p->pluginname); CharLower(p->pluginname); if ( useWhiteList ? isPluginOnWhiteList(p->pluginname) : 1 ) { @@ -623,11 +592,9 @@ static pluginEntry* getCListModule(TCHAR * exe, TCHAR * slice, int useWhiteList) int UnloadPlugin(TCHAR* buf, int bufLen) { int i; - for ( i = pluginList.getCount()-1; i >= 0; i-- ) - { + for ( i = pluginList.getCount()-1; i >= 0; i-- ) { pluginEntry* p = pluginList[i]; - if (!_tcsicmp( p->pluginname, buf)) - { + if ( !_tcsicmp(p->pluginname, buf)) { GetModuleFileName( p->bpi.hInst, buf, bufLen); Plugin_Uninit( p ); return TRUE; @@ -701,10 +668,8 @@ int LoadServiceModePlugin(void) void UnloadNewPlugins(void) { - int i; - // unload everything but the special db/clist plugins - for ( i = pluginList.getCount()-1; i >= 0; i-- ) { + for ( int i = pluginList.getCount()-1; i >= 0; i-- ) { pluginEntry* p = pluginList[i]; if ( !(p->pclass & PCLASS_LAST) && (p->pclass & PCLASS_OK)) Plugin_Uninit( p ); @@ -776,7 +741,7 @@ static BOOL dialogListPlugins(WIN32_FIND_DATA* fd, TCHAR* path, WPARAM, LPARAM l void* pVerInfo = mir_alloc(verInfoSize); GetFileVersionInfo(buf, 0, verInfoSize, pVerInfo); VerQueryValue(pVerInfo, _T("\\"), (LPVOID*)&fi, &blockSize); - mir_sntprintf(buf, SIZEOF(buf), _T("%d.%d.%d.%d"), HIWORD(fi->dwProductVersionMS), + mir_sntprintf(buf, SIZEOF(buf), _T("%d.%d.%d.%d"), HIWORD(fi->dwProductVersionMS), LOWORD(fi->dwProductVersionMS), HIWORD(fi->dwProductVersionLS), LOWORD(fi->dwProductVersionLS)); mir_free( pVerInfo ); } @@ -819,7 +784,7 @@ INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar switch (msg) { case WM_INITDIALOG: { - HWND hwndList=GetDlgItem(hwndDlg,IDC_PLUGLIST); + HWND hwndList=GetDlgItem(hwndDlg, IDC_PLUGLIST); LVCOLUMN col; HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | (IsWinVerXPPlus()? ILC_COLOR32 : ILC_COLOR16), 4, 0); ImageList_AddIcon_IconLibLoaded( hIml, SKINICON_OTHER_UNICODE ); @@ -846,139 +811,132 @@ INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar col.pszText = _T(""); col.cx = 20; ListView_InsertColumn(hwndList, 3, &col); - //ListView_InsertColumn(hwndList,4,&col); + //ListView_InsertColumn(hwndList, 4, &col); // XXX: Won't work on windows 95 without IE3+ or 4.70 ListView_SetExtendedListViewStyleEx( hwndList, 0, LVS_EX_SUBITEMIMAGES | LVS_EX_CHECKBOXES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT ); // scan the plugin dir for plugins, cos enumPlugins( dialogListPlugins, ( WPARAM )hwndDlg, ( LPARAM )hwndList ); // sort out the headers - { - int w, max; - - ListView_SetColumnWidth( hwndList, 0, LVSCW_AUTOSIZE ); // dll name - w = ListView_GetColumnWidth( hwndList, 0 ); - if (w>140) { - ListView_SetColumnWidth( hwndList, 0, 140 ); - w = 140; - } - max = w<140? 220+140-w:220; - ListView_SetColumnWidth( hwndList, 1, LVSCW_AUTOSIZE ); // short name - w = ListView_GetColumnWidth( hwndList, 1 ); - if (w>max) - ListView_SetColumnWidth( hwndList, 1, max ); - } - return TRUE; - } - case WM_NOTIFY: - { - NMLISTVIEW * hdr = (NMLISTVIEW *) lParam; - if ( hdr && hdr->hdr.code == LVN_ITEMCHANGED && hdr->uOldState != 0 - && (hdr->uNewState == 0x1000 || hdr->uNewState == 0x2000 ) && IsWindowVisible(hdr->hdr.hwndFrom) ) { - HWND hwndList = GetDlgItem(hwndDlg,IDC_PLUGLIST); - PluginListItemData* dat; - int iRow; - LVITEM it; - it.mask=LVIF_PARAM | LVIF_STATE; - it.iItem = hdr->iItem; - if ( !ListView_GetItem( hwndList, &it )) - break; + { + int w, max; - dat = ( PluginListItemData* )it.lParam; - if ( dat->flags == DEFMOD_DB ) { - ListView_SetItemState(hwndList, hdr->iItem, 0x3000, LVIS_STATEIMAGEMASK); - return FALSE; + ListView_SetColumnWidth( hwndList, 0, LVSCW_AUTOSIZE ); // dll name + w = ListView_GetColumnWidth( hwndList, 0 ); + if (w > 140) { + ListView_SetColumnWidth( hwndList, 0, 140 ); + w = 140; } - // if enabling and replaces, find all other replaces and toggle off - if ( hdr->uNewState & 0x2000 && dat->flags != 0 ) { - for ( iRow=0; iRow != -1; ) { - if ( iRow != hdr->iItem ) { - LVITEM dt; - dt.mask = LVIF_PARAM; - dt.iItem = iRow; - if ( ListView_GetItem( hwndList, &dt )) { - PluginListItemData* dat2 = ( PluginListItemData* )dt.lParam; - if ( dat2->flags == dat->flags ) { - // the lParam is unset, so when the check is unset the clist block doesnt trigger - int lParam = dat2->flags; - dat2->flags = 0; - ListView_SetItemState(hwndList, iRow, 0x1000, LVIS_STATEIMAGEMASK ); - dat2->flags = lParam; - } } } - - iRow = ListView_GetNextItem( hwndList, iRow, LVNI_ALL ); - } } - - ShowWindow( GetDlgItem(hwndDlg, IDC_RESTART ), TRUE ); - SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); - break; + max = w<140? 220+140-w:220; + ListView_SetColumnWidth( hwndList, 1, LVSCW_AUTOSIZE ); // short name + w = ListView_GetColumnWidth( hwndList, 1 ); + if (w > max) + ListView_SetColumnWidth( hwndList, 1, max ); } - - if ( hdr && hdr->hdr.code == LVN_ITEMCHANGED && IsWindowVisible(hdr->hdr.hwndFrom) && hdr->iItem != -1 ) { - TCHAR buf[1024]; - int sel = hdr->uNewState & LVIS_SELECTED; - HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); - LVITEM lvi = { 0 }; - lvi.mask = LVIF_PARAM; - lvi.iItem = hdr->iItem; - if ( ListView_GetItem( hwndList, &lvi )) { - PluginListItemData* dat = ( PluginListItemData* )lvi.lParam; - - ListView_GetItemText(hwndList, hdr->iItem, 1, buf, SIZEOF(buf)); - SetWindowText(GetDlgItem(hwndDlg,IDC_PLUGININFOFRAME),sel ? buf : _T("")); - - SetWindowTextA(GetDlgItem(hwndDlg,IDC_PLUGINAUTHOR), sel ? dat->author : "" ); - SetWindowTextA(GetDlgItem(hwndDlg,IDC_PLUGINEMAIL), sel ? dat->authorEmail : "" ); - { - TCHAR* p = LangPackPcharToTchar( dat->description ); - SetWindowText(GetDlgItem(hwndDlg,IDC_PLUGINLONGINFO), sel ? p : _T("")); - mir_free( p ); - } - SetWindowTextA(GetDlgItem(hwndDlg,IDC_PLUGINCPYR), sel ? dat->copyright : "" ); - SetWindowTextA(GetDlgItem(hwndDlg,IDC_PLUGINURL), sel ? dat->homepage : "" ); - if(equalUUID(miid_last, dat->uuid)) - SetWindowText(GetDlgItem(hwndDlg,IDC_PLUGINPID), sel ? TranslateT("") : _T("")); - else - { - char szUID[128]; - uuidToString( dat->uuid, szUID, sizeof(szUID)); - SetWindowTextA(GetDlgItem(hwndDlg,IDC_PLUGINPID), sel ? szUID : "" ); + return TRUE; + } + case WM_NOTIFY: + if ( lParam ) { + NMLISTVIEW * hdr = (NMLISTVIEW *) lParam; + if ( hdr->hdr.code == LVN_ITEMCHANGED && IsWindowVisible(hdr->hdr.hwndFrom)) { + if (hdr->uOldState != 0 && (hdr->uNewState == 0x1000 || hdr->uNewState == 0x2000 )) { + HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); + + LVITEM it; + it.mask = LVIF_PARAM | LVIF_STATE; + it.iItem = hdr->iItem; + if ( !ListView_GetItem( hwndList, &it )) + break; + + PluginListItemData* dat = ( PluginListItemData* )it.lParam; + if ( dat->flags == DEFMOD_DB ) { + ListView_SetItemState(hwndList, hdr->iItem, 0x3000, LVIS_STATEIMAGEMASK); + return FALSE; + } + // if enabling and replaces, find all other replaces and toggle off + if ( hdr->uNewState & 0x2000 && dat->flags != 0 ) { + for ( int iRow=0; iRow != -1; ) { + if ( iRow != hdr->iItem ) { + LVITEM dt; + dt.mask = LVIF_PARAM; + dt.iItem = iRow; + if ( ListView_GetItem( hwndList, &dt )) { + PluginListItemData* dat2 = ( PluginListItemData* )dt.lParam; + if ( dat2->flags == dat->flags ) { + // the lParam is unset, so when the check is unset the clist block doesnt trigger + int lParam = dat2->flags; + dat2->flags = 0; + ListView_SetItemState(hwndList, iRow, 0x1000, LVIS_STATEIMAGEMASK ); + dat2->flags = lParam; + } } } + + iRow = ListView_GetNextItem( hwndList, iRow, LVNI_ALL ); + } } + + ShowWindow( GetDlgItem(hwndDlg, IDC_RESTART ), TRUE ); + SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); + break; } - } } - if ( hdr && hdr->hdr.code == PSN_APPLY ) { - HWND hwndList=GetDlgItem(hwndDlg,IDC_PLUGLIST); - int iRow; - int iState; - TCHAR buf[1024]; - for (iRow=0 ; iRow != (-1) ; ) { - ListView_GetItemText(hwndList, iRow, 0, buf, SIZEOF(buf)); - iState=ListView_GetItemState(hwndList, iRow, LVIS_STATEIMAGEMASK); - SetPluginOnWhiteList(buf, iState&0x2000 ? 1 : 0); - iRow=ListView_GetNextItem(hwndList, iRow, LVNI_ALL); - } } + if ( hdr->iItem != -1 ) { + TCHAR buf[1024]; + int sel = hdr->uNewState & LVIS_SELECTED; + HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); + LVITEM lvi = { 0 }; + lvi.mask = LVIF_PARAM; + lvi.iItem = hdr->iItem; + if ( ListView_GetItem( hwndList, &lvi )) { + PluginListItemData* dat = ( PluginListItemData* )lvi.lParam; + + ListView_GetItemText(hwndList, hdr->iItem, 1, buf, SIZEOF(buf)); + SetWindowText(GetDlgItem(hwndDlg, IDC_PLUGININFOFRAME), sel ? buf : _T("")); + + SetWindowTextA(GetDlgItem(hwndDlg, IDC_PLUGINAUTHOR), sel ? dat->author : "" ); + SetWindowTextA(GetDlgItem(hwndDlg, IDC_PLUGINEMAIL), sel ? dat->authorEmail : "" ); + { + TCHAR* p = LangPackPcharToTchar( dat->description ); + SetWindowText(GetDlgItem(hwndDlg, IDC_PLUGINLONGINFO), sel ? p : _T("")); + mir_free( p ); + } + SetWindowTextA(GetDlgItem(hwndDlg, IDC_PLUGINCPYR), sel ? dat->copyright : "" ); + SetWindowTextA(GetDlgItem(hwndDlg, IDC_PLUGINURL), sel ? dat->homepage : "" ); + if (equalUUID(miid_last, dat->uuid)) + SetWindowText(GetDlgItem(hwndDlg, IDC_PLUGINPID), sel ? TranslateT("") : _T("")); + else { + char szUID[128]; + uuidToString( dat->uuid, szUID, sizeof(szUID)); + SetWindowTextA(GetDlgItem(hwndDlg, IDC_PLUGINPID), sel ? szUID : "" ); + } } } } + + if ( hdr->hdr.code == PSN_APPLY ) { + HWND hwndList=GetDlgItem(hwndDlg, IDC_PLUGLIST); + int iRow; + int iState; + TCHAR buf[1024]; + for (iRow=0 ; iRow != (-1) ; ) { + ListView_GetItemText(hwndList, iRow, 0, buf, SIZEOF(buf)); + iState=ListView_GetItemState(hwndList, iRow, LVIS_STATEIMAGEMASK); + SetPluginOnWhiteList(buf, iState&0x2000 ? 1 : 0); + iRow=ListView_GetNextItem(hwndList, iRow, LVNI_ALL); + } } } break; - } case WM_COMMAND: if ( HIWORD(wParam) == STN_CLICKED ) { switch (LOWORD(wParam)) { - case IDC_PLUGINEMAIL: - case IDC_PLUGINURL: - { - char buf[512]; - char * p = &buf[7]; - lstrcpyA(buf,"mailto:"); - if ( GetWindowTextA(GetDlgItem(hwndDlg, LOWORD(wParam)), p, SIZEOF(buf) - 7) ) { - CallService(MS_UTILS_OPENURL,0,(LPARAM) (LOWORD(wParam)==IDC_PLUGINEMAIL ? buf : p) ); - } - break; - } - case IDC_GETMOREPLUGINS: - { - CallService(MS_UTILS_OPENURL,0,(LPARAM) "http://addons.miranda-im.org/index.php?action=display&id=1" ); - break; - } + case IDC_PLUGINEMAIL: + case IDC_PLUGINURL: + { + char buf[512]; + char *p = &buf[7]; + lstrcpyA(buf, "mailto:"); + if ( GetWindowTextA(GetDlgItem(hwndDlg, LOWORD(wParam)), p, SIZEOF(buf) - 7)) + CallService(MS_UTILS_OPENURL, 0, (LPARAM) (LOWORD(wParam)==IDC_PLUGINEMAIL ? buf : p) ); + break; + } + case IDC_GETMOREPLUGINS: + CallService(MS_UTILS_OPENURL, 0, (LPARAM) "http://addons.miranda-im.org/index.php?action=display&id=1" ); + break; } } break; diff --git a/src/modules/protocols/protoaccs.cpp b/src/modules/protocols/protoaccs.cpp index 36176560e6..e865450967 100644 --- a/src/modules/protocols/protoaccs.cpp +++ b/src/modules/protocols/protoaccs.cpp @@ -606,7 +606,7 @@ void UnloadAccountsModule() if ( !bModuleInitialized ) return; - for( i=accounts.getCount()-1; i >= 0; i-- ) { + for ( i=accounts.getCount()-1; i >= 0; i-- ) { PROTOACCOUNT* pa = accounts[ i ]; UnloadAccount( pa, false, false ); accounts.remove(i); diff --git a/src/modules/protocols/protochains.cpp b/src/modules/protocols/protochains.cpp index a49cdee424..c8c1b3d5c6 100644 --- a/src/modules/protocols/protochains.cpp +++ b/src/modules/protocols/protochains.cpp @@ -79,7 +79,7 @@ static INT_PTR CallRecvChain(WPARAM wParam,LPARAM lParam) if ( wParam == (WPARAM)(-1)) return 1; //shouldn't happen - sanity check if ( wParam == 0 ) { //begin processing by finding end of chain - for( ;;wParam++ ) { + for ( ;;wParam++ ) { _itoa( wParam, str, 10 ); if ( DBGetContactSettingString( ccs->hContact, "_Filter", str, &dbv )) break; @@ -165,17 +165,17 @@ static INT_PTR Proto_IsProtoOnContact(WPARAM wParam,LPARAM lParam) if (!lParam) return 0; - if(!DBGetContactSettingString((HANDLE)wParam,"Protocol","p",&dbv)) { - if(!_stricmp((char*)lParam,dbv.pszVal)) { + if (!DBGetContactSettingString((HANDLE)wParam,"Protocol","p",&dbv)) { + if (!_stricmp((char*)lParam,dbv.pszVal)) { mir_free(dbv.pszVal); return -1; } mir_free(dbv.pszVal); } - for(i=0;;i++) { + for (i=0;;i++) { _itoa(i,str,10); - if(DBGetContactSettingString((HANDLE)wParam,"_Filter",str,&dbv)) break; - if(!strcmp((char*)lParam,dbv.pszVal)) { + if (DBGetContactSettingString((HANDLE)wParam,"_Filter",str,&dbv)) break; + if (!strcmp((char*)lParam,dbv.pszVal)) { mir_free(dbv.pszVal); return i+1; } @@ -202,25 +202,25 @@ static INT_PTR Proto_AddToContact(WPARAM wParam,LPARAM lParam) DBWriteContactSettingString((HANDLE)wParam,"Protocol","p",(char*)lParam); return 0; } - if(Proto_IsProtoOnContact(wParam,lParam)) return 1; + if (Proto_IsProtoOnContact(wParam,lParam)) return 1; { /* v:0.3.3 + PROTO FILTERS ARE NOW KEPT IN THEIR OWN DB MODULE! */ int i; char str[10],*lastProto; DBVARIANT dbv; - for(i=0;;i++) { + for (i=0;;i++) { _itoa(i,str,10); - if(DBGetContactSettingString((HANDLE)wParam,"_Filter",str,&dbv)) break; + if (DBGetContactSettingString((HANDLE)wParam,"_Filter",str,&dbv)) break; pdCompare = Proto_IsProtocolLoaded(( char* )dbv.pszVal ); mir_free(dbv.pszVal); - if(pdCompare==NULL) continue; - if(pd->type > pdCompare->type) break; + if (pdCompare==NULL) continue; + if (pd->type > pdCompare->type) break; } //put the new module at position i lastProto=mir_strdup((char*)lParam); - for(;;i++) { + for (;;i++) { _itoa(i,str,10); - if(DBGetContactSettingString((HANDLE)wParam,"_Filter",str,&dbv)) { + if (DBGetContactSettingString((HANDLE)wParam,"_Filter",str,&dbv)) { DBWriteContactSettingString((HANDLE)wParam,"_Filter",str,lastProto); mir_free(lastProto); break; @@ -240,13 +240,13 @@ static INT_PTR Proto_RemoveFromContact(WPARAM wParam,LPARAM lParam) char str[10]; i = Proto_IsProtoOnContact(wParam,lParam); - if(!i) return 1; - if(i==-1) + if (!i) return 1; + if (i==-1) DBDeleteContactSetting((HANDLE)wParam,"Protocol","p"); else { - for(i--;;i++) { //we have to decrease i, as Proto_IsOnContact returns +1 more number than read from database + for (i--;;i++) { //we have to decrease i, as Proto_IsOnContact returns +1 more number than read from database _itoa(i+1,str,10); - if(0!=DBGetContactSettingString((HANDLE)wParam,"_Filter",str,&dbv)) { + if (0!=DBGetContactSettingString((HANDLE)wParam,"_Filter",str,&dbv)) { _itoa(i,str,10); DBDeleteContactSetting((HANDLE)wParam,"_Filter",str); break; diff --git a/src/modules/protocols/protocols.cpp b/src/modules/protocols/protocols.cpp index 9d51b754ed..8916ff1512 100644 --- a/src/modules/protocols/protocols.cpp +++ b/src/modules/protocols/protocols.cpp @@ -329,7 +329,7 @@ char** __fastcall Proto_FilesMatrixA( wchar_t **files ) while( files[ count++ ] ); char** filesA = ( char** )mir_alloc( count * sizeof( char* )); - for( int i = 0; i < count; ++i ) + for ( int i = 0; i < count; ++i ) filesA[ i ] = mir_u2a( files[ i ] ); return filesA; @@ -343,7 +343,7 @@ static wchar_t** __fastcall Proto_FilesMatrixU( char **files ) while( files[ count++ ] ); wchar_t** filesU = ( wchar_t** )mir_alloc( count * sizeof( wchar_t* )); - for( int i = 0; i < count; ++i ) + for ( int i = 0; i < count; ++i ) filesU[ i ] = mir_a2u( files[ i ] ); return filesU; @@ -817,7 +817,7 @@ void UnloadProtocolsModule() } if ( protos.getCount() ) { - for( i=0; i < protos.getCount(); i++ ) { + for ( i=0; i < protos.getCount(); i++ ) { mir_free( protos[i]->szName); mir_free( protos[i] ); } diff --git a/src/modules/protocols/protodir.cpp b/src/modules/protocols/protodir.cpp index bb024d06c4..2311e1a1e2 100644 --- a/src/modules/protocols/protodir.cpp +++ b/src/modules/protocols/protodir.cpp @@ -75,7 +75,7 @@ int contactCacheCompare(void * a, void * b) int rc=0; // same protocol? rc = strcmp(x->proto, y->proto); - if ( rc == 0 ) { + if ( rc == 0 ) { // same id? id's might be missing if ( x->id && y->id ) rc = strcmp(x->id, y->id); } @@ -137,7 +137,7 @@ void contactDir_Contact_Add(contactDir * cd, HANDLE hContact, char * proto, char { // if a contact is gonna exist anywhere it's going to be in the ->protoCache which has a key of hContact // if id is not null then the contact should be indexed via the ->contactCache instead - if ( id == NULL ) { + if ( id == NULL ) { int index = 0; contactEntry e; e.hContact=hContact; @@ -184,7 +184,7 @@ void contactDir_Proto_Walk(contactDir * cd) dbvProto.pszVal = (char *) &buf; dbvProto.cchVal = SIZEOF(buf); // figure out what hContact/Protocol/p is - if ( CallService(MS_DB_CONTACT_GETSETTINGSTATIC,(WPARAM)hContact, (LPARAM)&gsProto) == 0 ) { + if ( CallService(MS_DB_CONTACT_GETSETTINGSTATIC,(WPARAM)hContact, (LPARAM)&gsProto) == 0 ) { contactDir_Contact_Add(cd, hContact, buf, NULL); } // find next diff --git a/src/modules/protocols/protoopts.cpp b/src/modules/protocols/protoopts.cpp index 344166f2e4..c98445cfbd 100644 --- a/src/modules/protocols/protoopts.cpp +++ b/src/modules/protocols/protoopts.cpp @@ -173,7 +173,7 @@ static INT_PTR CALLBACK AccFormDlgProc(HWND hwndDlg,UINT message, WPARAM wParam, rtrim( buf ); if ( buf[0] == 0 ) { int count = 1; - for( ;; ) { + for ( ;; ) { DBVARIANT dbv; mir_snprintf( buf, SIZEOF(buf), "%s_%d", pa->szProtoName, count++ ); if ( DBGetContactSettingString( NULL, buf, "AM_BaseProto", &dbv )) @@ -245,8 +245,7 @@ static void sttClickButton(HWND hwndDlg, int idcButton) static LRESULT CALLBACK sttEditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - switch (msg) - { + switch (msg) { case WM_KEYDOWN: switch (wParam) { case VK_RETURN: @@ -254,7 +253,7 @@ static LRESULT CALLBACK sttEditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, return 0; case VK_ESCAPE: - SetWindowLongPtr(hwnd, GWLP_WNDPROC, GetWindowLongPtr(hwnd, GWLP_USERDATA)); + SetWindowLongPtr(hwnd, GWLP_WNDPROC, GetWindowLongPtr(hwnd, GWLP_USERDATA)); DestroyWindow(hwnd); return 0; } diff --git a/src/modules/skin/sounds.cpp b/src/modules/skin/sounds.cpp index 8c6865f012..6e0906782e 100644 --- a/src/modules/skin/sounds.cpp +++ b/src/modules/skin/sounds.cpp @@ -175,7 +175,7 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM tvis.hInsertAfter = TVI_SORT; tvis.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM; tvis.item.state = tvis.item.stateMask = TVIS_EXPANDED; - for( i=0; i < soundCount; i++ ) { + for ( i=0; i < soundCount; i++ ) { tvis.item.stateMask = TVIS_EXPANDED; tvis.item.state = TVIS_EXPANDED; tvis.hParent = FindNamedTreeItemAtRoot( hwndTree, soundList[i].section ); @@ -257,7 +257,7 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM NotifyEventHooks(hPlayEvent, 1, (LPARAM)soundList[tvi.lParam].tempFile); else { DBVARIANT dbv; - if(!DBGetContactSettingString(NULL,"SkinSounds",soundList[tvi.lParam].name,&dbv)) { + if (!DBGetContactSettingString(NULL,"SkinSounds",soundList[tvi.lParam].name,&dbv)) { char szPathFull[MAX_PATH]; pathToAbsolute(dbv.pszVal, szPathFull, NULL); @@ -310,16 +310,16 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM ofn.nMaxFile = SIZEOF(str); ofn.nMaxFileTitle = MAX_PATH; ofn.lpstrDefExt = "wav"; - if(!GetOpenFileNameA(&ofn)) break; + if (!GetOpenFileNameA(&ofn)) break; CallService(MS_UTILS_PATHTORELATIVE, (WPARAM)str, (LPARAM)strFull); soundList[tvi.lParam].tempFile = mir_strdup(strFull); SetDlgItemTextA(hwndDlg, IDC_LOCATION, strFull); } - if(LOWORD(wParam)==IDC_GETMORE) { + if (LOWORD(wParam)==IDC_GETMORE) { CallService(MS_UTILS_OPENURL,1,(LPARAM)"http://addons.miranda-im.org/index.php?action=display&id=5"); break; } - if(LOWORD(wParam)==IDC_LOCATION) { + if (LOWORD(wParam)==IDC_LOCATION) { break; } SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); @@ -379,7 +379,7 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM SetDlgItemText(hwndDlg, IDC_NAMEVAL, buf); if (soundList[tvi.lParam].tempFile) SetDlgItemTextA(hwndDlg, IDC_LOCATION, soundList[tvi.lParam].tempFile); - else if(!DBGetContactSettingString(NULL,"SkinSounds",soundList[tvi.lParam].name,&dbv)) { + else if (!DBGetContactSettingString(NULL,"SkinSounds",soundList[tvi.lParam].name,&dbv)) { SetDlgItemTextA(hwndDlg, IDC_LOCATION, dbv.pszVal); DBFreeVariant(&dbv); } @@ -402,9 +402,9 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM hti.pt.x=(short)LOWORD(GetMessagePos()); hti.pt.y=(short)HIWORD(GetMessagePos()); ScreenToClient(((LPNMHDR)lParam)->hwndFrom,&hti.pt); - if(TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom,&hti)) + if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom,&hti)) if (hti.flags&TVHT_ONITEM) - if(hti.flags&TVHT_ONITEMSTATEICON) + if (hti.flags&TVHT_ONITEMSTATEICON) if (TreeView_GetParent(hwndTree, hti.hItem)!=NULL) SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; @@ -459,11 +459,11 @@ void UnloadSkinSounds(void) if ( !bModuleInitialized ) return; - for(i=0;itszCurrentFile); - if(fts->ptszFiles) { - for( int i=0;itotalFiles;i++) mir_free(fts->ptszFiles[i]); + if (fts->ptszFiles) { + for ( int i=0;itotalFiles;i++) mir_free(fts->ptszFiles[i]); mir_free(fts->ptszFiles); } mir_free(fts->tszWorkingDir); @@ -198,7 +198,7 @@ void CopyProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *dest, PROTOFILETRANSFE if ( src->tszCurrentFile ) dest->tszCurrentFile = PFTS_StringToTchar(src->flags, src->tszCurrentFile); if ( src->ptszFiles ) { dest->ptszFiles = (TCHAR**)mir_alloc(sizeof(TCHAR*)*src->totalFiles); - for( int i=0; i < src->totalFiles; i++ ) + for ( int i=0; i < src->totalFiles; i++ ) dest->ptszFiles[i] = PFTS_StringToTchar(src->flags, src->ptszFiles[i] ); } if ( src->tszWorkingDir ) dest->tszWorkingDir = PFTS_StringToTchar(src->flags, src->tszWorkingDir ); @@ -211,7 +211,7 @@ void UpdateProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *dest, PROTOFILETRANS dest->hContact = src->hContact; dest->flags = src->flags; if ( dest->totalFiles != src->totalFiles ) { - for( int i=0;itotalFiles;i++) mir_free(dest->ptszFiles[i]); + for ( int i=0;itotalFiles;i++) mir_free(dest->ptszFiles[i]); mir_free(dest->ptszFiles); dest->ptszFiles = NULL; dest->totalFiles = src->totalFiles; @@ -229,7 +229,7 @@ void UpdateProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *dest, PROTOFILETRANS } } else if (dest->ptszFiles) { - for( int i=0; i < dest->totalFiles; i++ ) + for ( int i=0; i < dest->totalFiles; i++ ) mir_free(dest->ptszFiles[i]); mir_free( dest->ptszFiles ); dest->ptszFiles = NULL; @@ -272,7 +272,7 @@ static void RemoveUnreadFileEvents(void) while(hDbEvent) { dbei.cbBlob=0; CallService(MS_DB_EVENT_GET,(WPARAM)hDbEvent,(LPARAM)&dbei); - if(!(dbei.flags&(DBEF_SENT|DBEF_READ)) && dbei.eventType==EVENTTYPE_FILE) + if (!(dbei.flags&(DBEF_SENT|DBEF_READ)) && dbei.eventType==EVENTTYPE_FILE) CallService(MS_DB_EVENT_MARKREAD,(WPARAM)hContact,(LPARAM)hDbEvent); hDbEvent=(HANDLE)CallService(MS_DB_EVENT_FINDNEXT,(WPARAM)hDbEvent,0); } diff --git a/src/modules/srfile/fileexistsdlg.cpp b/src/modules/srfile/fileexistsdlg.cpp index f5b28753dc..1ba90b11c0 100644 --- a/src/modules/srfile/fileexistsdlg.cpp +++ b/src/modules/srfile/fileexistsdlg.cpp @@ -52,7 +52,7 @@ static void SetControlToUnixTime(HWND hwndDlg, UINT idCtrl, time_t unixTime) static void DoAnnoyingShellCommand(HWND hwnd,const TCHAR *szFilename,int cmd,POINT *ptCursor) { IShellFolder *pDesktopFolder; - if(SHGetDesktopFolder(&pDesktopFolder)==NOERROR) { + if (SHGetDesktopFolder(&pDesktopFolder)==NOERROR) { ITEMIDLIST *pCurrentIdl; #if defined( _UNICODE ) WCHAR* wszFilename = ( LPWSTR )szFilename; @@ -60,14 +60,14 @@ static void DoAnnoyingShellCommand(HWND hwnd,const TCHAR *szFilename,int cmd,POI WCHAR wszFilename[MAX_PATH]; MultiByteToWideChar(CP_ACP,0,szFilename,-1,wszFilename,SIZEOF(wszFilename)); #endif - if(pDesktopFolder->ParseDisplayName(NULL,NULL,wszFilename,NULL,&pCurrentIdl,NULL)==NOERROR) { - if(pCurrentIdl->mkid.cb) { + if (pDesktopFolder->ParseDisplayName(NULL,NULL,wszFilename,NULL,&pCurrentIdl,NULL)==NOERROR) { + if (pCurrentIdl->mkid.cb) { ITEMIDLIST *pidl,*pidlNext,*pidlFilename; IShellFolder *pFileFolder; - for(pidl=pCurrentIdl;;) { + for (pidl=pCurrentIdl;;) { pidlNext=(ITEMIDLIST*)((PBYTE)pidl+pidl->mkid.cb); - if(pidlNext->mkid.cb==0) { + if (pidlNext->mkid.cb==0) { pidlFilename = (ITEMIDLIST*)CoTaskMemAlloc(pidl->mkid.cb+sizeof(pidl->mkid.cb)); CopyMemory(pidlFilename,pidl,pidl->mkid.cb+sizeof(pidl->mkid.cb)); pidl->mkid.cb=0; @@ -75,9 +75,9 @@ static void DoAnnoyingShellCommand(HWND hwnd,const TCHAR *szFilename,int cmd,POI } pidl=pidlNext; } - if(pDesktopFolder->BindToObject(pCurrentIdl,NULL,IID_IShellFolder,(void**)&pFileFolder)==NOERROR) { + if (pDesktopFolder->BindToObject(pCurrentIdl,NULL,IID_IShellFolder,(void**)&pFileFolder)==NOERROR) { IContextMenu *pContextMenu; - if(pFileFolder->GetUIObjectOf(NULL,1,(LPCITEMIDLIST*)&pidlFilename,IID_IContextMenu,NULL,(void**)&pContextMenu)==NOERROR) { + if (pFileFolder->GetUIObjectOf(NULL,1,(LPCITEMIDLIST*)&pidlFilename,IID_IContextMenu,NULL,(void**)&pContextMenu)==NOERROR) { switch(cmd) { case C_PROPERTIES: { CMINVOKECOMMANDINFO ici={0}; @@ -91,10 +91,10 @@ static void DoAnnoyingShellCommand(HWND hwnd,const TCHAR *szFilename,int cmd,POI case C_CONTEXTMENU: { HMENU hMenu; hMenu=CreatePopupMenu(); - if(SUCCEEDED(pContextMenu->QueryContextMenu(hMenu,0,1000,65535,(GetKeyState(VK_SHIFT)&0x8000?CMF_EXTENDEDVERBS:0)|CMF_NORMAL))) { + if (SUCCEEDED(pContextMenu->QueryContextMenu(hMenu,0,1000,65535,(GetKeyState(VK_SHIFT)&0x8000?CMF_EXTENDEDVERBS:0)|CMF_NORMAL))) { int cmd; cmd=TrackPopupMenu(hMenu,TPM_RETURNCMD,ptCursor->x,ptCursor->y,0,hwnd,NULL); - if(cmd) { + if (cmd) { CMINVOKECOMMANDINFO ici={0}; ici.cbSize=sizeof(ici); ici.hwnd=hwnd; @@ -165,7 +165,7 @@ void __cdecl LoadIconsAndTypesThread(void* param) szExtension[0]='\0'; } CharUpper(szExtension); - if ( fileInfo.szTypeName[0]=='\0' ) + if ( fileInfo.szTypeName[0] == '\0' ) mir_sntprintf( fileInfo.szTypeName, SIZEOF(fileInfo.szTypeName), TranslateT("%s File"),szExtension); SetDlgItemText(info->hwndDlg,IDC_EXISTINGTYPE,fileInfo.szTypeName); SetDlgItemText(info->hwndDlg,IDC_NEWTYPE,fileInfo.szTypeName); @@ -176,9 +176,9 @@ void __cdecl LoadIconsAndTypesThread(void* param) } else { TCHAR szTypeName[MAX_PATH]; - if(SRFile_GetRegValue(HKEY_CLASSES_ROOT,pszExtension,NULL,szTypeName,SIZEOF(szTypeName))) { + if (SRFile_GetRegValue(HKEY_CLASSES_ROOT,pszExtension,NULL,szTypeName,SIZEOF(szTypeName))) { lstrcat(szTypeName,_T("\\DefaultIcon")); - if(SRFile_GetRegValue(HKEY_CLASSES_ROOT,szTypeName,NULL,szIconFile,SIZEOF(szIconFile))) { + if (SRFile_GetRegValue(HKEY_CLASSES_ROOT,szTypeName,NULL,szIconFile,SIZEOF(szIconFile))) { if ( _tcsstr( szIconFile, _T("%1"))) SRFile_GetRegValue(HKEY_LOCAL_MACHINE,_T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Icons"),_T("0"),szIconFile,SIZEOF(szIconFile)); else szIconFile[0]='\0'; @@ -235,7 +235,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM SetControlToUnixTime(hwndDlg,IDC_EXISTINGDATE,statbuf.st_mtime); GetSensiblyFormattedSize(statbuf.st_size,szSize,SIZEOF(szSize),0,1,NULL); SetDlgItemText(hwndDlg,IDC_EXISTINGSIZE,szSize); - if(statbuf.st_size>(int)fts->currentFileSize) { + if (statbuf.st_size>(int)fts->currentFileSize) { EnableWindow(GetDlgItem(hwndDlg,IDC_RESUME),FALSE); hwndFocus=GetDlgItem(hwndDlg,IDC_OVERWRITE); } } @@ -307,7 +307,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM ofn.lpstrFile = str; ofn.nMaxFile = SIZEOF(str); ofn.nMaxFileTitle = MAX_PATH; - if(!GetSaveFileName(&ofn)) + if (!GetSaveFileName(&ofn)) return FALSE; pfr.szFilename = mir_tstrdup(str); diff --git a/src/modules/srfile/fileopts.cpp b/src/modules/srfile/fileopts.cpp index 1449c4c38b..c1c0b23870 100644 --- a/src/modules/srfile/fileopts.cpp +++ b/src/modules/srfile/fileopts.cpp @@ -84,8 +84,8 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L { TCHAR szScanExe[MAX_PATH]; int i,iItem; - for( i=0; i < SIZEOF(virusScanners); i++ ) { - if(SRFile_GetRegValue(HKEY_LOCAL_MACHINE,virusScanners[i].szExeRegPath,virusScanners[i].szExeRegValue,szScanExe,SIZEOF(szScanExe))) { + for ( i=0; i < SIZEOF(virusScanners); i++ ) { + if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE,virusScanners[i].szExeRegPath,virusScanners[i].szExeRegValue,szScanExe,SIZEOF(szScanExe))) { iItem=SendDlgItemMessage(hwndDlg,IDC_SCANCMDLINE,CB_ADDSTRING,0,(LPARAM)virusScanners[i].szProductName); SendDlgItemMessage(hwndDlg,IDC_SCANCMDLINE,CB_SETITEMDATA,iItem,i); } @@ -98,12 +98,12 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L } DBVARIANT dbv; - if(DBGetContactSettingTString(NULL,"SRFile","ScanCmdLine",&dbv)==0) { + if (DBGetContactSettingTString(NULL,"SRFile","ScanCmdLine",&dbv)==0) { SetDlgItemText(hwndDlg,IDC_SCANCMDLINE,dbv.ptszVal); DBFreeVariant(&dbv); } else { - if(SendDlgItemMessage(hwndDlg,IDC_SCANCMDLINE,CB_GETCOUNT,0,0)) { + if (SendDlgItemMessage(hwndDlg,IDC_SCANCMDLINE,CB_GETCOUNT,0,0)) { SendDlgItemMessage(hwndDlg,IDC_SCANCMDLINE,CB_SETCURSEL,0,0); PostMessage(hwndDlg,M_SCANCMDLINESELCHANGE,0,0); } @@ -130,9 +130,9 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L { TCHAR str[512]; TCHAR szScanExe[MAX_PATH]; int iScanner=SendDlgItemMessage(hwndDlg,IDC_SCANCMDLINE,CB_GETITEMDATA,SendDlgItemMessage(hwndDlg,IDC_SCANCMDLINE,CB_GETCURSEL,0,0),0); - if(iScanner >= SIZEOF(virusScanners) || iScanner<0) break; + if (iScanner >= SIZEOF(virusScanners) || iScanner<0) break; str[0]='\0'; - if(SRFile_GetRegValue(HKEY_LOCAL_MACHINE,virusScanners[iScanner].szExeRegPath,virusScanners[iScanner].szExeRegValue,szScanExe,SIZEOF(szScanExe))) + if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE,virusScanners[iScanner].szExeRegPath,virusScanners[iScanner].szExeRegValue,szScanExe,SIZEOF(szScanExe))) mir_sntprintf(str, SIZEOF(str), virusScanners[iScanner].szCommandLine,szScanExe); SetDlgItemText(hwndDlg,IDC_SCANCMDLINE,str); break; @@ -140,12 +140,12 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_FILEDIR: - if((HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus())) return 0; + if ((HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus())) return 0; break; case IDC_FILEDIRBROWSE: { TCHAR str[MAX_PATH]; GetDlgItemText(hwndDlg,IDC_FILEDIR,str,SIZEOF(str)); - if(BrowseForFolder(hwndDlg,str)) + if (BrowseForFolder(hwndDlg,str)) SetDlgItemText(hwndDlg,IDC_FILEDIR,str); break; } @@ -156,8 +156,8 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L SendMessage(hwndDlg,M_UPDATEENABLING,0,0); break; case IDC_SCANCMDLINE: - if(HIWORD(wParam)==CBN_SELCHANGE) PostMessage(hwndDlg,M_SCANCMDLINESELCHANGE,0,0); - else if(HIWORD(wParam)!=CBN_EDITCHANGE) return 0; + if (HIWORD(wParam)==CBN_SELCHANGE) PostMessage(hwndDlg,M_SCANCMDLINESELCHANGE,0,0); + else if (HIWORD(wParam)!=CBN_EDITCHANGE) return 0; break; case IDC_SCANCMDLINEBROWSE: { TCHAR str[MAX_PATH+2]; @@ -182,7 +182,7 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L ofn.lpstrFilter = filter; ofn.lpstrFile = str; ofn.nMaxFile = SIZEOF(str)-2; - if(str[0]=='"') { + if (str[0] == '"') { TCHAR *pszQuote = _tcschr(str + 1, '"'); if (pszQuote) *pszQuote = 0; MoveMemory(str, str + 1, _tcslen(str) * sizeof(TCHAR)); diff --git a/src/modules/srfile/filerecvdlg.cpp b/src/modules/srfile/filerecvdlg.cpp index 83e6b0077e..1e399a83d7 100644 --- a/src/modules/srfile/filerecvdlg.cpp +++ b/src/modules/srfile/filerecvdlg.cpp @@ -39,10 +39,10 @@ static void GetLowestExistingDirName(const TCHAR *szTestDir,TCHAR *szExistingDir lstrcpyn(szExistingDir,szTestDir,cchExistingDir); while((dwAttributes=GetFileAttributes(szExistingDir))!=INVALID_FILE_ATTRIBUTES && !(dwAttributes&FILE_ATTRIBUTE_DIRECTORY)) { pszLastBackslash=_tcsrchr(szExistingDir,'\\'); - if(pszLastBackslash==NULL) {*szExistingDir='\0'; break;} + if (pszLastBackslash==NULL) {*szExistingDir='\0'; break;} *pszLastBackslash='\0'; } - if(szExistingDir[0]=='\0') GetCurrentDirectory(cchExistingDir,szExistingDir); + if (szExistingDir[0] == '\0') GetCurrentDirectory(cchExistingDir,szExistingDir); } static const TCHAR InvalidFilenameChars[] = _T("\\/:*?\"<>|"); @@ -50,8 +50,8 @@ void RemoveInvalidFilenameChars(TCHAR *tszString) { size_t i; if (tszString) { - for(i=_tcscspn(tszString,InvalidFilenameChars); tszString[i]; i+=_tcscspn(tszString+i+1,InvalidFilenameChars)+1) - if(tszString[i] >= 0) + for (i=_tcscspn(tszString,InvalidFilenameChars); tszString[i]; i+=_tcscspn(tszString+i+1,InvalidFilenameChars)+1) + if (tszString[i] >= 0) tszString[i] = _T('_'); } } @@ -61,8 +61,8 @@ void RemoveInvalidPathChars(TCHAR *tszString) { size_t i; if (tszString) { - for(i=_tcscspn(tszString,InvalidPathChars); tszString[i]; i+=_tcscspn(tszString+i+1,InvalidPathChars)+1) - if(tszString[i] >= 0) + for (i=_tcscspn(tszString,InvalidPathChars); tszString[i]; i+=_tcscspn(tszString+i+1,InvalidPathChars)+1) + if (tszString[i] >= 0) tszString[i] = _T('_'); } } @@ -95,7 +95,7 @@ int BrowseForFolder(HWND hwnd,TCHAR *szPath) bi.lParam=(LPARAM)szPath; pidlResult=SHBrowseForFolder(&bi); - if(pidlResult) { + if (pidlResult) { SHGetPathFromIDList(pidlResult,szPath); lstrcat(szPath,_T("\\")); CoTaskMemFree(pidlResult); @@ -244,9 +244,9 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l if (shAutoComplete) shAutoComplete(GetWindow(GetDlgItem(hwndDlg,IDC_FILEDIR),GW_CHILD),1); - for(i=0;ihContact,"CList","NotOnList",0)) { + if (DBGetContactSettingByte(dat->hContact,"CList","NotOnList",0)) { RECT rcBtn1,rcBtn2,rcDateCtrl; GetWindowRect(GetDlgItem(hwndDlg,IDC_ADD),&rcBtn1); GetWindowRect(GetDlgItem(hwndDlg,IDC_USERMENU),&rcBtn2); GetWindowRect(GetDlgItem(hwndDlg,IDC_DATE),&rcDateCtrl); SetWindowPos(GetDlgItem(hwndDlg,IDC_DATE),0,0,0,rcDateCtrl.right-rcDateCtrl.left-(rcBtn2.left-rcBtn1.left),rcDateCtrl.bottom-rcDateCtrl.top,SWP_NOZORDER|SWP_NOMOVE); } - else if(DBGetContactSettingByte(NULL,"SRFile","AutoAccept",0)) { + else if (DBGetContactSettingByte(NULL,"SRFile","AutoAccept",0)) { //don't check auto-min here to fix BUG#647620 PostMessage(hwndDlg,WM_COMMAND,MAKEWPARAM(IDOK,BN_CLICKED),(LPARAM)GetDlgItem(hwndDlg,IDOK)); } - if(!DBGetContactSettingByte(dat->hContact,"CList","NotOnList",0)) + if (!DBGetContactSettingByte(dat->hContact,"CList","NotOnList",0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD),SW_HIDE); return TRUE; } @@ -327,7 +327,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l case WM_DRAWITEM: { LPDRAWITEMSTRUCT dis=(LPDRAWITEMSTRUCT)lParam; - if(dis->hwndItem==GetDlgItem(hwndDlg, IDC_PROTOCOL)) { + if (dis->hwndItem==GetDlgItem(hwndDlg, IDC_PROTOCOL)) { char *szProto; szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)dat->hContact,0); @@ -352,7 +352,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l GetDlgItemText(hwndDlg,IDC_FILEDIR,szDirName,SIZEOF(szDirName)); GetLowestExistingDirName(szDirName,szExistingDirName,SIZEOF(szExistingDirName)); - if(BrowseForFolder(hwndDlg,szExistingDirName)) + if (BrowseForFolder(hwndDlg,szExistingDirName)) SetDlgItemText(hwndDlg,IDC_FILEDIR,szExistingDirName); } break; @@ -363,13 +363,13 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l GetDlgItemText(hwndDlg,IDC_FILEDIR,szRecvDir,SIZEOF(szRecvDir)); RemoveInvalidPathChars(szRecvDir); GetContactReceivedFilesDir(NULL,szDefaultRecvDir,SIZEOF(szDefaultRecvDir),TRUE); - if(_tcsnicmp(szRecvDir,szDefaultRecvDir,lstrlen(szDefaultRecvDir))) { + if (_tcsnicmp(szRecvDir,szDefaultRecvDir,lstrlen(szDefaultRecvDir))) { char idstr[32]; int i; DBVARIANT dbv; - for(i=MAX_MRU_DIRS-2;i>=0;i--) { + for (i=MAX_MRU_DIRS-2;i>=0;i--) { mir_snprintf(idstr, SIZEOF(idstr), "MruDir%d",i); - if(DBGetContactSettingTString(NULL,"SRFile",idstr,&dbv)) continue; + if (DBGetContactSettingTString(NULL,"SRFile",idstr,&dbv)) continue; mir_snprintf(idstr, SIZEOF(idstr), "MruDir%d",i+1); DBWriteContactSettingTString(NULL,"SRFile",idstr,dbv.ptszVal); DBFreeVariant(&dbv); @@ -388,7 +388,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l dat->hwndTransfer = FtMgr_AddTransfer(dat); SetWindowLongPtr( hwndDlg, GWLP_USERDATA, 0); //check for auto-minimize here to fix BUG#647620 - if(DBGetContactSettingByte(NULL,"SRFile","AutoAccept",0) && DBGetContactSettingByte(NULL,"SRFile","AutoMin",0)) { + if (DBGetContactSettingByte(NULL,"SRFile","AutoAccept",0) && DBGetContactSettingByte(NULL,"SRFile","AutoMin",0)) { ShowWindow(hwndDlg,SW_HIDE); ShowWindow(hwndDlg,SW_SHOWMINNOACTIVE); } @@ -408,7 +408,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l acs.handleType=HANDLE_CONTACT; acs.szProto=""; CallService(MS_ADDCONTACT_SHOW,(WPARAM)hwndDlg,(LPARAM)&acs); - if(!DBGetContactSettingByte(dat->hContact,"CList","NotOnList",0)) + if (!DBGetContactSettingByte(dat->hContact,"CList","NotOnList",0)) ShowWindow(GetDlgItem(hwndDlg,IDC_ADD), SW_HIDE); } break; diff --git a/src/modules/srfile/filesenddlg.cpp b/src/modules/srfile/filesenddlg.cpp index ea29aa2b00..de07d65689 100644 --- a/src/modules/srfile/filesenddlg.cpp +++ b/src/modules/srfile/filesenddlg.cpp @@ -42,13 +42,13 @@ static void SetFileListAndSizeControls(HWND hwndDlg,struct FileDlgData *dat) GetSensiblyFormattedSize(totalSize,str,SIZEOF(str),0,1,NULL); SetDlgItemText(hwndDlg,IDC_TOTALSIZE,str); - if(i>1) { + if (i>1) { TCHAR szFormat[32]; - if(fileCount && dirCount) { + if (fileCount && dirCount) { mir_sntprintf(szFormat,SIZEOF(szFormat),_T("%s, %s"),TranslateTS(fileCount==1?_T("%d file"):_T("%d files")),TranslateTS(dirCount==1?_T("%d directory"):_T("%d directories"))); mir_sntprintf(str,SIZEOF(str),szFormat,fileCount,dirCount); } - else if(fileCount) { + else if (fileCount) { lstrcpy(szFormat,TranslateT("%d files")); mir_sntprintf(str,SIZEOF(str),szFormat,fileCount); } @@ -112,11 +112,11 @@ static void FilenameToFileList(HWND hwndDlg, struct FileDlgData* dat, const TCHA #if defined( _UNICODE ) CopyMemory(dat->files[nTemp], buf, (fileOffset-1)*sizeof( TCHAR )); dat->files[nTemp][fileOffset-1] = '\\'; - _tcscpy(dat->files[nTemp] + fileOffset - (buf[fileOffset-2]=='\\'?1:0), pBuf); + _tcscpy(dat->files[nTemp] + fileOffset - (buf[fileOffset-2] == '\\'?1:0), pBuf); #else CopyMemory(dat->files[nTemp], buf, fileOffset-1 ); dat->files[nTemp][fileOffset-1] = '\\'; - strcpy(dat->files[nTemp] + fileOffset - (buf[fileOffset-2]=='\\'?1:0), pBuf); + strcpy(dat->files[nTemp] + fileOffset - (buf[fileOffset-2] == '\\'?1:0), pBuf); #endif // Move pointers to next file... pBuf += cbFileNameLen + 1; @@ -179,13 +179,13 @@ static LRESULT CALLBACK SendEditSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LP { switch(msg) { case WM_CHAR: - if(wParam=='\n' && GetKeyState(VK_CONTROL)&0x8000) { + if (wParam=='\n' && GetKeyState(VK_CONTROL)&0x8000) { PostMessage(GetParent(hwnd),WM_COMMAND,IDOK,0); return 0; } break; case WM_SYSCHAR: - if((wParam=='s' || wParam=='S') && GetKeyState(VK_MENU)&0x8000) { + if ((wParam=='s' || wParam=='S') && GetKeyState(VK_MENU)&0x8000) { PostMessage(GetParent(hwnd),WM_COMMAND,IDOK,0); return 0; } @@ -223,11 +223,11 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE); - if(fsd->ppFiles!=NULL && fsd->ppFiles[0]!=NULL) { + if (fsd->ppFiles!=NULL && fsd->ppFiles[0]!=NULL) { int totalCount,i; - for(totalCount=0;fsd->ppFiles[totalCount];totalCount++); + for (totalCount=0;fsd->ppFiles[totalCount];totalCount++); dat->files = ( TCHAR** )mir_alloc( sizeof(TCHAR*)*(totalCount+1)); // Leaks - for(i=0;ifiles[i] = mir_tstrdup( fsd->ppFiles[i] ); dat->files[totalCount]=NULL; SetFileListAndSizeControls(hwndDlg,dat); @@ -281,7 +281,7 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l case WM_DRAWITEM: { LPDRAWITEMSTRUCT dis=(LPDRAWITEMSTRUCT)lParam; - if(dis->hwndItem==GetDlgItem(hwndDlg, IDC_PROTOCOL)) { + if (dis->hwndItem==GetDlgItem(hwndDlg, IDC_PROTOCOL)) { char *szProto; szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)dat->hContact,0); @@ -294,17 +294,17 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l return CallService(MS_CLIST_MENUDRAWITEM,wParam,lParam); case M_FILECHOOSEDONE: - if( lParam != 0 ) { + if ( lParam != 0 ) { FilenameToFileList( hwndDlg, dat, ( TCHAR* )lParam ); mir_free(( TCHAR* )lParam ); dat->closeIfFileChooseCancelled = 0; } - else if(dat->closeIfFileChooseCancelled) DestroyWindow(hwndDlg); + else if (dat->closeIfFileChooseCancelled) DestroyWindow(hwndDlg); EnableWindow(hwndDlg,TRUE); break; case WM_COMMAND: - if(CallService(MS_CLIST_MENUPROCESSCOMMAND,MAKEWPARAM(LOWORD(wParam),MPCF_CONTACTMENU),(LPARAM)dat->hContact)) + if (CallService(MS_CLIST_MENUPROCESSCOMMAND,MAKEWPARAM(LOWORD(wParam),MPCF_CONTACTMENU),(LPARAM)dat->hContact)) break; switch (LOWORD(wParam)) { diff --git a/src/modules/srfile/filexferdlg.cpp b/src/modules/srfile/filexferdlg.cpp index c4a41e750f..fa72e91f10 100644 --- a/src/modules/srfile/filexferdlg.cpp +++ b/src/modules/srfile/filexferdlg.cpp @@ -28,10 +28,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static int CheckVirusScanned(HWND hwnd,struct FileDlgData *dat,int i) { - if(dat->send) return 1; - if(dat->fileVirusScanned == NULL) return 0; - if(dat->fileVirusScanned[i]) return 1; - if(DBGetContactSettingByte(NULL,"SRFile","WarnBeforeOpening",1)==0) return 1; + if (dat->send) return 1; + if (dat->fileVirusScanned == NULL) return 0; + if (dat->fileVirusScanned[i]) return 1; + if (DBGetContactSettingByte(NULL,"SRFile","WarnBeforeOpening",1)==0) return 1; return IDYES==MessageBox(hwnd,TranslateT("This file has not yet been scanned for viruses. Are you certain you want to open it?"),TranslateT("File Received"),MB_YESNO|MB_DEFBUTTON2); } @@ -127,7 +127,7 @@ static void __cdecl RunVirusScannerThread(struct virusscanthreadstartinfo *info) if (!DBGetContactSettingTString(NULL,"SRFile", "ScanCmdLine", &dbv)) { - if(dbv.ptszVal[0]) + if (dbv.ptszVal[0]) { TCHAR *pszReplace; si.cb=sizeof(si); @@ -140,8 +140,8 @@ static void __cdecl RunVirusScannerThread(struct virusscanthreadstartinfo *info) mir_sntprintf(szCmdLine, SIZEOF(szCmdLine), _T("%s\"%s\"%s"), dbv.ptszVal, info->szFile, pszReplace+2); } else lstrcpyn(szCmdLine, dbv.ptszVal, SIZEOF(szCmdLine)); - if(CreateProcess(NULL,szCmdLine,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi)) { - if(WaitForSingleObject(pi.hProcess,3600*1000)==WAIT_OBJECT_0) + if (CreateProcess(NULL,szCmdLine,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi)) { + if (WaitForSingleObject(pi.hProcess,3600*1000)==WAIT_OBJECT_0) PostMessage(info->hwndReply,M_VIRUSSCANDONE,info->returnCode,0); CloseHandle(pi.hProcess); CloseHandle(pi.hThread); @@ -264,7 +264,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); dat->hNotifyEvent=HookEventMessage(ME_PROTO_ACK,hwndDlg,HM_RECVEVENT); dat->transferStatus.currentFileNumber = -1; - if(dat->send) { + if (dat->send) { dat->fs=(HANDLE)CallContactService(dat->hContact,PSS_FILET,(WPARAM)dat->szMsg,(LPARAM)dat->files); SetFtStatus(hwndDlg, LPGENT("Request sent, waiting for acceptance..."), FTS_TEXT); SetOpenFileButtonStyle(GetDlgItem(hwndDlg,IDC_OPENFILE),1); @@ -277,7 +277,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR CreateDirectoryTreeT(dat->szSavePath); dat->fs=(HANDLE)CallContactService(dat->hContact,PSS_FILEALLOWT,(WPARAM)dat->fs,(LPARAM)dat->szSavePath); dat->transferStatus.tszWorkingDir = mir_tstrdup(dat->szSavePath); - if(DBGetContactSettingByte(dat->hContact,"CList","NotOnList",0)) dat->resumeBehaviour=FILERESUME_ASK; + if (DBGetContactSettingByte(dat->hContact,"CList","NotOnList",0)) dat->resumeBehaviour=FILERESUME_ASK; else dat->resumeBehaviour=DBGetContactSettingByte(NULL,"SRFile","IfExists",FILERESUME_ASK); SetFtStatus(hwndDlg, LPGENT("Waiting for connection..."), FTS_TEXT); } @@ -320,7 +320,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR SetDlgItemText(hwndDlg, IDC_CONTACTNAME, cli.pfnGetContactDisplayName( dat->hContact, 0 )); - if(!dat->waitingForAcceptance) SetTimer(hwndDlg,1,1000,NULL); + if (!dat->waitingForAcceptance) SetTimer(hwndDlg,1,1000,NULL); return TRUE; case WM_TIMER: MoveMemory(dat->bytesRecvedHistory+1,dat->bytesRecvedHistory,sizeof(dat->bytesRecvedHistory)-sizeof(dat->bytesRecvedHistory[0])); @@ -334,7 +334,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR FILETIME ft; GetSensiblyFormattedSize((dat->bytesRecvedHistory[0]-dat->bytesRecvedHistory[dat->bytesRecvedHistorySize-1])/dat->bytesRecvedHistorySize,szSpeed,SIZEOF(szSpeed),0,1,NULL); - if(dat->bytesRecvedHistory[0]==dat->bytesRecvedHistory[dat->bytesRecvedHistorySize-1]) + if (dat->bytesRecvedHistory[0]==dat->bytesRecvedHistory[dat->bytesRecvedHistorySize-1]) lstrcpy(szTime,_T("??:??:??")); else { li.QuadPart=BIGI(10000000)*(dat->transferStatus.currentFileSize-dat->transferStatus.currentFileProgress)*dat->bytesRecvedHistorySize/(dat->bytesRecvedHistory[0]-dat->bytesRecvedHistory[dat->bytesRecvedHistorySize-1]); @@ -342,7 +342,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR FileTimeToSystemTime(&ft,&st); GetTimeFormat(LOCALE_USER_DEFAULT,TIME_FORCE24HOURFORMAT|TIME_NOTIMEMARKER,&st,NULL,szTime,SIZEOF(szTime)); } - if(dat->bytesRecvedHistory[0]!=dat->bytesRecvedHistory[dat->bytesRecvedHistorySize-1]) { + if (dat->bytesRecvedHistory[0]!=dat->bytesRecvedHistory[dat->bytesRecvedHistorySize-1]) { li.QuadPart=BIGI(10000000)*(dat->transferStatus.totalBytes-dat->transferStatus.totalProgress)*dat->bytesRecvedHistorySize/(dat->bytesRecvedHistory[0]-dat->bytesRecvedHistory[dat->bytesRecvedHistorySize-1]); ft.dwHighDateTime=li.HighPart; ft.dwLowDateTime=li.LowPart; FileTimeToSystemTime(&ft,&st); @@ -454,7 +454,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR TCHAR *p = pszNewFileName; for (size_t pszlen=0; pszlen < cbFileNameLen; pszlen++) { *p++ = pszFilename[pszlen]; - if (pszFilename[pszlen]=='&') + if (pszFilename[pszlen] == '&') *p++ = '&'; } *p = '\0'; @@ -500,7 +500,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (dat->fs) CallContactService(dat->hContact,PSS_FILECANCEL,(WPARAM)dat->fs,0); dat->fs=NULL; mir_free(szOriginalFilename); - if(pfr->szFilename) mir_free((char*)pfr->szFilename); + if (pfr->szFilename) mir_free((char*)pfr->szFilename); mir_free(pfr); return 0; case FILERESUME_RESUMEALL: @@ -512,13 +512,13 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR pfr->action=FILERESUME_RENAME; { TCHAR *pszExtension,*pszFilename; int i; - if((pszFilename = _tcsrchr(szOriginalFilename,'\\'))==NULL) pszFilename=szOriginalFilename; - if((pszExtension = _tcsrchr(pszFilename+1,'.'))==NULL) pszExtension=pszFilename+lstrlen(pszFilename); - if(pfr->szFilename) mir_free((TCHAR*)pfr->szFilename); + if ((pszFilename = _tcsrchr(szOriginalFilename,'\\'))==NULL) pszFilename=szOriginalFilename; + if ((pszExtension = _tcsrchr(pszFilename+1,'.'))==NULL) pszExtension=pszFilename+lstrlen(pszFilename); + if (pfr->szFilename) mir_free((TCHAR*)pfr->szFilename); pfr->szFilename = (TCHAR*)mir_alloc(sizeof(TCHAR)*((pszExtension-szOriginalFilename)+21+lstrlen(pszExtension))); - for(i=1;;i++) { + for (i=1;;i++) { _stprintf((TCHAR*)pfr->szFilename,_T("%.*s (%u)%s"),pszExtension-szOriginalFilename,szOriginalFilename,i,pszExtension); - if(_taccess(pfr->szFilename,0)!=0) + if (_taccess(pfr->szFilename,0)!=0) break; } } @@ -526,17 +526,17 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR } mir_free(szOriginalFilename); CallProtoService(szProto,PS_FILERESUMET,(WPARAM)dat->fs,(LPARAM)pfr); - if(pfr->szFilename) mir_free((char*)pfr->szFilename); + if (pfr->szFilename) mir_free((char*)pfr->szFilename); mir_free(pfr); break; } case HM_RECVEVENT: { ACKDATA *ack=(ACKDATA*)lParam; if (ack->hProcess!=dat->fs) break; /* icq abuses this sometimes */ - if(ack->hContact!=dat->hContact) break; - if(ack->type!=ACKTYPE_FILE) break; + if (ack->hContact!=dat->hContact) break; + if (ack->type!=ACKTYPE_FILE) break; - if(dat->waitingForAcceptance) { + if (dat->waitingForAcceptance) { SetTimer(hwndDlg,1,1000,NULL); dat->waitingForAcceptance=0; } @@ -550,10 +550,10 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case ACKRESULT_NEXTFILE: SetFtStatus(hwndDlg, LPGENT("Moving to next file..."), FTS_TEXT); SetDlgItemTextA(hwndDlg,IDC_FILENAME,""); - if(dat->transferStatus.currentFileNumber==1 && dat->transferStatus.totalFiles>1 && !dat->send) + if (dat->transferStatus.currentFileNumber==1 && dat->transferStatus.totalFiles>1 && !dat->send) SetOpenFileButtonStyle(GetDlgItem(hwndDlg,IDC_OPENFILE),1); - if(dat->transferStatus.currentFileNumber!=-1 && dat->files && !dat->send && DBGetContactSettingByte(NULL,"SRFile","UseScanner",VIRUSSCAN_DISABLE)==VIRUSSCAN_DURINGDL) { - if(GetFileAttributes(dat->files[dat->transferStatus.currentFileNumber])&FILE_ATTRIBUTE_DIRECTORY) + if (dat->transferStatus.currentFileNumber!=-1 && dat->files && !dat->send && DBGetContactSettingByte(NULL,"SRFile","UseScanner",VIRUSSCAN_DISABLE)==VIRUSSCAN_DURINGDL) { + if (GetFileAttributes(dat->files[dat->transferStatus.currentFileNumber])&FILE_ATTRIBUTE_DIRECTORY) PostMessage(hwndDlg,M_VIRUSSCANDONE,dat->transferStatus.currentFileNumber,0); else { virusscanthreadstartinfo *vstsi; @@ -576,7 +576,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR break; SetFtStatus(hwndDlg, LPGENT("File already exists"), FTS_TEXT); - if(dat->resumeBehaviour==FILERESUME_ASK) { + if (dat->resumeBehaviour==FILERESUME_ASK) { TDlgProcFileExistsParam param = { hwndDlg, fts }; ShowWindow(hwndDlg,SW_SHOWNORMAL); CreateDialogParam(hMirandaInst,MAKEINTRESOURCE(IDD_FILEEXISTS),hwndDlg,DlgProcFileExists,(LPARAM)¶m); @@ -693,7 +693,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR struct virusscanthreadstartinfo *vstsi; vstsi=(struct virusscanthreadstartinfo*)mir_alloc(sizeof(struct virusscanthreadstartinfo)); vstsi->hwndReply=hwndDlg; - if(useScanner==VIRUSSCAN_DURINGDL) { + if (useScanner==VIRUSSCAN_DURINGDL) { vstsi->returnCode=dat->transferStatus.currentFileNumber; if ( GetFileAttributes(dat->files[dat->transferStatus.currentFileNumber])&FILE_ATTRIBUTE_DIRECTORY) { PostMessage(hwndDlg,M_VIRUSSCANDONE,vstsi->returnCode,0); @@ -707,7 +707,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR vstsi->returnCode = -1; } SetFtStatus(hwndDlg, LPGENT("Scanning for viruses..."), FTS_TEXT); - if(vstsi) forkthread((void (*)(void*))RunVirusScannerThread,0,vstsi); + if (vstsi) forkthread((void (*)(void*))RunVirusScannerThread,0,vstsi); } else { dat->fs=NULL; /* protocol will free structure */ } @@ -724,12 +724,12 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR } break; // case HM_RECVEVENT case M_VIRUSSCANDONE: { int done=1,i; - if((int)wParam==-1) { - for(i=0;itransferStatus.totalFiles;i++) dat->fileVirusScanned[i]=1; + if ((int)wParam==-1) { + for (i=0;itransferStatus.totalFiles;i++) dat->fileVirusScanned[i]=1; } else { dat->fileVirusScanned[wParam]=1; - for(i=0;itransferStatus.totalFiles;i++) if(!dat->fileVirusScanned[i]) {done=0; break;} + for (i=0;itransferStatus.totalFiles;i++) if (!dat->fileVirusScanned[i]) {done=0; break;} } if (done) { @@ -772,7 +772,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR void FreeFileDlgData( FileDlgData* dat ) { - if(dat->fs) + if (dat->fs) CallContactService(dat->hContact,PSS_FILECANCEL,(WPARAM)dat->fs,0); dat->fs = NULL; diff --git a/src/modules/srfile/ftmanager.cpp b/src/modules/srfile/ftmanager.cpp index b2c5dde516..4199c5b255 100644 --- a/src/modules/srfile/ftmanager.cpp +++ b/src/modules/srfile/ftmanager.cpp @@ -179,7 +179,7 @@ static INT_PTR CALLBACK FtMgrPageDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPA if (i == dat->wnds->realCount) PostMessage(GetParent(hwnd), WM_TIMER, 1, NULL); - if(dat->runningCount == 0 && (int)wParam == ACKRESULT_SUCCESS && DBGetContactSettingByte(NULL,"SRFile","AutoClose",0)) + if (dat->runningCount == 0 && (int)wParam == ACKRESULT_SUCCESS && DBGetContactSettingByte(NULL,"SRFile","AutoClose",0)) ShowWindow(hwndFtMgr, SW_HIDE); break; } diff --git a/src/modules/srurl/url.cpp b/src/modules/srurl/url.cpp index 7ae23cd01e..04d9ec84f7 100644 --- a/src/modules/srurl/url.cpp +++ b/src/modules/srurl/url.cpp @@ -48,7 +48,7 @@ static int UrlEventAdded(WPARAM wParam,LPARAM lParam) dbei.cbSize=sizeof(dbei); dbei.cbBlob=0; CallService(MS_DB_EVENT_GET,lParam,(LPARAM)&dbei); - if(dbei.flags&(DBEF_SENT|DBEF_READ) || dbei.eventType!=EVENTTYPE_URL) return 0; + if (dbei.flags&(DBEF_SENT|DBEF_READ) || dbei.eventType!=EVENTTYPE_URL) return 0; SkinPlaySound("RecvUrl"); ZeroMemory(&cle,sizeof(cle)); @@ -88,7 +88,7 @@ static void RestoreUnreadUrlAlerts(void) while(hDbEvent) { dbei.cbBlob=0; CallService(MS_DB_EVENT_GET,(WPARAM)hDbEvent,(LPARAM)&dbei); - if(!(dbei.flags&(DBEF_SENT|DBEF_READ)) && dbei.eventType==EVENTTYPE_URL) { + if (!(dbei.flags&(DBEF_SENT|DBEF_READ)) && dbei.eventType==EVENTTYPE_URL) { cle.hContact=hContact; cle.hDbEvent=hDbEvent; cle.flags = CLEF_TCHAR; @@ -108,7 +108,7 @@ static int ContactSettingChanged(WPARAM wParam, LPARAM lParam) char *szProto; szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0); - if(lstrcmpA(cws->szModule,"CList") && (szProto==NULL || lstrcmpA(cws->szModule,szProto))) return 0; + if (lstrcmpA(cws->szModule,"CList") && (szProto==NULL || lstrcmpA(cws->szModule,szProto))) return 0; WindowList_Broadcast(hUrlWindowList,DM_UPDATETITLE,0,0); return 0; } diff --git a/src/modules/srurl/urldialogs.cpp b/src/modules/srurl/urldialogs.cpp index 0c6fb2f21e..72a491bf17 100644 --- a/src/modules/srurl/urldialogs.cpp +++ b/src/modules/srurl/urldialogs.cpp @@ -138,7 +138,7 @@ INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP case WM_DRAWITEM: { LPDRAWITEMSTRUCT dis=(LPDRAWITEMSTRUCT)lParam; - if(dis->hwndItem==GetDlgItem(hwndDlg, IDC_PROTOCOL)) { + if (dis->hwndItem==GetDlgItem(hwndDlg, IDC_PROTOCOL)) { char *szProto; szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)dat->hContact,0); @@ -158,7 +158,7 @@ INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP case WM_COMMAND: if (dat) - if(CallService(MS_CLIST_MENUPROCESSCOMMAND,MAKEWPARAM(LOWORD(wParam),MPCF_CONTACTMENU),(LPARAM)dat->hContact)) + if (CallService(MS_CLIST_MENUPROCESSCOMMAND,MAKEWPARAM(LOWORD(wParam),MPCF_CONTACTMENU),(LPARAM)dat->hContact)) break; switch(LOWORD(wParam)) { case IDOK: @@ -180,7 +180,7 @@ INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP break; case IDM_COPYLINK: { HGLOBAL hData; - if(!OpenClipboard(hwndDlg)) break; + if (!OpenClipboard(hwndDlg)) break; EmptyClipboard(); hData=GlobalAlloc(GMEM_MOVEABLE,lstrlenA(url)+1); lstrcpyA((char*)GlobalLock(hData),url); @@ -267,7 +267,7 @@ static LRESULT DdeMessage(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam) case WM_DDE_DATA: UnpackDDElParam(msg,lParam,(PUINT_PTR)&hGlobalDdeData,(PUINT_PTR)&hSzItem); ddeData = 1; - if( hGlobalDdeData ) { + if ( hGlobalDdeData ) { DDEDATA* data = ( DDEDATA* )GlobalLock( hGlobalDdeData ); if ( data->fAckReq ) { DDEACK ack = {0}; @@ -289,24 +289,24 @@ static HGLOBAL DoDdeRequest(const char *szItemName,HWND hwndDlg) MSG msg; hSzItemName=GlobalAddAtomA(szItemName); - if(!PostMessage(hwndDde,WM_DDE_REQUEST,(WPARAM)hwndDlg,MAKELPARAM(CF_TEXT,hSzItemName))) { + if (!PostMessage(hwndDde,WM_DDE_REQUEST,(WPARAM)hwndDlg,MAKELPARAM(CF_TEXT,hSzItemName))) { GlobalDeleteAtom(hSzItemName); return NULL; } timeoutTick=GetTickCount()+5000; ddeData=0; ddeAcked=0; do { - if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { + if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } - if(ddeData || ddeAcked) break; + if (ddeData || ddeAcked) break; thisTick=GetTickCount(); - if(thisTick>timeoutTick) break; + if (thisTick>timeoutTick) break; } while(MsgWaitForMultipleObjects(0,NULL,FALSE,timeoutTick-thisTick,QS_ALLINPUT)==WAIT_OBJECT_0); - if(!ddeData) { + if (!ddeData) { GlobalDeleteAtom(hSzItemName); return NULL; } @@ -318,7 +318,7 @@ static void FreeDdeRequestData(HGLOBAL hData) { DDEDATA *data; data=(DDEDATA*)GlobalLock(hData); - if(data->fRelease) { + if (data->fRelease) { GlobalUnlock(hData); GlobalFree(hData); } @@ -329,35 +329,35 @@ static void AddBrowserPageToCombo(char *url,HWND hwndCombo) { char *title,*frame,*end; - if(url[0]!='"') return; + if (url[0]!='"') return; url++; title=strchr(url,'"'); - if(title==NULL) return; + if (title==NULL) return; *title='\0'; title++; - if(*title) { + if (*title) { title+=2; frame=strchr(title,'"'); - if(frame==NULL) return; + if (frame==NULL) return; *frame='\0'; frame++; - if(*frame) { + if (*frame) { frame+=2; end=strchr(frame,'"'); - if(end==NULL) return; + if (end==NULL) return; *end='\0'; } else frame=NULL; } else title=frame=NULL; - if(frame==NULL || *frame==0) { + if (frame==NULL || *frame==0) { char *szItemData; int i; char szExistingUrl[1024]; - for(i=SendMessage(hwndCombo,CB_GETCOUNT,0,0)-1;i>=0;i--) { - if(SendMessage(hwndCombo,CB_GETLBTEXTLEN,i,0) >= SIZEOF(szExistingUrl)) + for (i=SendMessage(hwndCombo,CB_GETCOUNT,0,0)-1;i>=0;i--) { + if (SendMessage(hwndCombo,CB_GETLBTEXTLEN,i,0) >= SIZEOF(szExistingUrl)) continue; SendMessageA(hwndCombo,CB_GETLBTEXT,i,(LPARAM)szExistingUrl); - if(!lstrcmpA(szExistingUrl,url)) return; + if (!lstrcmpA(szExistingUrl,url)) return; } i=SendMessageA(hwndCombo,CB_ADDSTRING,0,(LPARAM)url); szItemData=mir_strdup(title); @@ -380,14 +380,14 @@ static void GetOpenBrowserUrlsForBrowser(const char *szBrowser,HWND hwndDlg,HWND hSzTopic=GlobalAddAtomA("WWW_ListWindows"); ddeAcked=0; - if(!SendMessageTimeout(HWND_BROADCAST,WM_DDE_INITIATE,(WPARAM)hwndDlg,MAKELPARAM(hSzBrowser,hSzTopic),SMTO_ABORTIFHUNG|SMTO_NORMAL,DDEMESSAGETIMEOUT,(PDWORD_PTR)&dwResult) + if (!SendMessageTimeout(HWND_BROADCAST,WM_DDE_INITIATE,(WPARAM)hwndDlg,MAKELPARAM(hSzBrowser,hSzTopic),SMTO_ABORTIFHUNG|SMTO_NORMAL,DDEMESSAGETIMEOUT,(PDWORD_PTR)&dwResult) || !ddeAcked) { GlobalDeleteAtom(hSzTopic); GlobalDeleteAtom(hSzBrowser); return; } hData=DoDdeRequest("WWW_ListWindows",hwndDlg); - if(hData==NULL) { + if (hData==NULL) { GlobalDeleteAtom(hSzTopic); GlobalDeleteAtom(hSzBrowser); return; @@ -404,20 +404,20 @@ static void GetOpenBrowserUrlsForBrowser(const char *szBrowser,HWND hwndDlg,HWND hSzTopic=GlobalAddAtomA("WWW_GetWindowInfo"); ddeAcked=0; - if(!SendMessageTimeout(HWND_BROADCAST,WM_DDE_INITIATE,(WPARAM)hwndDlg,MAKELPARAM(hSzBrowser,hSzTopic),SMTO_ABORTIFHUNG|SMTO_NORMAL,DDEMESSAGETIMEOUT,(PDWORD_PTR)&dwResult) + if (!SendMessageTimeout(HWND_BROADCAST,WM_DDE_INITIATE,(WPARAM)hwndDlg,MAKELPARAM(hSzBrowser,hSzTopic),SMTO_ABORTIFHUNG|SMTO_NORMAL,DDEMESSAGETIMEOUT,(PDWORD_PTR)&dwResult) || !ddeAcked) { GlobalDeleteAtom(hSzTopic); GlobalDeleteAtom(hSzBrowser); mir_free(windowId); return; } - for(i=0;iValue,hwndCombo); @@ -443,13 +443,13 @@ static LRESULT CALLBACK SendEditSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LP { switch(msg) { case WM_CHAR: - if(wParam=='\n' && GetKeyState(VK_CONTROL)&0x8000) { + if (wParam=='\n' && GetKeyState(VK_CONTROL)&0x8000) { PostMessage(GetParent(hwnd),WM_COMMAND,IDOK,0); return 0; } break; case WM_SYSCHAR: - if((wParam=='s' || wParam=='S') && GetKeyState(VK_MENU)&0x8000) { + if ((wParam=='s' || wParam=='S') && GetKeyState(VK_MENU)&0x8000) { PostMessage(GetParent(hwnd),WM_COMMAND,IDOK,0); return 0; } @@ -536,7 +536,7 @@ INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP break; case WM_COMMAND: - if(CallService(MS_CLIST_MENUPROCESSCOMMAND,MAKEWPARAM(LOWORD(wParam),MPCF_CONTACTMENU),(LPARAM)dat->hContact)) + if (CallService(MS_CLIST_MENUPROCESSCOMMAND,MAKEWPARAM(LOWORD(wParam),MPCF_CONTACTMENU),(LPARAM)dat->hContact)) break; switch (LOWORD(wParam)) { @@ -577,7 +577,7 @@ INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP DestroyWindow(hwndDlg); return TRUE; case IDC_URLS: - if(HIWORD(wParam)==CBN_SELCHANGE) { + if (HIWORD(wParam)==CBN_SELCHANGE) { int i, urlSize; char *title; i=SendDlgItemMessage(hwndDlg,IDC_URLS,CB_GETCURSEL,0,0); @@ -586,7 +586,7 @@ INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP urlSize=SendDlgItemMessage(hwndDlg,IDC_URLS,CB_GETLBTEXTLEN,(WPARAM)i,0); EnableWindow(GetDlgItem(hwndDlg,IDOK), (urlSize>0)); } - else if(HIWORD(wParam)==CBN_EDITCHANGE) { + else if (HIWORD(wParam)==CBN_EDITCHANGE) { int urlSize = GetWindowTextLength(GetDlgItem(hwndDlg,IDC_URLS)); EnableWindow(GetDlgItem(hwndDlg,IDOK), (urlSize>0)); } @@ -622,9 +622,9 @@ INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP case HM_EVENTSENT: { ACKDATA *ack=(ACKDATA*)lParam; DBEVENTINFO dbei; - if(ack->hProcess!=dat->hSendId) break; - if(ack->hContact!=dat->hContact) break; - if(ack->type!=ACKTYPE_URL || ack->result!=ACKRESULT_SUCCESS) break; + if (ack->hProcess!=dat->hSendId) break; + if (ack->hContact!=dat->hContact) break; + if (ack->type!=ACKTYPE_URL || ack->result!=ACKRESULT_SUCCESS) break; ZeroMemory(&dbei,sizeof(dbei)); dbei.cbSize=sizeof(dbei); @@ -649,12 +649,12 @@ INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP WindowList_Remove(hUrlWindowList, hwndDlg); SetWindowLongPtr(GetWindow(GetDlgItem(hwndDlg,IDC_URLS),GW_CHILD),GWLP_WNDPROC,(LONG_PTR)OldSendEditProc); SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_MESSAGE),GWLP_WNDPROC,(LONG_PTR)OldSendEditProc); - if(dat->hAckEvent) UnhookEvent(dat->hAckEvent); - if(dat->sendBuffer!=NULL) mir_free(dat->sendBuffer); + if (dat->hAckEvent) UnhookEvent(dat->hAckEvent); + if (dat->sendBuffer!=NULL) mir_free(dat->sendBuffer); mir_free(dat); Utils_SaveWindowPosition(hwndDlg,NULL,"SRUrl","send"); { int i; - for(i=SendDlgItemMessage(hwndDlg,IDC_URLS,CB_GETCOUNT,0,0)-1;i>=0;i--) + for (i=SendDlgItemMessage(hwndDlg,IDC_URLS,CB_GETCOUNT,0,0)-1;i>=0;i--) mir_free((char*)SendDlgItemMessage(hwndDlg,IDC_URLS,CB_GETITEMDATA,i,0)); } break; diff --git a/src/modules/userinfo/contactinfo.cpp b/src/modules/userinfo/contactinfo.cpp index c8fcc9de0c..b8dd841835 100644 --- a/src/modules/userinfo/contactinfo.cpp +++ b/src/modules/userinfo/contactinfo.cpp @@ -30,7 +30,7 @@ static INT_PTR CALLBACK EditUserEmailDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar switch(msg) { case WM_INITDIALOG: SetWindowLongPtr(hwndDlg,GWLP_USERDATA,(LONG_PTR)lParam); - if(*(char*)lParam) SetWindowText(hwndDlg,TranslateT("Edit E-Mail Address")); + if (*(char*)lParam) SetWindowText(hwndDlg,TranslateT("Edit E-Mail Address")); TranslateDialogDefault(hwndDlg); SetDlgItemTextA(hwndDlg,IDC_EMAIL,(char*)lParam); EnableWindow(GetDlgItem(hwndDlg,IDOK),*(char*)lParam); @@ -43,7 +43,7 @@ static INT_PTR CALLBACK EditUserEmailDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar case IDCANCEL: EndDialog(hwndDlg,wParam); case IDC_EMAIL: - if(HIWORD(wParam)==EN_CHANGE) + if (HIWORD(wParam)==EN_CHANGE) EnableWindow(GetDlgItem(hwndDlg,IDOK),GetWindowTextLength(GetDlgItem(hwndDlg,IDC_EMAIL))); break; } @@ -62,9 +62,9 @@ static INT_PTR CALLBACK EditUserPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar int i,item,countryCount; struct CountryListEntry *countries; SetWindowLongPtr(hwndDlg,GWLP_USERDATA,(LONG_PTR)lParam); - if(szText[0]) SetWindowText(hwndDlg,TranslateT("Edit Phone Number")); + if (szText[0]) SetWindowText(hwndDlg,TranslateT("Edit Phone Number")); TranslateDialogDefault(hwndDlg); - if(lstrlenA(szText)>4 && !lstrcmpA(szText+lstrlenA(szText)-4," SMS")) { + if (lstrlenA(szText)>4 && !lstrcmpA(szText+lstrlenA(szText)-4," SMS")) { CheckDlgButton(hwndDlg,IDC_SMS,BST_CHECKED); szText[lstrlenA(szText)-4]='\0'; } @@ -72,8 +72,8 @@ static INT_PTR CALLBACK EditUserPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar SendDlgItemMessage(hwndDlg,IDC_AREA,EM_LIMITTEXT,31,0); SendDlgItemMessage(hwndDlg,IDC_NUMBER,EM_LIMITTEXT,63,0); CallService(MS_UTILS_GETCOUNTRYLIST,(WPARAM)&countryCount,(LPARAM)&countries); - for(i=0;i4 && !lstrcmpA(dbv.pszVal+lstrlenA(dbv.pszVal)-4," SMS")) { + if (lstrlenA(dbv.pszVal)>4 && !lstrcmpA(dbv.pszVal+lstrlenA(dbv.pszVal)-4," SMS")) { ListView_SetItemText(GetDlgItem(hwndDlg,IDC_PHONES),lvi.iItem,2,_T("y")); dbv.ptszVal[lstrlen(dbv.ptszVal)-4]='\0'; } @@ -318,14 +318,14 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP DBFreeVariant(&dbv); lvi.iItem++; } - if(!DBGetContactSettingTString(hContact,szProto,"CompanyPhone",&dbv)) { + if (!DBGetContactSettingTString(hContact,szProto,"CompanyPhone",&dbv)) { lvi.pszText=TranslateT("Work Phone"); ListView_InsertItem(GetDlgItem(hwndDlg,IDC_PHONES),&lvi); ListView_SetItemText(GetDlgItem(hwndDlg,IDC_PHONES),lvi.iItem,1,dbv.ptszVal); DBFreeVariant(&dbv); lvi.iItem++; } - if(!DBGetContactSettingTString(hContact,szProto,"CompanyFax",&dbv)) { + if (!DBGetContactSettingTString(hContact,szProto,"CompanyFax",&dbv)) { lvi.pszText=TranslateT("Work Fax"); ListView_InsertItem(GetDlgItem(hwndDlg,IDC_PHONES),&lvi); ListView_SetItemText(GetDlgItem(hwndDlg,IDC_PHONES),lvi.iItem,1,dbv.ptszVal); @@ -333,15 +333,15 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP lvi.iItem++; } lvi.iSubItem=0; - for(i=0;;i++) { + for (i=0;;i++) { lvi.lParam=i; mir_snprintf(idstr, SIZEOF(idstr), "MyPhone%d",i); - if(DBGetContactSettingTString(hContact,"UserInfo",idstr,&dbv)) + if (DBGetContactSettingTString(hContact,"UserInfo",idstr,&dbv)) break; lvi.pszText=idstr2; mir_sntprintf(idstr2, SIZEOF(idstr2), TranslateT("Custom %d"),i+1); ListView_InsertItem(GetDlgItem(hwndDlg,IDC_PHONES),&lvi); - if(lstrlen(dbv.ptszVal)>4 && !lstrcmp(dbv.ptszVal+lstrlen(dbv.ptszVal)-4,_T(" SMS"))) { + if (lstrlen(dbv.ptszVal)>4 && !lstrcmp(dbv.ptszVal+lstrlen(dbv.ptszVal)-4,_T(" SMS"))) { ListView_SetItemText(GetDlgItem(hwndDlg,IDC_PHONES),lvi.iItem,2,_T("y")); dbv.ptszVal[lstrlen(dbv.ptszVal)-4]='\0'; } @@ -378,7 +378,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP { RECT rc; ListView_GetSubItemRect(nm->nmcd.hdr.hwndFrom,nm->nmcd.dwItemSpec,nm->iSubItem,LVIR_LABEL,&rc); - if(nm->iSubItem==1 && nm->nmcd.hdr.idFrom==IDC_EMAILS) { + if (nm->iSubItem==1 && nm->nmcd.hdr.idFrom==IDC_EMAILS) { HFONT hoFont; TCHAR szText[256] = {0}; ListView_GetItemText(nm->nmcd.hdr.hwndFrom,nm->nmcd.dwItemSpec,nm->iSubItem,szText,SIZEOF(szText)); @@ -391,14 +391,14 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP } HICON hIcon = NULL; - if(nm->nmcd.lItemlParam==(LPARAM)(-2) && nm->iSubItem-3==(nm->nmcd.hdr.idFrom==IDC_PHONES)) + if (nm->nmcd.lItemlParam==(LPARAM)(-2) && nm->iSubItem-3==(nm->nmcd.hdr.idFrom==IDC_PHONES)) hIcon = LoadSkinIcon( SKINICON_OTHER_ADDCONTACT ); - else if(nm->iSubItem>1 && nm->nmcd.lItemlParam!=(LPARAM)(-1) && nm->nmcd.lItemlParam!=(LPARAM)(-2)) { + else if (nm->iSubItem>1 && nm->nmcd.lItemlParam!=(LPARAM)(-1) && nm->nmcd.lItemlParam!=(LPARAM)(-2)) { static int iconResources[3]={SKINICON_OTHER_RENAME,SKINICON_OTHER_DELETE}; - if(nm->iSubItem==2 && nm->nmcd.hdr.idFrom==IDC_PHONES) { + if (nm->iSubItem==2 && nm->nmcd.hdr.idFrom==IDC_PHONES) { TCHAR szText[2]; ListView_GetItemText(nm->nmcd.hdr.hwndFrom,nm->nmcd.dwItemSpec,nm->iSubItem,szText,SIZEOF(szText)); - if(szText[0]) hIcon = LoadSkinIcon( SKINICON_OTHER_SMS ); + if (szText[0]) hIcon = LoadSkinIcon( SKINICON_OTHER_SMS ); } else hIcon = LoadSkinIcon( iconResources[nm->iSubItem-3+(nm->nmcd.hdr.idFrom==IDC_EMAILS)] ); } @@ -419,33 +419,33 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP char *szIdTemplate=nm->hdr.idFrom==IDC_PHONES?"MyPhone%d":"Mye-mail%d"; LVHITTESTINFO hti; - if(IsOverEmail(hwndDlg,szEmail,SIZEOF(szEmail))) { + if (IsOverEmail(hwndDlg,szEmail,SIZEOF(szEmail))) { TCHAR szExec[264]; mir_sntprintf(szExec, SIZEOF(szExec), _T("mailto:%s"), szEmail); ShellExecute(hwndDlg,_T("open"),szExec,NULL,NULL,SW_SHOW); break; } - if(nm->iSubItem<2) break; + if (nm->iSubItem<2) break; hti.pt.x=(short)LOWORD(GetMessagePos()); hti.pt.y=(short)HIWORD(GetMessagePos()); ScreenToClient(nm->hdr.hwndFrom,&hti.pt); - if(ListView_SubItemHitTest(nm->hdr.hwndFrom,&hti)==-1) break; + if (ListView_SubItemHitTest(nm->hdr.hwndFrom,&hti) == -1) break; lvi.mask=LVIF_PARAM; lvi.iItem=hti.iItem; lvi.iSubItem=0; ListView_GetItem(nm->hdr.hwndFrom,&lvi); - if(lvi.lParam==(LPARAM)(-1)) break; - if(lvi.lParam==(LPARAM)(-2)) { - if(hti.iSubItem-3==(nm->hdr.idFrom==IDC_PHONES)) { + if (lvi.lParam==(LPARAM)(-1)) break; + if (lvi.lParam==(LPARAM)(-2)) { + if (hti.iSubItem-3==(nm->hdr.idFrom==IDC_PHONES)) { //add char szNewData[256]="",idstr[33]; int i; DBVARIANT dbv; - if(IDOK!=DialogBoxParam(hMirandaInst,MAKEINTRESOURCE(nm->hdr.idFrom==IDC_PHONES?IDD_ADDPHONE:IDD_ADDEMAIL),hwndDlg,nm->hdr.idFrom==IDC_PHONES?EditUserPhoneDlgProc:EditUserEmailDlgProc,(LPARAM)szNewData)) + if (IDOK!=DialogBoxParam(hMirandaInst,MAKEINTRESOURCE(nm->hdr.idFrom==IDC_PHONES?IDD_ADDPHONE:IDD_ADDEMAIL),hwndDlg,nm->hdr.idFrom==IDC_PHONES?EditUserPhoneDlgProc:EditUserEmailDlgProc,(LPARAM)szNewData)) break; - for(i=0;;i++) { + for (i=0;;i++) { mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate,i); - if(DBGetContactSettingString(hContact,"UserInfo",idstr,&dbv)) break; + if (DBGetContactSettingString(hContact,"UserInfo",idstr,&dbv)) break; DBFreeVariant(&dbv); } DBWriteContactSettingString(hContact,"UserInfo",idstr,szNewData); @@ -453,14 +453,14 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP } } else { - if(hti.iSubItem-3==(nm->hdr.idFrom==IDC_PHONES)) { + if (hti.iSubItem-3==(nm->hdr.idFrom==IDC_PHONES)) { //delete int i; char idstr[33]; DBVARIANT dbv; - for(i=lvi.lParam;;i++) { + for (i=lvi.lParam;;i++) { mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate,i+1); - if(DBGetContactSettingString(hContact,"UserInfo",idstr,&dbv)) break; + if (DBGetContactSettingString(hContact,"UserInfo",idstr,&dbv)) break; mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate,i); DBWriteContactSettingString(hContact,"UserInfo",idstr,dbv.pszVal); DBFreeVariant(&dbv); @@ -469,15 +469,15 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP DBDeleteContactSetting(hContact,"UserInfo",idstr); SendMessage(hwndDlg,M_REMAKELISTS,0,0); } - else if(hti.iSubItem-2==(nm->hdr.idFrom==IDC_PHONES)) { + else if (hti.iSubItem-2==(nm->hdr.idFrom==IDC_PHONES)) { //edit char szText[256],idstr[33]; DBVARIANT dbv; mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate,lvi.lParam); - if(DBGetContactSettingString(hContact,"UserInfo",idstr,&dbv)) break; + if (DBGetContactSettingString(hContact,"UserInfo",idstr,&dbv)) break; lstrcpynA(szText,dbv.pszVal,SIZEOF(szText)); DBFreeVariant(&dbv); - if(IDOK!=DialogBoxParam(hMirandaInst,MAKEINTRESOURCE(nm->hdr.idFrom==IDC_PHONES?IDD_ADDPHONE:IDD_ADDEMAIL),hwndDlg,nm->hdr.idFrom==IDC_PHONES?EditUserPhoneDlgProc:EditUserEmailDlgProc,(LPARAM)szText)) + if (IDOK!=DialogBoxParam(hMirandaInst,MAKEINTRESOURCE(nm->hdr.idFrom==IDC_PHONES?IDD_ADDPHONE:IDD_ADDEMAIL),hwndDlg,nm->hdr.idFrom==IDC_PHONES?EditUserPhoneDlgProc:EditUserEmailDlgProc,(LPARAM)szText)) break; DBWriteContactSettingString(hContact,"UserInfo",idstr,szText); SendMessage(hwndDlg,M_REMAKELISTS,0,0); @@ -490,14 +490,14 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP } break; case WM_SETCURSOR: - if(LOWORD(lParam)!=HTCLIENT) break; - if(GetForegroundWindow()==GetParent(hwndDlg)) { + if (LOWORD(lParam)!=HTCLIENT) break; + if (GetForegroundWindow()==GetParent(hwndDlg)) { POINT pt; GetCursorPos(&pt); ScreenToClient(hwndDlg,&pt); // SetFocus(ChildWindowFromPoint(hwndDlg,pt)); //ugly hack because listviews ignore their first click } - if(IsOverEmail(hwndDlg,NULL,0)) { + if (IsOverEmail(hwndDlg,NULL,0)) { SetCursor(hHandCursor); SetWindowLongPtr(hwndDlg,DWLP_MSGRESULT,TRUE); return TRUE; diff --git a/src/modules/userinfo/stdinfo.cpp b/src/modules/userinfo/stdinfo.cpp index 68de7a531d..976c590ac4 100644 --- a/src/modules/userinfo/stdinfo.cpp +++ b/src/modules/userinfo/stdinfo.cpp @@ -72,26 +72,26 @@ static void SetValue(HWND hwndDlg,int idCtrl,HANDLE hContact,char *szModule,char bool proto_service = szProto && (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_INFOSETTINGSVC); dbv.type=DBVT_DELETED; - if(szModule==NULL) unspecified=1; + if (szModule==NULL) unspecified=1; else if (proto_service) unspecified=Proto_GetContactInfoSetting(hContact,szProto,szModule,szSetting,&dbv,0); else unspecified=DBGetContactSettingW(hContact,szModule,szSetting,&dbv); - if(!unspecified) { + if (!unspecified) { switch(dbv.type) { case DBVT_BYTE: - if(special==SVS_GENDER) { - if(dbv.cVal=='M') ptstr=TranslateT("Male"); - else if(dbv.cVal=='F') ptstr=TranslateT("Female"); + if (special==SVS_GENDER) { + if (dbv.cVal=='M') ptstr=TranslateT("Male"); + else if (dbv.cVal=='F') ptstr=TranslateT("Female"); else unspecified=1; } - else if(special==SVS_MONTH) { - if(dbv.bVal>0 && dbv.bVal<=12) { + else if (special==SVS_MONTH) { + if (dbv.bVal>0 && dbv.bVal<=12) { pstr=str; GetLocaleInfoA(LOCALE_USER_DEFAULT,LOCALE_SABBREVMONTHNAME1-1+dbv.bVal,str,SIZEOF(str)); } else unspecified=1; } - else if(special==SVS_TIMEZONE) { - if(dbv.cVal==-100) unspecified=1; + else if (special==SVS_TIMEZONE) { + if (dbv.cVal==-100) unspecified=1; else { pstr=str; mir_snprintf(str, SIZEOF(str), dbv.cVal?"UTC%+d:%02d":"UTC",-dbv.cVal/2,(dbv.cVal&1)*30); @@ -103,7 +103,7 @@ static void SetValue(HWND hwndDlg,int idCtrl,HANDLE hContact,char *szModule,char } break; case DBVT_WORD: - if(special==SVS_COUNTRY) { + if (special==SVS_COUNTRY) { WORD wSave = dbv.wVal; if (wSave == ( WORD )-1) { char szSettingName[100]; @@ -125,20 +125,20 @@ static void SetValue(HWND hwndDlg,int idCtrl,HANDLE hContact,char *szModule,char break; case DBVT_DWORD: unspecified=(special==SVS_ZEROISUNSPEC && dbv.dVal==0); - if(special==SVS_IP) { + if (special==SVS_IP) { struct in_addr ia; ia.S_un.S_addr=htonl(dbv.dVal); pstr=inet_ntoa(ia); - if(dbv.dVal==0) unspecified=1; + if (dbv.dVal==0) unspecified=1; } else pstr=_itoa(special==SVS_SIGNED?dbv.lVal:dbv.dVal,str,10); break; case DBVT_ASCIIZ: - unspecified=(special==SVS_ZEROISUNSPEC && dbv.pszVal[0]=='\0'); + unspecified=(special==SVS_ZEROISUNSPEC && dbv.pszVal[0] == '\0'); pstr=dbv.pszVal; break; case DBVT_UTF8: - unspecified=(special==SVS_ZEROISUNSPEC && dbv.pszVal[0]=='\0'); + unspecified=(special==SVS_ZEROISUNSPEC && dbv.pszVal[0] == '\0'); #if defined( _UNICODE ) if ( !unspecified ) { WCHAR* wszStr; @@ -207,7 +207,7 @@ static INT_PTR CALLBACK SummaryDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP SendMessage(GetParent(hwndDlg),msg,wParam,lParam); break; case IDC_EMAIL: - if(IsWindowEnabled(GetDlgItem(hwndDlg,IDC_EMAIL))) { + if (IsWindowEnabled(GetDlgItem(hwndDlg,IDC_EMAIL))) { TCHAR szExec[264], szEmail[256]; GetDlgItemText(hwndDlg, IDC_EMAIL, szEmail, SIZEOF(szEmail)); mir_sntprintf(szExec, SIZEOF(szExec), _T("mailto:%s"), szEmail); @@ -283,7 +283,7 @@ static INT_PTR CALLBACK LocationDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L SendMessage(GetParent(hwndDlg),msg,wParam,lParam); break; case IDC_TIMEZONESELECT: - if(HIWORD(wParam) == CBN_SELCHANGE) { + if (HIWORD(wParam) == CBN_SELCHANGE) { HANDLE hContact = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); SendMessage(GetParent(hwndDlg),PSM_CHANGED, 0,0); @@ -330,7 +330,7 @@ static INT_PTR CALLBACK WorkDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA SendMessage(GetParent(hwndDlg),msg,wParam,lParam); break; case IDC_WEBPAGE: - if(IsWindowEnabled(GetDlgItem(hwndDlg,IDC_WEBPAGE))) { + if (IsWindowEnabled(GetDlgItem(hwndDlg,IDC_WEBPAGE))) { char szPage[256]; GetDlgItemTextA(hwndDlg,IDC_WEBPAGE,szPage,SIZEOF(szPage)); CallService(MS_UTILS_OPENURL,1,(LPARAM)szPage); @@ -394,38 +394,38 @@ static INT_PTR CALLBACK BackgroundDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, lvi.mask=LVIF_TEXT; lvi.iSubItem=0; lvi.iItem=0; - for(i=0;;i++) { + for (i=0;;i++) { mir_snprintf(idstr, SIZEOF(idstr), "Past%d",i); - if((proto_service && Proto_GetContactInfoSetting(hContact,szProto,szProto,idstr,&dbv,DBVT_TCHAR)) || + if ((proto_service && Proto_GetContactInfoSetting(hContact,szProto,szProto,idstr,&dbv,DBVT_TCHAR)) || (!proto_service && DBGetContactSettingTString(hContact,szProto,idstr,&dbv))) break; mir_snprintf(idstr, SIZEOF(idstr), "Past%dText",i); - if(DBGetContactSettingTString(hContact,szProto,idstr,&dbvText)) - {if(proto_service) Proto_FreeInfoVariant(&dbv); else DBFreeVariant(&dbv); break;} + if (DBGetContactSettingTString(hContact,szProto,idstr,&dbvText)) + {if (proto_service) Proto_FreeInfoVariant(&dbv); else DBFreeVariant(&dbv); break;} lvi.pszText=dbv.ptszVal; ListView_InsertItem(GetDlgItem(hwndDlg,IDC_PAST),&lvi); ListView_SetItemText(GetDlgItem(hwndDlg,IDC_PAST),lvi.iItem,1,dbvText.ptszVal); DBFreeVariant(&dbvText); - if(proto_service) + if (proto_service) Proto_FreeInfoVariant(&dbv); else DBFreeVariant(&dbv); lvi.iItem++; } - for(i=0;;i++) { + for (i=0;;i++) { mir_snprintf(idstr, SIZEOF(idstr), "Affiliation%d", i); - if((proto_service && Proto_GetContactInfoSetting(hContact,szProto,szProto,idstr,&dbv,DBVT_TCHAR)) || + if ((proto_service && Proto_GetContactInfoSetting(hContact,szProto,szProto,idstr,&dbv,DBVT_TCHAR)) || (!proto_service && DBGetContactSettingTString(hContact,szProto,idstr,&dbv))) break; mir_snprintf(idstr, SIZEOF(idstr), "Affiliation%dText",i); - if(DBGetContactSettingTString(hContact,szProto,idstr,&dbvText)) - {if(proto_service) Proto_FreeInfoVariant(&dbv); else DBFreeVariant(&dbv); break;} + if (DBGetContactSettingTString(hContact,szProto,idstr,&dbvText)) + {if (proto_service) Proto_FreeInfoVariant(&dbv); else DBFreeVariant(&dbv); break;} lvi.pszText=dbv.ptszVal; ListView_InsertItem(GetDlgItem(hwndDlg,IDC_PAST),&lvi); ListView_SetItemText(GetDlgItem(hwndDlg,IDC_PAST),lvi.iItem,1,dbvText.ptszVal); DBFreeVariant(&dbvText); - if(proto_service) + if (proto_service) Proto_FreeInfoVariant(&dbv); else DBFreeVariant(&dbv); @@ -439,19 +439,19 @@ static INT_PTR CALLBACK BackgroundDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, lvi.mask=LVIF_TEXT; lvi.iSubItem=0; lvi.iItem=0; - for(i=0;;i++) { + for (i=0;;i++) { mir_snprintf(idstr, SIZEOF(idstr), "Interest%dCat", i); - if((proto_service && Proto_GetContactInfoSetting(hContact,szProto,szProto,idstr,&dbv,DBVT_TCHAR)) || + if ((proto_service && Proto_GetContactInfoSetting(hContact,szProto,szProto,idstr,&dbv,DBVT_TCHAR)) || (!proto_service && DBGetContactSettingTString(hContact,szProto,idstr,&dbv))) break; mir_snprintf(idstr, SIZEOF(idstr), "Interest%dText", i); - if(DBGetContactSettingTString(hContact,szProto,idstr,&dbvText)) - {if(proto_service) Proto_FreeInfoVariant(&dbv); else DBFreeVariant(&dbv); break;} + if (DBGetContactSettingTString(hContact,szProto,idstr,&dbvText)) + {if (proto_service) Proto_FreeInfoVariant(&dbv); else DBFreeVariant(&dbv); break;} lvi.pszText=dbv.ptszVal; ListView_InsertItem(GetDlgItem(hwndDlg,IDC_INTERESTS),&lvi); ListView_SetItemText(GetDlgItem(hwndDlg,IDC_INTERESTS),lvi.iItem,1,dbvText.ptszVal); DBFreeVariant(&dbvText); - if(proto_service) + if (proto_service) Proto_FreeInfoVariant(&dbv); else DBFreeVariant(&dbv); @@ -468,7 +468,7 @@ static INT_PTR CALLBACK BackgroundDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, SendMessage(GetParent(hwndDlg),msg,wParam,lParam); break; case IDC_WEBPAGE: - if(IsWindowEnabled(GetDlgItem(hwndDlg,IDC_WEBPAGE))) { + if (IsWindowEnabled(GetDlgItem(hwndDlg,IDC_WEBPAGE))) { char szPage[256]; GetDlgItemTextA(hwndDlg,IDC_WEBPAGE,szPage,SIZEOF(szPage)); CallService(MS_UTILS_OPENURL,1,(LPARAM)szPage); @@ -508,7 +508,7 @@ static INT_PTR CALLBACK NotesDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR hFont = CreateFontIndirect(&lf); SendDlgItemMessage(hwndDlg, IDC_ABOUT, WM_SETFONT, (WPARAM) hFont, MAKELPARAM(TRUE, 0)); - if(!DBGetContactSettingString((HANDLE)lParam,"UserInfo","MyNotes",&dbv)) { + if (!DBGetContactSettingString((HANDLE)lParam,"UserInfo","MyNotes",&dbv)) { SetDlgItemTextA(hwndDlg,IDC_MYNOTES,dbv.pszVal); DBFreeVariant(&dbv); } @@ -531,7 +531,7 @@ static INT_PTR CALLBACK NotesDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR } case PSN_APPLY: { HANDLE hContact=(HANDLE)((LPPSHNOTIFY)lParam)->lParam; - if(GetWindowTextLength(GetDlgItem(hwndDlg,IDC_MYNOTES))) { + if (GetWindowTextLength(GetDlgItem(hwndDlg,IDC_MYNOTES))) { char text[2048]; GetDlgItemTextA(hwndDlg,IDC_MYNOTES,text,SIZEOF(text)); DBWriteContactSettingString(hContact,"UserInfo","MyNotes",text); @@ -544,9 +544,9 @@ static INT_PTR CALLBACK NotesDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR } break; case WM_COMMAND: - if(wParam==MAKEWPARAM(IDC_MYNOTES,EN_CHANGE)) + if (wParam==MAKEWPARAM(IDC_MYNOTES,EN_CHANGE)) SendMessage(GetParent(hwndDlg),PSM_CHANGED,0,0); - else if(LOWORD(wParam)==IDCANCEL) + else if (LOWORD(wParam)==IDCANCEL) SendMessage(GetParent(hwndDlg),msg,wParam,lParam); break; case WM_DESTROY: diff --git a/src/modules/userinfo/userinfo.cpp b/src/modules/userinfo/userinfo.cpp index 77729dd416..9a8daf0266 100644 --- a/src/modules/userinfo/userinfo.cpp +++ b/src/modules/userinfo/userinfo.cpp @@ -79,7 +79,7 @@ static INT_PTR ShowDetailsDialogCommand(WPARAM wParam,LPARAM) struct DetailsPageInit opi; int i; - if(hwnd=WindowList_Find(hWindowList,(HANDLE)wParam)) { + if (hwnd=WindowList_Find(hWindowList,(HANDLE)wParam)) { SetForegroundWindow(hwnd); SetFocus(hwnd); return 0; @@ -88,7 +88,7 @@ static INT_PTR ShowDetailsDialogCommand(WPARAM wParam,LPARAM) opi.pageCount=0; opi.odp=NULL; NotifyEventHooks(hDetailsInitEvent,(WPARAM)&opi,wParam); - if(opi.pageCount==0) return 0; + if (opi.pageCount==0) return 0; qsort(opi.odp,opi.pageCount,sizeof(OPTIONSDIALOGPAGE),(int (*)(const void*,const void*))PageSortProc); ZeroMemory(&psh,sizeof(psh)); @@ -101,12 +101,12 @@ static INT_PTR ShowDetailsDialogCommand(WPARAM wParam,LPARAM) psh.ppsp = (PROPSHEETPAGE*)opi.odp; //blatent misuse of the structure, but what the hell CreateDialogParam(hMirandaInst,MAKEINTRESOURCE(IDD_DETAILS), NULL, DlgProcDetails, (LPARAM)&psh); - for(i=0;icbSize!=sizeof(OPTIONSDIALOGPAGE) + if (odp==NULL||opi==NULL) return 1; + if (odp->cbSize!=sizeof(OPTIONSDIALOGPAGE) && odp->cbSize != OPTIONPAGE_OLD_SIZE2 && odp->cbSize != OPTIONPAGE_OLD_SIZE3) return 1; @@ -129,7 +129,7 @@ static INT_PTR AddDetailsPage(WPARAM wParam,LPARAM lParam) dst->hInstance = odp->hInstance; dst->pfnDlgProc = odp->pfnDlgProc; dst->position = odp->position; - if((DWORD_PTR)odp->pszTemplate&0xFFFF0000) dst->pszTemplate = mir_strdup(odp->pszTemplate); + if ((DWORD_PTR)odp->pszTemplate&0xFFFF0000) dst->pszTemplate = mir_strdup(odp->pszTemplate); else dst->pszTemplate = odp->pszTemplate; #if defined(_UNICODE) @@ -215,7 +215,7 @@ static int UserInfoContactDelete(WPARAM wParam,LPARAM) { HWND hwnd; hwnd=WindowList_Find(hWindowList,(HANDLE)wParam); - if(hwnd!=NULL) DestroyWindow(hwnd); + if (hwnd!=NULL) DestroyWindow(hwnd); return 0; } @@ -347,7 +347,7 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP TCHAR str[128]; mir_sntprintf(str,SIZEOF(str), _T("%.*s%s%.*s"),dat->updateAnimFrame%10,_T("........."),dat->szUpdating,dat->updateAnimFrame%10,_T(".........")); SetDlgItemText(hwndDlg,IDC_UPDATING,str); - if(++dat->updateAnimFrame==UPDATEANIMFRAMES) dat->updateAnimFrame=0; + if (++dat->updateAnimFrame==UPDATEANIMFRAMES) dat->updateAnimFrame=0; break; } case WM_CTLCOLORSTATIC: @@ -386,9 +386,9 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP pshn.hdr.code=PSN_INFOCHANGED; pshn.hdr.idFrom=0; pshn.lParam=(LPARAM)dat->hContact; - for(i=0;ipageCount;i++) { + for (i=0;ipageCount;i++) { pshn.hdr.hwndFrom=dat->opd[i].hwnd; - if(dat->opd[i].hwnd!=NULL) + if (dat->opd[i].hwnd!=NULL) SendMessage(dat->opd[i].hwnd,WM_NOTIFY,0,(LPARAM)&pshn); } break; @@ -398,8 +398,8 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP char *szProto; if (dat->hContact != NULL) { szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)dat->hContact,0); - if(szProto==NULL) {EnableWindow(GetDlgItem(hwndDlg,IDC_UPDATE),FALSE); break;} - if(CallProtoService(szProto,PS_GETSTATUS,0,0)hContact==NULL && ack->type==ACKTYPE_STATUS) { + if (ack->hContact==NULL && ack->type==ACKTYPE_STATUS) { SendMessage(hwndDlg,M_CHECKONLINE,0,0); break; } - if(ack->hContact!=dat->hContact) break; - if(ack->type!=ACKTYPE_GETINFO) break; + if (ack->hContact!=dat->hContact) break; + if (ack->type!=ACKTYPE_GETINFO) break; SendMessage(hwndDlg,PSM_FORCECHANGED,0,0); /* if they're not gonna send any more ACK's don't let that mean we should crash */ if (!ack->hProcess && !ack->lParam) { @@ -423,11 +423,11 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP SendMessage(hwndDlg,M_CHECKONLINE,0,0); break; } //if - if(dat->infosUpdated==NULL) dat->infosUpdated=(int*)mir_calloc(sizeof(int)*(INT_PTR)ack->hProcess); - if(ack->result==ACKRESULT_SUCCESS || ack->result==ACKRESULT_FAILED) dat->infosUpdated[ack->lParam]=1; - for(i=0;i<(int)ack->hProcess;i++) - if(dat->infosUpdated[i]==0) break; - if(i==(int)ack->hProcess) { + if (dat->infosUpdated==NULL) dat->infosUpdated=(int*)mir_calloc(sizeof(int)*(INT_PTR)ack->hProcess); + if (ack->result==ACKRESULT_SUCCESS || ack->result==ACKRESULT_FAILED) dat->infosUpdated[ack->lParam]=1; + for (i=0;i<(int)ack->hProcess;i++) + if (dat->infosUpdated[i]==0) break; + if (i==(int)ack->hProcess) { ShowWindow(GetDlgItem(hwndDlg,IDC_UPDATING),SW_HIDE); KillTimer(hwndDlg,1); SendMessage(hwndDlg,M_CHECKONLINE,0,0); @@ -493,7 +493,7 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP TVITEM tvi = pnmtv->itemNew; dat->currentPage = tvi.lParam; - if(dat->currentPage != -1) + if (dat->currentPage != -1) { CreateDetailsTabs(hwndDlg, dat, &dat->opd[dat->currentPage]); if (dat->opd[dat->currentPage].hwnd == NULL) @@ -517,8 +517,8 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP pshn.hdr.idFrom=0; pshn.lParam=(LPARAM)dat->hContact; pshn.hdr.code=PSN_RESET; - for(i=0;ipageCount;i++) { - if(dat->opd[i].hwnd==NULL || !dat->opd[i].changed) continue; + for (i=0;ipageCount;i++) { + if (dat->opd[i].hwnd==NULL || !dat->opd[i].changed) continue; pshn.hdr.hwndFrom=dat->opd[i].hwnd; SendMessage(dat->opd[i].hwnd,WM_NOTIFY,0,(LPARAM)&pshn); } @@ -531,20 +531,20 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP PSHNOTIFY pshn; pshn.hdr.idFrom=0; pshn.lParam=(LPARAM)dat->hContact; - if(dat->currentPage!=-1) { + if (dat->currentPage!=-1) { pshn.hdr.code=PSN_KILLACTIVE; pshn.hdr.hwndFrom=dat->opd[dat->currentPage].hwnd; - if(SendMessage(dat->opd[dat->currentPage].hwnd,WM_NOTIFY,0,(LPARAM)&pshn)) + if (SendMessage(dat->opd[dat->currentPage].hwnd,WM_NOTIFY,0,(LPARAM)&pshn)) break; } pshn.hdr.code=PSN_APPLY; - for(i=0;ipageCount;i++) { - if(dat->opd[i].hwnd==NULL || !dat->opd[i].changed) continue; + for (i=0;ipageCount;i++) { + if (dat->opd[i].hwnd==NULL || !dat->opd[i].changed) continue; pshn.hdr.hwndFrom=dat->opd[i].hwnd; - if(SendMessage(dat->opd[i].hwnd,WM_NOTIFY,0,(LPARAM)&pshn)==PSNRET_INVALID_NOCHANGEPAGE) { + if (SendMessage(dat->opd[i].hwnd,WM_NOTIFY,0,(LPARAM)&pshn)==PSNRET_INVALID_NOCHANGEPAGE) { TreeView_Select(GetDlgItem(hwndDlg,IDC_PAGETREE), dat->opd[i].hItem, TVGN_CARET); - if(dat->currentPage!=-1) ShowWindow(dat->opd[dat->currentPage].hwnd,SW_HIDE); + if (dat->currentPage!=-1) ShowWindow(dat->opd[dat->currentPage].hwnd,SW_HIDE); dat->currentPage=i; ShowWindow(dat->opd[dat->currentPage].hwnd,SW_SHOW); return 0; @@ -554,8 +554,8 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP break; } case IDC_UPDATE: - if(dat->infosUpdated!=NULL) {mir_free(dat->infosUpdated); dat->infosUpdated=NULL;} - if(dat->hContact != NULL) { + if (dat->infosUpdated!=NULL) {mir_free(dat->infosUpdated); dat->infosUpdated=NULL;} + if (dat->hContact != NULL) { if (!CallContactService(dat->hContact,PSS_GETINFO,0,0)) { EnableWindow(GetDlgItem(hwndDlg,IDC_UPDATE),FALSE); ShowWindow(GetDlgItem(hwndDlg,IDC_UPDATING),SW_SHOW); @@ -587,9 +587,9 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP WindowList_Remove(hWindowList,hwndDlg); UnhookEvent(dat->hProtoAckEvent); { int i; - for(i=0;ipageCount;i++) + for (i=0;ipageCount;i++) { - if(dat->opd[i].hwnd!=NULL) DestroyWindow(dat->opd[i].hwnd); + if (dat->opd[i].hwnd!=NULL) DestroyWindow(dat->opd[i].hwnd); mir_free(dat->opd[i].ptszTitle); mir_free(dat->opd[i].ptszTab); } diff --git a/src/modules/useronline/useronline.cpp b/src/modules/useronline/useronline.cpp index 8c6bf49eb5..543b0c4e95 100644 --- a/src/modules/useronline/useronline.cpp +++ b/src/modules/useronline/useronline.cpp @@ -29,13 +29,13 @@ static int UserOnlineSettingChanged(WPARAM wParam,LPARAM lParam) DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING*)lParam; int newStatus,oldStatus; - if((HANDLE)wParam==NULL || strcmp(cws->szSetting,"Status")) return 0; + if ((HANDLE)wParam==NULL || strcmp(cws->szSetting,"Status")) return 0; newStatus=cws->value.wVal; oldStatus=DBGetContactSettingWord((HANDLE)wParam,"UserOnline","OldStatus",ID_STATUS_OFFLINE); DBWriteContactSettingWord((HANDLE)wParam,"UserOnline","OldStatus",(WORD)newStatus); - if(CallService(MS_IGNORE_ISIGNORED,wParam,IGNOREEVENT_USERONLINE)) return 0; - if(DBGetContactSettingByte((HANDLE)wParam,"CList","Hidden",0)) return 0; - if(newStatus==ID_STATUS_OFFLINE&&oldStatus!=ID_STATUS_OFFLINE) { + if (CallService(MS_IGNORE_ISIGNORED,wParam,IGNOREEVENT_USERONLINE)) return 0; + if (DBGetContactSettingByte((HANDLE)wParam,"CList","Hidden",0)) return 0; + if (newStatus==ID_STATUS_OFFLINE&&oldStatus!=ID_STATUS_OFFLINE) { // Remove the event from the queue if it exists since they are now offline int lastEvent = (int)DBGetContactSettingDword((HANDLE)wParam,"UserOnline","LastEvent",0); @@ -44,7 +44,7 @@ static int UserOnlineSettingChanged(WPARAM wParam,LPARAM lParam) DBWriteContactSettingDword((HANDLE)wParam,"UserOnline", "LastEvent", 0); } } - if((newStatus==ID_STATUS_ONLINE || newStatus==ID_STATUS_FREECHAT) && + if ((newStatus==ID_STATUS_ONLINE || newStatus==ID_STATUS_FREECHAT) && oldStatus!=ID_STATUS_ONLINE && oldStatus!=ID_STATUS_FREECHAT) { { DWORD ticked = db_dword_get(NULL, "UserOnline", cws->szModule, GetTickCount()); diff --git a/src/modules/utils/colourpicker.cpp b/src/modules/utils/colourpicker.cpp index 0f2f9bf8f8..29d25a175f 100644 --- a/src/modules/utils/colourpicker.cpp +++ b/src/modules/utils/colourpicker.cpp @@ -51,7 +51,7 @@ static LRESULT CALLBACK ColourPickerWndProc(HWND hwnd,UINT message,WPARAM wParam cc.rgbResult=GetWindowLongPtr(hwnd,0); cc.lpCustColors=custColours; cc.Flags=CC_ANYCOLOR|CC_FULLOPEN|CC_RGBINIT; - if(ChooseColor(&cc)) { + if (ChooseColor(&cc)) { SetWindowLongPtr(hwnd,0,cc.rgbResult); SendMessage(GetParent(hwnd),WM_COMMAND,MAKEWPARAM(GetDlgCtrlID(hwnd),CPN_COLOURCHANGED),(LPARAM)hwnd); InvalidateRect(hwnd,NULL,FALSE); @@ -72,7 +72,7 @@ static LRESULT CALLBACK ColourPickerWndProc(HWND hwnd,UINT message,WPARAM wParam GetClientRect(hwnd,&rc); DrawEdge(hdc1,&rc,EDGE_ETCHED,BF_RECT); InflateRect(&rc,-2,-2); - if(IsWindowEnabled(hwnd)) + if (IsWindowEnabled(hwnd)) hBrush=CreateSolidBrush(GetWindowLongPtr(hwnd,0)); else hBrush=CreateHatchBrush(HS_BDIAGONAL,GetSysColor(COLOR_GRAYTEXT)); diff --git a/src/modules/utils/hyperlink.cpp b/src/modules/utils/hyperlink.cpp index 7ed16f6857..cb7a117845 100644 --- a/src/modules/utils/hyperlink.cpp +++ b/src/modules/utils/hyperlink.cpp @@ -43,16 +43,16 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM switch(msg) { case WM_NCCREATE: dat=(struct HyperlinkWndData*)mir_calloc(sizeof(struct HyperlinkWndData)); - if(dat==NULL) return FALSE; /* fail creation */ + if (dat==NULL) return FALSE; /* fail creation */ SetWindowLongPtr(hwnd,0,(LONG_PTR)dat); /* always succeeds */ /* fall thru */ case WM_SYSCOLORCHANGE: - if(!(dat->flags&HLKF_HASENABLECOLOR)) { - if(GetSysColorBrush(COLOR_HOTLIGHT)==NULL) dat->enableColor=RGB(0,0,255); + if (!(dat->flags&HLKF_HASENABLECOLOR)) { + if (GetSysColorBrush(COLOR_HOTLIGHT)==NULL) dat->enableColor=RGB(0,0,255); else dat->enableColor=GetSysColor(COLOR_HOTLIGHT); dat->focusColor = RGB(GetRValue(dat->enableColor) / 2, GetGValue(dat->enableColor) / 2, GetBValue(dat->enableColor) / 2); } - if(!(dat->flags&HLKF_HASDISABLECOLOR)) + if (!(dat->flags&HLKF_HASDISABLECOLOR)) dat->disableColor=GetSysColor(COLOR_GRAYTEXT); break; @@ -101,24 +101,24 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM case WM_LBUTTONDOWN: { POINT pt; POINTSTOPOINT(pt,MAKEPOINTS(lParam)); - if(!PtInRect(&dat->rcText,pt)) break; + if (!PtInRect(&dat->rcText,pt)) break; SendMessage(GetParent(hwnd),WM_COMMAND,MAKEWPARAM(GetDlgCtrlID(hwnd),STN_CLICKED),(LPARAM)hwnd); return 0; } case WM_SETFONT: { LOGFONT lf; HFONT hFont; - if((HFONT)wParam==NULL) { /* use default system color */ + if ((HFONT)wParam==NULL) { /* use default system color */ dat->hEnableFont=dat->hDisableFont=NULL; return 0; } - if(GetObject((HFONT)wParam,sizeof(lf),&lf)) { + if (GetObject((HFONT)wParam,sizeof(lf),&lf)) { lf.lfUnderline=1; hFont=CreateFontIndirect(&lf); - if(hFont!=NULL) { + if (hFont!=NULL) { dat->hEnableFont=hFont; dat->hDisableFont=(HFONT)wParam; - if(LOWORD(lParam)) SendMessage(hwnd,HLK_INVALIDATE,0,0); + if (LOWORD(lParam)) SendMessage(hwnd,HLK_INVALIDATE,0,0); SendMessage(hwnd,HLK_MEASURETEXT,0,0); } } @@ -131,12 +131,12 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM { RECT rcWnd; POINT pt; HWND hwndParent; - if(!GetWindowRect(hwnd,&rcWnd)) break; + if (!GetWindowRect(hwnd,&rcWnd)) break; pt.x=rcWnd.left; pt.y=rcWnd.top; hwndParent=GetParent(hwnd); - if(hwndParent==NULL) hwndParent=hwnd; - if(!ScreenToClient(hwndParent,&pt)) break; + if (hwndParent==NULL) hwndParent=hwnd; + if (!ScreenToClient(hwndParent,&pt)) break; rcWnd.right=pt.x+(rcWnd.right-rcWnd.left); rcWnd.bottom=pt.y+(rcWnd.bottom-rcWnd.top); rcWnd.left=pt.x; @@ -149,7 +149,7 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM case WM_CREATE: case HLK_MEASURETEXT: { TCHAR szText[256]; - if(!GetWindowText(hwnd,szText,SIZEOF(szText))) return 0; + if (!GetWindowText(hwnd,szText,SIZEOF(szText))) return 0; lParam=(LPARAM)szText; /* fall thru */ case WM_SETTEXT: @@ -160,34 +160,34 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM LONG style; BOOL fMeasured=FALSE; hdc=GetDC(hwnd); - if(hdc==NULL) return 0; /* text change failed */ - if(dat->hEnableFont!=NULL) hPrevFont=(HFONT)SelectObject(hdc,dat->hEnableFont); - if(dat->hEnableFont==NULL || hPrevFont!=NULL) /* select failed? */ - if(GetTextExtentPoint32(hdc,(TCHAR*)lParam,lstrlen((TCHAR*)lParam),&textSize)) - if(GetClientRect(hwnd,&rc)) { + if (hdc==NULL) return 0; /* text change failed */ + if (dat->hEnableFont!=NULL) hPrevFont=(HFONT)SelectObject(hdc,dat->hEnableFont); + if (dat->hEnableFont==NULL || hPrevFont!=NULL) /* select failed? */ + if (GetTextExtentPoint32(hdc,(TCHAR*)lParam,lstrlen((TCHAR*)lParam),&textSize)) + if (GetClientRect(hwnd,&rc)) { dat->rcText.top=0; dat->rcText.bottom=dat->rcText.top+textSize.cy; style=GetWindowLongPtr(hwnd,GWL_STYLE); - if(style&SS_CENTER) dat->rcText.left=(rc.right-textSize.cx)/2; - else if(style&SS_RIGHT) dat->rcText.left=rc.right-textSize.cx; + if (style&SS_CENTER) dat->rcText.left=(rc.right-textSize.cx)/2; + else if (style&SS_RIGHT) dat->rcText.left=rc.right-textSize.cx; else dat->rcText.left=0; dat->rcText.right=dat->rcText.left+textSize.cx; fMeasured=TRUE; } - if(dat->hEnableFont!=NULL && hPrevFont!=NULL) SelectObject(hdc,hPrevFont); + if (dat->hEnableFont!=NULL && hPrevFont!=NULL) SelectObject(hdc,hPrevFont); ReleaseDC(hwnd,hdc); - if(!fMeasured) return 0; /* text change failed */ + if (!fMeasured) return 0; /* text change failed */ SendMessage(hwnd,HLK_INVALIDATE,0,0); break; }} case WM_SETCURSOR: { POINT pt; HCURSOR hCursor; - if(!GetCursorPos(&pt)) return FALSE; - if(!ScreenToClient(hwnd,&pt)) return FALSE; - if(PtInRect(&dat->rcText,pt)) { + if (!GetCursorPos(&pt)) return FALSE; + if (!ScreenToClient(hwnd,&pt)) return FALSE; + if (PtInRect(&dat->rcText,pt)) { hCursor=(HCURSOR)GetClassLongPtr(hwnd,GCLP_HCURSOR); - if(hCursor==NULL) hCursor=LoadCursor(NULL,IDC_HAND); /* Win2000+ */ + if (hCursor==NULL) hCursor=LoadCursor(NULL,IDC_HAND); /* Win2000+ */ } else hCursor=LoadCursor(NULL,IDC_ARROW); SetCursor(hCursor); @@ -218,15 +218,15 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM HDC hdc; hdc=BeginPaint(hwnd,&ps); - if(hdc!=NULL) { - if(IsWindowEnabled(hwnd)) { + if (hdc!=NULL) { + if (IsWindowEnabled(hwnd)) { hPrevFont=(HFONT)SelectObject(hdc,dat->hEnableFont); textColor = (GetFocus() == hwnd) ? dat->focusColor : dat->enableColor; } else { hPrevFont=(HFONT)SelectObject(hdc,dat->hDisableFont); textColor=dat->disableColor; } - if(GetClientRect(hwnd,&rc) && GetWindowText(hwnd,szText,SIZEOF(szText))) { + if (GetClientRect(hwnd,&rc) && GetWindowText(hwnd,szText,SIZEOF(szText))) { if (drawThemeParentBackground && IsWinVerXPPlus()) { BOOL fSmoothing; @@ -241,13 +241,13 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM alignFlag=(GetWindowLongPtr(hwnd,GWL_STYLE)&(SS_CENTER|SS_RIGHT|SS_LEFT)); DrawText(hdc,szText,-1,&rc,alignFlag|DT_NOPREFIX|DT_SINGLELINE|DT_TOP); } - if(hPrevFont!=NULL) SelectObject(hdc,hPrevFont); + if (hPrevFont!=NULL) SelectObject(hdc,hPrevFont); EndPaint(hwnd,&ps); } return 0; } case WM_NCDESTROY: - if(dat->hEnableFont!=NULL) DeleteObject(dat->hEnableFont); + if (dat->hEnableFont!=NULL) DeleteObject(dat->hEnableFont); mir_free(dat); break; } @@ -262,7 +262,7 @@ int InitHyperlink(void) wcl.cbClsExtra=0; wcl.cbWndExtra=sizeof(struct HyperlinkWndData*); wcl.hInstance=hMirandaInst; - if(IsWinVer2000Plus()) wcl.hCursor=NULL; + if (IsWinVer2000Plus()) wcl.hCursor=NULL; else wcl.hCursor=LoadCursor(wcl.hInstance,MAKEINTRESOURCE(IDC_HYPERLINKHAND)); wcl.lpszClassName=WNDCLASS_HYPERLINK; wcl.hbrBackground=NULL; diff --git a/src/modules/utils/openurl.cpp b/src/modules/utils/openurl.cpp index 02ea139090..d6a4a937f4 100644 --- a/src/modules/utils/openurl.cpp +++ b/src/modules/utils/openurl.cpp @@ -46,18 +46,18 @@ static LRESULT CALLBACK DdeMessageWindow(HWND hwnd,UINT msg,WPARAM wParam,LPARAM case WM_DDE_DATA: UnpackDDElParam(msg,lParam,(PUINT_PTR)&hDdeData,(PUINT_PTR)&hSzItem); dat->fData=1; - if(hDdeData) { + if (hDdeData) { DDEDATA *data; int release; data=(DDEDATA*)GlobalLock(hDdeData); - if(data->fAckReq) { + if (data->fAckReq) { DDEACK ack={0}; PostMessage((HWND)wParam,WM_DDE_ACK,(WPARAM)hwnd,PackDDElParam(WM_DDE_ACK,*(PUINT)&ack,(UINT)hSzItem)); } else GlobalDeleteAtom(hSzItem); release=data->fRelease; GlobalUnlock(hDdeData); - if(release) GlobalFree(hDdeData); + if (release) GlobalFree(hDdeData); } else GlobalDeleteAtom(hSzItem); return 0; @@ -73,23 +73,23 @@ static int DoDdeRequest(const char *szItemName,HWND hwndDdeMsg) struct DdeMsgWindowData *dat=(struct DdeMsgWindowData*)GetWindowLongPtr(hwndDdeMsg,0); hSzItemName=GlobalAddAtomA(szItemName); - if(!PostMessage(dat->hwndDde,WM_DDE_REQUEST,(WPARAM)hwndDdeMsg,MAKELPARAM(CF_TEXT,hSzItemName))) { + if (!PostMessage(dat->hwndDde,WM_DDE_REQUEST,(WPARAM)hwndDdeMsg,MAKELPARAM(CF_TEXT,hSzItemName))) { GlobalDeleteAtom(hSzItemName); return 1; } timeoutTick=GetTickCount()+5000; dat->fData=0; dat->fAcked=0; do { - if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { + if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } - if(dat->fData || dat->fAcked) break; + if (dat->fData || dat->fAcked) break; thisTick=GetTickCount(); - if(thisTick>timeoutTick) break; + if (thisTick>timeoutTick) break; } while(MsgWaitForMultipleObjects(0,NULL,FALSE,timeoutTick-thisTick,QS_ALLINPUT)==WAIT_OBJECT_0); - if(!dat->fData) { + if (!dat->fData) { GlobalDeleteAtom(hSzItemName); return 1; } @@ -107,7 +107,7 @@ static int DdeOpenUrl(const char *szBrowser,char *szUrl,int newWindow,HWND hwndD hSzBrowser=GlobalAddAtomA(szBrowser); hSzTopic=GlobalAddAtomA("WWW_OpenURL"); dat->fAcked=0; - if(!SendMessageTimeout(HWND_BROADCAST,WM_DDE_INITIATE,(WPARAM)hwndDdeMsg,MAKELPARAM(hSzBrowser,hSzTopic),SMTO_ABORTIFHUNG|SMTO_NORMAL,DDEMESSAGETIMEOUT,&dwResult) + if (!SendMessageTimeout(HWND_BROADCAST,WM_DDE_INITIATE,(WPARAM)hwndDdeMsg,MAKELPARAM(hSzBrowser,hSzTopic),SMTO_ABORTIFHUNG|SMTO_NORMAL,DDEMESSAGETIMEOUT,&dwResult) || !dat->fAcked) { GlobalDeleteAtom(hSzTopic); GlobalDeleteAtom(hSzBrowser); @@ -115,7 +115,7 @@ static int DdeOpenUrl(const char *szBrowser,char *szUrl,int newWindow,HWND hwndD } szItemName=(char*)mir_alloc(lstrlenA(szUrl)+7); wsprintfA(szItemName,"\"%s\",,%d",szUrl,newWindow?0:-1); - if(DoDdeRequest(szItemName,hwndDdeMsg)) { + if (DoDdeRequest(szItemName,hwndDdeMsg)) { mir_free(szItemName); GlobalDeleteAtom(hSzTopic); GlobalDeleteAtom(hSzBrowser); @@ -150,21 +150,21 @@ static void OpenURLThread(void *arg) hwndDdeMsg=CreateWindow(WNDCLASS_DDEMSGWINDOW,_T(""),0,0,0,0,0,NULL,NULL,hMirandaInst,NULL); SetWindowLongPtr(hwndDdeMsg,0,(LONG_PTR)&msgWndData); - if(!_strnicmp(hUrlInfo->szUrl,"ftp:",4) || !_strnicmp(hUrlInfo->szUrl,"ftp.",4)) pszProtocol="ftp"; - if(!_strnicmp(hUrlInfo->szUrl,"mailto:",7)) pszProtocol="mailto"; - if(!_strnicmp(hUrlInfo->szUrl,"news:",5)) pszProtocol="news"; + if (!_strnicmp(hUrlInfo->szUrl,"ftp:",4) || !_strnicmp(hUrlInfo->szUrl,"ftp.",4)) pszProtocol="ftp"; + if (!_strnicmp(hUrlInfo->szUrl,"mailto:",7)) pszProtocol="mailto"; + if (!_strnicmp(hUrlInfo->szUrl,"news:",5)) pszProtocol="news"; else pszProtocol="http"; wsprintfA(szSubkey,"%s\\shell\\open\\command",pszProtocol); - if(RegOpenKeyExA(HKEY_CURRENT_USER,szSubkey,0,KEY_QUERY_VALUE,&hKey)==ERROR_SUCCESS + if (RegOpenKeyExA(HKEY_CURRENT_USER,szSubkey,0,KEY_QUERY_VALUE,&hKey)==ERROR_SUCCESS || RegOpenKeyExA(HKEY_CLASSES_ROOT,szSubkey,0,KEY_QUERY_VALUE,&hKey)==ERROR_SUCCESS) { dataLength=SIZEOF(szCommandName); - if(RegQueryValueEx(hKey,NULL,NULL,NULL,(PBYTE)szCommandName,&dataLength)==ERROR_SUCCESS) { + if (RegQueryValueEx(hKey,NULL,NULL,NULL,(PBYTE)szCommandName,&dataLength)==ERROR_SUCCESS) { _strlwr(szCommandName); - if(strstr(szCommandName,"mozilla") || strstr(szCommandName,"netscape")) + if (strstr(szCommandName,"mozilla") || strstr(szCommandName,"netscape")) success=(DdeOpenUrl("mozilla",hUrlInfo->szUrl,hUrlInfo->newWindow,hwndDdeMsg)==0 || DdeOpenUrl("netscape",hUrlInfo->szUrl,hUrlInfo->newWindow,hwndDdeMsg)==0); - else if(strstr(szCommandName,"iexplore") || strstr(szCommandName,"msimn")) + else if (strstr(szCommandName,"iexplore") || strstr(szCommandName,"msimn")) success=0==DdeOpenUrl("iexplore",hUrlInfo->szUrl,hUrlInfo->newWindow,hwndDdeMsg); - else if(strstr(szCommandName,"opera")) + else if (strstr(szCommandName,"opera")) success=0==DdeOpenUrl("opera",hUrlInfo->szUrl,hUrlInfo->newWindow,hwndDdeMsg); //opera's the default anyway } @@ -172,19 +172,19 @@ static void OpenURLThread(void *arg) } DestroyWindow(hwndDdeMsg); - if(success) return; + if (success) return; //wack a protocol on it - if((isalpha(hUrlInfo->szUrl[0]) && hUrlInfo->szUrl[1]==':') || hUrlInfo->szUrl[0]=='\\') { + if ((isalpha(hUrlInfo->szUrl[0]) && hUrlInfo->szUrl[1] == ':') || hUrlInfo->szUrl[0] == '\\') { szResult=(char*)mir_alloc(lstrlenA(hUrlInfo->szUrl)+9); wsprintfA(szResult,"file:///%s",hUrlInfo->szUrl); } else { int i; - for(i=0;isalpha(hUrlInfo->szUrl[i]);i++); - if(hUrlInfo->szUrl[i]==':') szResult=mir_strdup(hUrlInfo->szUrl); + for (i=0;isalpha(hUrlInfo->szUrl[i]);i++); + if (hUrlInfo->szUrl[i] == ':') szResult=mir_strdup(hUrlInfo->szUrl); else { - if(!_strnicmp(hUrlInfo->szUrl,"ftp.",4)) { + if (!_strnicmp(hUrlInfo->szUrl,"ftp.",4)) { szResult=(char*)mir_alloc(lstrlenA(hUrlInfo->szUrl)+7); wsprintfA(szResult,"ftp://%s",hUrlInfo->szUrl); } diff --git a/src/modules/utils/path.cpp b/src/modules/utils/path.cpp index ff6a5550bb..ed29b7fa24 100644 --- a/src/modules/utils/path.cpp +++ b/src/modules/utils/path.cpp @@ -35,7 +35,7 @@ static int pathIsAbsolute(const char *path) { if ( strlen(path) <= 2 ) return 0; - if ((path[1]==':'&&path[2]=='\\')||(path[0]=='\\'&&path[1]=='\\')) + if ((path[1] == ':'&&path[2] == '\\')||(path[0] == '\\'&&path[1] == '\\')) return 1; return 0; } @@ -137,7 +137,7 @@ static int pathIsAbsoluteW(const TCHAR *path) { if ( lstrlen(path) <= 2 ) return 0; - if ((path[1]==':'&&path[2]=='\\')||(path[0]=='\\'&&path[1]=='\\')) + if ((path[1] == ':'&&path[2] == '\\')||(path[0] == '\\'&&path[1] == '\\')) return 1; return 0; } diff --git a/src/modules/utils/resizer.cpp b/src/modules/utils/resizer.cpp index 31806f644e..17358aadfb 100644 --- a/src/modules/utils/resizer.cpp +++ b/src/modules/utils/resizer.cpp @@ -61,26 +61,26 @@ INT_PTR ResizeDialog(WPARAM, LPARAM lParam) int procResult; int extendedDlg,itemCount; - if(urd==NULL||urd->cbSize!=sizeof(UTILRESIZEDIALOG)) return 1; + if (urd==NULL||urd->cbSize!=sizeof(UTILRESIZEDIALOG)) return 1; pTemplate=(DLGTEMPLATE*)LockResource(LoadResource(urd->hInstance,FindResourceA(urd->hInstance,urd->lpTemplate,MAKEINTRESOURCEA(5)))); pTemplateEx=(START_OF_DLGTEMPLATEEX*)pTemplate; extendedDlg=pTemplateEx->signature==0xFFFF; - if(extendedDlg && pTemplateEx->dlgVer!=1) + if (extendedDlg && pTemplateEx->dlgVer!=1) return 1; - if(extendedDlg) pWord=(PWORD)(pTemplateEx+1); + if (extendedDlg) pWord=(PWORD)(pTemplateEx+1); else pWord=(PWORD)(pTemplate+1); - if(*pWord==0xFFFF) pWord+=2; else while(*pWord++); //menu - if(*pWord==0xFFFF) pWord+=2; else while(*pWord++); //class + if (*pWord==0xFFFF) pWord+=2; else while(*pWord++); //menu + if (*pWord==0xFFFF) pWord+=2; else while(*pWord++); //class while(*pWord++); //title - if(extendedDlg) { - if(pTemplateEx->style&DS_SETFONT) { + if (extendedDlg) { + if (pTemplateEx->style&DS_SETFONT) { pWord+=3; //font size,weight,italic while(*pWord++); //font name } } else { - if(pTemplate->style&DS_SETFONT) { + if (pTemplate->style&DS_SETFONT) { pWord++; //font size while(*pWord++); //font name } @@ -88,20 +88,20 @@ INT_PTR ResizeDialog(WPARAM, LPARAM lParam) urc.cbSize=sizeof(UTILRESIZECONTROL); rc.left=0; rc.top=0; - if(extendedDlg) {rc.right=pTemplateEx->cx; rc.bottom=pTemplateEx->cy;} + if (extendedDlg) {rc.right=pTemplateEx->cx; rc.bottom=pTemplateEx->cy;} else {rc.right=pTemplate->cx; rc.bottom=pTemplate->cy;} MapDialogRect(urd->hwndDlg,&rc); urc.dlgOriginalSize.cx=rc.right; urc.dlgOriginalSize.cy=rc.bottom; GetClientRect(urd->hwndDlg,&rc); urc.dlgNewSize.cx=rc.right; urc.dlgNewSize.cy=rc.bottom; - if(extendedDlg) itemCount=pTemplateEx->cDlgItems; + if (extendedDlg) itemCount=pTemplateEx->cDlgItems; else itemCount=pTemplate->cdit; hDwp=BeginDeferWindowPos(itemCount); - for(i=0;ix; urc.rcItem.top=pItem->y; urc.rcItem.right=urc.rcItem.left+pItem->cx; urc.rcItem.bottom=urc.rcItem.top+pItem->cy; } - if(*pWord==0xFFFF) pWord+=2; else while(*pWord++); //menu - if(*pWord==0xFFFF) pWord+=2; else while(*pWord++); //class + if (*pWord==0xFFFF) pWord+=2; else while(*pWord++); //menu + if (*pWord==0xFFFF) pWord+=2; else while(*pWord++); //class pWord+=1+(1+*pWord)/2; //creation data - if(urc.wId==65535) continue; //using this breaks the dwp, so just ignore it + if (urc.wId==65535) continue; //using this breaks the dwp, so just ignore it MapDialogRect(urd->hwndDlg,&urc.rcItem); procResult=(urd->pfnResizer)(urd->hwndDlg,urd->lParam,&urc); - if(procResult&RD_ANCHORX_RIGHT) { + if (procResult&RD_ANCHORX_RIGHT) { urc.rcItem.left+=urc.dlgNewSize.cx-urc.dlgOriginalSize.cx; urc.rcItem.right+=urc.dlgNewSize.cx-urc.dlgOriginalSize.cx; } - else if(procResult&RD_ANCHORX_WIDTH) + else if (procResult&RD_ANCHORX_WIDTH) urc.rcItem.right+=urc.dlgNewSize.cx-urc.dlgOriginalSize.cx; - else if(procResult&RD_ANCHORX_CENTRE) { + else if (procResult&RD_ANCHORX_CENTRE) { urc.rcItem.left+=(urc.dlgNewSize.cx-urc.dlgOriginalSize.cx)/2; urc.rcItem.right+=(urc.dlgNewSize.cx-urc.dlgOriginalSize.cx)/2; } - if(procResult&RD_ANCHORY_BOTTOM) { + if (procResult&RD_ANCHORY_BOTTOM) { urc.rcItem.top+=urc.dlgNewSize.cy-urc.dlgOriginalSize.cy; urc.rcItem.bottom+=urc.dlgNewSize.cy-urc.dlgOriginalSize.cy; } - else if(procResult&RD_ANCHORY_HEIGHT) + else if (procResult&RD_ANCHORY_HEIGHT) urc.rcItem.bottom+=urc.dlgNewSize.cy-urc.dlgOriginalSize.cy; - else if(procResult&RD_ANCHORY_CENTRE) { + else if (procResult&RD_ANCHORY_CENTRE) { urc.rcItem.top+=(urc.dlgNewSize.cy-urc.dlgOriginalSize.cy)/2; urc.rcItem.bottom+=(urc.dlgNewSize.cy-urc.dlgOriginalSize.cy)/2; } diff --git a/src/modules/utils/timezones.cpp b/src/modules/utils/timezones.cpp index 06e66bfbd3..b7947d6e98 100644 --- a/src/modules/utils/timezones.cpp +++ b/src/modules/utils/timezones.cpp @@ -361,12 +361,12 @@ static const ListMessages *GetListMessages(HWND hWnd, DWORD dwFlags) GetClassName(hWnd, tszClassName, SIZEOF(tszClassName)); if (!_tcsicmp(tszClassName, _T("COMBOBOX"))) dwFlags |= TZF_PLF_CB; - else if(!_tcsicmp(tszClassName, _T("LISTBOX"))) + else if (!_tcsicmp(tszClassName, _T("LISTBOX"))) dwFlags |= TZF_PLF_LB; } if (dwFlags & TZF_PLF_CB) return & cbMessages; - else if(dwFlags & TZF_PLF_LB) + else if (dwFlags & TZF_PLF_LB) return & lbMessages; else return NULL; diff --git a/src/modules/utils/utils.cpp b/src/modules/utils/utils.cpp index bbd6deb19f..04a7da1b5b 100644 --- a/src/modules/utils/utils.cpp +++ b/src/modules/utils/utils.cpp @@ -301,8 +301,8 @@ static INT_PTR GetCountryByNumber(WPARAM wParam, LPARAM) { int i; - for(i=0; i < SIZEOF(countries); i++ ) - if((int)wParam==countries[i].id) return (INT_PTR)countries[i].szName; + for (i=0; i < SIZEOF(countries); i++ ) + if ((int)wParam==countries[i].id) return (INT_PTR)countries[i].szName; return (INT_PTR)NULL; } @@ -388,8 +388,8 @@ static INT_PTR RestoreWindowPosition(WPARAM wParam,LPARAM lParam) x=DBGetContactSettingDword(swp->hContact,swp->szModule,szSettingName,-1); mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sy", swp->szNamePrefix); y=(int)DBGetContactSettingDword(swp->hContact,swp->szModule,szSettingName,-1); - if(x==-1) return 1; - if(wParam&RWPF_NOSIZE) { + if (x==-1) return 1; + if (wParam&RWPF_NOSIZE) { OffsetRect(&wp.rcNormalPosition,x-wp.rcNormalPosition.left,y-wp.rcNormalPosition.top); } else { @@ -534,21 +534,21 @@ char* __fastcall ltrimp(char* str) bool __fastcall wildcmp(char * name, char * mask) { char * last='\0'; - for(;; mask++, name++) + for (;; mask++, name++) { - if(*mask != '?' && *mask != *name) break; - if(*name == '\0') return ((BOOL)!*mask); + if (*mask != '?' && *mask != *name) break; + if (*name == '\0') return ((BOOL)!*mask); } - if(*mask != '*') return FALSE; - for(;; mask++, name++) + if (*mask != '*') return FALSE; + for (;; mask++, name++) { while(*mask == '*') { last = mask++; - if(*mask == '\0') return ((BOOL)!*mask); /* true */ + if (*mask == '\0') return ((BOOL)!*mask); /* true */ } - if(*name == '\0') return ((BOOL)!*mask); /* *mask == EOS */ - if(*mask != '?' && *mask != *name) name -= (size_t)(mask - last) - 1, mask = last; + if (*name == '\0') return ((BOOL)!*mask); /* *mask == EOS */ + if (*mask != '?' && *mask != *name) name -= (size_t)(mask - last) - 1, mask = last; } } diff --git a/src/modules/utils/windowlist.cpp b/src/modules/utils/windowlist.cpp index ac1e34f569..fea07ac5fb 100644 --- a/src/modules/utils/windowlist.cpp +++ b/src/modules/utils/windowlist.cpp @@ -41,8 +41,8 @@ static INT_PTR AddToWindowList(WPARAM, LPARAM lParam) static INT_PTR RemoveFromWindowList(WPARAM wParam,LPARAM lParam) { int i; - for(i=0;imessage,msg->wParam,msg->lParam); return 0; } @@ -73,8 +73,8 @@ static INT_PTR BroadcastToWindowListAsync(WPARAM wParam,LPARAM lParam) { int i; MSG *msg=(MSG*)lParam; - for(i=0;imessage,msg->wParam,msg->lParam); return 0; } diff --git a/src/modules/visibility/visibility.cpp b/src/modules/visibility/visibility.cpp index 13c9d6b191..984d5e036a 100644 --- a/src/modules/visibility/visibility.cpp +++ b/src/modules/visibility/visibility.cpp @@ -32,30 +32,30 @@ static void SetListGroupIcons(HWND hwndList,HANDLE hFirstItem,HANDLE hParentItem typeOfFirst=SendMessage(hwndList,CLM_GETITEMTYPE,(WPARAM)hFirstItem,0); //check groups - if(typeOfFirst==CLCIT_GROUP) hItem=hFirstItem; + if (typeOfFirst==CLCIT_GROUP) hItem=hFirstItem; else hItem=(HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_NEXTGROUP,(LPARAM)hFirstItem); while(hItem) { hChildItem=(HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_CHILD,(LPARAM)hItem); - if(hChildItem) SetListGroupIcons(hwndList,hChildItem,hItem,childCount); - for( i=0; i < SIZEOF(iconOn); i++) - if(iconOn[i] && SendMessage(hwndList,CLM_GETEXTRAIMAGE,(WPARAM)hItem,i)==0) iconOn[i]=0; + if (hChildItem) SetListGroupIcons(hwndList,hChildItem,hItem,childCount); + 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); } //check contacts - if(typeOfFirst==CLCIT_CONTACT) hItem=hFirstItem; + if (typeOfFirst==CLCIT_CONTACT) hItem=hFirstItem; else hItem=(HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_NEXTCONTACT,(LPARAM)hFirstItem); while(hItem) { for ( i=0; i < SIZEOF(iconOn); i++) { iImage=SendMessage(hwndList,CLM_GETEXTRAIMAGE,(WPARAM)hItem,i); - if(iconOn[i] && iImage==0) iconOn[i]=0; - if(iImage!=0xFF) childCount[i]++; + if (iconOn[i] && iImage==0) iconOn[i]=0; + if (iImage!=0xFF) childCount[i]++; } 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+1:0):0xFF)); - if(groupChildCount) groupChildCount[i]+=childCount[i]; + if (groupChildCount) groupChildCount[i]+=childCount[i]; } } @@ -66,19 +66,19 @@ static void SetAllChildIcons(HWND hwndList,HANDLE hFirstItem,int iColumn,int iIm typeOfFirst=SendMessage(hwndList,CLM_GETITEMTYPE,(WPARAM)hFirstItem,0); //check groups - if(typeOfFirst==CLCIT_GROUP) hItem=hFirstItem; + if (typeOfFirst==CLCIT_GROUP) hItem=hFirstItem; else hItem=(HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_NEXTGROUP,(LPARAM)hFirstItem); while(hItem) { hChildItem=(HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_CHILD,(LPARAM)hItem); - if(hChildItem) SetAllChildIcons(hwndList,hChildItem,iColumn,iImage); + if (hChildItem) SetAllChildIcons(hwndList,hChildItem,iColumn,iImage); hItem=(HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_NEXTGROUP,(LPARAM)hItem); } //check contacts - if(typeOfFirst==CLCIT_CONTACT) hItem=hFirstItem; + if (typeOfFirst==CLCIT_CONTACT) hItem=hFirstItem; else hItem=(HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_NEXTCONTACT,(LPARAM)hFirstItem); while(hItem) { iOldIcon=SendMessage(hwndList,CLM_GETEXTRAIMAGE,(WPARAM)hItem,iColumn); - if(iOldIcon!=0xFF && iOldIcon!=iImage) SendMessage(hwndList,CLM_SETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(iColumn,iImage)); + if (iOldIcon!=0xFF && iOldIcon!=iImage) SendMessage(hwndList,CLM_SETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(iColumn,iImage)); hItem=(HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_NEXTCONTACT,(LPARAM)hItem); } } @@ -92,7 +92,7 @@ static void ResetListOptions(HWND hwndList) SendMessage(hwndList,CLM_SETGREYOUTFLAGS,0,0); SendMessage(hwndList,CLM_SETLEFTMARGIN,2,0); SendMessage(hwndList,CLM_SETINDENT,10,0); - for(i=0;i<=FONTID_MAX;i++) + for (i=0;i<=FONTID_MAX;i++) SendMessage(hwndList,CLM_SETTEXTCOLOR,i,GetSysColor(COLOR_WINDOWTEXT)); SetWindowLongPtr(hwndList,GWL_STYLE,GetWindowLongPtr(hwndList,GWL_STYLE)|CLS_SHOWHIDDEN); } @@ -107,19 +107,19 @@ static void SetAllContactIcons(HWND hwndList) hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0); do { hItem=(HANDLE)SendMessage(hwndList,CLM_FINDCONTACT,(WPARAM)hContact,0); - if(hItem) { + if (hItem) { szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0); - if(szProto==NULL) {flags=0; status=0;} + if (szProto==NULL) {flags=0; status=0;} else { flags=CallProtoService(szProto,PS_GETCAPS,PFLAGNUM_1,0); status=DBGetContactSettingWord(hContact,szProto,"ApparentMode",0); } - if(flags&PF1_INVISLIST) { - if(SendMessage(hwndList,CLM_GETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(0,0))==0xFF) + if (flags&PF1_INVISLIST) { + if (SendMessage(hwndList,CLM_GETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(0,0))==0xFF) SendMessage(hwndList,CLM_SETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(0,status==ID_STATUS_ONLINE?1:0)); } - if(flags&PF1_VISLIST) { - if(SendMessage(hwndList,CLM_GETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(1,0))==0xFF) + if (flags&PF1_VISLIST) { + if (SendMessage(hwndList,CLM_GETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(1,0))==0xFF) SendMessage(hwndList,CLM_SETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(1,status==ID_STATUS_OFFLINE?2:0)); } } @@ -245,17 +245,17 @@ static INT_PTR CALLBACK DlgProcVisibilityOpts(HWND hwndDlg, UINT msg, WPARAM, LP hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0); do { hItem=(HANDLE)SendDlgItemMessage(hwndDlg,IDC_LIST,CLM_FINDCONTACT,(WPARAM)hContact,0); - if(hItem) { + if (hItem) { set=0; - for(i=0;i<2;i++) { + for (i=0;i<2;i++) { iImage=SendDlgItemMessage(hwndDlg,IDC_LIST,CLM_GETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(i,0)); - if(iImage==i+1) { + if (iImage==i+1) { CallContactService(hContact,PSS_SETAPPARENTMODE,iImage==1?ID_STATUS_ONLINE:ID_STATUS_OFFLINE,0); set=1; break; } } - if(!set) CallContactService(hContact,PSS_SETAPPARENTMODE,0,0); + if (!set) CallContactService(hContact,PSS_SETAPPARENTMODE,0,0); } } while(hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0)); return TRUE; diff --git a/src/modules/xml/xmlParser.cpp b/src/modules/xml/xmlParser.cpp index fdcd644be0..a3e070496e 100644 --- a/src/modules/xml/xmlParser.cpp +++ b/src/modules/xml/xmlParser.cpp @@ -1140,7 +1140,7 @@ int XMLNode::removeOrderElement(XMLNodeData *d, XMLElementType t, int index) int n=d->nChild+d->nText+d->nClear, *o=d->pOrder,i=findPosition(d,index,t); memmove(o+i, o+i+1, (n-i)*sizeof(int)); for (;ipOrder=(int)realloc(d->pOrder,n*sizeof(int)); // but we skip reallocation because it's too time consuming. @@ -1166,7 +1166,7 @@ void *XMLNode::addToOrder(int memoryIncrease,int *_pos, int nc, void *p, int siz if (pos==n) { *_pos=nc; o[n]=(int)((nc<<2)+xtype); return p; } o[i]=o[pos]; - for (i=pos+1;i<=n;i++) if ((o[i]&3)==(int)xtype) o[i]+=4; + for (i=pos+1;i<=n;i++) if ((o[i]&3) == (int)xtype) o[i]+=4; *_pos=pos=o[pos]>>2; memmove(((char*)p)+(pos+1)*size,((char*)p)+pos*size,(nc-pos)*size); @@ -1356,7 +1356,7 @@ int XMLNode::ParseXMLElement(void *pa) } // Iterate through the tokens in the document - for(;;) + for (;;) { // Obtain the next token token = GetNextToken(pXML, &cbToken, &xtype); @@ -2213,7 +2213,7 @@ void XMLNode::emptyTheNode(char force) if (d->pParent) detachFromParent(d); int i; XMLNode *pc; - for(i=0; inChild; i++) + for (i=0; inChild; i++) { pc=dd->pChild+i; pc->d->pParent=NULL; @@ -2221,11 +2221,11 @@ void XMLNode::emptyTheNode(char force) pc->emptyTheNode(force); } myFree(dd->pChild); - for(i=0; inText; i++) free((void*)dd->pText[i]); + for (i=0; inText; i++) free((void*)dd->pText[i]); myFree(dd->pText); - for(i=0; inClear; i++) free((void*)dd->pClear[i].lpszValue); + for (i=0; inClear; i++) free((void*)dd->pClear[i].lpszValue); myFree(dd->pClear); - for(i=0; inAttribute; i++) + for (i=0; inAttribute; i++) { free((void*)dd->pAttribute[i].lpszName); if (dd->pAttribute[i].lpszValue) free((void*)dd->pAttribute[i].lpszValue); @@ -2905,7 +2905,7 @@ XMLSTR XMLParserBase64Tool::encode(unsigned char *inbuf, unsigned int inlen, cha int i=encodeLength(inlen,formatted),k=17,eLen=inlen/3,j; alloc(i*sizeof(XMLCHAR)); XMLSTR curr=(XMLSTR)buf; - for(i=0;i