summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2016-04-27 13:14:43 +0000
committerGeorge Hazan <george.hazan@gmail.com>2016-04-27 13:14:43 +0000
commitfb5f50bc10318b32d3d99480874813a05551d740 (patch)
tree0a15ed6ba91db7a3ceeaf01767bf2ef7e34c41dd
parent6524ac4e637dba2de42df5ca6eac4a9a5501a4d2 (diff)
persistent cache, no need to call pfnGetCacheEntry each time
git-svn-id: http://svn.miranda-ng.org/main/trunk@16774 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--include/m_clistint.h9
-rw-r--r--plugins/Clist_modern/src/modern_cachefuncs.cpp5
-rw-r--r--plugins/Clist_modern/src/modern_clc.cpp5
-rw-r--r--plugins/Clist_modern/src/modern_clcitems.cpp25
-rw-r--r--plugins/Clist_modern/src/modern_clcpaint.cpp98
-rw-r--r--plugins/Clist_modern/src/modern_clcpaint.h4
-rw-r--r--plugins/Clist_modern/src/modern_commonprototypes.h2
-rw-r--r--plugins/Clist_modern/src/modern_contact.cpp3
-rw-r--r--plugins/Clist_modern/src/modern_rowheight_funcs.cpp186
-rw-r--r--src/mir_app/src/clcitems.cpp99
-rw-r--r--src/mir_app/src/clistmod.cpp4
-rw-r--r--src/mir_app/src/clistsettings.cpp19
-rw-r--r--src/mir_app/src/extraicons.cpp4
-rw-r--r--src/mir_app/src/skinicons.cpp5
14 files changed, 224 insertions, 244 deletions
diff --git a/include/m_clistint.h b/include/m_clistint.h
index a4a705c368..4d30d4e23c 100644
--- a/include/m_clistint.h
+++ b/include/m_clistint.h
@@ -73,6 +73,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define GROUP_ALLOCATE_STEP 8
+struct ClcContact;
+struct ClcData;
+struct ClcCacheEntry;
+
struct ContactList
{
struct ClcContact** items;
@@ -113,6 +117,7 @@ struct ClcContactBase
WORD iExtraImage[EXTRA_ICON_COUNT];
TCHAR szText[120-EXTRA_ICON_COUNT];
char *proto; // MS_PROTO_GETBASEPROTO
+ ClcCacheEntry *pce; // cache is persistent, contacts aren't
};
struct ClcDataBase
@@ -173,10 +178,6 @@ struct CListEvent : public CLISTEVENT, public MZeroedObject
int imlIconOverlayIndex;
};
-struct ClcContact;
-struct ClcData;
-struct ClcCacheEntry;
-
struct trayIconInfo_t
{
int id;
diff --git a/plugins/Clist_modern/src/modern_cachefuncs.cpp b/plugins/Clist_modern/src/modern_cachefuncs.cpp
index 9aaeabbe22..af7a5d4ff7 100644
--- a/plugins/Clist_modern/src/modern_cachefuncs.cpp
+++ b/plugins/Clist_modern/src/modern_cachefuncs.cpp
@@ -69,8 +69,7 @@ void Cache_GetText(ClcData *dat, ClcContact *contact, BOOL forceRenew)
{
Cache_GetFirstLineText(dat, contact);
if (!dat->force_in_dialog) {
- ClcCacheEntry *pdnce = pcli->pfnGetCacheEntry(contact->hContact);
- if ((dat->second_line_show && (forceRenew || pdnce->szSecondLineText == NULL)) || (dat->third_line_show && (forceRenew || pdnce->szThirdLineText == NULL)))
+ if ((dat->second_line_show && (forceRenew || contact->pce->szSecondLineText == NULL)) || (dat->third_line_show && (forceRenew || contact->pce->szThirdLineText == NULL)))
gtaAddRequest(dat, contact->hContact);
}
}
@@ -479,7 +478,7 @@ void Cache_GetFirstLineText(ClcData *dat, ClcContact *contact)
if (GetCurrentThreadId() != g_dwMainThreadID)
return;
- ClcCacheEntry *pdnce = pcli->pfnGetCacheEntry(contact->hContact);
+ ClcCacheEntry *pdnce = contact->pce;
TCHAR *name = pcli->pfnGetContactDisplayName(contact->hContact, 0);
if (dat->first_line_append_nick && !dat->force_in_dialog) {
DBVARIANT dbv = { 0 };
diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp
index a4183bc8f2..094ca5b4f8 100644
--- a/plugins/Clist_modern/src/modern_clc.cpp
+++ b/plugins/Clist_modern/src/modern_clc.cpp
@@ -273,9 +273,8 @@ static BOOL clcItemNotHiddenOffline(ClcGroup *group, ClcContact *contact)
if (g_CluiData.bFilterEffective) return FALSE;
if (!contact) return FALSE;
- ClcCacheEntry *pdnce = pcli->pfnGetCacheEntry(contact->hContact);
- if (!pdnce) return FALSE;
- if (pdnce->m_bNoHiddenOffline) return TRUE;
+
+ if (contact->pce->m_bNoHiddenOffline) return TRUE;
if (!group) return FALSE;
if (group->hideOffline) return FALSE;
diff --git a/plugins/Clist_modern/src/modern_clcitems.cpp b/plugins/Clist_modern/src/modern_clcitems.cpp
index 67f9a7afc6..d14f500579 100644
--- a/plugins/Clist_modern/src/modern_clcitems.cpp
+++ b/plugins/Clist_modern/src/modern_clcitems.cpp
@@ -30,7 +30,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void AddSubcontacts(ClcData *dat, ClcContact *cont, BOOL showOfflineHereGroup)
{
- ClcCacheEntry *cacheEntry = pcli->pfnGetCacheEntry(cont->hContact);
cont->SubExpanded = (db_get_b(cont->hContact, "CList", "Expanded", 0) && (db_get_b(NULL, "CLC", "MetaExpanding", SETTING_METAEXPANDING_DEFAULT)));
int subcount = db_mc_getSubCount(cont->hContact);
if (subcount <= 0) {
@@ -48,7 +47,7 @@ void AddSubcontacts(ClcData *dat, ClcContact *cont, BOOL showOfflineHereGroup)
int bHideOffline = db_get_b(NULL, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT);
for (int j = 0; j < subcount; j++) {
MCONTACT hsub = db_mc_getSub(cont->hContact, j);
- cacheEntry = pcli->pfnGetCacheEntry(hsub);
+ ClcCacheEntry *cacheEntry = pcli->pfnGetCacheEntry(hsub);
WORD wStatus = cacheEntry->getStatus();
if (!showOfflineHereGroup && bHideOffline && !cacheEntry->m_bNoHiddenOffline && wStatus == ID_STATUS_OFFLINE)
@@ -149,7 +148,11 @@ static void _LoadDataToContact(ClcContact *cont, ClcGroup *group, ClcData *dat,
if (!cont)
return;
+ ClcCacheEntry *cacheEntry = pcli->pfnGetCacheEntry(hContact);
+ char *szProto = cacheEntry->m_pszProto;
+
cont->type = CLCIT_CONTACT;
+ cont->pce = cacheEntry;
cont->SubAllocated = 0;
cont->isSubcontact = 0;
cont->subcontacts = NULL;
@@ -157,13 +160,10 @@ static void _LoadDataToContact(ClcContact *cont, ClcGroup *group, ClcData *dat,
cont->lastPaintCounter = 0;
cont->image_is_special = FALSE;
cont->hContact = hContact;
+ cont->proto = szProto;
pcli->pfnInvalidateDisplayNameCacheEntry(hContact);
- ClcCacheEntry *cacheEntry = pcli->pfnGetCacheEntry(hContact);
- char *szProto = cacheEntry->m_pszProto;
- cont->proto = szProto;
-
if (szProto != NULL && !pcli->pfnIsHiddenMode(dat, cacheEntry->m_iStatus))
cont->flags |= CONTACTF_ONLINE;
@@ -201,21 +201,20 @@ static void _LoadDataToContact(ClcContact *cont, ClcGroup *group, ClcData *dat,
cont->bContactRate = db_get_b(hContact, "CList", "Rate", 0);
}
-static ClcContact* AddContactToGroup(ClcData *dat, ClcGroup *group, ClcCacheEntry *cacheEntry)
+static ClcContact* AddContactToGroup(ClcData *dat, ClcGroup *group, MCONTACT hContact)
{
- if (cacheEntry == NULL || group == NULL || dat == NULL)
+ if (group == NULL || dat == NULL)
return NULL;
- MCONTACT hContact = cacheEntry->hContact;
dat->needsResort = 1;
int i;
for (i = group->cl.count - 1; i >= 0; i--)
if (group->cl.items[i]->type != CLCIT_INFO || !(group->cl.items[i]->flags & CLCIIF_BELOWCONTACTS))
break;
+
i = cli_AddItemToGroup(group, i + 1);
_LoadDataToContact(group->cl.items[i], group, dat, hContact);
- cacheEntry = pcli->pfnGetCacheEntry(hContact);
ClearRowByIndexCache();
return group->cl.items[i];
}
@@ -341,12 +340,12 @@ void cliRebuildEntireList(HWND hwnd, ClcData *dat)
if (!(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->hideOffline)) {
if (cacheEntry->m_pszProto == NULL) {
if (!pcli->pfnIsHiddenMode(dat, ID_STATUS_OFFLINE) || cacheEntry->m_bNoHiddenOffline || CLCItems_IsShowOfflineGroup(group))
- cont = AddContactToGroup(dat, group, cacheEntry);
+ cont = AddContactToGroup(dat, group, hContact);
}
else if (!pcli->pfnIsHiddenMode(dat, cacheEntry->m_iStatus) || cacheEntry->m_bNoHiddenOffline || CLCItems_IsShowOfflineGroup(group))
- cont = AddContactToGroup(dat, group, cacheEntry);
+ cont = AddContactToGroup(dat, group, hContact);
}
- else cont = AddContactToGroup(dat, group, cacheEntry);
+ else cont = AddContactToGroup(dat, group, hContact);
}
}
if (cont) {
diff --git a/plugins/Clist_modern/src/modern_clcpaint.cpp b/plugins/Clist_modern/src/modern_clcpaint.cpp
index cfaa374d46..5a256386f5 100644
--- a/plugins/Clist_modern/src/modern_clcpaint.cpp
+++ b/plugins/Clist_modern/src/modern_clcpaint.cpp
@@ -152,10 +152,6 @@ HFONT CLCPaint::ChangeToFont(HDC hdc, ClcData *dat, int id, int *fontHeight)
int CLCPaint::GetBasicFontID(ClcContact *contact)
{
- ClcCacheEntry *pdnce = NULL;
- if (contact->type == CLCIT_CONTACT)
- pdnce = pcli->pfnGetCacheEntry(contact->hContact);
-
switch (contact->type) {
case CLCIT_GROUP:
return (contact->group->expanded) ? FONTID_OPENGROUPS : FONTID_CLOSEDGROUPS;
@@ -177,7 +173,7 @@ int CLCPaint::GetBasicFontID(ClcContact *contact)
return (contact->flags & CONTACTF_ONLINE) ? FONTID_INVIS : FONTID_OFFINVIS;
}
- switch (pdnce->getStatus()) {
+ switch (contact->pce->getStatus()) {
case ID_STATUS_OFFLINE: return FONTID_OFFLINE;
case ID_STATUS_AWAY: return FONTID_AWAY;
case ID_STATUS_DND: return FONTID_DND;
@@ -657,7 +653,7 @@ void CLCPaint::_RTLRect(RECT *rect, int width)
rect->right = right;//-offset;
}
-void CLCPaint::_PaintRowItemsEx(HWND hwnd, HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT row_rc, RECT free_row_rc, int selected, int hottrack)
+void CLCPaint::_PaintRowItemsEx(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT row_rc, RECT free_row_rc, int selected, int hottrack)
{
int i = 0;
int dx = free_row_rc.left;
@@ -668,14 +664,11 @@ void CLCPaint::_PaintRowItemsEx(HWND hwnd, HDC hdcMem, ClcData *dat, ClcContact
int minheight = dat->row_min_heigh;
int mode2 = -1;
BOOL InClistWindow = (dat->hWnd == pcli->hwndContactTree);
- ClcCacheEntry *pdnce = NULL;
- int height = RowHeight_CalcRowHeight(dat, hwnd, Drawing, -1);
+ int height = RowHeight_CalcRowHeight(dat, Drawing, -1);
+ ClcCacheEntry *pdnce = Drawing->pce;
// TO DO DEPRECATE OLD ROW LAYOUT
- if (Drawing->type == CLCIT_CONTACT)
- pdnce = pcli->pfnGetCacheEntry(Drawing->hContact);
-
if (Drawing->type == CLCIT_GROUP &&
Drawing->group->parent->groupId == 0 &&
Drawing->group->parent->cl.items[0] != Drawing) {
@@ -1686,7 +1679,7 @@ void CLCPaint::_DrawLines(HWND hWnd, ClcData *dat, int paintMode, RECT* rcPaint,
if (!gl_RowRoot)
RowHeights_GetRowHeight(dat, hWnd, Drawing, line_num);
else
- RowHeight_CalcRowHeight(dat, hWnd, Drawing, line_num);
+ RowHeight_CalcRowHeight(dat, Drawing, line_num);
// Init settings
int selected = ((line_num == dat->selection) && (dat->hwndRenameEdit != NULL || dat->showSelAlways || dat->exStyle&CLS_EX_SHOWSELALWAYS || is_foreground) && Drawing->type != CLCIT_DIVIDER);
@@ -1822,7 +1815,7 @@ void CLCPaint::_DrawLines(HWND hWnd, ClcData *dat, int paintMode, RECT* rcPaint,
// Store pos
Drawing->pos_check = rc;
}
- _PaintRowItems(hWnd, pc.hdcMem, dat, Drawing, row_rc, free_row_rc, left_pos, right_pos, selected, hottrack, rcPaint);
+ _PaintRowItems(pc.hdcMem, dat, Drawing, row_rc, free_row_rc, left_pos, right_pos, selected, hottrack, rcPaint);
if (mpRequest) {
if (!dat->force_in_dialog) {
mir_free(mpRequest->pl_Params[1].szValue);
@@ -2010,6 +2003,7 @@ void CLCPaint::_StoreItemPos(ClcContact *contact, int ItemType, RECT *rc)
void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT *in_row_rc, RECT *in_free_row_rc, int left_pos, int right_pos, int selected)
{
+ ClcCacheEntry *pdnce = Drawing->pce;
int item_iterator, item, item_text = 0, text_left_pos;
BOOL left = TRUE; //TODO remove
RECT free_row_rc = *in_free_row_rc;
@@ -2147,28 +2141,25 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT
break;
case ITEM_CONTACT_TIME: /////////////////////////////////////////////////////////////////////////////////////////////////////
- {
- ClcCacheEntry *pdnce = (Drawing->type == CLCIT_CONTACT) ? pcli->pfnGetCacheEntry(Drawing->hContact) : NULL;
- if (Drawing->type == CLCIT_CONTACT && dat->contact_time_show && pdnce->hTimeZone) {
- TCHAR szResult[80];
-
- if (!TimeZone_PrintDateTime(pdnce->hTimeZone, _T("t"), szResult, _countof(szResult), 0)) {
- // Select font
- ChangeToFont(hdcMem, dat, FONTID_CONTACT_TIME, NULL);
-
- // Get text size
- RECT rc;
- SIZE text_size;
- text_size.cy = ske_DrawText(hdcMem, szResult, (int)mir_tstrlen(szResult), &rc, DT_CALCRECT | DT_NOPREFIX | DT_SINGLELINE);
- text_size.cy = min(text_size.cy, free_row_rc.bottom - free_row_rc.top);
- text_size.cx = rc.right - rc.left;
-
- // Get rc
- rc = _GetRectangle(dat, &row_rc, &free_row_rc, &left_pos, &right_pos, left, text_size.cx, text_size.cx, text_size.cy, HORIZONTAL_SPACE);
- if (rc.left < rc.right) { // Store pos
- Drawing->pos_contact_time = rc;
- _StoreItemPos(Drawing, CIT_TIME, &rc);
- }
+ if (Drawing->type == CLCIT_CONTACT && dat->contact_time_show && pdnce->hTimeZone) {
+ TCHAR szResult[80];
+
+ if (!TimeZone_PrintDateTime(pdnce->hTimeZone, _T("t"), szResult, _countof(szResult), 0)) {
+ // Select font
+ ChangeToFont(hdcMem, dat, FONTID_CONTACT_TIME, NULL);
+
+ // Get text size
+ RECT rc;
+ SIZE text_size;
+ text_size.cy = ske_DrawText(hdcMem, szResult, (int)mir_tstrlen(szResult), &rc, DT_CALCRECT | DT_NOPREFIX | DT_SINGLELINE);
+ text_size.cy = min(text_size.cy, free_row_rc.bottom - free_row_rc.top);
+ text_size.cx = rc.right - rc.left;
+
+ // Get rc
+ rc = _GetRectangle(dat, &row_rc, &free_row_rc, &left_pos, &right_pos, left, text_size.cx, text_size.cx, text_size.cy, HORIZONTAL_SPACE);
+ if (rc.left < rc.right) { // Store pos
+ Drawing->pos_contact_time = rc;
+ _StoreItemPos(Drawing, CIT_TIME, &rc);
}
}
}
@@ -2329,7 +2320,6 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT
}
else if (Drawing->type == CLCIT_CONTACT && !CheckMiniMode(dat, selected)) {
int tmp;
- ClcCacheEntry *pdnce = (Drawing->type == CLCIT_CONTACT) ? pcli->pfnGetCacheEntry(Drawing->hContact) : NULL;
if (dat->second_line_show) {
if (dat->second_line_type == TEXT_CONTACT_TIME && pdnce->hTimeZone) {
// Get contact time
@@ -2774,21 +2764,19 @@ void CLCPaint::_DrawContactSubText(HDC hdcMem, ClcData *dat, ClcContact *Drawing
}
}
else if (Drawing->type == CLCIT_CONTACT) {
+ ClcCacheEntry *pdnce = Drawing->pce;
SIZE text_size = { _rcWidth(prcItem), _rcHeight(prcItem) };
- ClcCacheEntry *pdnce = (Drawing->type == CLCIT_CONTACT) ? pcli->pfnGetCacheEntry(Drawing->hContact) : NULL;
- if (pdnce) {
- ChangeToFont(hdcMem, dat, itemType == CIT_SUBTEXT1 ? FONTID_SECONDLINE : FONTID_THIRDLINE, NULL);
- //draw second and third line
- if (selected)
- SetTextColor(hdcMem, dat->selTextColour);
- else if (hottrack)
- _SetHotTrackColour(hdcMem, dat);
- uTextFormat |= DT_VCENTER;
- if (itemType == CIT_SUBTEXT1)
- _DrawTextSmiley(hdcMem, prcItem, &text_size, pdnce->szSecondLineText, 0, -1, pdnce->ssSecondLine.plText, uTextFormat, dat->text_resize_smileys);
- else
- _DrawTextSmiley(hdcMem, prcItem, &text_size, pdnce->szThirdLineText, 0, -1, pdnce->ssThirdLine.plText, uTextFormat, dat->text_resize_smileys);
- }
+ ChangeToFont(hdcMem, dat, itemType == CIT_SUBTEXT1 ? FONTID_SECONDLINE : FONTID_THIRDLINE, NULL);
+ //draw second and third line
+ if (selected)
+ SetTextColor(hdcMem, dat->selTextColour);
+ else if (hottrack)
+ _SetHotTrackColour(hdcMem, dat);
+ uTextFormat |= DT_VCENTER;
+ if (itemType == CIT_SUBTEXT1)
+ _DrawTextSmiley(hdcMem, prcItem, &text_size, pdnce->szSecondLineText, 0, -1, pdnce->ssSecondLine.plText, uTextFormat, dat->text_resize_smileys);
+ else
+ _DrawTextSmiley(hdcMem, prcItem, &text_size, pdnce->szThirdLineText, 0, -1, pdnce->ssThirdLine.plText, uTextFormat, dat->text_resize_smileys);
}
text_rc.right = max(text_rc.right, prcItem->right);
text_rc.left = min(text_rc.left, prcItem->left);
@@ -2797,7 +2785,7 @@ void CLCPaint::_DrawContactSubText(HDC hdcMem, ClcData *dat, ClcContact *Drawing
void CLCPaint::_DrawContactTime(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT *prcItem)
{
TCHAR szResult[80];
- ClcCacheEntry *pdnce = (Drawing->type == CLCIT_CONTACT) ? pcli->pfnGetCacheEntry(Drawing->hContact) : NULL;
+ ClcCacheEntry *pdnce = Drawing->pce;
if (!pdnce)
return;
@@ -2922,15 +2910,15 @@ void CLCPaint::_DrawContactItems(HDC hdcMem, ClcData *dat, ClcContact *Drawing,
_DrawContactLine(hdcMem, Drawing, free_row_rc, rcPaint, text_rc);
}
-void CLCPaint::_PaintRowItems(HWND hwnd, HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT row_rc, RECT free_row_rc, int left_pos, int right_pos, int selected, int hottrack, RECT *rcPaint)
+void CLCPaint::_PaintRowItems(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT row_rc, RECT free_row_rc, int left_pos, int right_pos, int selected, int hottrack, RECT *rcPaint)
{
- //Extended LAYOUT
+ // Extended LAYOUT
if (gl_RowRoot && (dat->hWnd == pcli->hwndContactTree)) {
- _PaintRowItemsEx(hwnd, hdcMem, dat, Drawing, row_rc, free_row_rc, selected, hottrack);
+ _PaintRowItemsEx(hdcMem, dat, Drawing, row_rc, free_row_rc, selected, hottrack);
ske_ResetTextEffect(hdcMem);
return;
}
- //END OFF Extended LAYOUT
+ // END OFF Extended LAYOUT
if (!Drawing->ext_fItemsValid) _CalcItemsPos(hdcMem, dat, Drawing, &row_rc, &free_row_rc, left_pos, right_pos, selected);
_DrawContactItems(hdcMem, dat, Drawing, &row_rc, &free_row_rc, selected, hottrack, rcPaint);
ske_ResetTextEffect(hdcMem);
diff --git a/plugins/Clist_modern/src/modern_clcpaint.h b/plugins/Clist_modern/src/modern_clcpaint.h
index 377f27d6eb..406bc51137 100644
--- a/plugins/Clist_modern/src/modern_clcpaint.h
+++ b/plugins/Clist_modern/src/modern_clcpaint.h
@@ -107,7 +107,7 @@ private:
void _FillParam(MASKPARAM * lpParam, DWORD dwParamHash, const char* szValue, DWORD dwValueHash);
MODERNMASK* _GetCLCContactRowBackModernMask(ClcGroup *group, ClcContact *Drawing, int indent, int index, BOOL selected, BOOL hottrack, ClcData *dat);
void _RTLRect(RECT *rect, int width);
- void _PaintRowItemsEx(HWND hwnd, HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT row_rc, RECT free_row_rc, int selected, int hottrack);
+ void _PaintRowItemsEx(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT row_rc, RECT free_row_rc, int selected, int hottrack);
void _DrawStatusIcon(ClcContact *Drawing, ClcData *dat, int iImage, HDC hdcMem, int x, int y, int cx, int cy, DWORD colorbg, DWORD colorfg, int mode);
BOOL _DrawNonEnginedBackground(HDC hdcMem, RECT *rcPaint, RECT clRect, ClcData *dat);
void _PaintClc(HWND hwnd, ClcData *dat, HDC hdc, RECT *rcPaint);
@@ -116,7 +116,7 @@ private:
BOOL __IsVisible(RECT *firtRect, RECT *secondRect);
void _GetBlendMode(IN ClcData *dat, IN ClcContact *Drawing, IN BOOL selected, IN BOOL hottrack, IN BOOL bFlag, OUT COLORREF * OutColourFg, OUT int * OutMode);
void _DrawContactItems(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT *row_rc, RECT *free_row_rc, int selected, int hottrack, RECT *rcPaint);
- void _PaintRowItems(HWND hwnd, HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT row_rc, RECT free_row_rc, int left_pos, int right_pos, int selected, int hottrack, RECT *rcPaint);
+ void _PaintRowItems(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT row_rc, RECT free_row_rc, int left_pos, int right_pos, int selected, int hottrack, RECT *rcPaint);
void _DrawContactAvatar(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT *row_rc, int& selected, int& hottrack, RECT *prcItem);
void _DrawContactIcon(HDC hdcMem, ClcData *dat, ClcContact *Drawing, int& selected, int& hottrack, RECT *prcItem);
diff --git a/plugins/Clist_modern/src/modern_commonprototypes.h b/plugins/Clist_modern/src/modern_commonprototypes.h
index 9d1e0e8515..d83c743db1 100644
--- a/plugins/Clist_modern/src/modern_commonprototypes.h
+++ b/plugins/Clist_modern/src/modern_commonprototypes.h
@@ -117,7 +117,7 @@ int ModernSkinButton_ReposButtons(HWND parent, BYTE draw, RECT *r);
int ModernSkinButtonUnloadModule(WPARAM, LPARAM);
/* RowHeight */
-int RowHeight_CalcRowHeight(ClcData *dat, HWND hwnd, ClcContact *contact, int item);
+int RowHeight_CalcRowHeight(ClcData *dat, ClcContact *contact, int item);
/* SkinEngine */
BOOL ske_AlphaBlend(HDC hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, HDC hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, BLENDFUNCTION blendFunction);
diff --git a/plugins/Clist_modern/src/modern_contact.cpp b/plugins/Clist_modern/src/modern_contact.cpp
index f7dc4aa4fb..36efba43c6 100644
--- a/plugins/Clist_modern/src/modern_contact.cpp
+++ b/plugins/Clist_modern/src/modern_contact.cpp
@@ -95,8 +95,7 @@ int cliCompareContacts(const ClcContact *contact1, const ClcContact *contact2)
if ((INT_PTR)contact1 < 100 || (INT_PTR)contact2 < 100)
return 0;
- ClcCacheEntry *c1 = pcli->pfnGetCacheEntry(contact1->hContact);
- ClcCacheEntry *c2 = pcli->pfnGetCacheEntry(contact2->hContact);
+ ClcCacheEntry *c1 = contact1->pce, *c2 = contact2->pce;
for (int i = 0; i < _countof(g_CluiData.bSortByOrder); i++) {
BYTE &by = g_CluiData.bSortByOrder[i];
diff --git a/plugins/Clist_modern/src/modern_rowheight_funcs.cpp b/plugins/Clist_modern/src/modern_rowheight_funcs.cpp
index 3a2de1caf3..00119588d1 100644
--- a/plugins/Clist_modern/src/modern_rowheight_funcs.cpp
+++ b/plugins/Clist_modern/src/modern_rowheight_funcs.cpp
@@ -31,7 +31,7 @@ Created by Pescuma, modified by Artem Shpynov
#include "modern_clcpaint.h"
int g_mutex_nCalcRowHeightLock = 0;
-int mod_CalcRowHeight_worker(ClcData *dat, HWND hwnd, ClcContact *contact, int item);
+int mod_CalcRowHeight_worker(ClcData *dat, ClcContact *contact, int item);
void RowHeights_CalcRowHeights_Worker(ClcData *dat, HWND hwnd);
int RowHeights_GetRowHeight_worker(ClcData *dat, HWND hwnd, ClcContact *contact, int item);
@@ -69,30 +69,28 @@ SIZE GetAvatarSize(int imageWidth, int imageHeight, int maxWidth, int maxHeight)
return sz;
}
-int RowHeight_CalcRowHeight(ClcData *dat, HWND hwnd, ClcContact *contact, int item)
+int RowHeight_CalcRowHeight(ClcData *dat, ClcContact *contact, int item)
{
if (MirandaExiting()) return 0;
g_mutex_nCalcRowHeightLock++;
- int res = mod_CalcRowHeight_worker(dat, hwnd, contact, item);
+ int res = mod_CalcRowHeight_worker(dat, contact, item);
g_mutex_nCalcRowHeightLock--;
return res;
}
-int mod_CalcRowHeight_worker(ClcData *dat, HWND hwnd, ClcContact *contact, int item)
+int mod_CalcRowHeight_worker(ClcData *dat, ClcContact *contact, int item)
{
- BYTE i = 0;
- int height = 0;
- ClcCacheEntry *pdnce;
- BOOL hasAvatar = FALSE;
- DWORD style;
- style = GetWindowLongPtr(hwnd, GWL_STYLE);
- pdnce = pcli->pfnGetCacheEntry(contact->hContact);
if (!RowHeights_Alloc(dat, item + 1))
return -1;
if (!pcli->hwndContactTree)
return 0;
+ BYTE i = 0;
+ int height = 0;
+ BOOL hasAvatar = FALSE;
+
+ ClcCacheEntry *pdnce = contact->pce;
if (dat->hWnd != pcli->hwndContactTree || !gl_RowRoot || contact->type == CLCIT_GROUP) {
int tmp = dat->fontModernInfo[g_clcPainter.GetBasicFontID(contact)].fontHeight;
if (dat->text_replace_smileys && dat->first_line_draw_smileys && !dat->text_resize_smileys)
@@ -123,99 +121,94 @@ int mod_CalcRowHeight_worker(ClcData *dat, HWND hwnd, ClcContact *contact, int i
SetRect(&(gl_RowTabAccess[i]->r), 0, 0, 0, 0);
switch (gl_RowTabAccess[i]->type) {
case TC_TEXT1:
- {
- int tmp = 0;
- tmp = dat->fontModernInfo[g_clcPainter.GetBasicFontID(contact)].fontHeight;
- if (dat->text_replace_smileys && dat->first_line_draw_smileys && !dat->text_resize_smileys)
- tmp = max(tmp, contact->ssText.iMaxSmileyHeight);
- if (item == -1)
{
- //calculate text width here
- SIZE size = { 0 };
- RECT dummyRect = { 0, 0, 1024, tmp };
- HDC hdc = CreateCompatibleDC(NULL);
- g_clcPainter.ChangeToFont(hdc, dat, g_clcPainter.GetBasicFontID(contact), NULL);
- g_clcPainter.GetTextSize(&size, hdc, dummyRect, contact->szText, contact->ssText.plText, 0, dat->text_resize_smileys ? 0 : contact->ssText.iMaxSmileyHeight);
- if (contact->type == CLCIT_GROUP) {
- TCHAR *szCounts = pcli->pfnGetGroupCountsText(dat, contact);
- if (szCounts && mir_tstrlen(szCounts) > 0) {
- RECT count_rc = { 0 };
- // calc width and height
- g_clcPainter.ChangeToFont(hdc, dat, contact->group->expanded ? FONTID_OPENGROUPCOUNTS : FONTID_CLOSEDGROUPCOUNTS, NULL);
- ske_DrawText(hdc, _T(" "), 1, &count_rc, DT_CALCRECT | DT_NOPREFIX);
- size.cx += count_rc.right - count_rc.left;
- count_rc.right = 0;
- count_rc.left = 0;
- ske_DrawText(hdc, szCounts, (int)mir_tstrlen(szCounts), &count_rc, DT_CALCRECT);
- size.cx += count_rc.right - count_rc.left;
- tmp = max(tmp, count_rc.bottom - count_rc.top);
- }
- }
- gl_RowTabAccess[i]->w = size.cx;
- SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
- ske_ResetTextEffect(hdc);
- DeleteDC(hdc);
- }
- gl_RowTabAccess[i]->h = tmp;
- }
- break;
-
- case TC_TEXT2:
- {
- int tmp = 0;
- if (dat->second_line_show && pdnce->szSecondLineText && pdnce->szSecondLineText[0])
- {
- tmp = dat->fontModernInfo[FONTID_SECONDLINE].fontHeight;
- if (dat->text_replace_smileys && dat->second_line_draw_smileys && !dat->text_resize_smileys)
- tmp = max(tmp, pdnce->ssSecondLine.iMaxSmileyHeight);
- if (item == -1)
- {
+ int tmp = dat->fontModernInfo[g_clcPainter.GetBasicFontID(contact)].fontHeight;
+ if (dat->text_replace_smileys && dat->first_line_draw_smileys && !dat->text_resize_smileys)
+ tmp = max(tmp, contact->ssText.iMaxSmileyHeight);
+ if (item == -1) {
//calculate text width here
-
SIZE size = { 0 };
RECT dummyRect = { 0, 0, 1024, tmp };
HDC hdc = CreateCompatibleDC(NULL);
- g_clcPainter.ChangeToFont(hdc, dat, FONTID_SECONDLINE, NULL);
- g_clcPainter.GetTextSize(&size, hdc, dummyRect, pdnce->szSecondLineText, pdnce->ssSecondLine.plText, 0, dat->text_resize_smileys ? 0 : pdnce->ssSecondLine.iMaxSmileyHeight);
+ g_clcPainter.ChangeToFont(hdc, dat, g_clcPainter.GetBasicFontID(contact), NULL);
+ g_clcPainter.GetTextSize(&size, hdc, dummyRect, contact->szText, contact->ssText.plText, 0, dat->text_resize_smileys ? 0 : contact->ssText.iMaxSmileyHeight);
+ if (contact->type == CLCIT_GROUP) {
+ TCHAR *szCounts = pcli->pfnGetGroupCountsText(dat, contact);
+ if (szCounts && mir_tstrlen(szCounts) > 0) {
+ RECT count_rc = { 0 };
+ // calc width and height
+ g_clcPainter.ChangeToFont(hdc, dat, contact->group->expanded ? FONTID_OPENGROUPCOUNTS : FONTID_CLOSEDGROUPCOUNTS, NULL);
+ ske_DrawText(hdc, _T(" "), 1, &count_rc, DT_CALCRECT | DT_NOPREFIX);
+ size.cx += count_rc.right - count_rc.left;
+ count_rc.right = 0;
+ count_rc.left = 0;
+ ske_DrawText(hdc, szCounts, (int)mir_tstrlen(szCounts), &count_rc, DT_CALCRECT);
+ size.cx += count_rc.right - count_rc.left;
+ tmp = max(tmp, count_rc.bottom - count_rc.top);
+ }
+ }
gl_RowTabAccess[i]->w = size.cx;
SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
ske_ResetTextEffect(hdc);
DeleteDC(hdc);
}
+ gl_RowTabAccess[i]->h = tmp;
}
- gl_RowTabAccess[i]->h = tmp;
- }
- break;
+ break;
+
+ case TC_TEXT2:
+ {
+ int tmp = 0;
+ if (dat->second_line_show && pdnce->szSecondLineText && pdnce->szSecondLineText[0]) {
+ tmp = dat->fontModernInfo[FONTID_SECONDLINE].fontHeight;
+ if (dat->text_replace_smileys && dat->second_line_draw_smileys && !dat->text_resize_smileys)
+ tmp = max(tmp, pdnce->ssSecondLine.iMaxSmileyHeight);
+ if (item == -1) {
+ //calculate text width here
+
+ SIZE size = { 0 };
+ RECT dummyRect = { 0, 0, 1024, tmp };
+ HDC hdc = CreateCompatibleDC(NULL);
+ g_clcPainter.ChangeToFont(hdc, dat, FONTID_SECONDLINE, NULL);
+ g_clcPainter.GetTextSize(&size, hdc, dummyRect, pdnce->szSecondLineText, pdnce->ssSecondLine.plText, 0, dat->text_resize_smileys ? 0 : pdnce->ssSecondLine.iMaxSmileyHeight);
+ gl_RowTabAccess[i]->w = size.cx;
+ SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
+ ske_ResetTextEffect(hdc);
+ DeleteDC(hdc);
+ }
+ }
+ gl_RowTabAccess[i]->h = tmp;
+ }
+ break;
case TC_TEXT3:
- {
- int tmp = 0;
- if (dat->third_line_show && pdnce->szThirdLineText && pdnce->szThirdLineText[0]) {
- tmp = dat->fontModernInfo[FONTID_THIRDLINE].fontHeight;
- if (dat->text_replace_smileys && dat->third_line_draw_smileys && !dat->text_resize_smileys)
- tmp = max(tmp, pdnce->ssThirdLine.iMaxSmileyHeight);
- if (item == -1) {
- //calculate text width here
- SIZE size = { 0 };
- RECT dummyRect = { 0, 0, 1024, tmp };
- HDC hdc = CreateCompatibleDC(NULL);
- g_clcPainter.ChangeToFont(hdc, dat, FONTID_THIRDLINE, NULL);
- g_clcPainter.GetTextSize(&size, hdc, dummyRect, pdnce->szThirdLineText, pdnce->ssThirdLine.plText, 0, dat->text_resize_smileys ? 0 : pdnce->ssThirdLine.iMaxSmileyHeight);
- gl_RowTabAccess[i]->w = size.cx;
- SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
- ske_ResetTextEffect(hdc);
- DeleteDC(hdc);
+ {
+ int tmp = 0;
+ if (dat->third_line_show && pdnce->szThirdLineText && pdnce->szThirdLineText[0]) {
+ tmp = dat->fontModernInfo[FONTID_THIRDLINE].fontHeight;
+ if (dat->text_replace_smileys && dat->third_line_draw_smileys && !dat->text_resize_smileys)
+ tmp = max(tmp, pdnce->ssThirdLine.iMaxSmileyHeight);
+ if (item == -1) {
+ //calculate text width here
+ SIZE size = { 0 };
+ RECT dummyRect = { 0, 0, 1024, tmp };
+ HDC hdc = CreateCompatibleDC(NULL);
+ g_clcPainter.ChangeToFont(hdc, dat, FONTID_THIRDLINE, NULL);
+ g_clcPainter.GetTextSize(&size, hdc, dummyRect, pdnce->szThirdLineText, pdnce->ssThirdLine.plText, 0, dat->text_resize_smileys ? 0 : pdnce->ssThirdLine.iMaxSmileyHeight);
+ gl_RowTabAccess[i]->w = size.cx;
+ SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
+ ske_ResetTextEffect(hdc);
+ DeleteDC(hdc);
+ }
}
+ gl_RowTabAccess[i]->h = tmp;
}
- gl_RowTabAccess[i]->h = tmp;
- }
- break;
+ break;
case TC_STATUS:
if ((contact->type == CLCIT_GROUP && !dat->row_hide_group_icon) ||
(contact->type == CLCIT_CONTACT && contact->iImage != -1 &&
- !(dat->icon_hide_on_avatar && dat->avatars_show && (hasAvatar || (!hasAvatar && dat->icon_draw_on_avatar_space && contact->iImage != -1)) && !contact->image_is_special)))
- {
+ !(dat->icon_hide_on_avatar && dat->avatars_show && (hasAvatar || (!hasAvatar && dat->icon_draw_on_avatar_space && contact->iImage != -1)) && !contact->image_is_special))) {
gl_RowTabAccess[i]->h = ICON_HEIGHT;
gl_RowTabAccess[i]->w = ICON_HEIGHT;
}
@@ -224,8 +217,7 @@ int mod_CalcRowHeight_worker(ClcData *dat, HWND hwnd, ClcContact *contact, int i
case TC_AVATAR:
if (dat->avatars_show &&
contact->type == CLCIT_CONTACT &&
- (hasAvatar || (dat->icon_hide_on_avatar && dat->icon_draw_on_avatar_space && contact->iImage != -1)))
- {
+ (hasAvatar || (dat->icon_hide_on_avatar && dat->icon_draw_on_avatar_space && contact->iImage != -1))) {
int iW = 0, iH = 0;
if (contact->avatar_data) {
iH = contact->avatar_data->bmHeight;
@@ -245,15 +237,14 @@ int mod_CalcRowHeight_worker(ClcData *dat, HWND hwnd, ClcContact *contact, int i
// Draw extra icons
if (contact->type == CLCIT_CONTACT &&
- (!contact->isSubcontact || db_get_b(NULL, "CLC", "MetaHideExtra", SETTING_METAHIDEEXTRA_DEFAULT) == 0 && dat->extraColumnsCount > 0))
- {
+ (!contact->isSubcontact || db_get_b(NULL, "CLC", "MetaHideExtra", SETTING_METAHIDEEXTRA_DEFAULT) == 0 && dat->extraColumnsCount > 0)) {
BOOL hasExtra = FALSE;
int width = 0;
for (int k = 0; k < dat->extraColumnsCount; k++)
if (contact->iExtraImage[k] != EMPTY_EXTRA_ICON || !dat->MetaIgnoreEmptyExtra) {
hasExtra = TRUE;
if (item != -1) break;
- width += (width>0) ? dat->extraColumnSpacing : (dat->extraColumnSpacing - 2);
+ width += (width > 0) ? dat->extraColumnSpacing : (dat->extraColumnSpacing - 2);
}
if (hasExtra) {
gl_RowTabAccess[i]->h = ICON_HEIGHT;
@@ -272,8 +263,7 @@ int mod_CalcRowHeight_worker(ClcData *dat, HWND hwnd, ClcContact *contact, int i
case TC_EXTRA8:
case TC_EXTRA9:
if (contact->type == CLCIT_CONTACT &&
- (!contact->isSubcontact || db_get_b(NULL, "CLC", "MetaHideExtra", SETTING_METAHIDEEXTRA_DEFAULT) == 0 && dat->extraColumnsCount > 0))
- {
+ (!contact->isSubcontact || db_get_b(NULL, "CLC", "MetaHideExtra", SETTING_METAHIDEEXTRA_DEFAULT) == 0 && dat->extraColumnsCount > 0)) {
int eNum = gl_RowTabAccess[i]->type - TC_EXTRA1;
if (eNum < dat->extraColumnsCount)
if (contact->iExtraImage[eNum] != EMPTY_EXTRA_ICON || !dat->MetaIgnoreEmptyExtra) {
@@ -497,7 +487,7 @@ void RowHeights_CalcRowHeights_Worker(ClcData *dat, HWND hwnd)
if (!gl_RowRoot)
RowHeights_GetRowHeight(dat, hwnd, Drawing, line_num);
else
- RowHeight_CalcRowHeight(dat, hwnd, Drawing, line_num);
+ RowHeight_CalcRowHeight(dat, Drawing, line_num);
//increment by subcontacts
if (group->cl.items[group->scanIndex]->subcontacts != NULL && group->cl.items[group->scanIndex]->type != CLCIT_GROUP) {
@@ -535,7 +525,7 @@ int RowHeights_GetRowHeight(ClcData *dat, HWND hwnd, ClcContact *contact, int it
int RowHeights_GetRowHeight_worker(ClcData *dat, HWND hwnd, ClcContact *contact, int item)
{
if (gl_RowRoot)
- return RowHeight_CalcRowHeight(dat, hwnd, contact, item);
+ return RowHeight_CalcRowHeight(dat, contact, item);
DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE);
//TODO replace futher code with new rowheight definition
@@ -546,7 +536,7 @@ int RowHeights_GetRowHeight_worker(ClcData *dat, HWND hwnd, ClcContact *contact,
return -1;
int height = 0;
- ClcCacheEntry *pdnce = (contact->type == CLCIT_CONTACT) ? pcli->pfnGetCacheEntry(contact->hContact) : NULL;
+ ClcCacheEntry *pdnce = contact->pce;
if (dat->row_variable_height) {
if (!dat->text_ignore_size_for_row_height) {
@@ -579,16 +569,14 @@ int RowHeights_GetRowHeight_worker(ClcData *dat, HWND hwnd, ClcContact *contact,
// Checkbox size
if ((style & CLS_CHECKBOXES && contact->type == CLCIT_CONTACT) ||
(style & CLS_GROUPCHECKBOXES && contact->type == CLCIT_GROUP) ||
- (contact->type == CLCIT_INFO && contact->flags & CLCIIF_CHECKBOX))
- {
+ (contact->type == CLCIT_INFO && contact->flags & CLCIIF_CHECKBOX)) {
height = max(height, dat->checkboxSize);
}
// Icon size
if (!dat->icon_ignore_size_for_row_height) {
if (contact->type == CLCIT_GROUP ||
- (contact->type == CLCIT_CONTACT && contact->iImage != -1 && !(dat->icon_hide_on_avatar && dat->avatars_show && contact->avatar_data != NULL && !contact->image_is_special)))
- {
+ (contact->type == CLCIT_CONTACT && contact->iImage != -1 && !(dat->icon_hide_on_avatar && dat->avatars_show && contact->avatar_data != NULL && !contact->image_is_special))) {
height = max(height, ICON_HEIGHT);
}
}
diff --git a/src/mir_app/src/clcitems.cpp b/src/mir_app/src/clcitems.cpp
index 7a3c203e8b..acb04a8f5f 100644
--- a/src/mir_app/src/clcitems.cpp
+++ b/src/mir_app/src/clcitems.cpp
@@ -185,39 +185,39 @@ int fnAddContactToGroup(struct ClcData *dat, ClcGroup *group, MCONTACT hContact)
index = i;
}
- i = cli.pfnAddItemToGroup(group, index + 1);
char *szProto = GetContactProto(hContact);
- group->cl.items[i]->type = CLCIT_CONTACT;
- group->cl.items[i]->iImage = cli.pfnGetContactIcon(hContact);
- group->cl.items[i]->hContact = hContact;
- group->cl.items[i]->proto = szProto;
+
+ ClcCacheEntry *pce = cli.pfnGetCacheEntry(hContact);
+ replaceStrT(pce->tszGroup, NULL);
+
+ i = cli.pfnAddItemToGroup(group, index + 1);
+
+ ClcContact *cc = group->cl.items[i];
+ cc->type = CLCIT_CONTACT;
+ cc->iImage = cli.pfnGetContactIcon(hContact);
+ cc->hContact = hContact;
+ cc->proto = szProto;
+ cc->pce = pce;
if (szProto != NULL && !cli.pfnIsHiddenMode(dat, db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE)))
- group->cl.items[i]->flags |= CONTACTF_ONLINE;
+ cc->flags |= CONTACTF_ONLINE;
WORD apparentMode = szProto != NULL ? db_get_w(hContact, szProto, "ApparentMode", 0) : 0;
if (apparentMode == ID_STATUS_OFFLINE)
- group->cl.items[i]->flags |= CONTACTF_INVISTO;
+ cc->flags |= CONTACTF_INVISTO;
else if (apparentMode == ID_STATUS_ONLINE)
- group->cl.items[i]->flags |= CONTACTF_VISTO;
+ cc->flags |= CONTACTF_VISTO;
else if (apparentMode)
- group->cl.items[i]->flags |= CONTACTF_VISTO | CONTACTF_INVISTO;
+ cc->flags |= CONTACTF_VISTO | CONTACTF_INVISTO;
if (db_get_b(hContact, "CList", "NotOnList", 0))
- group->cl.items[i]->flags |= CONTACTF_NOTONLIST;
+ cc->flags |= CONTACTF_NOTONLIST;
DWORD idleMode = szProto != NULL ? db_get_dw(hContact, szProto, "IdleTS", 0) : 0;
if (idleMode)
- group->cl.items[i]->flags |= CONTACTF_IDLE;
- mir_tstrncpy(group->cl.items[i]->szText, cli.pfnGetContactDisplayName(hContact, 0), _countof(group->cl.items[i]->szText));
-
- ClcCacheEntry *p = cli.pfnGetCacheEntry(hContact);
- if (p != NULL)
- replaceStrT(p->tszGroup, NULL);
-
+ cc->flags |= CONTACTF_IDLE;
+ mir_tstrncpy(cc->szText, cli.pfnGetContactDisplayName(hContact, 0), _countof(cc->szText));
return i;
}
void fnAddContactToTree(HWND hwnd, struct ClcData *dat, MCONTACT hContact, int updateTotalCount, int checkHideOffline)
{
- ClcGroup *group;
- DBVARIANT dbv;
DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE);
WORD status = ID_STATUS_OFFLINE;
char *szProto = GetContactProto(hContact);
@@ -229,49 +229,46 @@ void fnAddContactToTree(HWND hwnd, struct ClcData *dat, MCONTACT hContact, int u
if (szProto != NULL)
status = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
- if (db_get_ts(hContact, "CList", "Group", &dbv))
+ int i;
+ DWORD groupFlags;
+ ClcGroup *group;
+ ptrT tszGroup(db_get_tsa(hContact, "CList", "Group"));
+ if (tszGroup == NULL)
group = &dat->list;
else {
- group = cli.pfnAddGroup(hwnd, dat, dbv.ptszVal, (DWORD) - 1, 0, 0);
+ group = cli.pfnAddGroup(hwnd, dat, tszGroup, (DWORD)-1, 0, 0);
if (group == NULL) {
- int i;
- DWORD groupFlags;
- TCHAR *szGroupName;
- if (!(style & CLS_HIDEEMPTYGROUPS)) {
- mir_free(dbv.ptszVal);
+ if (!(style & CLS_HIDEEMPTYGROUPS))
return;
- }
+
if (checkHideOffline && cli.pfnIsHiddenMode(dat, status)) {
for (i = 1;; i++) {
- szGroupName = Clist_GroupGetName(i, &groupFlags);
- if (szGroupName == NULL) {
- mir_free(dbv.ptszVal);
+ TCHAR *szGroupName = Clist_GroupGetName(i, &groupFlags);
+ if (szGroupName == NULL)
return;
- }
- if (!mir_tstrcmp(szGroupName, dbv.ptszVal))
+
+ if (!mir_tstrcmp(szGroupName, tszGroup))
break;
}
- if (groupFlags & GROUPF_HIDEOFFLINE) {
- mir_free(dbv.ptszVal);
+ if (groupFlags & GROUPF_HIDEOFFLINE)
return;
- }
}
for (i = 1;; i++) {
- szGroupName = Clist_GroupGetName(i, &groupFlags);
- if (szGroupName == NULL) {
- mir_free(dbv.ptszVal);
+ TCHAR *szGroupName = Clist_GroupGetName(i, &groupFlags);
+ if (szGroupName == NULL)
return;
- }
- if (!mir_tstrcmp(szGroupName, dbv.ptszVal))
+
+ if (!mir_tstrcmp(szGroupName, tszGroup))
break;
+
size_t len = mir_tstrlen(szGroupName);
- if (!_tcsncmp(szGroupName, dbv.ptszVal, len) && dbv.ptszVal[len] == '\\')
+ if (!_tcsncmp(szGroupName, tszGroup, len) && tszGroup[len] == '\\')
cli.pfnAddGroup(hwnd, dat, szGroupName, groupFlags, i, 1);
}
- group = cli.pfnAddGroup(hwnd, dat, dbv.ptszVal, groupFlags, i, 1);
+ group = cli.pfnAddGroup(hwnd, dat, tszGroup, groupFlags, i, 1);
}
- mir_free(dbv.ptszVal);
}
+
if (checkHideOffline) {
if (cli.pfnIsHiddenMode(dat, status) && (style & CLS_HIDEOFFLINE || group->hideOffline)) {
if (updateTotalCount)
@@ -286,17 +283,15 @@ void fnAddContactToTree(HWND hwnd, struct ClcData *dat, MCONTACT hContact, int u
ClcGroup* fnRemoveItemFromGroup(HWND hwnd, ClcGroup *group, ClcContact *contact, int updateTotalCount)
{
- int iContact;
- if ((iContact = List_IndexOf((SortedList*)&group->cl, contact)) == -1)
+ int iContact = List_IndexOf((SortedList*)&group->cl, contact);
+ if (iContact == -1)
return group;
if (contact->type == CLCIT_CONTACT) {
if (updateTotalCount)
group->totalMembers--;
- ClcCacheEntry *p = cli.pfnGetCacheEntry(contact->hContact);
- if (p != NULL)
- replaceStrT(p->tszGroup, NULL);
+ cli.pfnInvalidateDisplayNameCacheEntry(contact->hContact);
}
cli.pfnFreeContact(group->cl.items[iContact]);
@@ -332,9 +327,11 @@ void fnDeleteItemFromTree(HWND hwnd, MCONTACT hItem)
for (i=0;; i++) {
if (group->scanIndex == group->cl.count)
break;
- if (group->cl.items[i]->type == CLCIT_GROUP) {
- size_t len = mir_tstrlen(group->cl.items[i]->szText);
- if (!_tcsncmp(group->cl.items[i]->szText, dbv.ptszVal + nameOffset, len) &&
+
+ ClcContact *cc = group->cl.items[i];
+ if (cc->type == CLCIT_GROUP) {
+ size_t len = mir_tstrlen(cc->szText);
+ if (!_tcsncmp(cc->szText, dbv.ptszVal + nameOffset, len) &&
(dbv.ptszVal[nameOffset + len] == '\\' || dbv.ptszVal[nameOffset + len] == '\0')) {
group->totalMembers--;
if (dbv.ptszVal[nameOffset + len] == '\0')
diff --git a/src/mir_app/src/clistmod.cpp b/src/mir_app/src/clistmod.cpp
index 9ea47517ce..60b6023cb3 100644
--- a/src/mir_app/src/clistmod.cpp
+++ b/src/mir_app/src/clistmod.cpp
@@ -30,7 +30,8 @@ int InitCListEvents(void);
void UninitCListEvents(void);
void UninitGroupServices(void);
int ContactSettingChanged(WPARAM wParam, LPARAM lParam);
-int ContactAdded(WPARAM wParam, LPARAM lParam);
+int ContactAdded(WPARAM hContact, LPARAM);
+int ContactDeleted(WPARAM hContact, LPARAM);
INT_PTR GetContactDisplayName(WPARAM wParam, LPARAM lParam);
INT_PTR InvalidateDisplayName(WPARAM wParam, LPARAM lParam);
int InitGroupServices(void);
@@ -421,6 +422,7 @@ int LoadContactListModule2(void)
HookEvent(ME_PROTO_ACCLISTCHANGED, ContactListAccountsChanged);
HookEvent(ME_DB_CONTACT_SETTINGCHANGED, ContactSettingChanged);
HookEvent(ME_DB_CONTACT_ADDED, ContactAdded);
+ HookEvent(ME_DB_CONTACT_DELETED, ContactDeleted);
HookEvent(ME_PROTO_ACK, ProtocolAck);
hContactDoubleClicked = CreateHookableEvent(ME_CLIST_DOUBLECLICKED);
diff --git a/src/mir_app/src/clistsettings.cpp b/src/mir_app/src/clistsettings.cpp
index 55aa9ec808..b74bd28139 100644
--- a/src/mir_app/src/clistsettings.cpp
+++ b/src/mir_app/src/clistsettings.cpp
@@ -119,7 +119,7 @@ TCHAR* fnGetContactDisplayName(MCONTACT hContact, int mode)
if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
if (ci.type == CNFT_ASCIIZ) {
if (cacheEntry != NULL)
- cacheEntry->tszName = ci.pszVal;
+ replaceStrT(cacheEntry->tszName, ci.pszVal);
return ci.pszVal;
}
@@ -127,7 +127,7 @@ TCHAR* fnGetContactDisplayName(MCONTACT hContact, int mode)
TCHAR *buffer = (TCHAR*)mir_alloc(15 * sizeof(TCHAR));
_ltot(ci.dVal, buffer, 10);
if (cacheEntry != NULL)
- cacheEntry->tszName = buffer;
+ replaceStrT(cacheEntry->tszName, buffer);
return buffer;
}
}
@@ -137,9 +137,20 @@ TCHAR* fnGetContactDisplayName(MCONTACT hContact, int mode)
return (cacheEntry == NULL) ? mir_tstrdup(buffer) : buffer;
}
-int ContactAdded(WPARAM wParam, LPARAM)
+int ContactAdded(WPARAM hContact, LPARAM)
{
- cli.pfnChangeContactIcon(wParam, cli.pfnIconFromStatusMode(GetContactProto(wParam), ID_STATUS_OFFLINE, NULL));
+ cli.pfnChangeContactIcon(hContact, cli.pfnIconFromStatusMode(GetContactProto(hContact), ID_STATUS_OFFLINE, NULL));
+ return 0;
+}
+
+int ContactDeleted(WPARAM hContact, LPARAM)
+{
+ int idx = clistCache.getIndex((ClcCacheEntry*)&hContact);
+ if (idx != -1) {
+ cli.pfnFreeCacheItem(clistCache[idx]);
+ mir_free(clistCache[idx]);
+ clistCache.remove(idx);
+ }
return 0;
}
diff --git a/src/mir_app/src/extraicons.cpp b/src/mir_app/src/extraicons.cpp
index f6ef9ac916..bdaa2d746f 100644
--- a/src/mir_app/src/extraicons.cpp
+++ b/src/mir_app/src/extraicons.cpp
@@ -319,10 +319,6 @@ void fnSetAllExtraIcons(MCONTACT hContact)
hContact = db_find_first();
for (; hContact; hContact = db_find_next(hContact)) {
- ClcCacheEntry* pdnce = (ClcCacheEntry*)cli.pfnGetCacheEntry(hContact);
- if (pdnce == NULL)
- continue;
-
NotifyEventHooks(hEventExtraImageApplying, hContact, 0);
if (hcontgiven)
break;
diff --git a/src/mir_app/src/skinicons.cpp b/src/mir_app/src/skinicons.cpp
index a6db6c3a7c..360e1742d5 100644
--- a/src/mir_app/src/skinicons.cpp
+++ b/src/mir_app/src/skinicons.cpp
@@ -226,7 +226,7 @@ MIR_APP_DLL(HICON) Skin_LoadProtoIcon(const char *szProto, int status, bool big)
INT_PTR caps2;
if (szProto == NULL)
caps2 = -1;
- else if ((caps2 = CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_2, 0)) == CALLSERVICE_NOTFOUND)
+ else if ((caps2 = CallProtoServiceInt(NULL, szProto, PS_GETCAPS, PFLAGNUM_2, 0)) == CALLSERVICE_NOTFOUND)
caps2 = 0;
if (IsStatusConnecting(status)) {
@@ -306,7 +306,7 @@ MIR_APP_DLL(HICON) Skin_LoadProtoIcon(const char *szProto, int status, bool big)
else
lowidx = 0, highidx = _countof(statusIcons);
- for (int i = lowidx; i < highidx; i++)
+ for (int i = lowidx; i < highidx; i++) {
if (caps2 == 0 || (caps2 & statusIcons[i].pf2)) {
// format: core_%s%d
mir_snprintf(iconName, "%s%s%d", statusIconsFmt, szProto, i);
@@ -315,6 +315,7 @@ MIR_APP_DLL(HICON) Skin_LoadProtoIcon(const char *szProto, int status, bool big)
sid.iDefaultIndex = statusIcons[i].resource_id;
IcoLib_AddIcon(&sid, 0);
}
+ }
}
// format: core_status_%s%d