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/TipperYM/src/popwin.cpp | 62 ++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 32 deletions(-) (limited to 'plugins/TipperYM/src/popwin.cpp') 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); } } } -- cgit v1.2.3