From 1d9fd398b75a5a6eca9d40db2e2abb60c96ebc7d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 17 May 2013 19:23:37 +0000 Subject: some more fixes for MS_DB_CONTACT_DELETE & loops git-svn-id: http://svn.miranda-ng.org/main/trunk@4710 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/NewsAggregator/Src/Options.cpp | 30 ++++++++++++++---------------- plugins/StopSpamPlus/src/services.cpp | 16 +++++++--------- plugins/TabSRMM/src/msgdialog.cpp | 7 +++---- 3 files changed, 24 insertions(+), 29 deletions(-) (limited to 'plugins') diff --git a/plugins/NewsAggregator/Src/Options.cpp b/plugins/NewsAggregator/Src/Options.cpp index 697d5d8bc7..6a18c492bc 100644 --- a/plugins/NewsAggregator/Src/Options.cpp +++ b/plugins/NewsAggregator/Src/Options.cpp @@ -491,23 +491,21 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA ListView_GetItemText(hwndList, sel, 1, url, MAX_PATH); for (HANDLE hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) { - DBVARIANT dbNick = {0}; - if (db_get_ts(hContact, MODULE, "Nick", &dbNick)) + ptrT dbNick( db_get_tsa(hContact, MODULE, "Nick")); + if (dbNick == NULL) break; - else if (lstrcmp(dbNick.ptszVal, nick) == 0) { - db_free(&dbNick); - DBVARIANT dbURL = {0}; - if (db_get_ts(hContact, MODULE, "URL", &dbURL)) - break; - else if (lstrcmp(dbURL.ptszVal, url) == 0) { - db_free(&dbURL); - CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0); - ListView_DeleteItem(hwndList, sel); - break; - } - db_free(&dbURL); - } - db_free(&dbNick); + if ( lstrcmp(dbNick, nick)) + continue; + + ptrT dbURL( db_get_tsa(hContact, MODULE, "URL")); + if (dbURL == NULL) + break; + if ( lstrcmp(dbURL, url)) + continue; + + CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0); + ListView_DeleteItem(hwndList, sel); + break; } } return FALSE; diff --git a/plugins/StopSpamPlus/src/services.cpp b/plugins/StopSpamPlus/src/services.cpp index 43470f8de7..c6ea59fe31 100644 --- a/plugins/StopSpamPlus/src/services.cpp +++ b/plugins/StopSpamPlus/src/services.cpp @@ -22,19 +22,17 @@ INT_PTR IsContactPassed(WPARAM wParam, LPARAM /*lParam*/) INT_PTR RemoveTempContacts(WPARAM wParam,LPARAM lParam) { - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - DBVARIANT dbv = { 0 }; - if ( db_get_ts( hContact, "CList", "Group", &dbv )) - dbv.ptszVal = NULL; + for (HANDLE hContact = db_find_first(); hContact; ) { + HANDLE hNext = db_find_next(hContact); + ptrT szGroup( db_get_tsa( hContact, "CList", "Group")); - if ( db_get_b(hContact, "CList", "NotOnList", 0) || db_get_b(hContact, "CList", "Hidden", 0 ) || (dbv.ptszVal != NULL && (_tcsstr(dbv.ptszVal, _T("Not In List")) || _tcsstr(dbv.ptszVal, TranslateT("Not In List"))))) { + if ( db_get_b(hContact, "CList", "NotOnList", 0) || db_get_b(hContact, "CList", "Hidden", 0 ) || (szGroup != NULL && (_tcsstr(szGroup, _T("Not In List")) || _tcsstr(szGroup, TranslateT("Not In List"))))) { char *szProto = GetContactProto(hContact); - if ( szProto != NULL ) { + if (szProto != NULL) { // Check if protocol uses server side lists DWORD caps = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0); if ( caps & PF1_SERVERCLIST ) { - int status; - status = CallProtoService(szProto, PS_GETSTATUS, 0, 0); + int status = CallProtoService(szProto, PS_GETSTATUS, 0, 0); if (status == ID_STATUS_OFFLINE || (status >= ID_STATUS_CONNECTING && status < ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES)) // Set a flag so we remember to delete the contact when the protocol goes online the next time db_set_b( hContact, "CList", "Delete", 1 ); @@ -44,7 +42,7 @@ INT_PTR RemoveTempContacts(WPARAM wParam,LPARAM lParam) } } - db_free( &dbv ); + hContact = hNext; } int hGroup = 1; diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index d8f8d03799..3e109d2a20 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -3763,11 +3763,10 @@ quote_from_last: if (m_pContainer->dwFlags & CNT_SIDEBAR) m_pContainer->SideBar->removeSession(dat); dat->cache->setWindowData(); - if (dat->cache->isValid() && !dat->fIsReattach && dat->hContact && M->GetByte("deletetemp", 0)) { - if (M->GetByte(dat->hContact, "CList", "NotOnList", 0)) { + if (dat->cache->isValid() && !dat->fIsReattach && dat->hContact && M->GetByte("deletetemp", 0)) + if (M->GetByte(dat->hContact, "CList", "NotOnList", 0)) CallService(MS_DB_CONTACT_DELETE, (WPARAM)dat->hContact, 0); - } - } + delete dat->Panel; free(dat); } -- cgit v1.2.3