From fe076d92eca402b27979bacf4062563e759e7279 Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Sat, 29 Nov 2014 15:30:09 +0000 Subject: -Fixed a bug in Ping and other small things reported in #837 git-svn-id: http://svn.miranda-ng.org/main/trunk@11151 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_nicer/src/extBackg.cpp | 16 +++++------- plugins/Ping/src/rawping.cpp | 33 ++++++++++++++++--------- protocols/JabberG/src/jabber_file.cpp | 3 +-- protocols/JabberG/src/jabber_groupchat.cpp | 2 +- protocols/Yahoo/src/proto.cpp | 39 ++++++++++++++++-------------- src/modules/skin/hotkey_opts.cpp | 5 ++-- 6 files changed, 53 insertions(+), 45 deletions(-) diff --git a/plugins/Clist_nicer/src/extBackg.cpp b/plugins/Clist_nicer/src/extBackg.cpp index d623f56707..5b176c7a3f 100644 --- a/plugins/Clist_nicer/src/extBackg.cpp +++ b/plugins/Clist_nicer/src/extBackg.cpp @@ -1176,20 +1176,15 @@ static void BTN_ReadItem(char *itemName, char *file) void IMG_LoadItems() { - char *szSections = NULL; - char *p; DBVARIANT dbv; - char szFileName[MAX_PATH]; - TCHAR tszFileName[MAX_PATH]; - int i = 0; - if (cfg::getTString(NULL, "CLC", "AdvancedSkin", &dbv)) return; + TCHAR tszFileName[MAX_PATH]; MY_pathToAbsolute(dbv.ptszVal, tszFileName); // TODO: rewrite the skin loading in TCHAR manner - + char szFileName[MAX_PATH]; WideCharToMultiByte(CP_ACP, 0, tszFileName, MAX_PATH, szFileName, MAX_PATH, 0, 0); db_free(&dbv); @@ -1197,15 +1192,16 @@ void IMG_LoadItems() if (!PathFileExists(tszFileName)) return; + int i = 0; + IMG_DeleteItems(); - szSections = reinterpret_cast(malloc(3002)); + char *szSections = reinterpret_cast(malloc(3002)); ZeroMemory(szSections, 3002); - p = szSections; GetPrivateProfileSectionNamesA(szSections, 3000, szFileName); szSections[3001] = szSections[3000] = 0; - p = szSections; + char *p = szSections; while (lstrlenA(p) > 1) { if (p[0] == '$' || p[0] == '@') IMG_ReadItem(p, szFileName); diff --git a/plugins/Ping/src/rawping.cpp b/plugins/Ping/src/rawping.cpp index 007200fa23..f31868db5a 100644 --- a/plugins/Ping/src/rawping.cpp +++ b/plugins/Ping/src/rawping.cpp @@ -149,38 +149,48 @@ extern int raw_ping(char *host, int timeout) if (bread == SOCKET_ERROR) { if(WSAGetLastError() != WSAETIMEDOUT) { - if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: socket error...cycling"), 0); + if(options.logging) + CallService(PLUG "/Log", (WPARAM)_T("rawping error: socket error...cycling"), 0); } continue; } - if(reply_header->proto != ICMP_PROTO) - if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: packet not ICMP...cycling"), 0); + if(reply_header->proto != ICMP_PROTO) { + if(options.logging) + CallService(PLUG "/Log", (WPARAM)_T("rawping error: packet not ICMP...cycling"), 0); continue; + } - if(reply_header->tos != 0) - if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: TOS not 0...cycling"), 0); + if(reply_header->tos != 0) { + if(options.logging) + CallService(PLUG "/Log", (WPARAM)_T("rawping error: TOS not 0...cycling"), 0); continue; + } reply = (ICMPHeader *)(recv_buff + reply_header->h_len * 4); if((unsigned)bread < reply_header->h_len * 4 + sizeof(ICMPHeader)) { - if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: short header"), 0); + if(options.logging) + CallService(PLUG "/Log", (WPARAM)_T("rawping error: short header"), 0); continue; } - if(reply->id != (USHORT)GetCurrentProcessId()) - if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: wrong ID...cycling"), 0); + if(reply->id != (USHORT)GetCurrentProcessId()) { + if(options.logging) + CallService(PLUG "/Log", (WPARAM)_T("rawping error: wrong ID...cycling"), 0); continue; + } if(reply->type != PT_ICMP_ECHO_REPLY && reply->type != PT_ICMP_SOURCE_QUENCH) { - if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: wrong type...cycling"), 0); + if(options.logging) + CallService(PLUG "/Log", (WPARAM)_T("rawping error: wrong type...cycling"), 0); continue; } //if(reply->seq < seq_no) continue; //if(reply->seq > seq_no) return -1; if(reply->seq != seq_no) { - if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: wrong sequence number...cycling"), 0); + if(options.logging) + CallService(PLUG "/Log", (WPARAM)_T("rawping error: wrong sequence number...cycling"), 0); continue; } @@ -197,7 +207,8 @@ extern int raw_ping(char *host, int timeout) } else return current_time - send_time; } - if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: timeout"), 0); + if(options.logging) + CallService(PLUG "/Log", (WPARAM)_T("rawping error: timeout"), 0); return -1; } diff --git a/protocols/JabberG/src/jabber_file.cpp b/protocols/JabberG/src/jabber_file.cpp index f394d8ff8e..078cbcc98f 100644 --- a/protocols/JabberG/src/jabber_file.cpp +++ b/protocols/JabberG/src/jabber_file.cpp @@ -37,7 +37,6 @@ void __cdecl CJabberProto::FileReceiveThread(filetransfer *ft) NETLIBOPENCONNECTION nloc = { 0 }; nloc.cbSize = sizeof(nloc); - nloc.cbSize = sizeof(NETLIBOPENCONNECTION); nloc.szHost = ft->httpHostName; nloc.wPort = ft->httpPort; info.s = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hNetlibUser, (LPARAM)&nloc); @@ -73,7 +72,7 @@ void __cdecl CJabberProto::FileReceiveThread(filetransfer *ft) ft->s = NULL; - if (ft->state == FT_DONE || (ft->state == FT_RECEIVING && ft->std.currentFileSize < 0)) + if (ft->state == FT_DONE || (ft->state == FT_RECEIVING && ft->std.currentFileSize == 0)) ft->complete(); debugLogA("Thread ended: type=file_receive server='%s'", ft->httpHostName); diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp index 5c8ab6f357..330f472c40 100644 --- a/protocols/JabberG/src/jabber_groupchat.cpp +++ b/protocols/JabberG/src/jabber_groupchat.cpp @@ -519,7 +519,7 @@ INT_PTR CJabberDlgGcJoin::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) case WM_DRAWITEM: { LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam; - if (lpdis->CtlID != IDC_ROOM || lpdis->itemID < 0) + if (lpdis->CtlID != IDC_ROOM) break; RoomInfo *info = (RoomInfo *)SendDlgItemMessage(m_hwnd, IDC_ROOM, CB_GETITEMDATA, lpdis->itemID, 0); diff --git a/protocols/Yahoo/src/proto.cpp b/protocols/Yahoo/src/proto.cpp index 3b0f6e7494..2d635246bf 100644 --- a/protocols/Yahoo/src/proto.cpp +++ b/protocols/Yahoo/src/proto.cpp @@ -767,36 +767,39 @@ INT_PTR CALLBACK first_run_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM case WM_NOTIFY: if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) { char str[128]; - BOOL reconnectRequired = FALSE; + bool reconnectRequired = false; GetDlgItemTextA(hwndDlg, IDC_HANDLE, str, sizeof(str)); - - dbv.pszVal = NULL; - - if (ppro->getString(YAHOO_LOGINID, &dbv) || lstrcmpA(str, dbv.pszVal)) - reconnectRequired = TRUE; - - if (dbv.pszVal != NULL) + + if (ppro->getString(YAHOO_LOGINID, &dbv)) { + reconnectRequired = true; + } + else { + if(lstrcmpA(str, dbv.pszVal)) + reconnectRequired = true; db_free(&dbv); + } ppro->setString(YAHOO_LOGINID, str); GetDlgItemTextA(hwndDlg, IDC_PASSWORD, str, sizeof(str)); - dbv.pszVal = NULL; - if (ppro->getString(YAHOO_PASSWORD, &dbv) || lstrcmpA(str, dbv.pszVal)) - reconnectRequired = TRUE; - if (dbv.pszVal != NULL) + if (ppro->getString(YAHOO_PASSWORD, &dbv)) { + reconnectRequired = true; + } + else { + if(lstrcmpA(str, dbv.pszVal)) + reconnectRequired = true; db_free(&dbv); - - if (reconnectRequired) - ppro->delSetting(YAHOO_PWTOKEN); + } ppro->setString(YAHOO_PASSWORD, str); ppro->setByte("YahooJapan", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_YAHOO_JAPAN)); - if (reconnectRequired && ppro->m_bLoggedIn) - MessageBoxA(hwndDlg, Translate("The changes you have made require you to reconnect to the Yahoo network before they take effect"), Translate("YAHOO Options"), MB_OK); - + if (reconnectRequired) { + ppro->delSetting(YAHOO_PWTOKEN); + if (ppro->m_bLoggedIn) + MessageBox(hwndDlg, TranslateT("The changes you have made require you to reconnect to the Yahoo network before they take effect"), TranslateT("YAHOO Options"), MB_OK); + } return TRUE; } break; diff --git a/src/modules/skin/hotkey_opts.cpp b/src/modules/skin/hotkey_opts.cpp index bcbbac7ac1..bd450805b8 100644 --- a/src/modules/skin/hotkey_opts.cpp +++ b/src/modules/skin/hotkey_opts.cpp @@ -558,16 +558,15 @@ static INT_PTR CALLBACK sttOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, rc.left += 5; HIMAGELIST hIml = ListView_GetImageList(hwndHotkey, LVSIL_SMALL); - if (lpdis->CtlID == IDC_CANVAS2) { sttOptionsDrawTextChunk(lpdis->hDC, TranslateT("Scope:"), &rc); - rc.left = prefix + width * 0; + rc.left = prefix; ImageList_Draw(hIml, 0, lpdis->hDC, rc.left, (rc.top+rc.bottom-16)/2, ILD_TRANSPARENT); rc.left += 20; sttOptionsDrawTextChunk(lpdis->hDC, TranslateT("System"), &rc); - rc.left = prefix + width * 1; + rc.left = prefix + width; ImageList_Draw(hIml, 1, lpdis->hDC, rc.left, (rc.top+rc.bottom-16)/2, ILD_TRANSPARENT); rc.left += 20; sttOptionsDrawTextChunk(lpdis->hDC, TranslateT("Miranda"), &rc); -- cgit v1.2.3