From 4410284da77786594d7009b6c515176de0d5a51e Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Sat, 28 Feb 2015 00:26:43 +0000 Subject: Core: -Some major and minor issues fixed git-svn-id: http://svn.miranda-ng.org/main/trunk@12280 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/core/stdaway/src/awaymsg.cpp | 2 +- src/core/stdaway/src/sendmsg.cpp | 1 - src/core/stdchat/src/window.cpp | 10 +++--- src/core/stdfile/src/fileexistsdlg.cpp | 10 ++++-- src/core/stdfile/src/fileopts.cpp | 4 +-- src/core/stdfile/src/filerecvdlg.cpp | 16 ++++----- src/core/stdfile/src/filexferdlg.cpp | 5 ++- src/core/stdfile/src/ftmanager.cpp | 2 +- src/core/stdmsg/src/msgoptions.cpp | 5 ++- src/core/stdurl/urldialogs.cpp | 60 ++++++++++++++++------------------ 10 files changed, 60 insertions(+), 55 deletions(-) (limited to 'src/core') diff --git a/src/core/stdaway/src/awaymsg.cpp b/src/core/stdaway/src/awaymsg.cpp index d420df71ca..6d476adcff 100644 --- a/src/core/stdaway/src/awaymsg.cpp +++ b/src/core/stdaway/src/awaymsg.cpp @@ -140,7 +140,7 @@ static int AwayMsgPreBuildMenu(WPARAM hContact, LPARAM) mi.flags = CMIM_FLAGS | CMIF_NOTOFFLINE | CMIF_HIDDEN | CMIF_TCHAR; if (szProto != NULL) { - int chatRoom = szProto ? db_get_b(hContact, szProto, "ChatRoom", 0) : 0; + int chatRoom = db_get_b(hContact, szProto, "ChatRoom", 0); if (!chatRoom) { int status = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE); mir_sntprintf(str, SIZEOF(str), TranslateT("Re&ad %s message"), pcli->pfnGetStatusModeDescription(status, 0)); diff --git a/src/core/stdaway/src/sendmsg.cpp b/src/core/stdaway/src/sendmsg.cpp index 667db52b6a..e7ab0681ed 100644 --- a/src/core/stdaway/src/sendmsg.cpp +++ b/src/core/stdaway/src/sendmsg.cpp @@ -431,7 +431,6 @@ static INT_PTR CALLBACK DlgProcAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam { LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam; if (dis->CtlID != IDC_LST_STATUS) break; - if (dis->itemID < 0) break; TCHAR buf[128]; SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_GETTEXT, dis->itemID, (LPARAM)buf); diff --git a/src/core/stdchat/src/window.cpp b/src/core/stdchat/src/window.cpp index 87309e530c..d89dc41914 100644 --- a/src/core/stdchat/src/window.cpp +++ b/src/core/stdchat/src/window.cpp @@ -2138,11 +2138,13 @@ LABEL_SHOWWINDOW: case ID_LOCKPOSITION: TabCtrl_GetItem(GetDlgItem(hwndDlg, IDC_TAB), i, &id); - if (!(GetMenuState(hSubMenu, ID_LOCKPOSITION, MF_BYCOMMAND)&MF_CHECKED)) { - if (s->hContact) - db_set_w(s->hContact, s->pszModule, "TabPosition", (WORD)(i + 1)); + if (s!=0) { + if (!(GetMenuState(hSubMenu, ID_LOCKPOSITION, MF_BYCOMMAND)&MF_CHECKED)) { + if (s->hContact) + db_set_w(s->hContact, s->pszModule, "TabPosition", (WORD)(i + 1)); + } + else db_unset(s->hContact, s->pszModule, "TabPosition"); } - else db_unset(s->hContact, s->pszModule, "TabPosition"); break; } } diff --git a/src/core/stdfile/src/fileexistsdlg.cpp b/src/core/stdfile/src/fileexistsdlg.cpp index 2fbc9dce60..3c15484676 100644 --- a/src/core/stdfile/src/fileexistsdlg.cpp +++ b/src/core/stdfile/src/fileexistsdlg.cpp @@ -177,7 +177,13 @@ void __cdecl LoadIconsAndTypesThread(void* param) if (szIconFile[0]) { TCHAR *pszComma = _tcsrchr(szIconFile, ','); - int iconIndex = (pszComma == NULL) ? 0 : _ttoi(pszComma + 1); *pszComma = '\0'; + int iconIndex; + if (pszComma) { + iconIndex = _ttoi(pszComma + 1); + *pszComma = '\0'; + } + else + iconIndex = 0; HICON hIcon = ExtractIcon(hInst, szIconFile, iconIndex); if (hIcon) fileInfo.hIcon = hIcon; @@ -281,7 +287,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.hwndOwner = hwndDlg; ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY; - _tcscpy(filter, TranslateT("All files")); + _tcsncpy(filter, TranslateT("All files"),SIZEOF(filter)-1); _tcscat(filter, _T(" (*)")); pfilter = filter + _tcslen(filter) + 1; _tcscpy(pfilter, _T("*")); diff --git a/src/core/stdfile/src/fileopts.cpp b/src/core/stdfile/src/fileopts.cpp index 42903c987f..899eb224a6 100644 --- a/src/core/stdfile/src/fileopts.cpp +++ b/src/core/stdfile/src/fileopts.cpp @@ -34,9 +34,7 @@ struct virusscannerinfo { const TCHAR *szExeRegPath; const TCHAR *szExeRegValue; const TCHAR *szCommandLine; -}; - -static const struct virusscannerinfo virusScanners[] = { +} virusScanners[] = { {_T("Network Associates/McAfee VirusScan"), _T("SOFTWARE\\McAfee\\VirusScan"), _T("Scan32EXE"), _T("\"%s\" %%f /nosplash /comp /autoscan /autoexit /noboot")}, {_T("Dr Solomon's VirusScan (Network Associates)"), _T("SOFTWARE\\Network Associates\\TVD\\VirusScan\\AVConsol\\General"), _T("szScannerExe"), _T("\"%s\" %%f /uinone /noboot /comp /prompt /autoexit")}, {_T("Norton AntiVirus"), _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Navw32.exe"), NULL, _T("\"%s\" %%f /b- /m- /s+ /noresults")}, diff --git a/src/core/stdfile/src/filerecvdlg.cpp b/src/core/stdfile/src/filerecvdlg.cpp index e1cff072ea..f28660dea0 100644 --- a/src/core/stdfile/src/filerecvdlg.cpp +++ b/src/core/stdfile/src/filerecvdlg.cpp @@ -54,8 +54,7 @@ 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) - tszString[i] = _T('_'); + tszString[i] = _T('_'); } } @@ -64,8 +63,7 @@ void RemoveInvalidPathChars(TCHAR *tszString) { if (tszString) for (size_t i = _tcscspn(tszString, InvalidPathChars); tszString[i]; i += _tcscspn(tszString + i + 1, InvalidPathChars) + 1) - if (tszString[i] >= 0) - tszString[i] = _T('_'); + tszString[i] = _T('_'); } static INT CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData) @@ -317,7 +315,10 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l if (hIcon) { DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL); DestroyIcon(hIcon); - } } } } + } + } + } + } return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam); case WM_COMMAND: @@ -415,9 +416,8 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l case HM_RECVEVENT: { ACKDATA *ack = (ACKDATA*)lParam; - if (ack->hProcess != dat->fs) break; - if (ack->type != ACKTYPE_FILE) break; - if (ack->hContact != dat->hContact) break; + if ((ack == NULL) || (ack->hProcess != dat->fs) || (ack->type != ACKTYPE_FILE) || (ack->hContact != dat->hContact)) + break; if (ack->result == ACKRESULT_DENIED || ack->result == ACKRESULT_FAILED) { EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE); diff --git a/src/core/stdfile/src/filexferdlg.cpp b/src/core/stdfile/src/filexferdlg.cpp index e435e2627b..c89c518fa4 100644 --- a/src/core/stdfile/src/filexferdlg.cpp +++ b/src/core/stdfile/src/filexferdlg.cpp @@ -341,6 +341,9 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR break; case WM_COMMAND: + if (!dat) + break; + if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)dat->hContact)) break; @@ -368,7 +371,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR } case IDC_OPENFOLDER: - if (dat) { + { TCHAR *path = dat->transferStatus.tszWorkingDir; if (!path || !path[0]) { path = NEWTSTR_ALLOCA(dat->transferStatus.tszCurrentFile); diff --git a/src/core/stdfile/src/ftmanager.cpp b/src/core/stdfile/src/ftmanager.cpp index c99577b89f..a361dd7a30 100644 --- a/src/core/stdfile/src/ftmanager.cpp +++ b/src/core/stdfile/src/ftmanager.cpp @@ -177,7 +177,7 @@ static INT_PTR CALLBACK FtMgrPageDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPA case WM_MOUSEWHEEL: { - int zDelta = GET_WHEEL_DELTA_WPARAM(wParam); + short zDelta = GET_WHEEL_DELTA_WPARAM(wParam); if (zDelta) { int nScrollLines = 0; SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, (void*)&nScrollLines, 0); diff --git a/src/core/stdmsg/src/msgoptions.cpp b/src/core/stdmsg/src/msgoptions.cpp index 85e4ac4475..8582886b1d 100644 --- a/src/core/stdmsg/src/msgoptions.cpp +++ b/src/core/stdmsg/src/msgoptions.cpp @@ -82,7 +82,7 @@ bool LoadMsgDlgFont(int i, LOGFONT* lf, COLORREF * colour) DBVARIANT dbv; if (db_get_ts(NULL, SRMMMOD, str, &dbv)) - _tcscpy(lf->lfFaceName, fontOptionsList[i].szDefFace); + _tcsncpy(lf->lfFaceName, fontOptionsList[i].szDefFace, SIZEOF(lf->lfFaceName)-1); else { mir_tstrncpy(lf->lfFaceName, dbv.ptszVal, SIZEOF(lf->lfFaceName)); db_free(&dbv); @@ -135,8 +135,7 @@ struct CheckBoxValues_t { DWORD style; TCHAR* szDescr; -} -static const statusValues[] = +} statusValues[] = { { MODEF_OFFLINE, LPGENT("Offline") }, { PF2_ONLINE, LPGENT("Online") }, diff --git a/src/core/stdurl/urldialogs.cpp b/src/core/stdurl/urldialogs.cpp index afe0d103ad..96bef0f424 100644 --- a/src/core/stdurl/urldialogs.cpp +++ b/src/core/stdurl/urldialogs.cpp @@ -57,7 +57,8 @@ static void sttUpdateTitle(HWND hwndDlg, MCONTACT hContact) hasName = 1; mir_snprintf(buf, SIZEOF(buf), "%u", ci.dVal); break; - } } + } + } contactName = pcli->pfnGetContactDisplayName(hContact, 0); if (hasName) @@ -65,7 +66,7 @@ static void sttUpdateTitle(HWND hwndDlg, MCONTACT hContact) else SetDlgItemText(hwndDlg, IDC_NAME, contactName); - szStatus = pcli->pfnGetStatusModeDescription(szProto == NULL ? ID_STATUS_OFFLINE : db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE), 0); + szStatus = pcli->pfnGetStatusModeDescription(db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE), 0); mir_sntprintf(newtitle, SIZEOF(newtitle), _T("%s %s (%s)"), pszNewTitleStart, contactName, szStatus); } } @@ -136,17 +137,16 @@ INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP { LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam; if (dis->hwndItem == GetDlgItem(hwndDlg, IDC_PROTOCOL)) { - char *szProto; - - szProto = GetContactProto(dat->hContact); + char *szProto = GetContactProto(dat->hContact); if (szProto) { - HICON hIcon; - - hIcon = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0); + HICON hIcon = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0); if (hIcon) { DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL); DestroyIcon(hIcon); - } } } } + } + } + } + } return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam); case DM_UPDATETITLE: @@ -154,17 +154,18 @@ INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP break; case WM_COMMAND: - if (dat) - if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)dat->hContact)) - break; + if (!dat) + break; + if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)dat->hContact)) + break; switch(LOWORD(wParam)) { case IDOK: - { HMENU hMenu, hSubMenu; + { RECT rc; char url[256]; - hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXT)); - hSubMenu = GetSubMenu(hMenu, 6); + HMENU hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXT)); + HMENU hSubMenu = GetSubMenu(hMenu, 6); TranslateMenu(hSubMenu); GetWindowRect((HWND)lParam, &rc); GetDlgItemTextA(hwndDlg, IDC_URL, url, SIZEOF(url)); @@ -176,10 +177,10 @@ INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP CallService(MS_UTILS_OPENURL, 0, (LPARAM)url); break; case IDM_COPYLINK: - { HGLOBAL hData; + { if ( !OpenClipboard(hwndDlg)) break; EmptyClipboard(); - hData = GlobalAlloc(GMEM_MOVEABLE, mir_strlen(url)+1); + HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, mir_strlen(url)+1); mir_strcpy((char*)GlobalLock(hData), url); GlobalUnlock(hData); SetClipboardData(CF_TEXT, hData); @@ -279,11 +280,10 @@ static LRESULT DdeMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) static HGLOBAL DoDdeRequest(const char *szItemName, HWND hwndDlg) { - ATOM hSzItemName; DWORD timeoutTick, thisTick; MSG msg; - hSzItemName = GlobalAddAtomA(szItemName); + ATOM hSzItemName = GlobalAddAtomA(szItemName); if ( !PostMessage(hwndDde, WM_DDE_REQUEST, (WPARAM)hwndDlg, MAKELPARAM(CF_TEXT, hSzItemName))) { GlobalDeleteAtom(hSzItemName); return NULL; @@ -311,8 +311,7 @@ static HGLOBAL DoDdeRequest(const char *szItemName, HWND hwndDlg) static void FreeDdeRequestData(HGLOBAL hData) { - DDEDATA *data; - data = (DDEDATA*)GlobalLock(hData); + DDEDATA *data = (DDEDATA*)GlobalLock(hData); if (data->fRelease) { GlobalUnlock(hData); GlobalFree(hData); @@ -363,17 +362,13 @@ static void AddBrowserPageToCombo(char *url, HWND hwndCombo) //see Q160957 and http://developer.netscape.com/docs/manuals/communicator/DDE/index.htm static void GetOpenBrowserUrlsForBrowser(const char *szBrowser, HWND hwndDlg, HWND hwndCombo) { - ATOM hSzBrowser, hSzTopic; int windowCount, i; DWORD *windowId; DWORD dwResult; - HGLOBAL hData; - DDEDATA *data; - int dataLength; - hSzBrowser = GlobalAddAtomA(szBrowser); + ATOM hSzBrowser = GlobalAddAtomA(szBrowser); - hSzTopic = GlobalAddAtomA("WWW_ListWindows"); + ATOM 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) || !ddeAcked) { @@ -381,14 +376,14 @@ static void GetOpenBrowserUrlsForBrowser(const char *szBrowser, HWND hwndDlg, HW GlobalDeleteAtom(hSzBrowser); return; } - hData = DoDdeRequest("WWW_ListWindows", hwndDlg); + HGLOBAL hData = DoDdeRequest("WWW_ListWindows", hwndDlg); if (hData == NULL) { GlobalDeleteAtom(hSzTopic); GlobalDeleteAtom(hSzBrowser); return; } - dataLength = GlobalSize(hData)-offsetof(DDEDATA, Value); - data = (DDEDATA*)GlobalLock(hData); + int dataLength = GlobalSize(hData)-offsetof(DDEDATA, Value); + DDEDATA *data = (DDEDATA*)GlobalLock(hData); windowCount = dataLength/sizeof(DWORD); windowId = (PDWORD)mir_alloc(sizeof(DWORD)*windowCount); memcpy(windowId, data->Value, windowCount*sizeof(DWORD)); @@ -522,7 +517,10 @@ INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (hIcon) { DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL); DestroyIcon(hIcon); - } } } } + } + } + } + } return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam); case DM_UPDATETITLE: -- cgit v1.2.3