From f1f98fe541c790141fec87b943af535a943c7100 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 26 Sep 2016 11:01:47 +0000 Subject: - duplicated code removed from cliFindItem; - FindItem function removed completely; - CLIST_INTERFACE::pfnFindItem now only compare one item; - static function Clist_FindItem now serves as pcli->pfnFindItem git-svn-id: http://svn.miranda-ng.org/main/trunk@17335 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- bin10/lib/mir_app.lib | Bin 82042 -> 82262 bytes bin10/lib/mir_app64.lib | Bin 78634 -> 78830 bytes bin12/lib/mir_app.lib | Bin 82042 -> 82262 bytes bin12/lib/mir_app64.lib | Bin 78634 -> 78830 bytes bin14/lib/mir_app.lib | Bin 82042 -> 82262 bytes bin14/lib/mir_app64.lib | Bin 78634 -> 78830 bytes include/delphi/m_clistint.inc | 4 +- include/m_clistint.h | 75 ++++++++++--------- plugins/Clist_modern/src/modern_clc.cpp | 26 +++---- plugins/Clist_modern/src/modern_clc.h | 1 - plugins/Clist_modern/src/modern_clcidents.cpp | 82 ++------------------- plugins/Clist_modern/src/modern_clcitems.cpp | 4 +- plugins/Clist_modern/src/modern_clcmsgs.cpp | 4 +- plugins/Clist_modern/src/modern_commonprototypes.h | 54 +++++++------- plugins/Clist_modern/src/modern_contact.cpp | 3 - plugins/Clist_nicer/src/clc.cpp | 32 ++++---- plugins/Clist_nicer/src/clcmsgs.cpp | 8 +- plugins/Clist_nicer/src/clistmenus.cpp | 8 +- src/mir_app/src/clc.cpp | 24 +++--- src/mir_app/src/clc.h | 3 +- src/mir_app/src/clcidents.cpp | 29 ++++++-- src/mir_app/src/clcitems.cpp | 6 +- src/mir_app/src/clcmsgs.cpp | 30 ++++---- src/mir_app/src/clistmod.cpp | 2 +- src/mir_app/src/mir_app.def | 1 + src/mir_app/src/mir_app64.def | 1 + 26 files changed, 173 insertions(+), 224 deletions(-) diff --git a/bin10/lib/mir_app.lib b/bin10/lib/mir_app.lib index 85a2414656..9dc2bae69c 100644 Binary files a/bin10/lib/mir_app.lib and b/bin10/lib/mir_app.lib differ diff --git a/bin10/lib/mir_app64.lib b/bin10/lib/mir_app64.lib index 45cd497275..34e53fe748 100644 Binary files a/bin10/lib/mir_app64.lib and b/bin10/lib/mir_app64.lib differ diff --git a/bin12/lib/mir_app.lib b/bin12/lib/mir_app.lib index 85a2414656..9dc2bae69c 100644 Binary files a/bin12/lib/mir_app.lib and b/bin12/lib/mir_app.lib differ diff --git a/bin12/lib/mir_app64.lib b/bin12/lib/mir_app64.lib index 45cd497275..34e53fe748 100644 Binary files a/bin12/lib/mir_app64.lib and b/bin12/lib/mir_app64.lib differ diff --git a/bin14/lib/mir_app.lib b/bin14/lib/mir_app.lib index 85a2414656..9dc2bae69c 100644 Binary files a/bin14/lib/mir_app.lib and b/bin14/lib/mir_app.lib differ diff --git a/bin14/lib/mir_app64.lib b/bin14/lib/mir_app64.lib index 45cd497275..34e53fe748 100644 Binary files a/bin14/lib/mir_app64.lib and b/bin14/lib/mir_app64.lib differ diff --git a/include/delphi/m_clistint.inc b/include/delphi/m_clistint.inc index 26d8b125f5..1c04a491cb 100644 --- a/include/delphi/m_clistint.inc +++ b/include/delphi/m_clistint.inc @@ -308,10 +308,10 @@ type pfnUnregisterFileDropping : procedure (hwnd:HWND); cdecl; (* clcidents.c *) + blablabla6 : procedure; cdecl; + pfnGetRowsPriorTo : function (var group:TClcGroup; var subgroup:TClcGroup; contactIndex:int):int; cdecl; - pfnFindItem : function (hwnd:HWND; var dat:TClcData; dwItem:dword; - var contact:PClcContact; var subgroup:PClcGroup; var isVisible:int):int; cdecl; pfnGetRowByIndex : function (var dat:TClcData; testindex:int; var contact:PClcContact; var subgroup:PClcGroup):int; cdecl; unused1 : function (var contact:TClcContact):THANDLE;cdecl; diff --git a/include/m_clistint.h b/include/m_clistint.h index 232ff67afd..ef71edd44c 100644 --- a/include/m_clistint.h +++ b/include/m_clistint.h @@ -250,6 +250,8 @@ EXTERN_C MIR_APP_DLL(HANDLE) Clist_ContactToItemHandle(ClcContact *contact, DWOR EXTERN_C MIR_APP_DLL(void) Clist_Broadcast(int msg, WPARAM wParam, LPARAM lParam); EXTERN_C MIR_APP_DLL(void) Clist_BroadcastAsync(int msg, WPARAM wParam, LPARAM lParam); +EXTERN_C MIR_APP_DLL(bool) Clist_FindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible); + ///////////////////////////////////////////////////////////////////////////////////////// // CLIST_INTERFACE structure definition @@ -290,15 +292,16 @@ struct CLIST_INTERFACE void (*pfnUnregisterFileDropping)(HWND hwnd); /* clcidents.c */ - int (*pfnGetRowsPriorTo)(ClcGroup *group, ClcGroup *subgroup, int contactIndex); - int (*pfnFindItem)(HWND hwnd, struct ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible); - int (*pfnGetRowByIndex)(struct ClcData *dat, int testindex, ClcContact **contact, ClcGroup **subgroup); - int (*pfnGetContactHiddenStatus)(MCONTACT hContact, char *szProto, ClcData *dat); - int (*pfnIsVisibleContact)(ClcCacheEntry *pce, ClcGroup *group); + ClcContact* (*pfnFindItem)(DWORD dwItem, ClcContact *contact); + + int (*pfnGetRowsPriorTo)(ClcGroup *group, ClcGroup *subgroup, int contactIndex); + int (*pfnGetRowByIndex)(ClcData *dat, int testindex, ClcContact **contact, ClcGroup **subgroup); + int (*pfnGetContactHiddenStatus)(MCONTACT hContact, char *szProto, ClcData *dat); + int (*pfnIsVisibleContact)(ClcCacheEntry *pce, ClcGroup *group); /* clcitems.c */ ClcContact* (*pfnCreateClcContact)(void); - struct ClcGroup* (*pfnAddGroup)(HWND hwnd, struct ClcData *dat, const wchar_t *szName, DWORD flags, int groupId, int calcTotalMembers); + struct ClcGroup* (*pfnAddGroup)(HWND hwnd, ClcData *dat, const wchar_t *szName, DWORD flags, int groupId, int calcTotalMembers); struct ClcGroup* (*pfnRemoveItemFromGroup)(HWND hwnd, ClcGroup *group, ClcContact *contact, int updateTotalCount); void (*pfnFreeContact)(ClcContact *contact); @@ -306,52 +309,52 @@ struct CLIST_INTERFACE ClcContact* (*pfnAddInfoItemToGroup)(ClcGroup *group, int flags, const wchar_t *pszText); ClcContact* (*pfnAddItemToGroup)(ClcGroup *group, int iAboveItem); - ClcContact* (*pfnAddContactToGroup)(struct ClcData *dat, ClcGroup *group, MCONTACT hContact); + ClcContact* (*pfnAddContactToGroup)(ClcData *dat, ClcGroup *group, MCONTACT hContact); - void (*pfnAddContactToTree)(HWND hwnd, struct ClcData *dat, MCONTACT hContact, int updateTotalCount, int checkHideOffline); + void (*pfnAddContactToTree)(HWND hwnd, ClcData *dat, MCONTACT hContact, int updateTotalCount, int checkHideOffline); void (*pfnDeleteItemFromTree)(HWND hwnd, MCONTACT hItem); - void (*pfnRebuildEntireList)(HWND hwnd, struct ClcData *dat); + void (*pfnRebuildEntireList)(HWND hwnd, ClcData *dat); int (*pfnGetGroupContentsCount)(ClcGroup *group, int visibleOnly); - void (*pfnSortCLC)(HWND hwnd, struct ClcData *dat, int useInsertionSort); - void (*pfnSaveStateAndRebuildList)(HWND hwnd, struct ClcData *dat); + void (*pfnSortCLC)(HWND hwnd, ClcData *dat, int useInsertionSort); + void (*pfnSaveStateAndRebuildList)(HWND hwnd, ClcData *dat); /* clcmsgs.c */ - LRESULT (*pfnProcessExternalMessages)(HWND hwnd, struct ClcData *dat, UINT msg, WPARAM wParam, LPARAM lParam); + LRESULT (*pfnProcessExternalMessages)(HWND hwnd, ClcData *dat, UINT msg, WPARAM wParam, LPARAM lParam); /* clcpaint.c */ - void (*pfnPaintClc)(HWND hwnd, struct ClcData *dat, HDC hdc, RECT * rcPaint); + void (*pfnPaintClc)(HWND hwnd, ClcData *dat, HDC hdc, RECT * rcPaint); /* clcutils.c */ - wchar_t* (*pfnGetGroupCountsText)(struct ClcData *dat, ClcContact *contact); - int (*pfnHitTest)(HWND hwnd, struct ClcData *dat, int testx, int testy, ClcContact **contact, ClcGroup **group, DWORD * flags); - void (*pfnScrollTo)(HWND hwnd, struct ClcData *dat, int desty, int noSmooth); - void (*pfnEnsureVisible)(HWND hwnd, struct ClcData *dat, int iItem, int partialOk); - void (*pfnRecalcScrollBar)(HWND hwnd, struct ClcData *dat); - void (*pfnSetGroupExpand)(HWND hwnd, struct ClcData *dat, ClcGroup *group, int newState); - void (*pfnDoSelectionDefaultAction)(HWND hwnd, struct ClcData *dat); - int (*pfnFindRowByText)(HWND hwnd, struct ClcData *dat, const wchar_t *text, int prefixOk); - void (*pfnEndRename)(HWND hwnd, struct ClcData *dat, int save); - void (*pfnDeleteFromContactList)(HWND hwnd, struct ClcData *dat); - void (*pfnBeginRenameSelection)(HWND hwnd, struct ClcData *dat); - void (*pfnCalcEipPosition)(struct ClcData *dat, ClcContact *contact, ClcGroup *group, POINT *result); - int (*pfnGetDropTargetInformation)(HWND hwnd, struct ClcData *dat, POINT pt); + wchar_t* (*pfnGetGroupCountsText)(ClcData *dat, ClcContact *contact); + int (*pfnHitTest)(HWND hwnd, ClcData *dat, int testx, int testy, ClcContact **contact, ClcGroup **group, DWORD * flags); + void (*pfnScrollTo)(HWND hwnd, ClcData *dat, int desty, int noSmooth); + void (*pfnEnsureVisible)(HWND hwnd, ClcData *dat, int iItem, int partialOk); + void (*pfnRecalcScrollBar)(HWND hwnd, ClcData *dat); + void (*pfnSetGroupExpand)(HWND hwnd, ClcData *dat, ClcGroup *group, int newState); + void (*pfnDoSelectionDefaultAction)(HWND hwnd, ClcData *dat); + int (*pfnFindRowByText)(HWND hwnd, ClcData *dat, const wchar_t *text, int prefixOk); + void (*pfnEndRename)(HWND hwnd, ClcData *dat, int save); + void (*pfnDeleteFromContactList)(HWND hwnd, ClcData *dat); + void (*pfnBeginRenameSelection)(HWND hwnd, ClcData *dat); + void (*pfnCalcEipPosition)(ClcData *dat, ClcContact *contact, ClcGroup *group, POINT *result); + int (*pfnGetDropTargetInformation)(HWND hwnd, ClcData *dat, POINT pt); int (*pfnClcStatusToPf2)(int status); - int (*pfnIsHiddenMode)(struct ClcData *dat, int status); - void (*pfnHideInfoTip)(HWND hwnd, struct ClcData *dat); + int (*pfnIsHiddenMode)(ClcData *dat, int status); + void (*pfnHideInfoTip)(HWND hwnd, ClcData *dat); void (*pfnNotifyNewContact)(HWND hwnd, MCONTACT hContact); DWORD (*pfnGetDefaultExStyle)(void); void (*pfnGetDefaultFontSetting)(int i, LOGFONT* lf, COLORREF* colour); void (*pfnGetFontSetting)(int i, LOGFONT* lf, COLORREF* colour); - void (*pfnLoadClcOptions)(HWND hwnd, struct ClcData *dat, BOOL bFirst); - void (*pfnRecalculateGroupCheckboxes)(HWND hwnd, struct ClcData *dat); + void (*pfnLoadClcOptions)(HWND hwnd, ClcData *dat, BOOL bFirst); + void (*pfnRecalculateGroupCheckboxes)(HWND hwnd, ClcData *dat); void (*pfnSetGroupChildCheckboxes)(ClcGroup *group, int checked); - void (*pfnInvalidateItem)(HWND hwnd, struct ClcData *dat, int iItem); + void (*pfnInvalidateItem)(HWND hwnd, ClcData *dat, int iItem); - int (*pfnGetRowBottomY)(struct ClcData *dat, int item); - int (*pfnGetRowHeight)(struct ClcData *dat, int item); - int (*pfnGetRowTopY)(struct ClcData *dat, int item); - int (*pfnGetRowTotalHeight)(struct ClcData *dat); - int (*pfnRowHitTest)(struct ClcData *dat, int y); + int (*pfnGetRowBottomY)(ClcData *dat, int item); + int (*pfnGetRowHeight)(ClcData *dat, int item); + int (*pfnGetRowTopY)(ClcData *dat, int item); + int (*pfnGetRowTotalHeight)(ClcData *dat); + int (*pfnRowHitTest)(ClcData *dat, int y); /* clistevents.c */ int (*pfnEventsProcessContactDoubleClick)(MCONTACT hContact); diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp index 6d5f29ad3f..fcfbb3d154 100644 --- a/plugins/Clist_modern/src/modern_clc.cpp +++ b/plugins/Clist_modern/src/modern_clc.cpp @@ -526,7 +526,7 @@ static LRESULT clcOnKeyDown(ClcData *dat, HWND hwnd, UINT, WPARAM wParam, LPARAM if (ht) { ClcContact *contact2; ClcGroup *group2; - if (FindItem(hwnd, dat, contact->hContact, &contact2, &group2, NULL, false)) { + if (Clist_FindItem(hwnd, dat, contact->hContact, &contact2, &group2, NULL)) { int i = cliGetRowsPriorTo(&dat->list, group2, GetContactIndex(group2, contact2)); pcli->pfnEnsureVisible(hwnd, dat, i + contact->iSubAllocated, 0); } @@ -620,7 +620,7 @@ static LRESULT clcOnTimer(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, LPAR int i = 0; ClcContact *contact; ClcGroup *group; - if (FindItem(hwnd, dat, hitcontact->hContact, &contact, &group, NULL, false)) { + if (Clist_FindItem(hwnd, dat, hitcontact->hContact, &contact, &group, NULL)) { i = cliGetRowsPriorTo(&dat->list, group, GetContactIndex(group, contact)); pcli->pfnEnsureVisible(hwnd, dat, i + hitcontact->iSubAllocated, 0); } @@ -1290,7 +1290,7 @@ static LRESULT clcOnIntmGroupChanged(ClcData *dat, HWND hwnd, UINT, WPARAM wPara BYTE flags = 0; ClcContact *contact; - if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) memset(iExtraImage, 0xFF, sizeof(iExtraImage)); else { memcpy(iExtraImage, contact->iExtraImage, sizeof(iExtraImage)); @@ -1300,7 +1300,7 @@ static LRESULT clcOnIntmGroupChanged(ClcData *dat, HWND hwnd, UINT, WPARAM wPara if (GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_SHOWHIDDEN || !db_get_b(wParam, "CList", "Hidden", 0)) { NMCLISTCONTROL nm; pcli->pfnAddContactToTree(hwnd, dat, wParam, 1, 1); - if (pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) { + if (Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) { memcpy(contact->iExtraImage, iExtraImage, sizeof(iExtraImage)); if (flags & CONTACTF_CHECKED) contact->flags |= CONTACTF_CHECKED; @@ -1344,13 +1344,13 @@ static LRESULT clcOnIntmIconChanged(ClcData *dat, HWND hwnd, UINT, WPARAM wParam ClcGroup *group = NULL; ClcContact *contact = NULL; - if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, &group, NULL)) { + if (!Clist_FindItem(hwnd, dat, wParam, &contact, &group, NULL)) { if (shouldShow && db_is_contact(wParam)) { if (dat->selection >= 0 && pcli->pfnGetRowByIndex(dat, dat->selection, &selcontact, NULL) != -1) hSelItem = Clist_ContactToHItem(selcontact); pcli->pfnAddContactToTree(hwnd, dat, wParam, (style & CLS_CONTACTLIST) == 0, 0); needRepaint = TRUE; - pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL); + Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL); if (contact) { contact->iImage = lParam; contact->bImageIsSpecial = bImageIsSpecial; @@ -1391,7 +1391,7 @@ static LRESULT clcOnIntmIconChanged(ClcData *dat, HWND hwnd, UINT, WPARAM wParam } if (hSelItem) { - if (pcli->pfnFindItem(hwnd, dat, hSelItem, &selcontact, &selgroup, NULL)) + if (Clist_FindItem(hwnd, dat, hSelItem, &selcontact, &selgroup, NULL)) dat->selection = pcli->pfnGetRowsPriorTo(&dat->list, selgroup, selgroup->cl.indexOf(selcontact)); else dat->selection = -1; @@ -1415,7 +1415,7 @@ static LRESULT clcOnIntmIconChanged(ClcData *dat, HWND hwnd, UINT, WPARAM wParam static LRESULT clcOnIntmAvatarChanged(ClcData *dat, HWND hwnd, UINT, WPARAM hContact, LPARAM) { ClcContact *contact; - if (FindItem(hwnd, dat, hContact, &contact, NULL, NULL, false)) + if (Clist_FindItem(hwnd, dat, hContact, &contact, NULL, NULL)) Cache_GetAvatar(dat, contact); else if (hContact == 0) UpdateAllAvatars(dat); @@ -1427,7 +1427,7 @@ static LRESULT clcOnIntmAvatarChanged(ClcData *dat, HWND hwnd, UINT, WPARAM hCon static LRESULT clcOnIntmTimeZoneChanged(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { ClcContact *contact; - if (!FindItem(hwnd, dat, wParam, &contact, NULL, NULL, false)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) return corecli.pfnContactListControlWndProc(hwnd, msg, wParam, lParam); if (contact) { @@ -1443,7 +1443,7 @@ static LRESULT clcOnIntmNameChanged(ClcData *dat, HWND hwnd, UINT msg, WPARAM wP LRESULT ret = corecli.pfnContactListControlWndProc(hwnd, msg, wParam, lParam); ClcContact *contact; - if (FindItem(hwnd, dat, wParam, &contact, NULL, NULL, false)) + if (Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) Cache_GetText(dat, contact); return ret; @@ -1460,7 +1460,7 @@ static LRESULT clcOnIntmStatusMsgChanged(ClcData *dat, HWND hwnd, UINT msg, WPAR return corecli.pfnContactListControlWndProc(hwnd, msg, hContact, lParam); ClcContact *contact; - if (!FindItem(hwnd, dat, hContact, &contact, NULL, NULL, false)) + if (!Clist_FindItem(hwnd, dat, hContact, &contact, NULL, NULL)) return corecli.pfnContactListControlWndProc(hwnd, msg, hContact, lParam); if (contact) { @@ -1476,7 +1476,7 @@ static LRESULT clcOnIntmNotOnListChanged(ClcData *dat, HWND hwnd, UINT msg, WPAR DBCONTACTWRITESETTING *dbcws = (DBCONTACTWRITESETTING*)lParam; ClcContact *contact; - if (!FindItem(hwnd, dat, wParam, &contact, NULL, NULL, true)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) /////////////// ?? return corecli.pfnContactListControlWndProc(hwnd, msg, wParam, lParam); if (contact->type != CLCIT_CONTACT) @@ -1508,7 +1508,7 @@ static LRESULT clcOnIntmStatusChanged(ClcData *dat, HWND hwnd, UINT msg, WPARAM if (wParam != 0) { ClcContact *contact; - if (FindItem(hwnd, dat, wParam, &contact, NULL, NULL, true)) { + if (Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) { /////////////////// ?? ClcCacheEntry *pdnce = contact->pce; if (pdnce && pdnce->m_pszProto) { if (!dat->bForceInDialog) { diff --git a/plugins/Clist_modern/src/modern_clc.h b/plugins/Clist_modern/src/modern_clc.h index f8413b9bff..f05184b1d3 100644 --- a/plugins/Clist_modern/src/modern_clc.h +++ b/plugins/Clist_modern/src/modern_clc.h @@ -335,7 +335,6 @@ void ClcOptionsChanged(void); // clcidents.c int cliGetRowsPriorTo(ClcGroup *group, ClcGroup *subgroup, int contactIndex); -int FindItem(HWND hwnd, ClcData *dat, DWORD hItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible, bool isIgnoreSubcontacts); int cliGetRowByIndex(ClcData *dat, int testindex, ClcContact **contact, ClcGroup **subgroup); // clcitems.c diff --git a/plugins/Clist_modern/src/modern_clcidents.cpp b/plugins/Clist_modern/src/modern_clcidents.cpp index f1d7a96ce8..03ef670329 100644 --- a/plugins/Clist_modern/src/modern_clcidents.cpp +++ b/plugins/Clist_modern/src/modern_clcidents.cpp @@ -77,84 +77,16 @@ int cliGetRowsPriorTo(ClcGroup *group, ClcGroup *subgroup, int contactIndex) return -1; } -int cliFindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible) +ClcContact* cliFindItem(DWORD dwItem, ClcContact *cc) { - return FindItem(hwnd, dat, dwItem, contact, subgroup, isVisible, false); -} - -int FindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible, bool isIgnoreSubcontacts) -{ - int index = 0; - int nowVisible = 1; - - ClcGroup *group = &dat->list; - group->scanIndex = 0; - group = &dat->list; - - for (;;) { - if (group->scanIndex == group->cl.getCount()) { - if ((group = group->parent) == NULL) - break; - - nowVisible = 1; - for (ClcGroup *tgroup = group; tgroup; tgroup = tgroup->parent) - if (!tgroup->expanded) { - nowVisible = 0; - break; - } - - group->scanIndex++; - continue; - } - - if (nowVisible) - index++; - - ClcContact *cc = group->cl[group->scanIndex]; - if ((IsHContactGroup(dwItem) && cc->type == CLCIT_GROUP && (dwItem & ~HCONTACT_ISGROUP) == cc->groupId) || - (IsHContactContact(dwItem) && cc->type == CLCIT_CONTACT && cc->hContact == dwItem) || - (IsHContactInfo(dwItem) && cc->type == CLCIT_INFO && cc->hContact == (dwItem & ~HCONTACT_ISINFO))) { - if (isVisible) { - if (!nowVisible) *isVisible = 0; - else { - int posy = cliGetRowTopY(dat, index + 1); - if (posy < dat->yScroll) - *isVisible = 0; - else { - RECT clRect; - GetClientRect(hwnd, &clRect); - *isVisible = (posy < dat->yScroll + clRect.bottom); - } - } - } - if (contact) *contact = cc; - if (subgroup) *subgroup = group; - - return 1; - } + if (corecli.pfnFindItem(dwItem, cc)) + return cc; - if (!isIgnoreSubcontacts && IsHContactContact(dwItem) && cc->type == CLCIT_CONTACT && cc->iSubAllocated > 0) { - for (int i = 0; i < cc->iSubAllocated; i++) { - if (cc->subcontacts[i].hContact == dwItem) { - if (contact) *contact = &cc->subcontacts[i]; - if (subgroup) *subgroup = group; - return 1; - } - } - } - - if (cc->type == CLCIT_GROUP) { - group = cc->group; - group->scanIndex = 0; - nowVisible &= group->expanded; - continue; - } - group->scanIndex++; - } + if (IsHContactContact(dwItem) && cc->type == CLCIT_CONTACT && cc->iSubAllocated > 0) + for (int i = 0; i < cc->iSubAllocated; i++) + if (cc->subcontacts[i].hContact == dwItem) + return &cc->subcontacts[i]; - if (isVisible) *isVisible = FALSE; - if (contact) *contact = NULL; - if (subgroup) *subgroup = NULL; return 0; } diff --git a/plugins/Clist_modern/src/modern_clcitems.cpp b/plugins/Clist_modern/src/modern_clcitems.cpp index c10c11a20e..513d431453 100644 --- a/plugins/Clist_modern/src/modern_clcitems.cpp +++ b/plugins/Clist_modern/src/modern_clcitems.cpp @@ -186,7 +186,7 @@ void cli_AddContactToTree(HWND hwnd, ClcData *dat, MCONTACT hContact, int update ClcGroup *group; ClcContact *cont; - if (FindItem(hwnd, dat, hContact, &cont, &group, NULL, false)) + if (Clist_FindItem(hwnd, dat, hContact, &cont, &group, NULL)) _LoadDataToContact(cont, pdnce, group, dat, hContact); } @@ -213,7 +213,7 @@ int RestoreSelection(ClcData *dat, MCONTACT hSelected) { ClcGroup *selgroup = NULL; ClcContact *selcontact = NULL; - if (!hSelected || !pcli->pfnFindItem(dat->hWnd, dat, hSelected, &selcontact, &selgroup, NULL)) { + if (!hSelected || !Clist_FindItem(dat->hWnd, dat, hSelected, &selcontact, &selgroup, NULL)) { dat->selection = -1; return dat->selection; } diff --git a/plugins/Clist_modern/src/modern_clcmsgs.cpp b/plugins/Clist_modern/src/modern_clcmsgs.cpp index 649d39736f..8960aaae5b 100644 --- a/plugins/Clist_modern/src/modern_clcmsgs.cpp +++ b/plugins/Clist_modern/src/modern_clcmsgs.cpp @@ -106,7 +106,7 @@ LRESULT cli_ProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wP { int i = 0; if (wParam != CLGN_ROOT) { - if (!pcli->pfnFindItem(hwnd, dat, lParam, &contact, &group, NULL)) + if (!Clist_FindItem(hwnd, dat, lParam, &contact, &group, NULL)) return NULL; i = group->cl.indexOf(contact); if (i < 0) return 0; @@ -187,7 +187,7 @@ LRESULT cli_ProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wP { int index = -1; int mainindex = -1; - if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, &group, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, &group, NULL)) break; for (tgroup = group; tgroup; tgroup = tgroup->parent) pcli->pfnSetGroupExpand(hwnd, dat, tgroup, 1); diff --git a/plugins/Clist_modern/src/modern_commonprototypes.h b/plugins/Clist_modern/src/modern_commonprototypes.h index e48b78c646..c898f33c57 100644 --- a/plugins/Clist_modern/src/modern_commonprototypes.h +++ b/plugins/Clist_modern/src/modern_commonprototypes.h @@ -227,34 +227,36 @@ void ToolbarButtonUnloadModule(); // INTERFACES -void cliCheckCacheItem(ClcCacheEntry *pdnce); -void cliFreeCacheItem(ClcCacheEntry *p); -void cliRebuildEntireList(HWND hwnd, ClcData *dat); -void cliRecalcScrollBar(HWND hwnd, ClcData *dat); -int cliGetGroupContentsCount(ClcGroup *group, int visibleOnly); -int cliFindRowByText(HWND hwnd, ClcData *dat, const wchar_t *text, int prefixOk); -int cliGetRowsPriorTo(ClcGroup *group, ClcGroup *subgroup, int contactIndex); -int cli_IconFromStatusMode(const char *szProto, int nStatus, MCONTACT hContact); -int cli_GetContactIcon(MCONTACT hContact); -int cli_RemoveEvent(MCONTACT hContact, MEVENT hDbEvent); -void cli_FreeContact(ClcContact*); -void cli_SetContactCheckboxes(ClcContact*, int); -LRESULT cli_ProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wParam, LPARAM lParam); +void cliCheckCacheItem(ClcCacheEntry *pdnce); +void cliFreeCacheItem(ClcCacheEntry *p); +void cliRebuildEntireList(HWND hwnd, ClcData *dat); +void cliRecalcScrollBar(HWND hwnd, ClcData *dat); +int cliGetGroupContentsCount(ClcGroup *group, int visibleOnly); +int cliFindRowByText(HWND hwnd, ClcData *dat, const wchar_t *text, int prefixOk); +int cliGetRowsPriorTo(ClcGroup *group, ClcGroup *subgroup, int contactIndex); +int cli_IconFromStatusMode(const char *szProto, int nStatus, MCONTACT hContact); +int cli_GetContactIcon(MCONTACT hContact); +int cli_RemoveEvent(MCONTACT hContact, MEVENT hDbEvent); +void cli_FreeContact(ClcContact*); +void cli_SetContactCheckboxes(ClcContact*, int); +LRESULT cli_ProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wParam, LPARAM lParam); +int cliShowHide(bool bAlwaysShow); +BOOL cliInvalidateRect(HWND hWnd, CONST RECT *lpRect, BOOL bErase); +int cliCompareContacts(const ClcContact *contact1, const ClcContact *contact2); +int cliTrayIconPauseAutoHide(WPARAM wParam, LPARAM lParam); +void cliCluiProtocolStatusChanged(int status, const char *proto); +void cliInvalidateDisplayNameCacheEntry(MCONTACT hContact); +void CLUI_cli_LoadCluiGlobalOpts(void); +INT_PTR cli_TrayIconProcessMessage(WPARAM wParam, LPARAM lParam); +int cliTrayIconInit(HWND hwnd); +int cliTrayCalcChanged(const char *szChangedProto, int averageMode, int netProtoCount); + CListEvent* cli_AddEvent(CLISTEVENT *cle); + LRESULT CALLBACK cli_ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -int cliShowHide(bool bAlwaysShow); -BOOL cliInvalidateRect(HWND hWnd, CONST RECT *lpRect, BOOL bErase); -int cliCompareContacts(const ClcContact *contact1, const ClcContact *contact2); -int cliFindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible); -int cliTrayIconPauseAutoHide(WPARAM wParam, LPARAM lParam); -void cliCluiProtocolStatusChanged(int status, const char *proto); -void cliInvalidateDisplayNameCacheEntry(MCONTACT hContact); -void CLUI_cli_LoadCluiGlobalOpts(void); -INT_PTR cli_TrayIconProcessMessage(WPARAM wParam, LPARAM lParam); -int cliTrayIconInit(HWND hwnd); -int cliTrayCalcChanged(const char *szChangedProto, int averageMode, int netProtoCount); - -ClcContact* cliCreateClcContact(void); + +ClcContact* cliFindItem(DWORD dwItem, ClcContact *contact); +ClcContact* cliCreateClcContact(void); ClcCacheEntry* cliCreateCacheItem(MCONTACT hContact); #define WM_DWMCOMPOSITIONCHANGED 0x031E diff --git a/plugins/Clist_modern/src/modern_contact.cpp b/plugins/Clist_modern/src/modern_contact.cpp index 47ffcfc574..4cc7b523c6 100644 --- a/plugins/Clist_modern/src/modern_contact.cpp +++ b/plugins/Clist_modern/src/modern_contact.cpp @@ -90,9 +90,6 @@ int GetProtoIndex(char * szName) int cliCompareContacts(const ClcContact *contact1, const ClcContact *contact2) { - if ((INT_PTR)contact1 < 100 || (INT_PTR)contact2 < 100) - return 0; - ClcCacheEntry *c1 = contact1->pce, *c2 = contact2->pce; for (int i = 0; i < _countof(g_CluiData.bSortByOrder); i++) { diff --git a/plugins/Clist_nicer/src/clc.cpp b/plugins/Clist_nicer/src/clc.cpp index c3adacca29..407208798d 100644 --- a/plugins/Clist_nicer/src/clc.cpp +++ b/plugins/Clist_nicer/src/clc.cpp @@ -275,7 +275,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L { WORD iExtraImage[EXTRA_ICON_COUNT]; BYTE flags = 0; - if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) memset(iExtraImage, 0xFF, sizeof(iExtraImage)); else { memcpy(iExtraImage, contact->iExtraImage, sizeof(iExtraImage)); @@ -284,7 +284,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L pcli->pfnDeleteItemFromTree(hwnd, wParam); if (GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_SHOWHIDDEN || !CLVM_GetContactHiddenStatus(wParam, NULL, dat)) { pcli->pfnAddContactToTree(hwnd, dat, wParam, 1, 1); - if (pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) { + if (Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) { memcpy(contact->iExtraImage, iExtraImage, sizeof(iExtraImage)); if (flags & CONTACTF_CHECKED) contact->flags |= CONTACTF_CHECKED; @@ -322,13 +322,13 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L !CLVM_GetContactHiddenStatus(hContact, szProto, dat)) && ((cfg::dat.bFilterEffective ? TRUE : !pcli->pfnIsHiddenMode(dat, status)) || pcli->pfnGetContactIcon(hContact) != lParam); // XXX CLVM changed - this means an offline msg is flashing, so the contact should be shown - if (!pcli->pfnFindItem(hwnd, dat, hContact, &contact, &group, NULL)) { + if (!Clist_FindItem(hwnd, dat, hContact, &contact, &group, NULL)) { if (shouldShow && db_is_contact(wParam)) { if (dat->selection >= 0 && pcli->pfnGetRowByIndex(dat, dat->selection, &selcontact, NULL) != -1) hSelItem = Clist_ContactToHItem(selcontact); pcli->pfnAddContactToTree(hwnd, dat, hContact, 0, 0); recalcScrollBar = 1; - pcli->pfnFindItem(hwnd, dat, hContact, &contact, NULL, NULL); + Clist_FindItem(hwnd, dat, hContact, &contact, NULL, NULL); if (contact) { contact->iImage = (WORD)lParam; pcli->pfnNotifyNewContact(hwnd, hContact); @@ -357,7 +357,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L } if (hSelItem) { ClcGroup *selgroup; - if (pcli->pfnFindItem(hwnd, dat, hSelItem, &selcontact, &selgroup, NULL)) + if (Clist_FindItem(hwnd, dat, hSelItem, &selcontact, &selgroup, NULL)) dat->selection = pcli->pfnGetRowsPriorTo(&dat->list, selgroup, selgroup->cl.indexOf(selcontact)); else dat->selection = -1; @@ -371,7 +371,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L return DefWindowProc(hwnd, msg, wParam, lParam); case INTM_METACHANGED: - if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) break; if (contact->bIsMeta && !(cfg::dat.dwFlags & CLUI_USEMETAICONS)) { @@ -381,7 +381,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L if (contact->pExtra) { TExtraCache *pSub = cfg::getCache(contact->hSubContact, contact->metaProto); ClcContact *subContact; - if (!pcli->pfnFindItem(hwnd, dat, contact->hSubContact, &subContact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, contact->hSubContact, &subContact, NULL, NULL)) break; contact->pExtra->proto_status_item = GetProtocolStatusItem(contact->metaProto); @@ -395,14 +395,14 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L return DefWindowProc(hwnd, msg, wParam, lParam); case INTM_METACHANGEDEVENT: - if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) break; if (lParam == 0) pcli->pfnInitAutoRebuild(hwnd); return DefWindowProc(hwnd, msg, wParam, lParam); case INTM_NAMECHANGED: - if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) break; mir_wstrncpy(contact->szText, pcli->pfnGetContactDisplayName(wParam, 0), _countof(contact->szText)); @@ -413,7 +413,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L return DefWindowProc(hwnd, msg, wParam, lParam); case INTM_CODEPAGECHANGED: - if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) break; contact->codePage = db_get_dw(wParam, "Tab_SRMsg", "ANSIcodepage", db_get_dw(wParam, "UserInfo", "ANSIcodepage", CP_ACP)); @@ -433,7 +433,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L return DefWindowProc(hwnd, msg, wParam, lParam); } - if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) return 0; contact->ace = cEntry; @@ -460,7 +460,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L TExtraCache *p; char *szProto = NULL; - if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) p = cfg::getCache(wParam, NULL); else { p = contact->pExtra; @@ -472,7 +472,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L return DefWindowProc(hwnd, msg, wParam, lParam); case INTM_STATUSCHANGED: - if (pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) { + if (Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) { WORD wStatus = db_get_w(wParam, contact->proto, "Status", ID_STATUS_OFFLINE); if (cfg::dat.bNoOfflineAvatars && wStatus != ID_STATUS_OFFLINE && contact->wStatus == ID_STATUS_OFFLINE) { contact->wStatus = wStatus; @@ -485,7 +485,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L break; case INTM_PROTOCHANGED: - if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) break; contact->proto = GetContactProto(wParam); @@ -520,7 +520,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L return DefWindowProc(hwnd, msg, wParam, lParam); case INTM_IDLECHANGED: - if (pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) { + if (Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) { DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lParam; char *szProto = (char*)cws->szModule; if (szProto == NULL) @@ -542,7 +542,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L MCONTACT hContact = wParam; TExtraCache *p; - if (!pcli->pfnFindItem(hwnd, dat, hContact, &contact, NULL, NULL)) { + if (!Clist_FindItem(hwnd, dat, hContact, &contact, NULL, NULL)) { p = cfg::getCache(hContact, szProto); if (!dat->bisEmbedded && szProto) { // may be a subcontact, forward the xstatus MCONTACT hMasterContact = db_mc_tryMeta(hContact); diff --git a/plugins/Clist_nicer/src/clcmsgs.cpp b/plugins/Clist_nicer/src/clcmsgs.cpp index 16859d8fa2..e4b0605ed8 100644 --- a/plugins/Clist_nicer/src/clcmsgs.cpp +++ b/plugins/Clist_nicer/src/clcmsgs.cpp @@ -33,7 +33,7 @@ LRESULT ProcessExternalMessages(HWND hwnd, struct ClcData *dat, UINT msg, WPARAM { ClcContact *contact; ClcGroup *group; - if (wParam == 0 || !pcli->pfnFindItem(hwnd, dat, wParam, &contact, &group, NULL)) + if (wParam == 0 || !Clist_FindItem(hwnd, dat, wParam, &contact, &group, NULL)) return 0; if (lParam) @@ -46,7 +46,7 @@ LRESULT ProcessExternalMessages(HWND hwnd, struct ClcData *dat, UINT msg, WPARAM case CLM_GETSTATUSMSG: if (wParam) { ClcContact *contact = NULL; - if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) return 0; if (contact->type != CLCIT_CONTACT) @@ -65,7 +65,7 @@ LRESULT ProcessExternalMessages(HWND hwnd, struct ClcData *dat, UINT msg, WPARAM case CLM_TOGGLEPRIORITYCONTACT: if (wParam) { ClcContact *contact = NULL; - if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) return 0; if (contact->type != CLCIT_CONTACT) return 0; @@ -78,7 +78,7 @@ LRESULT ProcessExternalMessages(HWND hwnd, struct ClcData *dat, UINT msg, WPARAM case CLM_QUERYPRIORITYCONTACT: if (wParam) { ClcContact *contact = NULL; - if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) return 0; if (contact->type != CLCIT_CONTACT) return 0; diff --git a/plugins/Clist_nicer/src/clistmenus.cpp b/plugins/Clist_nicer/src/clistmenus.cpp index 8f8f9b6018..5a71b78328 100644 --- a/plugins/Clist_nicer/src/clistmenus.cpp +++ b/plugins/Clist_nicer/src/clistmenus.cpp @@ -92,7 +92,7 @@ static INT_PTR CALLBACK IgnoreDialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPA SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("When needed by status message")); if (cfg::clcdat) { - pcli->pfnFindItem(pcli->hwndContactTree, cfg::clcdat, hContact, &contact, NULL, NULL); + Clist_FindItem(pcli->hwndContactTree, cfg::clcdat, hContact, &contact, NULL, NULL); if (contact && contact->type != CLCIT_CONTACT) { DestroyWindow(hWnd); return FALSE; @@ -204,7 +204,7 @@ static INT_PTR CALLBACK IgnoreDialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPA DWORD dwFlags = db_get_dw(hContact, "CList", "CLN_Flags", 0), dwXMask = 0; LRESULT checked = 0; - pcli->pfnFindItem(pcli->hwndContactTree, cfg::clcdat, hContact, &contact, NULL, NULL); + Clist_FindItem(pcli->hwndContactTree, cfg::clcdat, hContact, &contact, NULL, NULL); if (iSel != CB_ERR) { dwFlags &= ~(ECF_FORCEAVATAR | ECF_HIDEAVATAR); @@ -291,7 +291,7 @@ static INT_PTR CALLBACK IgnoreDialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPA case WM_USER + 120: // set visibility status { ClcContact *contact = NULL; - if (pcli->pfnFindItem(pcli->hwndContactTree, cfg::clcdat, hContact, &contact, NULL, NULL)) { + if (Clist_FindItem(pcli->hwndContactTree, cfg::clcdat, hContact, &contact, NULL, NULL)) { if (contact) { WORD wApparentMode = db_get_w(contact->hContact, contact->proto, "ApparentMode", 0); @@ -306,7 +306,7 @@ static INT_PTR CALLBACK IgnoreDialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPA { ClcContact *contact = NULL; - if (pcli->pfnFindItem(pcli->hwndContactTree, cfg::clcdat, hContact, &contact, NULL, NULL)) { + if (Clist_FindItem(pcli->hwndContactTree, cfg::clcdat, hContact, &contact, NULL, NULL)) { if (contact) { WORD wApparentMode = 0; diff --git a/src/mir_app/src/clc.cpp b/src/mir_app/src/clc.cpp index 4074bb4a91..3f56a2cb25 100644 --- a/src/mir_app/src/clc.cpp +++ b/src/mir_app/src/clc.cpp @@ -385,7 +385,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam int groupId = atoi(dbcws->szSetting) + 1; int i, eq; //check name of group and ignore message if just being expanded/collapsed - if (cli.pfnFindItem(hwnd, dat, groupId | HCONTACT_ISGROUP, &contact, &group, NULL)) { + if (Clist_FindItem(hwnd, dat, groupId | HCONTACT_ISGROUP, &contact, &group, NULL)) { CMStringW szFullName(contact->szText); while (group->parent) { ClcContact *cc = NULL; @@ -436,7 +436,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam if (GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_SHOWHIDDEN) break; if (dbcws->value.type == DBVT_DELETED || dbcws->value.bVal == 0) { - if (cli.pfnFindItem(hwnd, dat, wParam, NULL, NULL, NULL)) + if (Clist_FindItem(hwnd, dat, wParam, NULL, NULL, NULL)) break; cli.pfnAddContactToTree(hwnd, dat, wParam, 1, 1); cli.pfnNotifyNewContact(hwnd, wParam); @@ -452,7 +452,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam { WORD iExtraImage[EXTRA_ICON_COUNT]; BYTE flags = 0; - if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) memset(iExtraImage, 0xFF, sizeof(iExtraImage)); else { memcpy(iExtraImage, contact->iExtraImage, sizeof(iExtraImage)); @@ -462,7 +462,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam if (GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_SHOWHIDDEN || !db_get_b(wParam, "CList", "Hidden", 0)) { NMCLISTCONTROL nm; cli.pfnAddContactToTree(hwnd, dat, wParam, 1, 1); - if (cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) { + if (Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) { memcpy(contact->iExtraImage, iExtraImage, sizeof(iExtraImage)); if (flags & CONTACTF_CHECKED) contact->flags |= CONTACTF_CHECKED; @@ -498,12 +498,12 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam contact = NULL; group = NULL; - if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, &group, NULL)) { + if (!Clist_FindItem(hwnd, dat, wParam, &contact, &group, NULL)) { if (shouldShow && db_is_contact(wParam)) { if (dat->selection >= 0 && cli.pfnGetRowByIndex(dat, dat->selection, &selcontact, NULL) != -1) hSelItem = Clist_ContactToHItem(selcontact); cli.pfnAddContactToTree(hwnd, dat, wParam, (style & CLS_CONTACTLIST) == 0, 0); - cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL); + Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL); if (contact) { contact->iImage = (WORD)lParam; cli.pfnNotifyNewContact(hwnd, wParam); @@ -530,7 +530,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam } if (hSelItem) { ClcGroup *selgroup; - if (cli.pfnFindItem(hwnd, dat, hSelItem, &selcontact, &selgroup, NULL)) + if (Clist_FindItem(hwnd, dat, hSelItem, &selcontact, &selgroup, NULL)) dat->selection = cli.pfnGetRowsPriorTo(&dat->list, selgroup, selgroup->cl.indexOf(selcontact)); else dat->selection = -1; @@ -540,7 +540,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam break; case INTM_NAMECHANGED: - if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) break; mir_wstrncpy(contact->szText, cli.pfnGetContactDisplayName(wParam, 0), _countof(contact->szText)); @@ -549,7 +549,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam break; case INTM_PROTOCHANGED: - if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) break; contact->proto = GetContactProto(wParam); @@ -559,7 +559,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam break; case INTM_NOTONLISTCHANGED: - if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) break; if (contact->type == CLCIT_CONTACT) { @@ -577,7 +577,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam break; case INTM_APPARENTMODECHANGED: - if (cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) { + if (Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) { char *szProto = GetContactProto(wParam); if (szProto == NULL) break; @@ -599,7 +599,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam break; case INTM_IDLECHANGED: - if (cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) { + if (Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) { char *szProto = GetContactProto(wParam); if (szProto == NULL) break; diff --git a/src/mir_app/src/clc.h b/src/mir_app/src/clc.h index b58e36d1fc..46ae0cebd7 100644 --- a/src/mir_app/src/clc.h +++ b/src/mir_app/src/clc.h @@ -46,9 +46,10 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, /* clcidents.c */ int fnGetRowsPriorTo(ClcGroup *group, ClcGroup *subgroup, int contactIndex); -int fnFindItem(HWND hwnd, struct ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible); int fnGetRowByIndex(struct ClcData *dat, int testindex, ClcContact **contact, ClcGroup **subgroup); +ClcContact* fnFindItem(DWORD dwItem, ClcContact *contact); + /* clcitems.c */ ClcGroup* fnAddGroup(HWND hwnd, struct ClcData *dat, const wchar_t *szName, DWORD flags, int groupId, int calcTotalMembers); ClcGroup* fnRemoveItemFromGroup(HWND hwnd, ClcGroup *group, ClcContact *contact, int updateTotalCount); diff --git a/src/mir_app/src/clcidents.cpp b/src/mir_app/src/clcidents.cpp index fe310a8c97..aa8849ecb1 100644 --- a/src/mir_app/src/clcidents.cpp +++ b/src/mir_app/src/clcidents.cpp @@ -73,7 +73,21 @@ int fnGetRowsPriorTo(ClcGroup *group, ClcGroup *subgroup, int contactIndex) return -1; } -int fnFindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible) +ClcContact* fnFindItem(DWORD dwItem, ClcContact *cc) +{ + if (IsHContactGroup(dwItem) && cc->type == CLCIT_GROUP && (dwItem & ~HCONTACT_ISGROUP) == cc->groupId) + return cc; + + if (IsHContactContact(dwItem) && cc->type == CLCIT_CONTACT && cc->hContact == dwItem) + return cc; + + if (IsHContactInfo(dwItem) && cc->type == CLCIT_INFO && cc->hContact == (dwItem & ~HCONTACT_ISINFO)) + return cc; + + return NULL; +} + +MIR_APP_DLL(bool) Clist_FindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible) { int index = 0; int nowVisible = 1; @@ -98,10 +112,8 @@ int fnFindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcG index++; ClcContact *cc = group->cl[group->scanIndex]; - if ((IsHContactGroup(dwItem) && cc->type == CLCIT_GROUP && (dwItem & ~HCONTACT_ISGROUP) == cc->groupId) || - (IsHContactContact(dwItem) && cc->type == CLCIT_CONTACT && cc->hContact == dwItem) || - (IsHContactInfo(dwItem) && cc->type == CLCIT_INFO && cc->hContact == (dwItem & ~HCONTACT_ISINFO))) - { + ClcContact *res = cli.pfnFindItem(dwItem, cc); + if (res != NULL) { if (isVisible) { if (!nowVisible) *isVisible = 0; @@ -120,11 +132,12 @@ int fnFindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcG } } if (contact) - *contact = cc; + *contact = res; if (subgroup) *subgroup = group; - return 1; + return true; } + if (cc->type == CLCIT_GROUP) { group = cc->group; group->scanIndex = 0; @@ -137,7 +150,7 @@ int fnFindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcG if (isVisible) *isVisible = FALSE; if (contact) *contact = NULL; if (subgroup) *subgroup = NULL; - return 0; + return false; } int fnGetRowByIndex(ClcData *dat, int testindex, ClcContact **contact, ClcGroup **subgroup) diff --git a/src/mir_app/src/clcitems.cpp b/src/mir_app/src/clcitems.cpp index 7305d6658e..b25cf5f732 100644 --- a/src/mir_app/src/clcitems.cpp +++ b/src/mir_app/src/clcitems.cpp @@ -305,7 +305,7 @@ void fnDeleteItemFromTree(HWND hwnd, MCONTACT hItem) ClcGroup *group; ClcContact *contact; - if (!cli.pfnFindItem(hwnd, dat, hItem, &contact, &group, NULL)) { + if (!Clist_FindItem(hwnd, dat, hItem, &contact, &group, NULL)) { DBVARIANT dbv; int i, nameOffset; if (!IsHContactContact(hItem)) @@ -581,7 +581,7 @@ void fnSortCLC(HWND hwnd, ClcData *dat, int useInsertionSort) if (hSelItem) { ClcGroup *selgroup; - if (cli.pfnFindItem(hwnd, dat, hSelItem, &selcontact, &selgroup, NULL)) + if (Clist_FindItem(hwnd, dat, hSelItem, &selcontact, &selgroup, NULL)) dat->selection = cli.pfnGetRowsPriorTo(&dat->list, selgroup, selgroup->cl.indexOf(selcontact)); } @@ -702,7 +702,7 @@ void fnSaveStateAndRebuildList(HWND hwnd, ClcData *dat) group = &dat->list; else { ClcContact *contact; - if (!cli.pfnFindItem(hwnd, dat, saveInfo[i].parentId | HCONTACT_ISGROUP, &contact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, saveInfo[i].parentId | HCONTACT_ISGROUP, &contact, NULL, NULL)) continue; group = contact->group; } diff --git a/src/mir_app/src/clcmsgs.cpp b/src/mir_app/src/clcmsgs.cpp index 2aeecf815d..f5ab49e928 100644 --- a/src/mir_app/src/clcmsgs.cpp +++ b/src/mir_app/src/clcmsgs.cpp @@ -60,7 +60,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar if (cii->hParentGroup == NULL) group = &dat->list; else { - if (!cli.pfnFindItem(hwnd, dat, INT_PTR(cii->hParentGroup) | HCONTACT_ISGROUP, &contact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, INT_PTR(cii->hParentGroup) | HCONTACT_ISGROUP, &contact, NULL, NULL)) return NULL; group = contact->group; } @@ -96,7 +96,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar break; case CLM_ENSUREVISIBLE: - if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, &group, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, &group, NULL)) break; for (ClcGroup *tgroup = group; tgroup; tgroup = tgroup->parent) @@ -105,18 +105,18 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar break; case CLM_EXPAND: - if (cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) + if (Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) if (contact->type == CLCIT_GROUP) cli.pfnSetGroupExpand(hwnd, dat, contact->group, lParam); break; case CLM_FINDCONTACT: - if (!cli.pfnFindItem(hwnd, dat, wParam, NULL, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, NULL, NULL, NULL)) return NULL; return wParam; case CLM_FINDGROUP: - if (!cli.pfnFindItem(hwnd, dat, wParam | HCONTACT_ISGROUP, NULL, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam | HCONTACT_ISGROUP, NULL, NULL, NULL)) return NULL; return wParam | HCONTACT_ISGROUP; @@ -124,7 +124,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar return dat->bkColour; case CLM_GETCHECKMARK: - if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) return 0; return (contact->flags & CONTACTF_CHECKED) != 0; @@ -135,7 +135,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar return (LRESULT)dat->hwndRenameEdit; case CLM_GETEXPAND: - if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) return CLE_INVALID; if (contact->type != CLCIT_GROUP) return CLE_INVALID; @@ -151,7 +151,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar case CLM_GETEXTRAIMAGE: if (LOWORD(lParam) < dat->extraColumnsCount) { - if (cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) + if (Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) return contact->iExtraImage[LOWORD(lParam)]; } return EMPTY_EXTRA_ICON; @@ -175,13 +175,13 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar return mir_wstrlen(dat->szQuickSearch); case CLM_GETITEMTEXT: - if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) return 0; mir_wstrcpy((wchar_t*)lParam, contact->szText); return mir_wstrlen(contact->szText); case CLM_GETITEMTYPE: - if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) return CLCIT_INVALID; return contact->type; @@ -195,7 +195,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar return NULL; } - if (!cli.pfnFindItem(hwnd, dat, lParam, &contact, &group, NULL)) + if (!Clist_FindItem(hwnd, dat, lParam, &contact, &group, NULL)) return NULL; i = group->cl.indexOf(contact); @@ -288,7 +288,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar return Clist_ContactToHItem(contact); case CLM_SELECTITEM: - if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, &group, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, &group, NULL)) break; for (ClcGroup *tgroup = group; tgroup; tgroup = tgroup->parent) @@ -319,7 +319,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar break; case CLM_SETCHECKMARK: - if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) return 0; if (lParam) contact->flags |= CONTACTF_CHECKED; @@ -340,7 +340,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar case CLM_SETEXTRAIMAGE: if (LOWORD(lParam) < dat->extraColumnsCount) { int bVisible; - if (cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, &bVisible)) { + if (Clist_FindItem(hwnd, dat, wParam, &contact, NULL, &bVisible)) { contact->iExtraImage[LOWORD(lParam)] = HIWORD(lParam); if (bVisible) cli.pfnInvalidateRect(hwnd, NULL, FALSE); @@ -396,7 +396,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar break; case CLM_SETITEMTEXT: - if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) + if (!Clist_FindItem(hwnd, dat, wParam, &contact, NULL, NULL)) break; mir_wstrncpy(contact->szText, (wchar_t*)lParam, _countof(contact->szText)); cli.pfnSortCLC(hwnd, dat, 1); diff --git a/src/mir_app/src/clistmod.cpp b/src/mir_app/src/clistmod.cpp index bd4569688c..ec0c5ecc5b 100644 --- a/src/mir_app/src/clistmod.cpp +++ b/src/mir_app/src/clistmod.cpp @@ -404,7 +404,7 @@ MIR_APP_DLL(int) Clist_ContactCompare(MCONTACT hContact1, MCONTACT hContact2) ClcData *dat = (ClcData*)GetWindowLongPtr(cli.hwndContactTree, 0); if (dat != NULL) { ClcContact *p1, *p2; - if (cli.pfnFindItem(cli.hwndContactTree, dat, hContact1, &p1, NULL, NULL) && cli.pfnFindItem(cli.hwndContactTree, dat, hContact2, &p2, NULL, NULL)) + if (Clist_FindItem(cli.hwndContactTree, dat, hContact1, &p1, NULL, NULL) && Clist_FindItem(cli.hwndContactTree, dat, hContact2, &p2, NULL, NULL)) return cli.pfnCompareContacts(p1, p2); } diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index f01f362fa1..c6ec271572 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -310,3 +310,4 @@ Chat_SetStatusEx @310 Chat_Terminate @311 Chat_AddGroup @312 Chat_Control @313 +Clist_FindItem @314 diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index b6dffa06a8..05b5e0945b 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -310,3 +310,4 @@ Chat_SetStatusEx @310 Chat_Terminate @311 Chat_AddGroup @312 Chat_Control @313 +Clist_FindItem @314 -- cgit v1.2.3