From 3dc0d9b0b7c30ea2f77d74c4ce5b6ccd67bd525c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 9 Apr 2013 21:40:22 +0000 Subject: - the kernel filters out contacts by proto names much faster than a plugin; - database cycles simplified git-svn-id: http://svn.miranda-ng.org/main/trunk@4404 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/AVS/src/options.cpp | 10 +- plugins/Clist_modern/src/modern_viewmodebar.cpp | 24 ++- plugins/Clist_nicer/src/extBackg.cpp | 97 ++++++----- plugins/MetaContacts/src/meta_main.cpp | 21 +-- plugins/NewsAggregator/Src/Options.cpp | 214 ++++++++++++------------ plugins/NewsAggregator/Src/Services.cpp | 21 +-- plugins/NewsAggregator/Src/Update.cpp | 14 +- plugins/NewsAggregator/Src/Utils.cpp | 38 ++--- plugins/Non-IM Contact/src/files.cpp | 47 +++--- plugins/Non-IM Contact/src/timer.cpp | 12 +- plugins/QuickContacts/src/quickcontacts.cpp | 124 +++++++------- plugins/Quotes/src/ImportExport.cpp | 2 +- plugins/Quotes/src/QuotesProviders.cpp | 2 +- plugins/Scriver/src/chat/clist.cpp | 26 +-- plugins/SeenPlugin/src/utils.cpp | 12 +- plugins/SimpleStatusMsg/src/main.cpp | 7 +- plugins/StopSpamMod/src/utilities.cpp | 23 +-- plugins/StopSpamPlus/src/services.cpp | 6 +- plugins/TabSRMM/src/chat/clist.cpp | 22 ++- plugins/TabSRMM/src/typingnotify.cpp | 6 - plugins/TipperYM/src/options.cpp | 92 +++++----- plugins/TipperYM/src/popwin.cpp | 62 ++++--- plugins/Weather/src/weather_contacts.cpp | 32 ++-- plugins/Weather/src/weather_data.cpp | 83 +++++---- plugins/Weather/src/weather_mwin.cpp | 22 +-- plugins/Weather/src/weather_update.cpp | 10 +- plugins/YAMN/src/proto/pop3/pop3comm.cpp | 28 ++-- 27 files changed, 486 insertions(+), 571 deletions(-) (limited to 'plugins') diff --git a/plugins/AVS/src/options.cpp b/plugins/AVS/src/options.cpp index 4cd2748660..f151f8c370 100644 --- a/plugins/AVS/src/options.cpp +++ b/plugins/AVS/src/options.cpp @@ -429,13 +429,9 @@ INT_PTR CALLBACK DlgProcOptionsProtos(HWND hwndDlg, UINT msg, WPARAM wParam, LPA BOOL oldVal = db_get_b(NULL, AVS_MODULE, szProto, 1); BOOL newVal = ListView_GetCheckState(hwndList, i); - if (oldVal && !newVal) { - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - char *szContactProto = GetContactProto(hContact); - if (szContactProto != NULL && !strcmp(szContactProto, szProto)) - DeleteAvatarFromCache(hContact, TRUE); - } - } + if (oldVal && !newVal) + for (HANDLE hContact = db_find_first(szProto); hContact; hContact = db_find_next(hContact, szProto)) + DeleteAvatarFromCache(hContact, TRUE); if (newVal) db_set_b(NULL, AVS_MODULE, szProto, 1); diff --git a/plugins/Clist_modern/src/modern_viewmodebar.cpp b/plugins/Clist_modern/src/modern_viewmodebar.cpp index 79f399a174..de73bccc46 100644 --- a/plugins/Clist_modern/src/modern_viewmodebar.cpp +++ b/plugins/Clist_modern/src/modern_viewmodebar.cpp @@ -474,19 +474,17 @@ void SaveState() dwGlobalMask = GetMaskForItem(hInfoItem); for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { hItem = (HANDLE)SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0); - if (hItem) - { - if (SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) - { - dwLocalMask = GetMaskForItem(hItem); - db_set_dw(hContact, CLVM_MODULE, szModeName, MAKELONG(1, (unsigned short)dwLocalMask)); - stickies++; - } - else - { - if (db_get_dw(hContact, CLVM_MODULE, szModeName, 0)) - db_set_dw(hContact, CLVM_MODULE, szModeName, 0); - } + if (hItem == NULL) + continue; + + if (SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) { + dwLocalMask = GetMaskForItem(hItem); + db_set_dw(hContact, CLVM_MODULE, szModeName, MAKELONG(1, (unsigned short)dwLocalMask)); + stickies++; + } + else { + if (db_get_dw(hContact, CLVM_MODULE, szModeName, 0)) + db_set_dw(hContact, CLVM_MODULE, szModeName, 0); } } diff --git a/plugins/Clist_nicer/src/extBackg.cpp b/plugins/Clist_nicer/src/extBackg.cpp index 7e4f351407..b9a69e5e86 100644 --- a/plugins/Clist_nicer/src/extBackg.cpp +++ b/plugins/Clist_nicer/src/extBackg.cpp @@ -1223,7 +1223,7 @@ void IMG_LoadItems() void LoadPerContactSkins(TCHAR *tszFileName) { - char *p, *szProto, *uid, szItem[100]; + char *p, szItem[100]; char *szSections = reinterpret_cast(malloc(3002)); StatusItems_t *items = NULL, *this_item; int i = 1; @@ -1261,58 +1261,57 @@ void LoadPerContactSkins(TCHAR *tszFileName) if (items) { for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - char UIN[40]; - int j; + char *szProto = GetContactProto(hContact); + if (szProto == NULL) + continue; - szProto = GetContactProto(hContact); - if (szProto) { - uid = (char *)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); - if ((INT_PTR) uid != CALLSERVICE_NOTFOUND && uid != NULL) { - DBVARIANT dbv = {0}; + char *uid = (char *)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); + if ((INT_PTR) uid != CALLSERVICE_NOTFOUND && uid != NULL) { + DBVARIANT dbv = {0}; + db_get(hContact, szProto, uid, &dbv); - db_get(hContact, szProto, uid, &dbv); - switch(dbv.type) { - case DBVT_DWORD: - mir_snprintf(UIN, 40, "%d", dbv.dVal); - break; - case DBVT_ASCIIZ: - mir_snprintf(UIN, 40, "%s", dbv.pszVal); - db_free(&dbv); - break; - default: - UIN[0] = 0; + char UIN[40]; + switch(dbv.type) { + case DBVT_DWORD: + mir_snprintf(UIN, 40, "%d", dbv.dVal); + break; + case DBVT_ASCIIZ: + mir_snprintf(UIN, 40, "%s", dbv.pszVal); + db_free(&dbv); + break; + default: + UIN[0] = 0; + break; + } + + int j; + for (j = 0; j < i - 1; j++) { + if ( !strcmp(szProto, items[j].szName) && !strcmp(UIN, items[j].szDBname) && + lstrlenA(szProto) == lstrlenA(items[j].szName) && lstrlenA(UIN) == lstrlenA(items[j].szDBname)) { + cfg::writeDword(hContact, "EXTBK", "TEXT", items[j].TEXTCOLOR); + cfg::writeDword(hContact, "EXTBK", "COLOR1", items[j].COLOR); + cfg::writeDword(hContact, "EXTBK", "COLOR2", items[j].COLOR2); + cfg::writeByte(hContact, "EXTBK", "ALPHA", (BYTE)items[j].ALPHA); + + cfg::writeByte(hContact, "EXTBK", "LEFT", (BYTE)items[j].MARGIN_LEFT); + cfg::writeByte(hContact, "EXTBK", "RIGHT", (BYTE)items[j].MARGIN_RIGHT); + cfg::writeByte(hContact, "EXTBK", "TOP", (BYTE)items[j].MARGIN_TOP); + cfg::writeByte(hContact, "EXTBK", "BOTTOM", (BYTE)items[j].MARGIN_BOTTOM); + + cfg::writeByte(hContact, "EXTBK", "TRANS", items[j].COLOR2_TRANSPARENT); + cfg::writeDword(hContact, "EXTBK", "BDR", items[j].BORDERSTYLE); + + cfg::writeByte(hContact, "EXTBK", "CORNER", items[j].CORNER); + cfg::writeByte(hContact, "EXTBK", "GRAD", items[j].GRADIENT); + cfg::writeByte(hContact, "EXTBK", "TRANS", items[j].COLOR2_TRANSPARENT); + + cfg::writeByte(hContact, "EXTBK", "VALID", 1); break; } - for (j = 0; j < i - 1; j++) { - if ( !strcmp(szProto, items[j].szName) && !strcmp(UIN, items[j].szDBname) - && lstrlenA(szProto) == lstrlenA(items[j].szName) && lstrlenA(UIN) == lstrlenA(items[j].szDBname)) { - - //_DebugPopup(hContact, "Found: %s, %s", szProto, UIN); - cfg::writeDword(hContact, "EXTBK", "TEXT", items[j].TEXTCOLOR); - cfg::writeDword(hContact, "EXTBK", "COLOR1", items[j].COLOR); - cfg::writeDword(hContact, "EXTBK", "COLOR2", items[j].COLOR2); - cfg::writeByte(hContact, "EXTBK", "ALPHA", (BYTE)items[j].ALPHA); - - cfg::writeByte(hContact, "EXTBK", "LEFT", (BYTE)items[j].MARGIN_LEFT); - cfg::writeByte(hContact, "EXTBK", "RIGHT", (BYTE)items[j].MARGIN_RIGHT); - cfg::writeByte(hContact, "EXTBK", "TOP", (BYTE)items[j].MARGIN_TOP); - cfg::writeByte(hContact, "EXTBK", "BOTTOM", (BYTE)items[j].MARGIN_BOTTOM); - - cfg::writeByte(hContact, "EXTBK", "TRANS", items[j].COLOR2_TRANSPARENT); - cfg::writeDword(hContact, "EXTBK", "BDR", items[j].BORDERSTYLE); - - cfg::writeByte(hContact, "EXTBK", "CORNER", items[j].CORNER); - cfg::writeByte(hContact, "EXTBK", "GRAD", items[j].GRADIENT); - cfg::writeByte(hContact, "EXTBK", "TRANS", items[j].COLOR2_TRANSPARENT); - - cfg::writeByte(hContact, "EXTBK", "VALID", 1); - break; - } - } - if (j == i - 1) { // disable the db copy if it has been disabled in the skin .ini file - if (cfg::getByte(hContact, "EXTBK", "VALID", 0)) - cfg::writeByte(hContact, "EXTBK", "VALID", 0); - } + } + if (j == i - 1) { // disable the db copy if it has been disabled in the skin .ini file + if (cfg::getByte(hContact, "EXTBK", "VALID", 0)) + cfg::writeByte(hContact, "EXTBK", "VALID", 0); } } } diff --git a/plugins/MetaContacts/src/meta_main.cpp b/plugins/MetaContacts/src/meta_main.cpp index 3361bdc475..023bca8a82 100644 --- a/plugins/MetaContacts/src/meta_main.cpp +++ b/plugins/MetaContacts/src/meta_main.cpp @@ -151,18 +151,15 @@ extern "C" __declspec(dllexport) int Load(void) CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)(META_PROTO "/WindowOpen")); //set all contacts to 'offline', and initialize subcontact counter for db consistency check - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - char *proto = GetContactProto(hContact); - if (proto && !lstrcmpA( META_PROTO, proto)) { - db_set_w(hContact, META_PROTO, "Status", ID_STATUS_OFFLINE); - db_set_dw(hContact, META_PROTO, "IdleTS", 0); - db_set_b(hContact, META_PROTO, "ContactCountCheck", 0); - - // restore any saved defaults that might have remained if miranda was closed or crashed while a convo was happening - if (db_get_dw(hContact, META_PROTO, "SavedDefault", (DWORD)-1) != (DWORD)-1) { - db_set_dw(hContact, META_PROTO, "Default", db_get_dw(hContact, META_PROTO, "SavedDefault", 0)); - db_set_dw(hContact, META_PROTO, "SavedDefault", (DWORD)-1); - } + for (HANDLE hContact = db_find_first(META_PROTO); hContact; hContact = db_find_next(hContact, META_PROTO)) { + db_set_w(hContact, META_PROTO, "Status", ID_STATUS_OFFLINE); + db_set_dw(hContact, META_PROTO, "IdleTS", 0); + db_set_b(hContact, META_PROTO, "ContactCountCheck", 0); + + // restore any saved defaults that might have remained if miranda was closed or crashed while a convo was happening + if (db_get_dw(hContact, META_PROTO, "SavedDefault", (DWORD)-1) != (DWORD)-1) { + db_set_dw(hContact, META_PROTO, "Default", db_get_dw(hContact, META_PROTO, "SavedDefault", 0)); + db_set_dw(hContact, META_PROTO, "SavedDefault", (DWORD)-1); } } diff --git a/plugins/NewsAggregator/Src/Options.cpp b/plugins/NewsAggregator/Src/Options.cpp index 44a3a4a5a7..697d5d8bc7 100644 --- a/plugins/NewsAggregator/Src/Options.cpp +++ b/plugins/NewsAggregator/Src/Options.cpp @@ -154,49 +154,47 @@ INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP SendDlgItemMessage(hwndDlg, IDC_TIMEOUT_VALUE_SPIN, UDM_SETRANGE32, 0, 999); HANDLE hContact; - for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - if (IsMyContact(hContact)) { - DBVARIANT dbNick = {0}; - if (db_get_ts(hContact, MODULE, "Nick", &dbNick)) + for (hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) { + DBVARIANT dbNick = {0}; + if (db_get_ts(hContact, MODULE, "Nick", &dbNick)) + continue; + else if (lstrcmp(dbNick.ptszVal, SelItem.nick) == 0) { + db_free(&dbNick); + DBVARIANT dbURL = {0}; + if (db_get_ts(hContact, MODULE, "URL", &dbURL)) continue; - else if (lstrcmp(dbNick.ptszVal, SelItem.nick) == 0) { - db_free(&dbNick); - DBVARIANT dbURL = {0}; - if (db_get_ts(hContact, MODULE, "URL", &dbURL)) - continue; - else if (lstrcmp(dbURL.ptszVal, SelItem.url) == 0) { - db_free(&dbURL); - nSelItem->hContact = hContact; - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG)nSelItem); - SetDlgItemText(hwndDlg, IDC_FEEDURL, SelItem.url); - SetDlgItemText(hwndDlg, IDC_FEEDTITLE, SelItem.nick); - SetDlgItemInt(hwndDlg, IDC_CHECKTIME, db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME), TRUE); - DBVARIANT dbMsg = {0}; - if (!db_get_ts(hContact, MODULE, "MsgFormat", &dbMsg)) { - SetDlgItemText(hwndDlg, IDC_TAGSEDIT, dbMsg.ptszVal); - db_free(&dbMsg); + else if (lstrcmp(dbURL.ptszVal, SelItem.url) == 0) { + db_free(&dbURL); + nSelItem->hContact = hContact; + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG)nSelItem); + SetDlgItemText(hwndDlg, IDC_FEEDURL, SelItem.url); + SetDlgItemText(hwndDlg, IDC_FEEDTITLE, SelItem.nick); + SetDlgItemInt(hwndDlg, IDC_CHECKTIME, db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME), TRUE); + DBVARIANT dbMsg = {0}; + if (!db_get_ts(hContact, MODULE, "MsgFormat", &dbMsg)) { + SetDlgItemText(hwndDlg, IDC_TAGSEDIT, dbMsg.ptszVal); + db_free(&dbMsg); + } + if (db_get_b(hContact, MODULE, "UseAuth", 0)) { + CheckDlgButton(hwndDlg, IDC_USEAUTH, BST_CHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), TRUE); + EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE); + DBVARIANT dbLogin = {0}; + if (!db_get_ts(hContact, MODULE, "Login", &dbLogin)) { + SetDlgItemText(hwndDlg, IDC_LOGIN, dbLogin.ptszVal); + db_free(&dbLogin); } - if (db_get_b(hContact, MODULE, "UseAuth", 0)) { - CheckDlgButton(hwndDlg, IDC_USEAUTH, BST_CHECKED); - EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), TRUE); - EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE); - DBVARIANT dbLogin = {0}; - if (!db_get_ts(hContact, MODULE, "Login", &dbLogin)) { - SetDlgItemText(hwndDlg, IDC_LOGIN, dbLogin.ptszVal); - db_free(&dbLogin); - } - DBVARIANT dbPass = {0}; - if (!db_get_ts(hContact, MODULE, "Password", &dbPass)) { - SetDlgItemText(hwndDlg, IDC_PASSWORD, dbPass.ptszVal); - db_free(&dbPass); - } + DBVARIANT dbPass = {0}; + if (!db_get_ts(hContact, MODULE, "Password", &dbPass)) { + SetDlgItemText(hwndDlg, IDC_PASSWORD, dbPass.ptszVal); + db_free(&dbPass); } - break; } - db_free(&dbURL); + break; } - db_free(&dbNick); + db_free(&dbURL); } + db_free(&dbNick); } WindowList_Add(hChangeFeedDlgList, hwndDlg, hContact); Utils_RestoreWindowPositionNoSize(hwndDlg, hContact, MODULE, "ChangeDlg"); @@ -492,26 +490,24 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA ListView_GetItemText(hwndList, sel, 0, nick, MAX_PATH); ListView_GetItemText(hwndList, sel, 1, url, MAX_PATH); - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - if(IsMyContact(hContact)) { - DBVARIANT dbNick = {0}; - if (db_get_ts(hContact, MODULE, "Nick", &dbNick)) + 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)) + 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(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; - } + 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(&dbNick); + db_free(&dbURL); } + db_free(&dbNick); } } return FALSE; @@ -714,57 +710,55 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA HXML title = xi.addChild(header, _T("title"), _T("Miranda NG NewsAggregator plugin export")); header = xi.addChild(hXml, _T("body"), NULL); - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - if (IsMyContact(hContact)) { - TCHAR *title = NULL, *url = NULL, *siteurl = NULL, *group = NULL; - DBVARIANT dbv = {0}; - if (!db_get_ts(hContact, MODULE, "Nick", &dbv)) { - title = mir_tstrdup(dbv.ptszVal); - db_free(&dbv); - } - if (!db_get_ts(hContact, MODULE, "URL", &dbv)) { - url = mir_tstrdup(dbv.ptszVal); - db_free(&dbv); - } - if (!db_get_ts(hContact, MODULE, "Homepage", &dbv)) { - siteurl = mir_tstrdup(dbv.ptszVal); - db_free(&dbv); - } - if (!db_get_ts(hContact, "CList", "Group", &dbv)) { - group = mir_tstrdup(dbv.ptszVal); - db_free(&dbv); - } - HXML elem = header; - if (group) + for (HANDLE hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) { + TCHAR *title = NULL, *url = NULL, *siteurl = NULL, *group = NULL; + DBVARIANT dbv = {0}; + if (!db_get_ts(hContact, MODULE, "Nick", &dbv)) { + title = mir_tstrdup(dbv.ptszVal); + db_free(&dbv); + } + if (!db_get_ts(hContact, MODULE, "URL", &dbv)) { + url = mir_tstrdup(dbv.ptszVal); + db_free(&dbv); + } + if (!db_get_ts(hContact, MODULE, "Homepage", &dbv)) { + siteurl = mir_tstrdup(dbv.ptszVal); + db_free(&dbv); + } + if (!db_get_ts(hContact, "CList", "Group", &dbv)) { + group = mir_tstrdup(dbv.ptszVal); + db_free(&dbv); + } + HXML elem = header; + if (group) + { + TCHAR *section = _tcstok(group, _T("\\")); + while (section != NULL) { - TCHAR *section = _tcstok(group, _T("\\")); - while (section != NULL) + HXML existgroup = xi.getChildByAttrValue(header, _T("outline"), _T("title"), section); + if ( !existgroup) { - HXML existgroup = xi.getChildByAttrValue(header, _T("outline"), _T("title"), section); - if ( !existgroup) - { - elem = xi.addChild(elem, _T("outline"), NULL); - xi.addAttr(elem, _T("title"), section); - xi.addAttr(elem, _T("text"), section); - } else { - elem = existgroup; - } - section = _tcstok(NULL, _T("\\")); + elem = xi.addChild(elem, _T("outline"), NULL); + xi.addAttr(elem, _T("title"), section); + xi.addAttr(elem, _T("text"), section); + } else { + elem = existgroup; } - elem = xi.addChild(elem, _T("outline"), NULL); - } else - elem = xi.addChild(elem, _T("outline"), NULL); - xi.addAttr(elem, _T("text"), title); - xi.addAttr(elem, _T("title"), title); - xi.addAttr(elem, _T("type"), _T("rss")); - xi.addAttr(elem, _T("xmlUrl"), url); - xi.addAttr(elem, _T("htmlUrl"), siteurl); - - mir_free(title); - mir_free(url); - mir_free(siteurl); - mir_free(group); - } + section = _tcstok(NULL, _T("\\")); + } + elem = xi.addChild(elem, _T("outline"), NULL); + } else + elem = xi.addChild(elem, _T("outline"), NULL); + xi.addAttr(elem, _T("text"), title); + xi.addAttr(elem, _T("title"), title); + xi.addAttr(elem, _T("type"), _T("rss")); + xi.addAttr(elem, _T("xmlUrl"), url); + xi.addAttr(elem, _T("htmlUrl"), siteurl); + + mir_free(title); + mir_free(url); + mir_free(siteurl); + mir_free(group); } xi.toFile(hXml, FileName, 1); xi.destroyNode(hXml); @@ -786,18 +780,16 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA { db_set_b(NULL, MODULE, "StartupRetrieve", IsDlgButtonChecked(hwndDlg, IDC_STARTUPRETRIEVE)); int i = 0; - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - if(IsMyContact(hContact)) { - db_set_b(hContact, MODULE, "CheckState", ListView_GetCheckState(hwndList, i)); - if (!ListView_GetCheckState(hwndList, i)) - db_set_b(hContact, "CList", "Hidden", 1); - else - db_unset(hContact,"CList","Hidden"); - i += 1; - } + for (HANDLE hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) { + db_set_b(hContact, MODULE, "CheckState", ListView_GetCheckState(hwndList, i)); + if (!ListView_GetCheckState(hwndList, i)) + db_set_b(hContact, "CList", "Hidden", 1); + else + db_unset(hContact,"CList","Hidden"); + i += 1; } - break; } + break; case NM_DBLCLK: { diff --git a/plugins/NewsAggregator/Src/Services.cpp b/plugins/NewsAggregator/Src/Services.cpp index da1c899b86..43ecd6bd14 100644 --- a/plugins/NewsAggregator/Src/Services.cpp +++ b/plugins/NewsAggregator/Src/Services.cpp @@ -33,9 +33,8 @@ static void __cdecl WorkingThread(void* param) { int nStatus = (int)param; - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) - if(IsMyContact(hContact)) - SetContactStatus(hContact, nStatus); + for (HANDLE hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) + SetContactStatus(hContact, nStatus); } int OnFoldersChanged(WPARAM, LPARAM) @@ -52,12 +51,10 @@ int NewsAggrInit(WPARAM wParam, LPARAM lParam) else lstrcpyn(tszRoot, VARST( _T("%miranda_userdata%\\Avatars\\"_T(DEFAULT_AVATARS_FOLDER))), SIZEOF(tszRoot)); - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - if(IsMyContact(hContact)) { - if (!db_get_b(NULL, MODULE, "StartupRetrieve", 1)) - db_set_dw(hContact, MODULE, "LastCheck", time(NULL)); - SetContactStatus(hContact, ID_STATUS_ONLINE); - } + for (HANDLE hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) { + if (!db_get_b(NULL, MODULE, "StartupRetrieve", 1)) + db_set_dw(hContact, MODULE, "LastCheck", time(NULL)); + SetContactStatus(hContact, ID_STATUS_ONLINE); } NetlibInit(); @@ -154,10 +151,10 @@ INT_PTR NewsAggrGetInfo(WPARAM wParam,LPARAM lParam) INT_PTR CheckAllFeeds(WPARAM wParam,LPARAM lParam) { - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - if (IsMyContact(hContact) && lParam && db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME)) + for (HANDLE hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) { + if (lParam && db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME)) UpdateListAdd(hContact); - else if (IsMyContact(hContact) && !lParam) + else if (!lParam) UpdateListAdd(hContact); } if (!ThreadRunning) diff --git a/plugins/NewsAggregator/Src/Update.cpp b/plugins/NewsAggregator/Src/Update.cpp index 7acc0373cc..c104a7d949 100644 --- a/plugins/NewsAggregator/Src/Update.cpp +++ b/plugins/NewsAggregator/Src/Update.cpp @@ -30,14 +30,12 @@ VOID CALLBACK timerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) // only run if it is not current updating and the auto update option is enabled if (!ThreadRunning && !Miranda_Terminated()) { BOOL HaveUpdates = FALSE; - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - if(IsMyContact(hContact)) { - if (db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME)) { - double diff = difftime(time(NULL), db_get_dw(hContact, MODULE, "LastCheck", 0)); - if (db_get_b(NULL, MODULE, "AutoUpdate", 1) != 0 && diff >= db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME) * 60) { - UpdateListAdd(hContact); - HaveUpdates = TRUE; - } + for (HANDLE hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) { + if (db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME)) { + double diff = difftime(time(NULL), db_get_dw(hContact, MODULE, "LastCheck", 0)); + if (db_get_b(NULL, MODULE, "AutoUpdate", 1) != 0 && diff >= db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME) * 60) { + UpdateListAdd(hContact); + HaveUpdates = TRUE; } } } diff --git a/plugins/NewsAggregator/Src/Utils.cpp b/plugins/NewsAggregator/Src/Utils.cpp index 745869e27d..5658a25c5f 100644 --- a/plugins/NewsAggregator/Src/Utils.cpp +++ b/plugins/NewsAggregator/Src/Utils.cpp @@ -240,27 +240,25 @@ VOID UpdateList(HWND hwndList) // Initialize LVITEM members that are common to all // items. int i = 0; - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - if (IsMyContact(hContact)) { - UpdateListFlag = TRUE; - lvI.mask = LVIF_TEXT; - lvI.iSubItem = 0; - DBVARIANT dbNick = {0}; - if (!db_get_ts(hContact, MODULE, "Nick", &dbNick)) { - lvI.pszText = dbNick.ptszVal; - lvI.iItem = i; - ListView_InsertItem(hwndList, &lvI); - lvI.iSubItem = 1; - DBVARIANT dbURL = {0}; - if (!db_get_ts(hContact, MODULE, "URL", &dbURL)) { - lvI.pszText = dbURL.ptszVal; - ListView_SetItem(hwndList, &lvI); - i += 1; - ListView_SetCheckState(hwndList, lvI.iItem, db_get_b(hContact, MODULE, "CheckState", 1)); - db_free(&dbURL); - } - db_free(&dbNick); + for (HANDLE hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) { + UpdateListFlag = TRUE; + lvI.mask = LVIF_TEXT; + lvI.iSubItem = 0; + DBVARIANT dbNick = {0}; + if (!db_get_ts(hContact, MODULE, "Nick", &dbNick)) { + lvI.pszText = dbNick.ptszVal; + lvI.iItem = i; + ListView_InsertItem(hwndList, &lvI); + lvI.iSubItem = 1; + DBVARIANT dbURL = {0}; + if (!db_get_ts(hContact, MODULE, "URL", &dbURL)) { + lvI.pszText = dbURL.ptszVal; + ListView_SetItem(hwndList, &lvI); + i += 1; + ListView_SetCheckState(hwndList, lvI.iItem, db_get_b(hContact, MODULE, "CheckState", 1)); + db_free(&dbURL); } + db_free(&dbNick); } } UpdateListFlag = FALSE; diff --git a/plugins/Non-IM Contact/src/files.cpp b/plugins/Non-IM Contact/src/files.cpp index cdf17aed7c..d559fc6df8 100644 --- a/plugins/Non-IM Contact/src/files.cpp +++ b/plugins/Non-IM Contact/src/files.cpp @@ -14,31 +14,28 @@ INT_PTR exportContacts(WPARAM wParam,LPARAM lParam) if (!file) return 0; - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - const char* proto = GetContactProto(hContact); - if (proto && !strcmp(proto, MODNAME)) { - int tmp; - char DBVar[1024]; - if (db_get_static(hContact, MODNAME, "Name", DBVar)) { - fprintf(file, "\r\n[Non-IM Contact]\r\nName=%s\r\n", DBVar); - if (db_get_static(hContact, MODNAME, "ProgramString", DBVar)) - fprintf(file, "ProgramString=%s\r\n", DBVar); - if (db_get_static(hContact, MODNAME, "ProgramParamString", DBVar)) - fprintf(file, "ProgramParamString=%s\r\n", DBVar); - if (db_get_static(hContact, MODNAME, "ToolTip", DBVar)) - fprintf(file, "ToolTip=%s\r\n", DBVar); - if (db_get_static(hContact, "CList", "Group", DBVar)) - fprintf(file, "Group=%s\r\n", DBVar); - if (tmp = db_get_w(hContact, MODNAME, "Icon", 40072)) - fprintf(file, "Icon=%d\r\n", tmp); - if (tmp = db_get_b(hContact, MODNAME, "UseTimer", 0)) - fprintf(file, "UseTimer=%d\r\n", tmp); - if (tmp = db_get_b(hContact, MODNAME, "Minutes", 1)) - fprintf(file, "Minutes=%d\r\n", tmp); - if (tmp = db_get_w(hContact, MODNAME, "Timer", 0)) - fprintf(file, "Timer=%d\r\n", tmp); - fprintf(file, "[/Non-IM Contact]\r\n"); - } + for (HANDLE hContact = db_find_first(MODNAME); hContact; hContact = db_find_next(hContact, MODNAME)) { + int tmp; + char DBVar[1024]; + if (db_get_static(hContact, MODNAME, "Name", DBVar)) { + fprintf(file, "\r\n[Non-IM Contact]\r\nName=%s\r\n", DBVar); + if (db_get_static(hContact, MODNAME, "ProgramString", DBVar)) + fprintf(file, "ProgramString=%s\r\n", DBVar); + if (db_get_static(hContact, MODNAME, "ProgramParamString", DBVar)) + fprintf(file, "ProgramParamString=%s\r\n", DBVar); + if (db_get_static(hContact, MODNAME, "ToolTip", DBVar)) + fprintf(file, "ToolTip=%s\r\n", DBVar); + if (db_get_static(hContact, "CList", "Group", DBVar)) + fprintf(file, "Group=%s\r\n", DBVar); + if (tmp = db_get_w(hContact, MODNAME, "Icon", 40072)) + fprintf(file, "Icon=%d\r\n", tmp); + if (tmp = db_get_b(hContact, MODNAME, "UseTimer", 0)) + fprintf(file, "UseTimer=%d\r\n", tmp); + if (tmp = db_get_b(hContact, MODNAME, "Minutes", 1)) + fprintf(file, "Minutes=%d\r\n", tmp); + if (tmp = db_get_w(hContact, MODNAME, "Timer", 0)) + fprintf(file, "Timer=%d\r\n", tmp); + fprintf(file, "[/Non-IM Contact]\r\n"); } } fclose(file); diff --git a/plugins/Non-IM Contact/src/timer.cpp b/plugins/Non-IM Contact/src/timer.cpp index 42e2b47df1..0abd79e458 100644 --- a/plugins/Non-IM Contact/src/timer.cpp +++ b/plugins/Non-IM Contact/src/timer.cpp @@ -40,13 +40,11 @@ void timerFunc(LPVOID di) } /* update all the contacts */ - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - if (!strcmp(MODNAME, GetContactProto(hContact))) { - int timer = db_get_w(hContact, MODNAME, "Timer", 15); - if (timer && !(timerCount % timer)) - if (db_get_static(hContact, MODNAME, "Name", text)) - replaceAllStrings(hContact); - } + for (HANDLE hContact = db_find_first(MODNAME); hContact; hContact = db_find_next(hContact, MODNAME)) { + int timer = db_get_w(hContact, MODNAME, "Timer", 15); + if (timer && !(timerCount % timer)) + if (db_get_static(hContact, MODNAME, "Name", text)) + replaceAllStrings(hContact); } } diff --git a/plugins/QuickContacts/src/quickcontacts.cpp b/plugins/QuickContacts/src/quickcontacts.cpp index 1a978df72b..d554ecf031 100644 --- a/plugins/QuickContacts/src/quickcontacts.cpp +++ b/plugins/QuickContacts/src/quickcontacts.cpp @@ -361,89 +361,89 @@ void LoadContacts(HWND hwndDlg, BOOL show_all) for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { char *pszProto = GetContactProto(hContact); - if(pszProto != NULL) + if(pszProto == NULL) + continue; + + // Get meta + HANDLE hMeta = NULL; + if (metacontactsEnabled) { - // Get meta - HANDLE hMeta = NULL; - if (metacontactsEnabled) - { - if ((!show_all && opts.hide_subcontacts) || opts.group_append) - hMeta = (HANDLE) CallService(MS_MC_GETMETACONTACT, (WPARAM)hContact, 0); - } - else - { - if (metacontacts_proto != NULL && strcmp(metacontacts_proto, pszProto) == 0) - continue; - } + if ((!show_all && opts.hide_subcontacts) || opts.group_append) + hMeta = (HANDLE) CallService(MS_MC_GETMETACONTACT, (WPARAM)hContact, 0); + } + else + { + if (metacontacts_proto != NULL && strcmp(metacontacts_proto, pszProto) == 0) + continue; + } - if (!show_all) + if (!show_all) + { + // Check if is offline and have to show + if (GetStatus(hContact, pszProto) <= ID_STATUS_OFFLINE) { - // Check if is offline and have to show - if (GetStatus(hContact, pszProto) <= ID_STATUS_OFFLINE) - { - // See if has to show - char setting[128]; - mir_snprintf(setting, sizeof(setting), "ShowOffline%s", pszProto); + // See if has to show + char setting[128]; + mir_snprintf(setting, sizeof(setting), "ShowOffline%s", pszProto); - if (!db_get_b(NULL, MODULE_NAME, setting, FALSE)) - continue; + if (!db_get_b(NULL, MODULE_NAME, setting, FALSE)) + continue; - // Check if proto offline - else if (opts.hide_from_offline_proto - && CallProtoService(pszProto, PS_GETSTATUS, 0, 0) <= ID_STATUS_OFFLINE) - continue; + // Check if proto offline + else if (opts.hide_from_offline_proto + && CallProtoService(pszProto, PS_GETSTATUS, 0, 0) <= ID_STATUS_OFFLINE) + continue; - } + } - // Check if is subcontact - if (opts.hide_subcontacts && hMeta != NULL) - { - if (!opts.keep_subcontacts_from_offline) - continue; + // Check if is subcontact + if (opts.hide_subcontacts && hMeta != NULL) + { + if (!opts.keep_subcontacts_from_offline) + continue; - if (GetStatus(hMeta, metacontacts_proto) > ID_STATUS_OFFLINE) - { + if (GetStatus(hMeta, metacontacts_proto) > ID_STATUS_OFFLINE) + { + continue; + } + else + { + char setting[128]; + mir_snprintf(setting, sizeof(setting), "ShowOffline%s", metacontacts_proto); + if (db_get_b(NULL, MODULE_NAME, setting, FALSE)) continue; - } - else - { - char setting[128]; - mir_snprintf(setting, sizeof(setting), "ShowOffline%s", metacontacts_proto); - if (db_get_b(NULL, MODULE_NAME, setting, FALSE)) - continue; - } } } + } - // Add to list + // Add to list - // Get group - c_struct *contact = new c_struct(); + // Get group + c_struct *contact = new c_struct(); - if (opts.group_append) + if (opts.group_append) + { + DBVARIANT dbv; + if (db_get_ts(hMeta == NULL ? hContact : hMeta, "CList", "Group", &dbv) == 0) { - DBVARIANT dbv; - if (db_get_ts(hMeta == NULL ? hContact : hMeta, "CList", "Group", &dbv) == 0) - { - if (dbv.ptszVal != NULL) - lstrcpyn(contact->szgroup, dbv.ptszVal, SIZEOF(contact->szgroup)); + if (dbv.ptszVal != NULL) + lstrcpyn(contact->szgroup, dbv.ptszVal, SIZEOF(contact->szgroup)); - db_free(&dbv); - } + db_free(&dbv); } + } - // Make contact name - TCHAR *tmp = (TCHAR *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, GCDNF_TCHAR); - lstrcpyn(contact->szname, tmp, SIZEOF(contact->szname)); + // Make contact name + TCHAR *tmp = (TCHAR *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, GCDNF_TCHAR); + lstrcpyn(contact->szname, tmp, SIZEOF(contact->szname)); - PROTOACCOUNT *acc = ProtoGetAccount(pszProto); - if (acc != NULL) - lstrcpyn(contact->proto, acc->tszAccountName, SIZEOF(contact->proto)); + PROTOACCOUNT *acc = ProtoGetAccount(pszProto); + if (acc != NULL) + lstrcpyn(contact->proto, acc->tszAccountName, SIZEOF(contact->proto)); - contact->hcontact = hContact; - contacts.insert(contact); - } + contact->hcontact = hContact; + contacts.insert(contact); } SortArray(); diff --git a/plugins/Quotes/src/ImportExport.cpp b/plugins/Quotes/src/ImportExport.cpp index c8b7d9afbf..6ffaef1594 100644 --- a/plugins/Quotes/src/ImportExport.cpp +++ b/plugins/Quotes/src/ImportExport.cpp @@ -298,7 +298,7 @@ INT_PTR Quotes_Export(WPARAM wp,LPARAM lp) } else { - for(hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) + for(hContact = db_find_first(QUOTES_MODULE_NAME); hContact; hContact = db_find_next(hContact, QUOTES_MODULE_NAME)) { CQuotesProviders::TQuotesProviderPtr pProvider = pProviders->GetContactProviderPtr(hContact); if(pProvider) diff --git a/plugins/Quotes/src/QuotesProviders.cpp b/plugins/Quotes/src/QuotesProviders.cpp index 8047977983..cfab6903ab 100644 --- a/plugins/Quotes/src/QuotesProviders.cpp +++ b/plugins/Quotes/src/QuotesProviders.cpp @@ -60,7 +60,7 @@ void CQuotesProviders::InitProviders() const WORD nCurrentVersion = 17; WORD nVersion = db_get_w(NULL,QUOTES_MODULE_NAME,LAST_RUN_VERSION,1); - for(HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) + for(HANDLE hContact = db_find_first(QUOTES_MODULE_NAME); hContact; hContact = db_find_next(hContact, QUOTES_MODULE_NAME)) { TQuotesProviderPtr pProvider = GetContactProviderPtr(hContact); if(pProvider) diff --git a/plugins/Scriver/src/chat/clist.cpp b/plugins/Scriver/src/chat/clist.cpp index 91c3e3f78c..857380f87e 100644 --- a/plugins/Scriver/src/chat/clist.cpp +++ b/plugins/Scriver/src/chat/clist.cpp @@ -282,20 +282,20 @@ BOOL CList_AddEvent(HANDLE hContact, HICON Icon, HANDLE event, int type, TCHAR* return TRUE; } -HANDLE CList_FindRoom ( const char* pszModule, const TCHAR* pszRoom) +HANDLE CList_FindRoom(const char* pszModule, const TCHAR* pszRoom) { - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - char *szProto = GetContactProto(hContact); - if (szProto && !lstrcmpiA(szProto, pszModule)) { - if ( db_get_b( hContact, szProto, "ChatRoom", 0) != 0) { - DBVARIANT dbv; - if ( !db_get_ts( hContact, szProto, "ChatRoomID", &dbv)) { - if ( !lstrcmpi(dbv.ptszVal, pszRoom)) { - db_free(&dbv); - return hContact; - } - db_free(&dbv); - } } } + for (HANDLE hContact = db_find_first(pszModule); hContact; hContact = db_find_next(hContact, pszModule)) { + if ( !db_get_b( hContact, pszModule, "ChatRoom", 0)) + continue; + + DBVARIANT dbv; + if ( !db_get_ts( hContact, pszModule, "ChatRoomID", &dbv)) { + if ( !lstrcmpi(dbv.ptszVal, pszRoom)) { + db_free(&dbv); + return hContact; + } + db_free(&dbv); + } } return 0; } diff --git a/plugins/SeenPlugin/src/utils.cpp b/plugins/SeenPlugin/src/utils.cpp index 41c4271955..22f41290f9 100644 --- a/plugins/SeenPlugin/src/utils.cpp +++ b/plugins/SeenPlugin/src/utils.cpp @@ -653,20 +653,14 @@ int UpdateValues(WPARAM wparam,LPARAM lparam) static void cleanThread(void *param) { logthread_info* infoParam = (logthread_info*)param; + char *szProto = infoParam->sProtoName; // I hope in 10 secons all logged-in contacts will be listed if ( WaitForSingleObject(g_hShutdownEvent, 10000) == WAIT_TIMEOUT) { - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - char *contactProto = GetContactProto(hContact); - if (!contactProto) - continue; - - if ( strncmp(infoParam->sProtoName, contactProto, MAXMODULELABELLENGTH)) - continue; - + for (HANDLE hContact = db_find_first(szProto); hContact; hContact = db_find_next(hContact, szProto)) { WORD oldStatus = db_get_w(hContact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE) | 0x8000; if (oldStatus > ID_STATUS_OFFLINE) { - if (db_get_w(hContact,contactProto,"Status",ID_STATUS_OFFLINE)==ID_STATUS_OFFLINE){ + if (db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE)==ID_STATUS_OFFLINE){ db_set_w(hContact,S_MOD,"OldStatus",(WORD)(oldStatus|0x8000)); if (includeIdle)db_set_b(hContact,S_MOD,"OldIdle",(BYTE)((oldStatus&0x8000)?0:1)); db_set_w(hContact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE); diff --git a/plugins/SimpleStatusMsg/src/main.cpp b/plugins/SimpleStatusMsg/src/main.cpp index e3150943da..792367ff8c 100644 --- a/plugins/SimpleStatusMsg/src/main.cpp +++ b/plugins/SimpleStatusMsg/src/main.cpp @@ -1813,13 +1813,12 @@ static int OnICQStatusMsgRequest(WPARAM wParam, LPARAM lParam, LPARAM lMirParam) if (db_get_b(NULL, "SimpleStatusMsg", "NoUpdateOnICQReq", 1)) return 0; - char *szProto; + char *szProto = (char *)lMirParam; BOOL bContactFound = FALSE; HANDLE hContact; - for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - szProto = GetContactProto(hContact); - if (szProto != NULL && !strcmp(szProto, (char *)lMirParam) && db_get_dw(hContact, szProto, "UIN", 0) == (DWORD)lParam) { + for (hContact = db_find_first(szProto); hContact; hContact = db_find_next(hContact, szProto)) { + if (db_get_dw(hContact, szProto, "UIN", 0) == (DWORD)lParam) { bContactFound = TRUE; break; } diff --git a/plugins/StopSpamMod/src/utilities.cpp b/plugins/StopSpamMod/src/utilities.cpp index 4e31ebfbb3..c61b47f2d2 100755 --- a/plugins/StopSpamMod/src/utilities.cpp +++ b/plugins/StopSpamMod/src/utilities.cpp @@ -310,13 +310,10 @@ void CleanProtocolTmpThread(std::string proto) } std::list contacts; - for(HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - char *proto_tmp = GetContactProto(hContact); - if(proto_tmp) - if(!strcmp(proto.c_str(), proto_tmp)) - if(db_get_b(hContact, "CList", "NotOnList", 0)|| (_T("Not In List")== DBGetContactSettingStringPAN(hContact,"CList","Group",_T("")))) - contacts.push_back(hContact); - } + for(HANDLE hContact = db_find_first(proto.c_str()); hContact; hContact = db_find_next(hContact, proto.c_str())) + if(db_get_b(hContact, "CList", "NotOnList", 0)|| (_T("Not In List")== DBGetContactSettingStringPAN(hContact,"CList","Group",_T("")))) + contacts.push_back(hContact); + boost::this_thread::sleep(boost::posix_time::seconds(5)); clean_mutex.lock(); std::list::iterator end = contacts.end(); @@ -340,14 +337,10 @@ void CleanProtocolExclThread(std::string proto) } std::list contacts; - for(HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) - { - char *proto_tmp = GetContactProto(hContact); - if(proto_tmp) - if(!strcmp(proto.c_str(), proto_tmp)) - if(db_get_b(hContact, "CList", "NotOnList", 0) && db_get_b(hContact, pluginName, "Excluded", 0)) - contacts.push_back(hContact); - } + for(HANDLE hContact = db_find_first(proto.c_str()); hContact; hContact = db_find_next(hContact, proto.c_str())) + if(db_get_b(hContact, "CList", "NotOnList", 0) && db_get_b(hContact, pluginName, "Excluded", 0)) + contacts.push_back(hContact); + boost::this_thread::sleep(boost::posix_time::seconds(5)); clean_mutex.lock(); std::list::iterator end = contacts.end(); diff --git a/plugins/StopSpamPlus/src/services.cpp b/plugins/StopSpamPlus/src/services.cpp index 21b77e14f4..43470f8de7 100644 --- a/plugins/StopSpamPlus/src/services.cpp +++ b/plugins/StopSpamPlus/src/services.cpp @@ -22,10 +22,7 @@ INT_PTR IsContactPassed(WPARAM wParam, LPARAM /*lParam*/) INT_PTR RemoveTempContacts(WPARAM wParam,LPARAM lParam) { - HANDLE hContact = db_find_first(); - while ( hContact ) { - HANDLE hNext = db_find_next(hContact); - + 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; @@ -48,7 +45,6 @@ INT_PTR RemoveTempContacts(WPARAM wParam,LPARAM lParam) } db_free( &dbv ); - hContact = hNext; } int hGroup = 1; diff --git a/plugins/TabSRMM/src/chat/clist.cpp b/plugins/TabSRMM/src/chat/clist.cpp index 483603b24d..cab020142b 100644 --- a/plugins/TabSRMM/src/chat/clist.cpp +++ b/plugins/TabSRMM/src/chat/clist.cpp @@ -291,19 +291,17 @@ BOOL CList_AddEvent(HANDLE hContact, HICON Icon, HANDLE event, int type, const T HANDLE CList_FindRoom(const char* pszModule, const TCHAR* pszRoom) { - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - char *szProto = GetContactProto(hContact); - if (szProto && !lstrcmpiA(szProto, pszModule)) { - if (M->GetByte(hContact, szProto, "ChatRoom", 0) != 0) { - DBVARIANT dbv; - if (!M->GetTString(hContact, szProto, "ChatRoomID", &dbv)) { - if (!lstrcmpi(dbv.ptszVal, pszRoom)) { - db_free(&dbv); - return hContact; - } - db_free(&dbv); - } + for (HANDLE hContact = db_find_first(pszModule); hContact; hContact = db_find_next(hContact, pszModule)) { + if ( !M->GetByte(hContact, pszModule, "ChatRoom", 0)) + continue; + + DBVARIANT dbv; + if (!M->GetTString(hContact, pszModule, "ChatRoomID", &dbv)) { + if (!lstrcmpi(dbv.ptszVal, pszRoom)) { + db_free(&dbv); + return hContact; } + db_free(&dbv); } } return 0; diff --git a/plugins/TabSRMM/src/typingnotify.cpp b/plugins/TabSRMM/src/typingnotify.cpp index 3bef236dce..1b13fb3fea 100644 --- a/plugins/TabSRMM/src/typingnotify.cpp +++ b/plugins/TabSRMM/src/typingnotify.cpp @@ -303,12 +303,6 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA case IDC_PREVIEW: if (PluginConfig.g_PopupAvail) { - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - char *szProto = GetContactProto(hContact); - if (szProto != NULL) - break; - } - POPUPDATAT ppd = { 0 }; for (i=0; i < 2; i++) { int notyping; diff --git a/plugins/TipperYM/src/options.cpp b/plugins/TipperYM/src/options.cpp index 84ad4272c8..f422396f33 100644 --- a/plugins/TipperYM/src/options.cpp +++ b/plugins/TipperYM/src/options.cpp @@ -2072,71 +2072,61 @@ INT_PTR CALLBACK DlgProcOptsSkin(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l INT_PTR CALLBACK DlgProcFavouriteContacts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - switch (msg) - { - case WM_INITDIALOG: - { - TranslateDialogDefault(hwndDlg); + switch (msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); - if (CallService(MS_CLUI_GETCAPS, 0, 0) & CLUIF_DISABLEGROUPS && !db_get_b(NULL, "CList", "UseGroups", SETTING_USEGROUPS_DEFAULT)) - SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETUSEGROUPS, (WPARAM) FALSE, 0); - else - SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETUSEGROUPS, (WPARAM) TRUE, 0); - - SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETHIDEEMPTYGROUPS, 1, 0); - SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETGREYOUTFLAGS, 0, 0); - SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETLEFTMARGIN, 2, 0); + if (CallService(MS_CLUI_GETCAPS, 0, 0) & CLUIF_DISABLEGROUPS && !db_get_b(NULL, "CList", "UseGroups", SETTING_USEGROUPS_DEFAULT)) + SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETUSEGROUPS, (WPARAM) FALSE, 0); + else + SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETUSEGROUPS, (WPARAM) TRUE, 0); + SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETHIDEEMPTYGROUPS, 1, 0); + SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETGREYOUTFLAGS, 0, 0); + SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETLEFTMARGIN, 2, 0); + { for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { HANDLE hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0); if (hItem && db_get_b(hContact, MODULE, "FavouriteContact", 0)) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM)hItem, 1); } - - CheckDlgButton(hwndDlg, IDC_CHK_HIDEOFFLINE, opt.iFavoriteContFlags & FAVCONT_HIDE_OFFLINE); - CheckDlgButton(hwndDlg, IDC_CHK_APPENDPROTO, opt.iFavoriteContFlags & FAVCONT_APPEND_PROTO); - - return TRUE; } - case WM_COMMAND: - { - switch(LOWORD(wParam)) - { - case IDC_BTN_OK: - { - BYTE isChecked; - int count = 0; + CheckDlgButton(hwndDlg, IDC_CHK_HIDEOFFLINE, opt.iFavoriteContFlags & FAVCONT_HIDE_OFFLINE); + CheckDlgButton(hwndDlg, IDC_CHK_APPENDPROTO, opt.iFavoriteContFlags & FAVCONT_APPEND_PROTO); + return TRUE; - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - HANDLE hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0); - if (hItem) - { - isChecked = (BYTE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM)hItem, 0); - db_set_b(hContact, MODULE, "FavouriteContact", isChecked); - if (isChecked) count++; - } + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDC_BTN_OK: + { + BYTE isChecked; + int count = 0; + + for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { + HANDLE hItem = (HANDLE) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0); + if (hItem) { + isChecked = (BYTE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM)hItem, 0); + db_set_b(hContact, MODULE, "FavouriteContact", isChecked); + if (isChecked) count++; } - db_set_dw(0, MODULE, "FavouriteContactsCount", count); + } + db_set_dw(0, MODULE, "FavouriteContactsCount", count); - opt.iFavoriteContFlags = 0; - opt.iFavoriteContFlags |= IsDlgButtonChecked(hwndDlg, IDC_CHK_HIDEOFFLINE) ? FAVCONT_HIDE_OFFLINE : 0 | - IsDlgButtonChecked(hwndDlg, IDC_CHK_APPENDPROTO) ? FAVCONT_APPEND_PROTO : 0; + opt.iFavoriteContFlags = 0; + opt.iFavoriteContFlags |= IsDlgButtonChecked(hwndDlg, IDC_CHK_HIDEOFFLINE) ? FAVCONT_HIDE_OFFLINE : 0 | + IsDlgButtonChecked(hwndDlg, IDC_CHK_APPENDPROTO) ? FAVCONT_APPEND_PROTO : 0; - db_set_dw(0, MODULE, "FavContFlags", opt.iFavoriteContFlags); - } // fall through - case IDC_BTN_CANCEL: - { - DestroyWindow(hwndDlg); - break; - } - } - return TRUE; - } - case WM_CLOSE: - { + db_set_dw(0, MODULE, "FavContFlags", opt.iFavoriteContFlags); + } // fall through + case IDC_BTN_CANCEL: DestroyWindow(hwndDlg); - return TRUE; + break; } + return TRUE; + + case WM_CLOSE: + DestroyWindow(hwndDlg); + return TRUE; } return FALSE; diff --git a/plugins/TipperYM/src/popwin.cpp b/plugins/TipperYM/src/popwin.cpp index 290c1fcdd6..03682178bb 100644 --- a/plugins/TipperYM/src/popwin.cpp +++ b/plugins/TipperYM/src/popwin.cpp @@ -1551,13 +1551,10 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa if (dwItems & TRAYTIP_NUMCONTACTS) { int iCount = 0, iCountOnline = 0; - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - char *proto = GetContactProto(hContact); - if (proto && !strcmp(proto, pa->szModuleName)) { - if (db_get_w(hContact, proto, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) - iCountOnline++; - iCount++; - } + for (HANDLE hContact = db_find_first(pa->szModuleName); hContact; hContact = db_find_next(hContact, pa->szModuleName)) { + if (db_get_w(hContact, pa->szModuleName, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) + iCountOnline++; + iCount++; } mir_sntprintf(buff, 64, _T("(%d/%d)"), iCountOnline, iCount); } @@ -1679,32 +1676,33 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { if (db_get_b(hContact, MODULE, "FavouriteContact", 0)) { char *proto = GetContactProto(hContact); - if (proto) { - WORD wStatus = db_get_w(hContact, proto, "Status", ID_STATUS_OFFLINE); - WordToStatusDesc(hContact, proto, "Status", swzStatus, 256); - - if (wStatus != ID_STATUS_OFFLINE) - iCountOnline++; - - iCount++; - - if ( !(opt.iFavoriteContFlags & FAVCONT_HIDE_OFFLINE && wStatus == ID_STATUS_OFFLINE)) { - if (!bTitlePainted) { - AddRow(pwd, TranslateT("Fav. contacts"), NULL, NULL, false, false, !bFirstItem, true, NULL); - bFirstItem = false; - bTitlePainted = true; - } - - TCHAR *swzNick = (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR); - if (opt.iFavoriteContFlags & FAVCONT_APPEND_PROTO) { - TCHAR *swzProto = a2t(proto); - mir_sntprintf(swzName, 256, _T("%s (%s)"), swzNick, swzProto); - mir_free(swzProto); - } - else _tcscpy(swzName, swzNick); - - AddRow(pwd, swzName, swzStatus, NULL, false, false, false); + if (proto == NULL) + continue; + + WORD wStatus = db_get_w(hContact, proto, "Status", ID_STATUS_OFFLINE); + WordToStatusDesc(hContact, proto, "Status", swzStatus, 256); + + if (wStatus != ID_STATUS_OFFLINE) + iCountOnline++; + + iCount++; + + if ( !(opt.iFavoriteContFlags & FAVCONT_HIDE_OFFLINE && wStatus == ID_STATUS_OFFLINE)) { + if (!bTitlePainted) { + AddRow(pwd, TranslateT("Fav. contacts"), NULL, NULL, false, false, !bFirstItem, true, NULL); + bFirstItem = false; + bTitlePainted = true; } + + TCHAR *swzNick = (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR); + if (opt.iFavoriteContFlags & FAVCONT_APPEND_PROTO) { + TCHAR *swzProto = a2t(proto); + mir_sntprintf(swzName, 256, _T("%s (%s)"), swzNick, swzProto); + mir_free(swzProto); + } + else _tcscpy(swzName, swzNick); + + AddRow(pwd, swzName, swzStatus, NULL, false, false, false); } } } diff --git a/plugins/Weather/src/weather_contacts.cpp b/plugins/Weather/src/weather_contacts.cpp index a52727f002..2cc4187bf1 100644 --- a/plugins/Weather/src/weather_contacts.cpp +++ b/plugins/Weather/src/weather_contacts.cpp @@ -448,26 +448,24 @@ int ContactDeleted(WPARAM wParam, LPARAM lParam) // now the default station is deleted, try to get a new one // start looking for other weather stations - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - if (IsMyContact(hContact)) { - if ( !db_get_ts(hContact, WEATHERPROTONAME, "ID", &dbv)) { - // if the station is not a default station, set it as the new default station - // this is the first weather station encountered from the search - if ( _tcscmp(opt.Default, dbv.ptszVal)) { - _tcscpy(opt.Default, dbv.ptszVal); - opt.DefStn = hContact; + for (HANDLE hContact = db_find_first(WEATHERPROTONAME); hContact; hContact = db_find_next(hContact, WEATHERPROTONAME)) { + if ( !db_get_ts(hContact, WEATHERPROTONAME, "ID", &dbv)) { + // if the station is not a default station, set it as the new default station + // this is the first weather station encountered from the search + if ( _tcscmp(opt.Default, dbv.ptszVal)) { + _tcscpy(opt.Default, dbv.ptszVal); + opt.DefStn = hContact; + db_free(&dbv); + if ( !db_get_ts(hContact, WEATHERPROTONAME, "Nick", &dbv)) { + TCHAR str[255]; + mir_sntprintf(str, SIZEOF(str), TranslateT("%s is now the default weather station"), dbv.ptszVal); db_free(&dbv); - if ( !db_get_ts(hContact, WEATHERPROTONAME, "Nick", &dbv)) { - TCHAR str[255]; - mir_sntprintf(str, SIZEOF(str), TranslateT("%s is now the default weather station"), dbv.ptszVal); - db_free(&dbv); - MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK | MB_ICONINFORMATION); - } - db_set_ts(NULL, WEATHERPROTONAME, "Default", opt.Default); - return 0; // exit this function quickly + MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK | MB_ICONINFORMATION); } - db_free(&dbv); + db_set_ts(NULL, WEATHERPROTONAME, "Default", opt.Default); + return 0; // exit this function quickly } + db_free(&dbv); } } // got here if no more weather station left diff --git a/plugins/Weather/src/weather_data.cpp b/plugins/Weather/src/weather_data.cpp index 3f6ce3b0f2..bcf0e22139 100644 --- a/plugins/Weather/src/weather_data.cpp +++ b/plugins/Weather/src/weather_data.cpp @@ -124,54 +124,51 @@ void EraseAllInfo() HANDLE LastContact = NULL; DBVARIANT dbv; // loop through all contacts - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - // see if the contact is a weather contact - if ( IsMyContact(hContact)) { - db_set_w(hContact,WEATHERPROTONAME, "Status",ID_STATUS_OFFLINE); - db_set_w(hContact,WEATHERPROTONAME, "StatusIcon",ID_STATUS_OFFLINE); - db_unset(hContact, "CList", "MyHandle"); - // clear all data - if ( db_get_ts(hContact, WEATHERPROTONAME, "Nick", &dbv)) { - db_set_ts(hContact, WEATHERPROTONAME, "Nick", TranslateT("")); - db_set_s(hContact, WEATHERPROTONAME, "LastLog", "never"); - db_set_s(hContact, WEATHERPROTONAME, "LastCondition", "None"); - db_set_s(hContact, WEATHERPROTONAME, "LastTemperature", "None"); - } - else db_free(&dbv); - - DBDataManage(hContact, WDBM_REMOVE, 0, 0); - db_set_s(hContact, "UserInfo", "MyNotes", ""); - // reset update tag - db_set_b(hContact,WEATHERPROTONAME, "IsUpdated",FALSE); - // reset logging settings - if ( !db_get_ts(hContact,WEATHERPROTONAME, "Log", &dbv)) { - db_set_b(hContact,WEATHERPROTONAME, "File",(BYTE)(dbv.ptszVal[0] != 0)); - db_free(&dbv); - } - else db_set_b(hContact,WEATHERPROTONAME, "File",FALSE); + for (HANDLE hContact = db_find_first(WEATHERPROTONAME); hContact; hContact = db_find_next(hContact, WEATHERPROTONAME)) { + db_set_w(hContact,WEATHERPROTONAME, "Status",ID_STATUS_OFFLINE); + db_set_w(hContact,WEATHERPROTONAME, "StatusIcon",ID_STATUS_OFFLINE); + db_unset(hContact, "CList", "MyHandle"); + // clear all data + if ( db_get_ts(hContact, WEATHERPROTONAME, "Nick", &dbv)) { + db_set_ts(hContact, WEATHERPROTONAME, "Nick", TranslateT("")); + db_set_s(hContact, WEATHERPROTONAME, "LastLog", "never"); + db_set_s(hContact, WEATHERPROTONAME, "LastCondition", "None"); + db_set_s(hContact, WEATHERPROTONAME, "LastTemperature", "None"); + } + else db_free(&dbv); + + DBDataManage(hContact, WDBM_REMOVE, 0, 0); + db_set_s(hContact, "UserInfo", "MyNotes", ""); + // reset update tag + db_set_b(hContact,WEATHERPROTONAME, "IsUpdated",FALSE); + // reset logging settings + if ( !db_get_ts(hContact,WEATHERPROTONAME, "Log", &dbv)) { + db_set_b(hContact,WEATHERPROTONAME, "File",(BYTE)(dbv.ptszVal[0] != 0)); + db_free(&dbv); + } + else db_set_b(hContact,WEATHERPROTONAME, "File",FALSE); - // if no default station find, assign a new one - if (opt.Default[0] == 0) { - GetStationID(hContact, opt.Default, SIZEOF(opt.Default)); + // if no default station find, assign a new one + if (opt.Default[0] == 0) { + GetStationID(hContact, opt.Default, SIZEOF(opt.Default)); - opt.DefStn = hContact; - if ( !db_get_ts(hContact,WEATHERPROTONAME, "Nick",&dbv)) { - wsprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal); - db_free(&dbv); - MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION); - } + opt.DefStn = hContact; + if ( !db_get_ts(hContact,WEATHERPROTONAME, "Nick",&dbv)) { + wsprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal); + db_free(&dbv); + MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION); } - // get the handle of the default station - if (opt.DefStn == NULL) { - if ( !db_get_ts(hContact,WEATHERPROTONAME, "ID",&dbv)) { - if ( !_tcscmp(dbv.ptszVal, opt.Default)) - opt.DefStn = hContact; - db_free(&dbv); - } + } + // get the handle of the default station + if (opt.DefStn == NULL) { + if ( !db_get_ts(hContact,WEATHERPROTONAME, "ID",&dbv)) { + if ( !_tcscmp(dbv.ptszVal, opt.Default)) + opt.DefStn = hContact; + db_free(&dbv); } - ContactCount++; // increment counter - LastContact = hContact; } + ContactCount++; // increment counter + LastContact = hContact; } // if weather contact exists, set the status to online so it is ready for update diff --git a/plugins/Weather/src/weather_mwin.cpp b/plugins/Weather/src/weather_mwin.cpp index 7f70b659d0..c127214999 100644 --- a/plugins/Weather/src/weather_mwin.cpp +++ b/plugins/Weather/src/weather_mwin.cpp @@ -384,25 +384,19 @@ void InitMwin(void) FontRegisterT(&fontid); } - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - // see if the contact is a weather contact - if (IsMyContact(hContact)) { - if (db_get_dw(hContact, WEATHERPROTONAME, "mwin", 0)) - addWindow(hContact); - } - } + for (HANDLE hContact = db_find_first(WEATHERPROTONAME); hContact; hContact = db_find_next(hContact, WEATHERPROTONAME)) + if (db_get_dw(hContact, WEATHERPROTONAME, "mwin", 0)) + addWindow(hContact); + hFontHook = HookEvent(ME_FONT_RELOAD, RedrawFrame); } void DestroyMwin(void) { - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - // see if the contact is a weather contact - if (IsMyContact(hContact)) { - DWORD frameId = db_get_dw(hContact, WEATHERPROTONAME, "mwin", 0); - if (frameId) - CallService(MS_CLIST_FRAMES_REMOVEFRAME, frameId, 0); - } + for (HANDLE hContact = db_find_first(WEATHERPROTONAME); hContact; hContact = db_find_next(hContact, WEATHERPROTONAME)) { + DWORD frameId = db_get_dw(hContact, WEATHERPROTONAME, "mwin", 0); + if (frameId) + CallService(MS_CLIST_FRAMES_REMOVEFRAME, frameId, 0); } UnregisterClass( _T("WeatherFrame"), hInst); UnhookEvent(hFontHook); diff --git a/plugins/Weather/src/weather_update.cpp b/plugins/Weather/src/weather_update.cpp index 4c7f819b1f..a6cee642ff 100644 --- a/plugins/Weather/src/weather_update.cpp +++ b/plugins/Weather/src/weather_update.cpp @@ -282,12 +282,10 @@ void DestroyUpdateList(void) void UpdateAll(BOOL AutoUpdate, BOOL RemoveData) { // add all weather contact to the update queue list - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - if (IsMyContact(hContact)) { - if ( !db_get_b(hContact,WEATHERPROTONAME, "AutoUpdate",FALSE) || !AutoUpdate) { - if (RemoveData) DBDataManage((HANDLE)hContact, WDBM_REMOVE, 0, 0); - UpdateListAdd(hContact); - } + for (HANDLE hContact = db_find_first(WEATHERPROTONAME); hContact; hContact = db_find_next(hContact, WEATHERPROTONAME)) { + if ( !db_get_b(hContact,WEATHERPROTONAME, "AutoUpdate",FALSE) || !AutoUpdate) { + if (RemoveData) DBDataManage((HANDLE)hContact, WDBM_REMOVE, 0, 0); + UpdateListAdd(hContact); } } diff --git a/plugins/YAMN/src/proto/pop3/pop3comm.cpp b/plugins/YAMN/src/proto/pop3/pop3comm.cpp index dcb2d55b59..da50c74b56 100644 --- a/plugins/YAMN/src/proto/pop3/pop3comm.cpp +++ b/plugins/YAMN/src/proto/pop3/pop3comm.cpp @@ -278,23 +278,19 @@ int RegisterPOP3Plugin(WPARAM,LPARAM) for (Finder=POP3Plugin->FirstAccount;Finder != NULL;Finder=Finder->Next) { Finder->hContact = NULL; - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - szProto = GetContactProto(hContact); - if (szProto != NULL && strcmp(szProto, YAMN_DBMODULE)==0) - { - if (!db_get_s(hContact,YAMN_DBMODULE,"Id",&dbv)) { - if ( strcmp( dbv.pszVal, Finder->Name) == 0) { - Finder->hContact = hContact; - db_set_w(Finder->hContact, YAMN_DBMODULE, "Status", ID_STATUS_ONLINE); - db_set_s(Finder->hContact, "CList", "StatusMsg", Translate("No new mail message")); - if ((Finder->Flags & YAMN_ACC_ENA) && (Finder->NewMailN.Flags & YAMN_ACC_CONT)) - db_unset(Finder->hContact, "CList", "Hidden"); - - if (!(Finder->Flags & YAMN_ACC_ENA) || !(Finder->NewMailN.Flags & YAMN_ACC_CONT)) - db_set_b(Finder->hContact, "CList", "Hidden", 1); - } - db_free(&dbv); + for (HANDLE hContact = db_find_first(YAMN_DBMODULE); hContact; hContact = db_find_next(hContact, YAMN_DBMODULE)) { + if (!db_get_s(hContact,YAMN_DBMODULE,"Id",&dbv)) { + if ( strcmp( dbv.pszVal, Finder->Name) == 0) { + Finder->hContact = hContact; + db_set_w(Finder->hContact, YAMN_DBMODULE, "Status", ID_STATUS_ONLINE); + db_set_s(Finder->hContact, "CList", "StatusMsg", Translate("No new mail message")); + if ((Finder->Flags & YAMN_ACC_ENA) && (Finder->NewMailN.Flags & YAMN_ACC_CONT)) + db_unset(Finder->hContact, "CList", "Hidden"); + + if (!(Finder->Flags & YAMN_ACC_ENA) || !(Finder->NewMailN.Flags & YAMN_ACC_CONT)) + db_set_b(Finder->hContact, "CList", "Hidden", 1); } + db_free(&dbv); } } -- cgit v1.2.3