diff options
author | George Hazan <george.hazan@gmail.com> | 2013-03-08 13:41:31 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-03-08 13:41:31 +0000 |
commit | 29caf2ccc31bc009d25b577cfc1cfbd82163aa3b (patch) | |
tree | d4122345850eaf1c2bbf4fce285bc63b5ffd937d | |
parent | c4c02e49eddd09393cafb55513f5067b5810c1c9 (diff) |
major speedup of clist nicer+ cache
git-svn-id: http://svn.miranda-ng.org/main/trunk@3920 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp | 2 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/Include/clc.h | 6 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/Include/config.h | 55 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/Include/rowheight_funcs.h | 2 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/clc.cpp | 64 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/clcidents.cpp | 2 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/clcitems.cpp | 141 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/clcmsgs.cpp | 6 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/clcpaint.cpp | 6 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/clcutils.cpp | 4 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/clistevents.cpp | 8 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/clistmenus.cpp | 10 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/clistmod.cpp | 2 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/clistopts.cpp | 2 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/clui.cpp | 2 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/config.cpp | 79 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/contact.cpp | 10 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/init.cpp | 4 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/viewmodes.cpp | 6 |
19 files changed, 194 insertions, 217 deletions
diff --git a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp b/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp index e8c41ab051..e15a91409b 100644 --- a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp +++ b/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp @@ -1590,7 +1590,7 @@ static int CLUIFramesLoadMainMenu() if (FramesSysNotStarted)
return -1;
- if (MainMIRoot != (HANDLE) - 1) {
+ if (MainMIRoot != (HANDLE)- 1) {
CallService(MS_CLIST_REMOVEMAINMENUITEM, (WPARAM)MainMIRoot, 0);
MainMIRoot = (HGENMENU) - 1;
}
diff --git a/plugins/Clist_nicer/src/Include/clc.h b/plugins/Clist_nicer/src/Include/clc.h index 5bafa1080c..e28143eeec 100644 --- a/plugins/Clist_nicer/src/Include/clc.h +++ b/plugins/Clist_nicer/src/Include/clc.h @@ -131,9 +131,9 @@ struct ClcContact : public ClcContactBase BYTE xStatus;
char *metaProto;
DWORD codePage;
- struct avatarCacheEntry *ace;
+ avatarCacheEntry *ace;
WORD wStatus;
- int extraCacheEntry;
+ TExtraCache* pExtra;
int avatarLeft, extraIconRightBegin;
int isRtl;
DWORD cFlags;
@@ -389,7 +389,7 @@ int GetDropTargetInformation(HWND hwnd, struct ClcData *dat, POINT pt); void LoadClcOptions(HWND hwnd, struct ClcData *dat);
void RecalculateGroupCheckboxes(HWND hwnd, struct ClcData *dat);
void SetGroupChildCheckboxes(ClcGroup *group, int checked);
-BYTE GetCachedStatusMsg(int iExtraCacheEntry, char *szProto);
+BYTE GetCachedStatusMsg(TExtraCache* p, char *szProto);
int __fastcall GetStatusOnlineness(int status);
void GetExtendedInfo(ClcContact *contact, struct ClcData *dat);
extern LRESULT CALLBACK NewStatusBarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
diff --git a/plugins/Clist_nicer/src/Include/config.h b/plugins/Clist_nicer/src/Include/config.h index f84b2b8238..c7dd518a25 100644 --- a/plugins/Clist_nicer/src/Include/config.h +++ b/plugins/Clist_nicer/src/Include/config.h @@ -79,45 +79,44 @@ private: class cfg
{
public:
- static void init ();
+ static void init();
- static DWORD getDword (const HANDLE hContact, const char *szModule, const char *szSetting, DWORD uDefault);
- static DWORD getDword (const char *szModule, const char *szSetting, DWORD uDefault);
- static DWORD getDword (const char *szSetting, DWORD uDefault);
+ static DWORD getDword(const HANDLE hContact, const char *szModule, const char *szSetting, DWORD uDefault);
+ static DWORD getDword(const char *szModule, const char *szSetting, DWORD uDefault);
+ static DWORD getDword(const char *szSetting, DWORD uDefault);
- static WORD getWord (const HANDLE hContact, const char *szModule, const char *szSetting, WORD uDefault);
- static WORD getWord (const char *szModule, const char *szSetting, WORD uDefault);
- static WORD getWord (const char *szSetting, WORD uDefault);
+ static WORD getWord(const HANDLE hContact, const char *szModule, const char *szSetting, WORD uDefault);
+ static WORD getWord(const char *szModule, const char *szSetting, WORD uDefault);
+ static WORD getWord(const char *szSetting, WORD uDefault);
- static int getByte (const HANDLE hContact, const char *szModule, const char *szSetting, int uDefault);
- static int getByte (const char *szModule, const char *szSetting, int uDefault);
- static int getByte (const char *szSetting, int uDefault);
+ static int getByte(const HANDLE hContact, const char *szModule, const char *szSetting, int uDefault);
+ static int getByte(const char *szModule, const char *szSetting, int uDefault);
+ static int getByte(const char *szSetting, int uDefault);
- static INT_PTR getTString (const HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv);
- static INT_PTR getString (const HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv);
+ static INT_PTR getTString(const HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv);
+ static INT_PTR getString(const HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv);
- static INT_PTR writeDword (const HANDLE hContact, const char *szModule, const char *szSetting, DWORD value);
- static INT_PTR writeDword (const char *szModule, const char *szSetting, DWORD value);
+ static INT_PTR writeDword(const HANDLE hContact, const char *szModule, const char *szSetting, DWORD value);
+ static INT_PTR writeDword(const char *szModule, const char *szSetting, DWORD value);
- static INT_PTR writeWord (const HANDLE hContact, const char *szModule, const char *szSetting, WORD value);
- static INT_PTR writeWord (const char *szModule, const char *szSetting, WORD value);
+ static INT_PTR writeWord(const HANDLE hContact, const char *szModule, const char *szSetting, WORD value);
+ static INT_PTR writeWord(const char *szModule, const char *szSetting, WORD value);
- static INT_PTR writeByte (const HANDLE hContact, const char *szModule, const char *szSetting, BYTE value);
- static INT_PTR writeByte (const char *szModule, const char *szSetting, BYTE value);
+ static INT_PTR writeByte(const HANDLE hContact, const char *szModule, const char *szSetting, BYTE value);
+ static INT_PTR writeByte(const char *szModule, const char *szSetting, BYTE value);
- static INT_PTR writeTString (const HANDLE hContact, const char *szModule, const char *szSetting, const TCHAR *st);
- static INT_PTR writeString (const HANDLE hContact, const char *szModule, const char *szSetting, const char *st);
- static int getCache (const HANDLE hContact, const char *szProto);
+ static INT_PTR writeTString(const HANDLE hContact, const char *szModule, const char *szSetting, const TCHAR *st);
+ static INT_PTR writeString(const HANDLE hContact, const char *szModule, const char *szSetting, const char *st);
+
+ static TExtraCache* getCache(const HANDLE hContact, const char *szProto);
public:
- static TCluiData dat;
- static ClcData* clcdat;
- static TExtraCache* eCache;
- static int nextCacheEntry, maxCacheEntry;
+ static TCluiData dat;
+ static ClcData* clcdat;
+
+ static LIST<TExtraCache> arCache;
- static CRITICAL_SECTION cachecs;
-
- static bool shutDown;
+ static bool shutDown;
};
struct TSysConfig {
diff --git a/plugins/Clist_nicer/src/Include/rowheight_funcs.h b/plugins/Clist_nicer/src/Include/rowheight_funcs.h index 89bc2f4ad2..d2292e6e5a 100644 --- a/plugins/Clist_nicer/src/Include/rowheight_funcs.h +++ b/plugins/Clist_nicer/src/Include/rowheight_funcs.h @@ -32,7 +32,7 @@ public: if ( !dat->bisEmbedded) {
if (contact->bSecondLine != MULTIROW_NEVER && contact->bSecondLine != MULTIROW_IFSPACE && contact->type == CLCIT_CONTACT) {
- if ((contact->bSecondLine == MULTIROW_ALWAYS || ((cfg::dat.dwFlags & CLUI_FRAME_SHOWSTATUSMSG && contact->bSecondLine == MULTIROW_IFNEEDED) && (contact->xStatus > 0 || cfg::eCache[contact->extraCacheEntry].bStatusMsgValid > STATUSMSG_XSTATUSID))))
+ if ((contact->bSecondLine == MULTIROW_ALWAYS || ((cfg::dat.dwFlags & CLUI_FRAME_SHOWSTATUSMSG && contact->bSecondLine == MULTIROW_IFNEEDED) && (contact->xStatus > 0 || contact->pExtra->bStatusMsgValid > STATUSMSG_XSTATUSID))))
height += (dat->fontInfo[FONTID_STATUS].fontHeight + cfg::dat.avatarPadding);
}
diff --git a/plugins/Clist_nicer/src/clc.cpp b/plugins/Clist_nicer/src/clc.cpp index e494790e72..ca2838d337 100644 --- a/plugins/Clist_nicer/src/clc.cpp +++ b/plugins/Clist_nicer/src/clc.cpp @@ -36,6 +36,8 @@ #include "../cluiframes/cluiframes.h"
#include "../coolsb/coolscroll.h"
+void CSH_Destroy();
+
int DefaultImageListColorDepth = ILC_COLOR32;
extern HPEN g_hPenCLUIFrames;
@@ -77,7 +79,6 @@ int __forceinline __strcmp(const char * src, const char * dst) static int ClcEventAdded(WPARAM wParam, LPARAM lParam)
{
DBEVENTINFO dbei = {0};
- int iEntry;
DWORD new_freq = 0;
cfg::dat.t_now = time(NULL);
@@ -94,11 +95,12 @@ static int ClcEventAdded(WPARAM wParam, LPARAM lParam) new_freq = count ? (dbei.timestamp - firstTime) / count : 0x7fffffff;
cfg::writeDword((HANDLE)wParam, "CList", "mf_freq", new_freq);
cfg::writeDword((HANDLE)wParam, "CList", "mf_count", count);
- iEntry = cfg::getCache((HANDLE)wParam, NULL);
- if (iEntry >= 0 && iEntry < cfg::nextCacheEntry) {
- cfg::eCache[iEntry].dwLastMsgTime = dbei.timestamp;
+
+ TExtraCache *p = cfg::getCache((HANDLE)wParam, NULL);
+ if (p) {
+ p->dwLastMsgTime = dbei.timestamp;
if (new_freq)
- cfg::eCache[iEntry].msgFrequency = new_freq;
+ p->msgFrequency = new_freq;
pcli->pfnClcBroadcast(INTM_FORCESORT, 0, 1);
}
}
@@ -205,28 +207,11 @@ int ClcShutdown(WPARAM wParam, LPARAM lParam) DestroyMenu(cfg::dat.hMenuNotify);
ClearIcons(1);
- if (cfg::eCache) {
- for (int i = 0; i < cfg::nextCacheEntry; i++) {
- if (cfg::eCache[i].statusMsg)
- free(cfg::eCache[i].statusMsg);
- if (cfg::eCache[i].status_item) {
- StatusItems_t *item = cfg::eCache[i].status_item;
-
- free(cfg::eCache[i].status_item);
- cfg::eCache[i].status_item = 0;
- for (int j = i; j < cfg::nextCacheEntry; j++) // avoid duplicate free()'ing status item pointers (there are references from sub to master contacts, so compare the pointers...
- if (cfg::eCache[j].status_item == item)
- cfg::eCache[j].status_item = 0;
- }
- }
- free(cfg::eCache);
- cfg::eCache = NULL;
- }
+ CSH_Destroy();
IMG_DeleteItems();
for (int i=0; i < arStatusItems.getCount(); i++)
mir_free(arStatusItems[i]);
arStatusItems.destroy();
- DeleteCriticalSection(&cfg::cachecs);
return 0;
}
@@ -403,18 +388,18 @@ LBL_Def: break;
if (contact->bIsMeta && cfg::dat.bMetaAvail && !(cfg::dat.dwFlags & CLUI_USEMETAICONS)) {
- contact->hSubContact = (HANDLE) CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM) contact->hContact, 0);
+ contact->hSubContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM) contact->hContact, 0);
contact->metaProto = GetContactProto(contact->hSubContact);
contact->iImage = CallService(MS_CLIST_GETCONTACTICON, (WPARAM) contact->hSubContact, 0);
- if (contact->extraCacheEntry >= 0 && contact->extraCacheEntry < cfg::nextCacheEntry) {
- int subIndex = cfg::getCache(contact->hSubContact, contact->metaProto);
+ if (contact->pExtra) {
+ TExtraCache *pSub = cfg::getCache(contact->hSubContact, contact->metaProto);
ClcContact *subContact;
if ( !pcli->pfnFindItem(hwnd, dat, (HANDLE)contact->hSubContact, &subContact, NULL, NULL))
break;
- cfg::eCache[contact->extraCacheEntry].proto_status_item = GetProtocolStatusItem(contact->metaProto);
- if (subIndex >= 0 && subIndex <= cfg::nextCacheEntry) {
- cfg::eCache[contact->extraCacheEntry].status_item = cfg::eCache[subIndex].status_item;
+ contact->pExtra->proto_status_item = GetProtocolStatusItem(contact->metaProto);
+ if (pSub) {
+ contact->pExtra->status_item = pSub->status_item;
memcpy(contact->iExtraImage, subContact->iExtraImage, sizeof(contact->iExtraImage));
}
}
@@ -469,8 +454,8 @@ LBL_Def: else {
DWORD dwFlags;
- if (contact->extraCacheEntry >= 0 && contact->extraCacheEntry < cfg::nextCacheEntry)
- dwFlags = cfg::eCache[contact->extraCacheEntry].dwDFlags;
+ if (contact->pExtra)
+ dwFlags = contact->pExtra->dwDFlags;
else
dwFlags = cfg::getDword(contact->hContact, "CList", "CLN_Flags", 0);
if (cfg::dat.dwFlags & CLUI_FRAME_AVATARS)
@@ -484,16 +469,16 @@ LBL_Def: case INTM_STATUSMSGCHANGED:
{
- int index = -1;
+ TExtraCache *p;
char *szProto = NULL;
if ( !FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL))
- index = cfg::getCache((HANDLE)wParam, NULL);
+ p = cfg::getCache((HANDLE)wParam, NULL);
else {
- index = contact->extraCacheEntry;
+ p = contact->pExtra;
szProto = contact->proto;
}
- GetCachedStatusMsg(index, szProto);
+ GetCachedStatusMsg(p, szProto);
PostMessage(hwnd, INTM_INVALIDATE, 0, (LPARAM)(contact ? contact->hContact : 0));
}
goto LBL_Def;
@@ -577,13 +562,12 @@ LBL_Def: case INTM_XSTATUSCHANGED:
{
- int index;
-
DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) lParam;
char *szProto = (char *)cws->szModule;
+ TExtraCache *p;
if ( !FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) {
- index = cfg::getCache((HANDLE)wParam, szProto);
+ p = cfg::getCache((HANDLE)wParam, szProto);
if ( !dat->bisEmbedded && cfg::dat.bMetaAvail && szProto) { // may be a subcontact, forward the xstatus
if (cfg::getByte((HANDLE)wParam, cfg::dat.szMetaName, "IsSubcontact", 0)) {
HANDLE hMasterContact = (HANDLE)cfg::getDword((HANDLE)wParam, cfg::dat.szMetaName, "Handle", 0);
@@ -595,12 +579,12 @@ LBL_Def: }
} else {
contact->xStatus = cfg::getByte((HANDLE)wParam, szProto, "XStatusId", 0);
- index = contact->extraCacheEntry;
+ p = contact->pExtra;
}
if (szProto == NULL)
break;
- GetCachedStatusMsg(index, szProto);
+ GetCachedStatusMsg(p, szProto);
PostMessage(hwnd, INTM_INVALIDATE, 0, (LPARAM)(contact ? contact->hContact : 0));
}
goto LBL_Def;
diff --git a/plugins/Clist_nicer/src/clcidents.cpp b/plugins/Clist_nicer/src/clcidents.cpp index 12f5464e41..319dff6893 100644 --- a/plugins/Clist_nicer/src/clcidents.cpp +++ b/plugins/Clist_nicer/src/clcidents.cpp @@ -63,7 +63,7 @@ int FindItem(HWND hwnd, struct ClcData *dat, HANDLE hItem, ClcContact **contact, }
if (nowVisible)
index++;
- if ((IsHContactGroup(hItem) && group->cl.items[group->scanIndex]->type == CLCIT_GROUP && ((UINT_PTR) hItem & ~HCONTACT_ISGROUP) == group->cl.items[group->scanIndex]->groupId) || (IsHContactContact(hItem) && group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && group->cl.items[group->scanIndex]->hContact == hItem) || (IsHContactInfo(hItem) && group->cl.items[group->scanIndex]->type == CLCIT_INFO && group->cl.items[group->scanIndex]->hContact == (HANDLE) ((UINT_PTR) hItem & ~HCONTACT_ISINFO))) {
+ if ((IsHContactGroup(hItem) && group->cl.items[group->scanIndex]->type == CLCIT_GROUP && ((UINT_PTR) hItem & ~HCONTACT_ISGROUP) == group->cl.items[group->scanIndex]->groupId) || (IsHContactContact(hItem) && group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && group->cl.items[group->scanIndex]->hContact == hItem) || (IsHContactInfo(hItem) && group->cl.items[group->scanIndex]->type == CLCIT_INFO && group->cl.items[group->scanIndex]->hContact == (HANDLE)((UINT_PTR) hItem & ~HCONTACT_ISINFO))) {
if (isVisible) {
if ( !nowVisible)
*isVisible = 0;
diff --git a/plugins/Clist_nicer/src/clcitems.cpp b/plugins/Clist_nicer/src/clcitems.cpp index 2170d2c9e6..757fa029f0 100644 --- a/plugins/Clist_nicer/src/clcitems.cpp +++ b/plugins/Clist_nicer/src/clcitems.cpp @@ -46,11 +46,7 @@ ClcContact* CreateClcContact( void ) ClcContact* p = (ClcContact*)mir_alloc( sizeof( ClcContact ));
if ( p != NULL ) {
ZeroMemory(p, sizeof(ClcContact));
- //p->clientId = -1;
- p->extraCacheEntry = -1;
p->avatarLeft = p->extraIconRightBegin = -1;
- p->isRtl = 0;
- p->ace = 0;
}
return p;
}
@@ -64,7 +60,7 @@ int AddInfoItemToGroup(ClcGroup *group, int flags, const TCHAR *pszText) p->bIsMeta = 0;
p->xStatus = 0;
p->ace = NULL;
- p->extraCacheEntry = -1;
+ p->pExtra = 0;
p->avatarLeft = p->extraIconRightBegin = -1;
return i;
}
@@ -82,8 +78,8 @@ void LoadAvatarForContact(ClcContact *p) {
DWORD dwFlags;
- if (p->extraCacheEntry >= 0 && p->extraCacheEntry < cfg::nextCacheEntry)
- dwFlags = cfg::eCache[p->extraCacheEntry].dwDFlags;
+ if (p->pExtra)
+ dwFlags = p->pExtra->dwDFlags;
else
dwFlags = cfg::getDword(p->hContact, "CList", "CLN_Flags", 0);
@@ -106,7 +102,7 @@ void LoadAvatarForContact(ClcContact *p) int AddContactToGroup(struct ClcData *dat, ClcGroup *group, HANDLE hContact)
{
- int i = saveAddContactToGroup( dat, group, hContact );
+ int i = saveAddContactToGroup(dat, group, hContact);
ClcContact* p = group->cl.items[i];
p->wStatus = cfg::getWord(hContact, p->proto, "Status", ID_STATUS_OFFLINE);
@@ -117,7 +113,7 @@ int AddContactToGroup(struct ClcData *dat, ClcGroup *group, HANDLE hContact) else
p->bIsMeta = FALSE;
if (p->bIsMeta && cfg::dat.bMetaAvail && !(cfg::dat.dwFlags & CLUI_USEMETAICONS)) {
- p->hSubContact = (HANDLE) CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM) hContact, 0);
+ p->hSubContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM) hContact, 0);
p->metaProto = GetContactProto(p->hSubContact);
p->iImage = CallService(MS_CLIST_GETCONTACTICON, (WPARAM) p->hSubContact, 0);
}
@@ -130,19 +126,19 @@ int AddContactToGroup(struct ClcData *dat, ClcGroup *group, HANDLE hContact) p->bSecondLine = cfg::getByte(hContact, "CList", "CLN_2ndline", cfg::dat.dualRowMode);
if (dat->bisEmbedded)
- p->extraCacheEntry = -1;
+ p->pExtra = 0;
else {
- p->extraCacheEntry = cfg::getCache(p->hContact, p->proto);
- GetExtendedInfo( p, dat);
- if (p->extraCacheEntry >= 0 && p->extraCacheEntry < cfg::nextCacheEntry)
- cfg::eCache[p->extraCacheEntry].proto_status_item = GetProtocolStatusItem(p->bIsMeta ? p->metaProto : p->proto);
+ p->pExtra = cfg::getCache(p->hContact, p->proto);
+ GetExtendedInfo(p, dat);
+ if (p->pExtra)
+ p->pExtra->proto_status_item = GetProtocolStatusItem(p->bIsMeta ? p->metaProto : p->proto);
LoadAvatarForContact(p);
// notify other plugins to re-supply their extra images (icq for xstatus, mBirthday etc...)
pcli->pfnSetAllExtraIcons(pcli->hwndContactTree, hContact);
}
- RTL_DetectAndSet( p, p->hContact);
+ RTL_DetectAndSet(p, p->hContact);
p->avatarLeft = p->extraIconRightBegin = -1;
p->flags |= cfg::getByte(p->hContact, "CList", "Priority", 0) ? CONTACTF_PRIORITY : 0;
@@ -234,21 +230,19 @@ void RebuildEntireList(HWND hwnd, struct ClcData *dat) * get it and store it properly formatted in the extra data cache
*/
-BYTE GetCachedStatusMsg(int iExtraCacheEntry, char *szProto)
+BYTE GetCachedStatusMsg(TExtraCache *p, char *szProto)
{
DBVARIANT dbv = {0};
- if (iExtraCacheEntry < 0 || iExtraCacheEntry > cfg::nextCacheEntry)
+ if (p == NULL)
return 0;
- TExtraCache *cEntry = &cfg::eCache[iExtraCacheEntry];
-
- cEntry->bStatusMsgValid = STATUSMSG_NOTFOUND;
- HANDLE hContact = cEntry->hContact;
+ p->bStatusMsgValid = STATUSMSG_NOTFOUND;
+ HANDLE hContact = p->hContact;
int result = cfg::getTString(hContact, "CList", "StatusMsg", &dbv);
if ( !result && lstrlen(dbv.ptszVal) > 1)
- cEntry->bStatusMsgValid = STATUSMSG_CLIST;
+ p->bStatusMsgValid = STATUSMSG_CLIST;
else {
if ( !szProto)
szProto = GetContactProto(hContact);
@@ -256,23 +250,23 @@ BYTE GetCachedStatusMsg(int iExtraCacheEntry, char *szProto) if ( !result )
DBFreeVariant( &dbv );
if ( !( result = cfg::getTString(hContact, szProto, "YMsg", &dbv)) && lstrlen(dbv.ptszVal) > 1)
- cEntry->bStatusMsgValid = STATUSMSG_YIM;
+ p->bStatusMsgValid = STATUSMSG_YIM;
else if ( !(result = cfg::getTString(hContact, szProto, "StatusDescr", &dbv)) && lstrlen(dbv.ptszVal) > 1)
- cEntry->bStatusMsgValid = STATUSMSG_GG;
+ p->bStatusMsgValid = STATUSMSG_GG;
else if ( !(result = cfg::getTString(hContact, szProto, "XStatusMsg", &dbv)) && lstrlen(dbv.ptszVal) > 1)
- cEntry->bStatusMsgValid = STATUSMSG_XSTATUS;
+ p->bStatusMsgValid = STATUSMSG_XSTATUS;
}
}
- if (cEntry->bStatusMsgValid == STATUSMSG_NOTFOUND) { // no status msg, consider xstatus name (if available)
+ if (p->bStatusMsgValid == STATUSMSG_NOTFOUND) { // no status msg, consider xstatus name (if available)
if ( !result )
DBFreeVariant( &dbv );
result = cfg::getTString(hContact, szProto, "XStatusName", &dbv);
if ( !result && lstrlen(dbv.ptszVal) > 1) {
int iLen = lstrlen(dbv.ptszVal);
- cEntry->bStatusMsgValid = STATUSMSG_XSTATUSNAME;
- cEntry->statusMsg = (TCHAR *)realloc(cEntry->statusMsg, (iLen + 2) * sizeof(TCHAR));
- _tcsncpy(cEntry->statusMsg, dbv.ptszVal, iLen + 1);
+ p->bStatusMsgValid = STATUSMSG_XSTATUSNAME;
+ p->statusMsg = (TCHAR *)realloc(p->statusMsg, (iLen + 2) * sizeof(TCHAR));
+ _tcsncpy(p->statusMsg, dbv.ptszVal, iLen + 1);
}
else {
int xStatus;
@@ -292,45 +286,45 @@ BYTE GetCachedStatusMsg(int iExtraCacheEntry, char *szProto) cst.ptszName = xStatusName;
if ( !CallService(szServiceName, (WPARAM)hContact, (LPARAM)&cst)) {
TCHAR *szwXstatusName = TranslateTS(xStatusName);
- cEntry->statusMsg = (TCHAR *)realloc(cEntry->statusMsg, (lstrlen(szwXstatusName) + 2) * sizeof(TCHAR));
- _tcsncpy(cEntry->statusMsg, szwXstatusName, lstrlen(szwXstatusName) + 1);
- cEntry->bStatusMsgValid = STATUSMSG_XSTATUSNAME;
+ p->statusMsg = (TCHAR *)realloc(p->statusMsg, (lstrlen(szwXstatusName) + 2) * sizeof(TCHAR));
+ _tcsncpy(p->statusMsg, szwXstatusName, lstrlen(szwXstatusName) + 1);
+ p->bStatusMsgValid = STATUSMSG_XSTATUSNAME;
}
}
}
}
- if (cEntry->bStatusMsgValid > STATUSMSG_XSTATUSNAME) {
+ if (p->bStatusMsgValid > STATUSMSG_XSTATUSNAME) {
int j = 0, i;
- cEntry->statusMsg = (TCHAR *)realloc(cEntry->statusMsg, (lstrlen(dbv.ptszVal) + 2) * sizeof(TCHAR));
+ p->statusMsg = (TCHAR *)realloc(p->statusMsg, (lstrlen(dbv.ptszVal) + 2) * sizeof(TCHAR));
for (i = 0; dbv.ptszVal[i]; i++) {
if (dbv.ptszVal[i] == (TCHAR)0x0d)
continue;
- cEntry->statusMsg[j] = dbv.ptszVal[i] == (wchar_t)0x0a ? (wchar_t)' ' : dbv.ptszVal[i];
+ p->statusMsg[j] = dbv.ptszVal[i] == (wchar_t)0x0a ? (wchar_t)' ' : dbv.ptszVal[i];
j++;
}
- cEntry->statusMsg[j] = (TCHAR)0;
+ p->statusMsg[j] = (TCHAR)0;
}
if ( !result )
DBFreeVariant( &dbv );
- if (cEntry->bStatusMsgValid != STATUSMSG_NOTFOUND) {
+ if (p->bStatusMsgValid != STATUSMSG_NOTFOUND) {
WORD infoTypeC2[12];
ZeroMemory(infoTypeC2, sizeof(WORD) * 12);
- int iLen = min(lstrlenW(cEntry->statusMsg), 10);
- GetStringTypeW(CT_CTYPE2, cEntry->statusMsg, iLen, infoTypeC2);
- cEntry->dwCFlags &= ~ECF_RTLSTATUSMSG;
+ int iLen = min(lstrlenW(p->statusMsg), 10);
+ GetStringTypeW(CT_CTYPE2, p->statusMsg, iLen, infoTypeC2);
+ p->dwCFlags &= ~ECF_RTLSTATUSMSG;
for (int i = 0; i < 10; i++) {
if (infoTypeC2[i] == C2_RIGHTTOLEFT) {
- cEntry->dwCFlags |= ECF_RTLSTATUSMSG;
+ p->dwCFlags |= ECF_RTLSTATUSMSG;
break;
}
}
}
- if (cEntry->hTimeZone == NULL)
- TZ_LoadTimeZone(hContact, cEntry, szProto);
- return cEntry->bStatusMsgValid;;
+ if (p->hTimeZone == NULL)
+ TZ_LoadTimeZone(hContact, p, szProto);
+ return p->bStatusMsgValid;;
}
/*
@@ -352,11 +346,11 @@ static void TZ_LoadTimeZone(HANDLE hContact, struct TExtraCache *c, const char * void ReloadExtraInfo(HANDLE hContact)
{
if (hContact && pcli->hwndContactTree) {
- int index = cfg::getCache(hContact, NULL);
- if (index >= 0 && index < cfg::nextCacheEntry) {
+ TExtraCache *p = cfg::getCache(hContact, NULL);
+ if (p) {
char *szProto = GetContactProto(hContact);
- TZ_LoadTimeZone(hContact, &cfg::eCache[index], szProto);
+ TZ_LoadTimeZone(hContact, p, szProto);
InvalidateRect(pcli->hwndContactTree, NULL, FALSE);
}
}
@@ -370,27 +364,28 @@ void ReloadExtraInfo(HANDLE hContact) void RTL_DetectAndSet(ClcContact *contact, HANDLE hContact)
{
WORD infoTypeC2[12];
- int i, index;
+ int i;
TCHAR *szText = NULL;
DWORD iLen;
-
+ TExtraCache *p;
+
ZeroMemory(infoTypeC2, sizeof(WORD) * 12);
if (contact == NULL) {
szText = pcli->pfnGetContactDisplayName(hContact, 0);
- index = cfg::getCache(hContact, NULL);
+ p = cfg::getCache(hContact, NULL);
}
else {
szText = contact->szText;
- index = contact->extraCacheEntry;
+ p = contact->pExtra;
}
- if (index >= 0 && index < cfg::nextCacheEntry) {
+ if (p) {
iLen = min(lstrlenW(szText), 10);
GetStringTypeW(CT_CTYPE2, szText, iLen, infoTypeC2);
- cfg::eCache[index].dwCFlags &= ~ECF_RTLNICK;
+ p->dwCFlags &= ~ECF_RTLNICK;
for (i = 0; i < 10; i++) {
if (infoTypeC2[i] == C2_RIGHTTOLEFT) {
- cfg::eCache[index].dwCFlags |= ECF_RTLNICK;
+ p->dwCFlags |= ECF_RTLNICK;
return;
}
}
@@ -422,7 +417,7 @@ void RTL_DetectGroupName(ClcContact *group) * set extra icons accordingly
*/
-void GetExtendedInfo(ClcContact *contact, struct ClcData *dat)
+void GetExtendedInfo(ClcContact *contact, ClcData *dat)
{
if (dat->bisEmbedded || contact == NULL)
return;
@@ -430,22 +425,19 @@ void GetExtendedInfo(ClcContact *contact, struct ClcData *dat) if (contact->proto == NULL || contact->hContact == 0)
return;
- int index = contact->extraCacheEntry;
-
- cfg::eCache[index].msgFrequency = cfg::getDword(contact->hContact, "CList", "mf_freq", 0x7fffffff);
+ TExtraCache *p = contact->pExtra;
+ if (p == NULL)
+ return;
- if (index >= 0 && index < cfg::nextCacheEntry) {
- if (cfg::eCache[index].valid)
- return;
- cfg::eCache[index].valid = TRUE;
- }
- else
+ p->msgFrequency = cfg::getDword(contact->hContact, "CList", "mf_freq", 0x7fffffff);
+ if (p->valid)
return;
- cfg::eCache[index].isChatRoom = cfg::getByte(contact->hContact, contact->proto, "ChatRoom", 0);
+ p->valid = TRUE;
+ p->isChatRoom = cfg::getByte(contact->hContact, contact->proto, "ChatRoom", 0);
}
-void LoadSkinItemToCache(struct TExtraCache *cEntry, const char *szProto)
+void LoadSkinItemToCache(TExtraCache *cEntry, const char *szProto)
{
HANDLE hContact = cEntry->hContact;
@@ -478,15 +470,6 @@ void LoadSkinItemToCache(struct TExtraCache *cEntry, const char *szProto) }
}
-void ReloadSkinItemsToCache()
-{
- for (int i = 0; i < cfg::nextCacheEntry; i++) {
- char *szProto = GetContactProto(cfg::eCache[i].hContact);
- if (szProto)
- LoadSkinItemToCache(&cfg::eCache[i], szProto);
- }
-}
-
/*
* checks the currently active view mode filter and returns true, if the contact should be hidden
* if no view mode is active, it returns the CList/Hidden setting
@@ -544,14 +527,14 @@ int __fastcall CLVM_GetContactHiddenStatus(HANDLE hContact, char *szProto, struc }
if (cfg::dat.bFilterEffective & CLVM_FILTER_LASTMSG) {
DWORD now;
- int iEntry = cfg::getCache(hContact, szProto);
- if (iEntry >= 0 && iEntry <= cfg::nextCacheEntry) {
+ TExtraCache *p = cfg::getCache(hContact, szProto);
+ if (p) {
now = cfg::dat.t_now;
now -= cfg::dat.lastMsgFilter;
if (cfg::dat.bFilterEffective & CLVM_FILTER_LASTMSG_OLDERTHAN)
- filterResult = filterResult & (cfg::eCache[iEntry].dwLastMsgTime < now);
+ filterResult = filterResult & (p->dwLastMsgTime < now);
else if (cfg::dat.bFilterEffective & CLVM_FILTER_LASTMSG_NEWERTHAN)
- filterResult = filterResult & (cfg::eCache[iEntry].dwLastMsgTime > now);
+ filterResult = filterResult & (p->dwLastMsgTime > now);
}
}
return (dbHidden | !filterResult);
diff --git a/plugins/Clist_nicer/src/clcmsgs.cpp b/plugins/Clist_nicer/src/clcmsgs.cpp index 7ea189e04c..2f9f4bb177 100644 --- a/plugins/Clist_nicer/src/clcmsgs.cpp +++ b/plugins/Clist_nicer/src/clcmsgs.cpp @@ -62,9 +62,9 @@ LRESULT ProcessExternalMessages(HWND hwnd, struct ClcData *dat, UINT msg, WPARAM if (contact->type != CLCIT_CONTACT)
return 0;
- if (contact->extraCacheEntry >= 0 && contact->extraCacheEntry <= cfg::nextCacheEntry)
- if (cfg::eCache[contact->extraCacheEntry].bStatusMsgValid != STATUSMSG_NOTFOUND)
- return((INT_PTR)cfg::eCache[contact->extraCacheEntry].statusMsg);
+ if (contact->pExtra)
+ if (contact->pExtra->bStatusMsgValid != STATUSMSG_NOTFOUND)
+ return((INT_PTR)contact->pExtra->statusMsg);
}
return 0;
diff --git a/plugins/Clist_nicer/src/clcpaint.cpp b/plugins/Clist_nicer/src/clcpaint.cpp index 0fd6cc0921..730b7db3a0 100644 --- a/plugins/Clist_nicer/src/clcpaint.cpp +++ b/plugins/Clist_nicer/src/clcpaint.cpp @@ -453,10 +453,10 @@ void __inline PaintItem(HDC hdcMem, ClcGroup *group, ClcContact *contact, int in avatar_done = FALSE;
TExtraCache *cEntry;
- if (contact->extraCacheEntry >= 0 && contact->extraCacheEntry < cfg::nextCacheEntry)
- cEntry = &cfg::eCache[contact->extraCacheEntry];
+ if (contact->pExtra)
+ cEntry = contact->pExtra;
else
- cEntry = cfg::eCache;
+ cEntry = cfg::arCache[0];
if (dat->bisEmbedded)
goto set_bg_l;
diff --git a/plugins/Clist_nicer/src/clcutils.cpp b/plugins/Clist_nicer/src/clcutils.cpp index 09c205686b..d329aa0460 100644 --- a/plugins/Clist_nicer/src/clcutils.cpp +++ b/plugins/Clist_nicer/src/clcutils.cpp @@ -232,7 +232,7 @@ int HitTest(HWND hwnd, struct ClcData *dat, int testx, int testy, ClcContact **c if ( !dat->bisEmbedded) {
if (hitcontact->type == CLCIT_CONTACT) {
- if (mirror_mode == 1 || (mirror_mode == 2 && cfg::eCache[hitcontact->extraCacheEntry].dwCFlags & ECF_RTLNICK))
+ if (mirror_mode == 1 || (mirror_mode == 2 && hitcontact->pExtra->dwCFlags & ECF_RTLNICK))
return RTL_HitTest(hwnd, dat, testx, testy, hitcontact, flags, indent, hit);
}
else if (hitcontact->type == CLCIT_GROUP) {
@@ -522,7 +522,7 @@ void BeginRenameSelection(HWND hwnd, struct ClcData *dat) dat->hwndRenameEdit = CreateWindowEx(0, _T("RichEdit20W"),contact->szText,WS_CHILD|WS_BORDER|ES_MULTILINE|ES_AUTOHSCROLL,x,y,clRect.right-x,h,hwnd,NULL,g_hInst,NULL);
{
- if ((contact->type == CLCIT_CONTACT && cfg::eCache[contact->extraCacheEntry].dwCFlags & ECF_RTLNICK) || (contact->type == CLCIT_GROUP && contact->isRtl)) {
+ if ((contact->type == CLCIT_CONTACT && contact->pExtra->dwCFlags & ECF_RTLNICK) || (contact->type == CLCIT_GROUP && contact->isRtl)) {
PARAFORMAT2 pf2;
ZeroMemory((void *)&pf2, sizeof(pf2));
pf2.cbSize = sizeof(pf2);
diff --git a/plugins/Clist_nicer/src/clistevents.cpp b/plugins/Clist_nicer/src/clistevents.cpp index 90fb3129dc..da9b5b7e6a 100644 --- a/plugins/Clist_nicer/src/clistevents.cpp +++ b/plugins/Clist_nicer/src/clistevents.cpp @@ -257,7 +257,7 @@ struct CListEvent* AddEvent(CLISTEVENT *cle) return NULL;
if (1) {
- if (p->cle.hContact != 0 && p->cle.hDbEvent != (HANDLE) 1 && !(p->cle.flags & CLEF_ONLYAFEW)) {
+ if (p->cle.hContact != 0 && p->cle.hDbEvent != (HANDLE)1 && !(p->cle.flags & CLEF_ONLYAFEW)) {
int j;
struct NotifyMenuItemExData *nmi = 0;
char *szProto;
@@ -270,7 +270,7 @@ struct CListEvent* AddEvent(CLISTEVENT *cle) for (j = 0; j < GetMenuItemCount(cfg::dat.hMenuNotify); j++) {
if (GetMenuItemInfo(cfg::dat.hMenuNotify, j, TRUE, &mii) != 0) {
nmi = (struct NotifyMenuItemExData *) mii.dwItemData;
- if (nmi != 0 && (HANDLE) nmi->hContact == (HANDLE) p->cle.hContact && nmi->iIcon == p->imlIconIndex)
+ if (nmi != 0 && (HANDLE)nmi->hContact == (HANDLE)p->cle.hContact && nmi->iIcon == p->imlIconIndex)
return p;
} } }
@@ -309,7 +309,7 @@ struct CListEvent* AddEvent(CLISTEVENT *cle) cfg::dat.hUpdateContact = p->cle.hContact;
}
if (cfg::dat.dwFlags & CLUI_STICKYEVENTS) {
- HANDLE hItem = (HANDLE) SendMessage(pcli->hwndContactTree, CLM_FINDCONTACT, (WPARAM) p->cle.hContact, 0);
+ HANDLE hItem = (HANDLE)SendMessage(pcli->hwndContactTree, CLM_FINDCONTACT, (WPARAM) p->cle.hContact, 0);
if (hItem) {
SendMessage(pcli->hwndContactTree, CLM_SETSTICKY, (WPARAM) hItem, 1);
pcli->pfnClcBroadcast(INTM_PROTOCHANGED, (WPARAM) p->cle.hContact, 0);
@@ -374,7 +374,7 @@ int RemoveEvent(HANDLE hContact, HANDLE hDbEvent) if (bUnstick) {
// clear "sticky" (sort) status
- hItem = (HANDLE) SendMessage(pcli->hwndContactTree, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ hItem = (HANDLE)SendMessage(pcli->hwndContactTree, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if (hItem) {
SendMessage(pcli->hwndContactTree, CLM_SETSTICKY, (WPARAM) hItem, 0);
pcli->pfnClcBroadcast(INTM_PROTOCHANGED, (WPARAM)hContact, 0);
diff --git a/plugins/Clist_nicer/src/clistmenus.cpp b/plugins/Clist_nicer/src/clistmenus.cpp index 300f7346e3..a9706be4c1 100644 --- a/plugins/Clist_nicer/src/clistmenus.cpp +++ b/plugins/Clist_nicer/src/clistmenus.cpp @@ -263,13 +263,13 @@ static INT_PTR CALLBACK IgnoreDialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPA }
cfg::writeDword(hContact, "CList", "CLN_xmask", dwXMask);
if (contact) {
- if (contact->extraCacheEntry >= 0 && contact->extraCacheEntry <= cfg::nextCacheEntry)
- cfg::eCache[contact->extraCacheEntry].dwDFlags = dwFlags;
+ if (contact->pExtra)
+ contact->pExtra->dwDFlags = dwFlags;
}
else {
- int iIndex = cfg::getCache(hContact, NULL);
- if (iIndex >= 0 && iIndex <= cfg::nextCacheEntry)
- cfg::eCache[iIndex].dwDFlags = dwFlags;
+ TExtraCache *p = cfg::getCache(hContact, NULL);
+ if (p)
+ p->dwDFlags = dwFlags;
}
cfg::writeByte(hContact, "CList", "Priority", (BYTE)(IsDlgButtonChecked(hWnd, IDC_IGN_PRIORITY) ? 1 : 0));
pcli->pfnClcBroadcast(CLM_AUTOREBUILD, 0, 0);
diff --git a/plugins/Clist_nicer/src/clistmod.cpp b/plugins/Clist_nicer/src/clistmod.cpp index c6f619f010..e5e5ae8baf 100644 --- a/plugins/Clist_nicer/src/clistmod.cpp +++ b/plugins/Clist_nicer/src/clistmod.cpp @@ -63,7 +63,7 @@ int IconFromStatusMode(const char *szProto, int status, HANDLE hContact, HICON * int finalStatus;
if (szProto != NULL && !strcmp(szProto, cfg::dat.szMetaName) && cfg::dat.bMetaAvail && hContact != 0 && !(cfg::dat.dwFlags & CLUI_USEMETAICONS)) {
- HANDLE hSubContact = (HANDLE) CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM) hContact, 0);
+ HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM) hContact, 0);
szFinalProto = GetContactProto(hSubContact);
finalStatus = (status == 0) ? (WORD) cfg::getWord(hSubContact, szFinalProto, "Status", ID_STATUS_OFFLINE) : status;
} else {
diff --git a/plugins/Clist_nicer/src/clistopts.cpp b/plugins/Clist_nicer/src/clistopts.cpp index fdb9c527f1..a8210472bd 100644 --- a/plugins/Clist_nicer/src/clistopts.cpp +++ b/plugins/Clist_nicer/src/clistopts.cpp @@ -48,7 +48,7 @@ INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP break;
case WM_DESTROY:
- UnhookEvent((HANDLE) GetWindowLongPtr(hwndDlg, GWLP_USERDATA));
+ UnhookEvent((HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA));
break;
case WM_INITDIALOG:
diff --git a/plugins/Clist_nicer/src/clui.cpp b/plugins/Clist_nicer/src/clui.cpp index b5a865b638..1d4fee7586 100644 --- a/plugins/Clist_nicer/src/clui.cpp +++ b/plugins/Clist_nicer/src/clui.cpp @@ -1516,7 +1516,7 @@ skipbg: return 0;
}
}
- else if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_MAINMENU), (LPARAM)(HANDLE) NULL))
+ else if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_MAINMENU), (LPARAM)(HANDLE)NULL))
return 0;
buttons_done:
diff --git a/plugins/Clist_nicer/src/config.cpp b/plugins/Clist_nicer/src/config.cpp index ab2d046b52..e224682e70 100644 --- a/plugins/Clist_nicer/src/config.cpp +++ b/plugins/Clist_nicer/src/config.cpp @@ -32,14 +32,13 @@ #include <commonheaders.h>
-TCluiData cfg::dat = {0};
-ClcData* cfg::clcdat = 0;
-TExtraCache* cfg::eCache = 0;
-int cfg::nextCacheEntry = 0, cfg::maxCacheEntry = 0;
+TCluiData cfg::dat = {0};
+ClcData* cfg::clcdat = 0;
-CRITICAL_SECTION cfg::cachecs = {0};
+static CRITICAL_SECTION cachecs;
+LIST<TExtraCache> cfg::arCache(100, LIST<TExtraCache>::FTSortFunc(HandleKeySortT));
-bool cfg::shutDown = false;
+bool cfg::shutDown = false;
pfnSetLayeredWindowAttributes_t API::pfnSetLayeredWindowAttributes = 0;
pfnUpdateLayeredWindow_t API::pfnUpdateLayeredWindow = 0;
@@ -202,37 +201,53 @@ INT_PTR cfg::writeString(const HANDLE hContact, const char *szModule = 0, const return(DBWriteContactSettingString(hContact, szModule, szSetting, str));
}
-int cfg::getCache(const HANDLE hContact, const char *szProto)
+TExtraCache* cfg::getCache(const HANDLE hContact, const char *szProto)
{
- int i, iFound = -1;
+ int idx = cfg::arCache.getIndex((TExtraCache*)&hContact);
+ if (idx != -1)
+ return cfg::arCache[idx];
- for (i = 0; i < nextCacheEntry; i++) {
- if (eCache[i].hContact == hContact) {
- iFound = i;
- break;
- }
+ mir_cslock lck(cachecs);
+ TExtraCache *p = (TExtraCache*)calloc(sizeof(TExtraCache), 1);
+ p->hContact = hContact;
+ LoadSkinItemToCache(p, szProto);
+ p->dwDFlags = DBGetContactSettingDword(hContact, "CList", "CLN_Flags", 0);
+ GetCachedStatusMsg(p, const_cast<char *>(szProto));
+ p->dwLastMsgTime = INTSORT_GetLastMsgTime(hContact);
+ cfg::arCache.insert(p);
+ return p;
+}
+
+void ReloadSkinItemsToCache()
+{
+ for (int i = 0; i < cfg::arCache.getCount(); i++) {
+ TExtraCache *p = cfg::arCache[i];
+ char *szProto = GetContactProto(p->hContact);
+ if (szProto)
+ LoadSkinItemToCache(p, szProto);
}
- if (iFound == -1) {
- EnterCriticalSection(&cachecs);
- if (nextCacheEntry == maxCacheEntry) {
- maxCacheEntry += 100;
- cfg::eCache = (TExtraCache *)realloc(cfg::eCache, maxCacheEntry * sizeof(TExtraCache));
+}
+
+void CSH_Destroy()
+{
+ for (int i = 0; i < cfg::arCache.getCount(); i++) {
+ TExtraCache *p = cfg::arCache[i];
+ if (p->statusMsg)
+ free(p->statusMsg);
+ if (p->status_item) {
+ StatusItems_t *item = p->status_item;
+
+ free(p->status_item);
+ p->status_item = 0;
+ for (int j = i; j < cfg::arCache.getCount(); j++) // avoid duplicate free()'ing status item pointers (there are references from sub to master contacts, so compare the pointers...
+ if (cfg::arCache[j]->status_item == item)
+ cfg::arCache[j]->status_item = 0;
}
- memset(&cfg::eCache[nextCacheEntry], 0, sizeof(TExtraCache));
- cfg::eCache[nextCacheEntry].hContact = hContact;
- cfg::eCache[nextCacheEntry].valid = FALSE;
- cfg::eCache[nextCacheEntry].bStatusMsgValid = 0;
- cfg::eCache[nextCacheEntry].statusMsg = NULL;
- cfg::eCache[nextCacheEntry].status_item = NULL;
- LoadSkinItemToCache(&cfg::eCache[nextCacheEntry], szProto);
- cfg::eCache[nextCacheEntry].dwCFlags = 0;
- cfg::eCache[nextCacheEntry].dwDFlags = DBGetContactSettingDword(hContact, "CList", "CLN_Flags", 0);
- GetCachedStatusMsg(nextCacheEntry, const_cast<char *>(szProto));
- cfg::eCache[nextCacheEntry].dwLastMsgTime = INTSORT_GetLastMsgTime(hContact);
- iFound = nextCacheEntry++;
- LeaveCriticalSection(&cachecs);
+ free(p);
}
- return iFound;
+
+ cfg::arCache.destroy();
+ DeleteCriticalSection(&cachecs);
}
void API::onInit()
diff --git a/plugins/Clist_nicer/src/contact.cpp b/plugins/Clist_nicer/src/contact.cpp index 0bce13f2ae..d4a0188164 100644 --- a/plugins/Clist_nicer/src/contact.cpp +++ b/plugins/Clist_nicer/src/contact.cpp @@ -261,9 +261,8 @@ int __forceinline INTSORT_CompareContacts(const ClcContact* c1, const ClcContact return CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE, namea, -1, nameb, -1) - 2;
case SORTBY_LASTMSG:
- if (c1->extraCacheEntry >= 0 && c1->extraCacheEntry < cfg::nextCacheEntry &&
- c2->extraCacheEntry >= 0 && c2->extraCacheEntry < cfg::nextCacheEntry)
- return(cfg::eCache[c2->extraCacheEntry].dwLastMsgTime - cfg::eCache[c1->extraCacheEntry].dwLastMsgTime);
+ if (c1->pExtra && c2->pExtra)
+ return c2->pExtra->dwLastMsgTime - c1->pExtra->dwLastMsgTime;
else {
DWORD timestamp1 = INTSORT_GetLastMsgTime(c1->hContact);
DWORD timestamp2 = INTSORT_GetLastMsgTime(c2->hContact);
@@ -271,9 +270,8 @@ int __forceinline INTSORT_CompareContacts(const ClcContact* c1, const ClcContact }
case SORTBY_FREQUENCY:
- if ( c1->extraCacheEntry >= 0 && c1->extraCacheEntry < cfg::nextCacheEntry &&
- c2->extraCacheEntry >= 0 && c2->extraCacheEntry < cfg::nextCacheEntry )
- return(cfg::eCache[c1->extraCacheEntry].msgFrequency - cfg::eCache[c2->extraCacheEntry].msgFrequency);
+ if ( c1->pExtra && c2->pExtra)
+ return c1->pExtra->msgFrequency - c2->pExtra->msgFrequency;
break;
case SORTBY_PROTO:
diff --git a/plugins/Clist_nicer/src/init.cpp b/plugins/Clist_nicer/src/init.cpp index 9a020f6b36..e50687c25f 100644 --- a/plugins/Clist_nicer/src/init.cpp +++ b/plugins/Clist_nicer/src/init.cpp @@ -222,10 +222,6 @@ extern "C" int __declspec(dllexport) CListInitialise() if ( iCount < 300 )
iCount = 300;
- cfg::eCache = reinterpret_cast<TExtraCache *>(malloc(sizeof(TExtraCache) * iCount));
- ZeroMemory(cfg::eCache, sizeof(struct TExtraCache) * iCount);
- cfg::nextCacheEntry = 0;
- cfg::maxCacheEntry = iCount;
cfg::init();
cfg::dat.hMenuNotify = CreatePopupMenu();
diff --git a/plugins/Clist_nicer/src/viewmodes.cpp b/plugins/Clist_nicer/src/viewmodes.cpp index 7442fc6e3e..2e6809b847 100644 --- a/plugins/Clist_nicer/src/viewmodes.cpp +++ b/plugins/Clist_nicer/src/viewmodes.cpp @@ -1122,8 +1122,10 @@ void ApplyViewMode(const char *name) BYTE bSaved = cfg::dat.sortOrder[0];
cfg::dat.sortOrder[0] = SORTBY_LASTMSG;
- for (int i = 0; i < cfg::nextCacheEntry; i++)
- cfg::eCache[i].dwLastMsgTime = INTSORT_GetLastMsgTime(cfg::eCache[i].hContact);
+ for (int i = 0; i < cfg::arCache.getCount(); i++) {
+ TExtraCache *p = cfg::arCache[i];
+ p->dwLastMsgTime = INTSORT_GetLastMsgTime(p->hContact);
+ }
cfg::dat.sortOrder[0] = bSaved;
|