From 3bb16e798cb51d5764aacbefd4edf26f52d8c4f0 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 4 Dec 2019 16:08:03 +0300 Subject: GetContactProto: useless duplicate function replaced with standard Proto_GetBaseAccountName --- plugins/UserInfoEx/src/Flags/svc_flags.cpp | 2 +- plugins/UserInfoEx/src/dlg_anniversarylist.cpp | 73 ++++++++++++++------------ 2 files changed, 39 insertions(+), 36 deletions(-) (limited to 'plugins/UserInfoEx/src') diff --git a/plugins/UserInfoEx/src/Flags/svc_flags.cpp b/plugins/UserInfoEx/src/Flags/svc_flags.cpp index 3f439e7f92..cc162d86ff 100644 --- a/plugins/UserInfoEx/src/Flags/svc_flags.cpp +++ b/plugins/UserInfoEx/src/Flags/svc_flags.cpp @@ -44,7 +44,7 @@ static LIST gMsgWndList(10, NumericKeySortT); static INT_PTR ServiceDetectContactOriginCountry(WPARAM wParam,LPARAM) { WORD countryNumber; - char *pszProto = GetContactProto(wParam); + char *pszProto = Proto_GetBaseAccountName(wParam); /* UserinfoEx */ if (countryNumber = db_get_w(wParam, USERINFO, SET_CONTACT_ORIGIN_COUNTRY, 0)) return countryNumber; diff --git a/plugins/UserInfoEx/src/dlg_anniversarylist.cpp b/plugins/UserInfoEx/src/dlg_anniversarylist.cpp index 0533f11e57..86817fcb89 100644 --- a/plugins/UserInfoEx/src/dlg_anniversarylist.cpp +++ b/plugins/UserInfoEx/src/dlg_anniversarylist.cpp @@ -641,7 +641,7 @@ class CAnnivList * @retval TRUE if successful * @retval FALSE if failed **/ - BYTE AddRow(MCONTACT hContact, LPCSTR pszProto, MAnnivDate &ad, MTime &mtNow, WORD wDaysBefore) + BYTE AddRow(MCONTACT hContact, LPCSTR pszProto, MAnnivDate &ad, MTime &mtNow, int wDaysBefore) { wchar_t szText[MAX_PATH]; int diff, iItem = -1; @@ -702,54 +702,57 @@ class CAnnivList // This method clears the list and adds contacts again, according to the current filter settings. void RebuildList() { - LPSTR pszProto; - MTime mtNow; MAnnivDate ad; int i = 0; DWORD age = 0; - WORD wDaysBefore = g_plugin.getWord(SET_REMIND_OFFSET, DEFVAL_REMIND_OFFSET); - WORD numMale = 0; - WORD numFemale = 0; - WORD numContacts = 0; - WORD numBirthContacts = 0; + int wDaysBefore = g_plugin.getWord(SET_REMIND_OFFSET, DEFVAL_REMIND_OFFSET); + int numMale = 0; + int numFemale = 0; + int numContacts = 0; + int numBirthContacts = 0; ShowWindow(_hList, SW_HIDE); DeleteAllItems(); + + MTime mtNow; mtNow.GetLocalTime(); // insert the items into the list for (auto &hContact : Contacts()) { - // ignore meta subcontacts here, as they are not interesting. - if (!db_mc_isSub(hContact)) { - // filter protocol - pszProto = Proto_GetBaseAccountName(hContact); - if (pszProto) { - numContacts++; - switch (GenderOf(hContact, pszProto)) { - case 'M': - numMale++; - break; - case 'F': - numFemale++; - } - - if (!ad.DBGetBirthDate(hContact, pszProto)) { - age += ad.Age(&mtNow); - numBirthContacts++; + // ignore metacontacts here, as they are not interesting. + if (db_mc_isMeta(hContact)) + continue; + + // filter protocol + char *pszProto = Proto_GetBaseAccountName(hContact); + if (!pszProto) + continue; + + numContacts++; + switch (GenderOf(hContact, pszProto)) { + case 'M': + numMale++; + break; + case 'F': + numFemale++; + } - // add birthday - if ((_filter.bFilterIndex != FILTER_ANNIV) && (!_filter.pszProto || !_strcmpi(pszProto, _filter.pszProto))) - AddRow(hContact, pszProto, ad, mtNow, wDaysBefore); - } + if (!ad.DBGetBirthDate(hContact, pszProto)) { + age += ad.Age(&mtNow); + numBirthContacts++; - // add anniversaries - if (_filter.bFilterIndex != FILTER_BIRTHDAY && (!_filter.pszProto || !_strcmpi(pszProto, _filter.pszProto))) - for (i = 0; !ad.DBGetAnniversaryDate(hContact, i); i++) - if (!_filter.pszAnniv || !mir_wstrcmpi(_filter.pszAnniv, ad.Description())) - AddRow(hContact, pszProto, ad, mtNow, wDaysBefore); - } + // add birthday + if ((_filter.bFilterIndex != FILTER_ANNIV) && (!_filter.pszProto || !_strcmpi(pszProto, _filter.pszProto))) + AddRow(hContact, pszProto, ad, mtNow, wDaysBefore); } + + // add anniversaries + if (_filter.bFilterIndex != FILTER_BIRTHDAY && (!_filter.pszProto || !_strcmpi(pszProto, _filter.pszProto))) + for (i = 0; !ad.DBGetAnniversaryDate(hContact, i); i++) + if (!_filter.pszAnniv || !mir_wstrcmpi(_filter.pszAnniv, ad.Description())) + AddRow(hContact, pszProto, ad, mtNow, wDaysBefore); } + ListView_SortItemsEx(_hList, (CMPPROC)cmpProc, this); ShowWindow(_hList, SW_SHOW); -- cgit v1.2.3