diff options
author | George Hazan <george.hazan@gmail.com> | 2016-03-23 16:49:53 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2016-03-23 16:49:53 +0000 |
commit | 8b45e0ccd87209b7e8992ecb6dc0279e5d1b03ad (patch) | |
tree | 71bf504279c6d2b91b6b7da75ebfbf820aafb28f /plugins/Clist_modern | |
parent | 9877c5881197a7a768a006cd87e54361c10096f7 (diff) |
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@16530 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Clist_modern')
-rw-r--r-- | plugins/Clist_modern/src/modern_awaymsg.cpp | 2 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_cachefuncs.cpp | 34 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_clc.cpp | 4 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_clcitems.cpp | 25 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_clcutils.cpp | 2 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_clist.h | 4 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_clistmod.cpp | 6 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_clistsettings.cpp | 113 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_commonprototypes.h | 1 | ||||
-rw-r--r-- | plugins/Clist_modern/src/stdafx.h | 4 |
10 files changed, 91 insertions, 104 deletions
diff --git a/plugins/Clist_modern/src/modern_awaymsg.cpp b/plugins/Clist_modern/src/modern_awaymsg.cpp index f154958a56..7a10a0cbb4 100644 --- a/plugins/Clist_modern/src/modern_awaymsg.cpp +++ b/plugins/Clist_modern/src/modern_awaymsg.cpp @@ -102,7 +102,7 @@ static void amThreadProc(void *) ack.hContact = hContact;
ack.type = ACKTYPE_AWAYMSG;
ack.result = ACKRESULT_FAILED;
- ack.szModule = dnce.m_cache_cszProto;
+ ack.szModule = dnce.m_pszProto;
ClcDoProtoAck(hContact, &ack);
}
CListSettings_FreeCacheItemData(&dnce);
diff --git a/plugins/Clist_modern/src/modern_cachefuncs.cpp b/plugins/Clist_modern/src/modern_cachefuncs.cpp index 2a1c7eb82a..361e54249e 100644 --- a/plugins/Clist_modern/src/modern_cachefuncs.cpp +++ b/plugins/Clist_modern/src/modern_cachefuncs.cpp @@ -196,9 +196,9 @@ void CSmileyString::ReplaceSmileys(SHORTDATA *dat, ClcCacheEntry *pdnce, TCHAR * sp.cbSize = sizeof(sp); if (dat->text_use_protocol_smileys) { - sp.Protocolname = pdnce->m_cache_cszProto; + sp.Protocolname = pdnce->m_pszProto; - if (db_get_b(NULL, "CLC", "Meta", SETTING_USEMETAICON_DEFAULT) != 1 && pdnce->m_cache_cszProto != NULL && mir_strcmp(pdnce->m_cache_cszProto, META_PROTO) == 0) { + if (db_get_b(NULL, "CLC", "Meta", SETTING_USEMETAICON_DEFAULT) != 1 && pdnce->m_pszProto != NULL && mir_strcmp(pdnce->m_pszProto, META_PROTO) == 0) { MCONTACT hContact = db_mc_getMostOnline(pdnce->hContact); if (hContact != 0) sp.Protocolname = GetContactProto(hContact); @@ -289,9 +289,9 @@ int GetStatusName(TCHAR *text, int text_size, ClcCacheEntry *pdnce, BOOL xstatus if (nStatus == ID_STATUS_OFFLINE || nStatus == 0) noXstatus = TRUE; text[0] = '\0'; // Get XStatusName - if (!noAwayMsg && !noXstatus && xstatus_has_priority && pdnce->hContact && pdnce->m_cache_cszProto) { + if (!noAwayMsg && !noXstatus && xstatus_has_priority && pdnce->hContact && pdnce->m_pszProto) { DBVARIANT dbv = { 0 }; - if (!db_get_ts(pdnce->hContact, pdnce->m_cache_cszProto, "XStatusName", &dbv)) { + if (!db_get_ts(pdnce->hContact, pdnce->m_pszProto, "XStatusName", &dbv)) { //mir_tstrncpy(text, dbv.pszVal, text_size); CopySkipUnprintableChars(text, dbv.ptszVal, text_size - 1); db_free(&dbv); @@ -309,9 +309,9 @@ int GetStatusName(TCHAR *text, int text_size, ClcCacheEntry *pdnce, BOOL xstatus } // Get XStatusName - if (!noAwayMsg && !noXstatus && !xstatus_has_priority && pdnce->hContact && pdnce->m_cache_cszProto) { + if (!noAwayMsg && !noXstatus && !xstatus_has_priority && pdnce->hContact && pdnce->m_pszProto) { DBVARIANT dbv = { 0 }; - if (!db_get_ts(pdnce->hContact, pdnce->m_cache_cszProto, "XStatusName", &dbv)) { + if (!db_get_ts(pdnce->hContact, pdnce->m_pszProto, "XStatusName", &dbv)) { CopySkipUnprintableChars(text, dbv.ptszVal, text_size - 1); db_free(&dbv); @@ -336,7 +336,7 @@ void GetListeningTo(TCHAR *text, int text_size, ClcCacheEntry *pdnce) if (wStatus == ID_STATUS_OFFLINE || wStatus == 0) return; - if (!db_get_ts(pdnce->hContact, pdnce->m_cache_cszProto, "ListeningTo", &dbv)) { + if (!db_get_ts(pdnce->hContact, pdnce->m_pszProto, "ListeningTo", &dbv)) { CopySkipUnprintableChars(text, dbv.ptszVal, text_size - 1); db_free(&dbv); } @@ -357,9 +357,9 @@ int GetStatusMessage(TCHAR *text, int text_size, ClcCacheEntry *pdnce, BOOL xsta if (wStatus == ID_STATUS_OFFLINE || wStatus == 0) noAwayMsg = TRUE; // Get XStatusMsg - if (!noAwayMsg && xstatus_has_priority && pdnce->hContact && pdnce->m_cache_cszProto) { + if (!noAwayMsg && xstatus_has_priority && pdnce->hContact && pdnce->m_pszProto) { // Try to get XStatusMsg - if (!db_get_ts(pdnce->hContact, pdnce->m_cache_cszProto, "XStatusMsg", &dbv)) { + if (!db_get_ts(pdnce->hContact, pdnce->m_pszProto, "XStatusMsg", &dbv)) { //mir_tstrncpy(text, dbv.pszVal, text_size); CopySkipUnprintableChars(text, dbv.ptszVal, text_size - 1); db_free(&dbv); @@ -382,9 +382,9 @@ int GetStatusMessage(TCHAR *text, int text_size, ClcCacheEntry *pdnce, BOOL xsta } // Get XStatusMsg - if (!noAwayMsg && !xstatus_has_priority && pdnce->hContact && pdnce->m_cache_cszProto && text[0] == '\0') { + if (!noAwayMsg && !xstatus_has_priority && pdnce->hContact && pdnce->m_pszProto && text[0] == '\0') { // Try to get XStatusMsg - if (!db_get_ts(pdnce->hContact, pdnce->m_cache_cszProto, "XStatusMsg", &dbv)) { + if (!db_get_ts(pdnce->hContact, pdnce->m_pszProto, "XStatusMsg", &dbv)) { //mir_tstrncpy(text, dbv.pszVal, text_size); CopySkipUnprintableChars(text, dbv.ptszVal, text_size - 1); db_free(&dbv); @@ -416,7 +416,7 @@ int Cache_GetLineText( DBVARIANT dbv = { 0 }; // Try to get XStatusMsg - if (!db_get_ts(pdnce->hContact, pdnce->m_cache_cszProto, "XStatusMsg", &dbv)) { + if (!db_get_ts(pdnce->hContact, pdnce->m_pszProto, "XStatusMsg", &dbv)) { if (dbv.ptszVal != NULL && dbv.ptszVal[0] != 0) { TCHAR *tmp = NEWTSTR_ALLOCA(text); mir_sntprintf(text, text_size, _T("%s: %s"), tmp, dbv.ptszVal); @@ -429,9 +429,9 @@ int Cache_GetLineText( return TEXT_STATUS; case TEXT_NICKNAME: - if (pdnce->hContact && pdnce->m_cache_cszProto) { + if (pdnce->hContact && pdnce->m_pszProto) { DBVARIANT dbv = { 0 }; - if (!db_get_ts(pdnce->hContact, pdnce->m_cache_cszProto, "Nick", &dbv)) { + if (!db_get_ts(pdnce->hContact, pdnce->m_pszProto, "Nick", &dbv)) { mir_tstrncpy(text, dbv.ptszVal, text_size); db_free(&dbv); CopySkipUnprintableChars(text, text, text_size - 1); @@ -445,7 +445,7 @@ int Cache_GetLineText( DBVARIANT dbv = { 0 }; // Try to get XStatusName - if (!db_get_ts(pdnce->hContact, pdnce->m_cache_cszProto, "XStatusName", &dbv)) { + if (!db_get_ts(pdnce->hContact, pdnce->m_pszProto, "XStatusName", &dbv)) { if (dbv.pszVal != NULL && dbv.pszVal[0] != 0) { TCHAR *tmp = NEWTSTR_ALLOCA(text); mir_sntprintf(text, text_size, _T("%s: %s"), dbv.pszVal, tmp); @@ -457,7 +457,7 @@ int Cache_GetLineText( else if (use_name_and_message_for_xstatus && xstatus_has_priority) { DBVARIANT dbv = { 0 }; // Try to get XStatusName - if (!db_get_ts(pdnce->hContact, pdnce->m_cache_cszProto, "XStatusName", &dbv)) { + if (!db_get_ts(pdnce->hContact, pdnce->m_pszProto, "XStatusName", &dbv)) { if (dbv.ptszVal != NULL && dbv.ptszVal[0] != 0) mir_tstrncpy(text, dbv.ptszVal, text_size); CopySkipUnprintableChars(text, text, text_size - 1); @@ -517,7 +517,7 @@ void Cache_GetFirstLineText(ClcData *dat, ClcContact *contact) TCHAR *name = pcli->pfnGetContactDisplayName(contact->hContact, 0); if (dat->first_line_append_nick && !dat->force_in_dialog) { DBVARIANT dbv = { 0 }; - if (!db_get_ts(pdnce->hContact, pdnce->m_cache_cszProto, "Nick", &dbv)) { + if (!db_get_ts(pdnce->hContact, pdnce->m_pszProto, "Nick", &dbv)) { TCHAR nick[_countof(contact->szText)]; mir_tstrncpy(nick, dbv.ptszVal, _countof(contact->szText)); db_free(&dbv); diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp index 6e51d3a2a4..8ac0853243 100644 --- a/plugins/Clist_modern/src/modern_clc.cpp +++ b/plugins/Clist_modern/src/modern_clc.cpp @@ -1563,8 +1563,8 @@ static LRESULT clcOnIntmStatusChanged(ClcData *dat, HWND hwnd, UINT msg, WPARAM int ret = corecli.pfnContactListControlWndProc(hwnd, msg, wParam, lParam); if (wParam != 0) { ClcCacheEntry *pdnce = pcli->pfnGetCacheEntry(wParam); - if (pdnce && pdnce->m_cache_cszProto) { - pdnce->m_cache_nStatus = GetStatusForContact(pdnce->hContact, pdnce->m_cache_cszProto); + if (pdnce && pdnce->m_pszProto) { + pdnce->m_cache_nStatus = GetStatusForContact(pdnce->hContact, pdnce->m_pszProto); if (!dat->force_in_dialog && (dat->second_line_show || dat->third_line_show)) gtaRenewText(pdnce->hContact); SendMessage(hwnd, INTM_ICONCHANGED, wParam, corecli.pfnGetContactIcon(wParam)); diff --git a/plugins/Clist_modern/src/modern_clcitems.cpp b/plugins/Clist_modern/src/modern_clcitems.cpp index 679c5deb81..2b4931bcd1 100644 --- a/plugins/Clist_modern/src/modern_clcitems.cpp +++ b/plugins/Clist_modern/src/modern_clcitems.cpp @@ -62,7 +62,7 @@ void AddSubcontacts(ClcData *dat, ClcContact *cont, BOOL showOfflineHereGroup) p.iImage = corecli.pfnGetContactIcon(cacheEntry->hContact); memset(p.iExtraImage, 0xFF, sizeof(p.iExtraImage)); - p.proto = cacheEntry->m_cache_cszProto; + p.proto = cacheEntry->m_pszProto; p.type = CLCIT_CONTACT; p.flags = 0;//CONTACTF_ONLINE; p.isSubcontact = i + 1; @@ -73,7 +73,7 @@ void AddSubcontacts(ClcData *dat, ClcContact *cont, BOOL showOfflineHereGroup) Cache_GetTimezone(dat, (&p)->hContact); Cache_GetText(dat, &p, 1); - char *szProto = cacheEntry->m_cache_cszProto; + char *szProto = cacheEntry->m_pszProto; if (szProto != NULL && !pcli->pfnIsHiddenMode(dat, wStatus)) p.flags |= CONTACTF_ONLINE; int apparentMode = szProto != NULL ? cacheEntry->ApparentMode : 0; @@ -167,7 +167,7 @@ static void _LoadDataToContact(ClcContact *cont, ClcGroup *group, ClcData *dat, pcli->pfnInvalidateDisplayNameCacheEntry(hContact); ClcCacheEntry *cacheEntry = pcli->pfnGetCacheEntry(hContact); - char *szProto = cacheEntry->m_cache_cszProto; + char *szProto = cacheEntry->m_pszProto; cont->proto = szProto; if (szProto != NULL && !pcli->pfnIsHiddenMode(dat, pdnce___GetStatus(cacheEntry))) @@ -260,7 +260,7 @@ void cli_AddContactToTree(HWND hwnd, ClcData *dat, MCONTACT hContact, int update if (dat->IsMetaContactsEnabled && cacheEntry && cacheEntry->m_bIsSub) return; //contact should not be added - if (!dat->IsMetaContactsEnabled && cacheEntry && !mir_strcmp(cacheEntry->m_cache_cszProto, META_PROTO)) + if (!dat->IsMetaContactsEnabled && cacheEntry && !mir_strcmp(cacheEntry->m_pszProto, META_PROTO)) return; corecli.pfnAddContactToTree(hwnd, dat, hContact, updateTotalCount, checkHideOffline); @@ -383,7 +383,7 @@ void cliRebuildEntireList(HWND hwnd, ClcData *dat) group->totalMembers++; if (!(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->hideOffline)) { - if (cacheEntry->m_cache_cszProto == NULL) { + if (cacheEntry->m_pszProto == NULL) { if (!pcli->pfnIsHiddenMode(dat, ID_STATUS_OFFLINE) || cacheEntry->m_cache_nNoHiddenOffline || CLCItems_IsShowOfflineGroup(group)) cont = AddContactToGroup(dat, group, cacheEntry); } @@ -616,12 +616,7 @@ ClcCacheEntry* cliCreateCacheItem(MCONTACT hContact) return NULL; p->hContact = hContact; - p->m_cache_cszProto = GetContactProto(hContact); - if (p->m_cache_cszProto == NULL) { - mir_free(p); - return NULL; - } - + p->m_pszProto = GetContactProto(hContact); p->dwLastMsgTime = -1;
p->bIsHidden = -1;
p->m_cache_nNoHiddenOffline = -1;
@@ -635,11 +630,7 @@ void cliInvalidateDisplayNameCacheEntry(MCONTACT hContact) { if (hContact == INVALID_CONTACT_ID) corecli.pfnInvalidateDisplayNameCacheEntry(INVALID_CONTACT_ID); - else { - ClcCacheEntry *p = pcli->pfnGetCacheEntry(hContact); - if (p) - InvalidateDNCEbyPointer(hContact, p, 0); - } + // no need to destroy a cache item otherwise } void cli_SetContactCheckboxes(ClcContact *cc, int checked) @@ -703,7 +694,7 @@ int __fastcall CLVM_GetContactHiddenStatus(MCONTACT hContact, char *szProto, Clc if (dat != NULL && dat->IsMetaContactsEnabled && db_mc_isSub(hContact)) return -1; //subcontact - if (pdnce && pdnce->isUnknown && dat != NULL && !dat->force_in_dialog) + if (pdnce && pdnce->m_bIsUnknown && dat != NULL && !dat->force_in_dialog) return 1; //'Unknown Contact' if (dat != NULL && dat->filterSearch && pdnce && pdnce->tszName) { // search filtering diff --git a/plugins/Clist_modern/src/modern_clcutils.cpp b/plugins/Clist_modern/src/modern_clcutils.cpp index 64ed32c0f0..5a48d2c855 100644 --- a/plugins/Clist_modern/src/modern_clcutils.cpp +++ b/plugins/Clist_modern/src/modern_clcutils.cpp @@ -697,7 +697,7 @@ void LoadCLCOptions(HWND hwnd, ClcData *dat, BOOL bFirst) dat->dbbBlend25 = db_get_b(NULL, "CLC", "Blend25%", SETTING_BLENDINACTIVESTATE_DEFAULT);
dat->bCompactMode = db_get_b(NULL, "CLC", "CompactMode", SETTING_COMPACTMODE_DEFAULT);
if ((pcli->hwndContactTree == hwnd || pcli->hwndContactTree == NULL))
- IvalidateDisplayNameCache(16);
+ IvalidateDisplayNameCache();
corecli.pfnLoadClcOptions(hwnd, dat, bFirst);
diff --git a/plugins/Clist_modern/src/modern_clist.h b/plugins/Clist_modern/src/modern_clist.h index 54360157f7..ad1e5dd342 100644 --- a/plugins/Clist_modern/src/modern_clist.h +++ b/plugins/Clist_modern/src/modern_clist.h @@ -77,9 +77,9 @@ struct ClcCacheEntry : public ClcCacheEntryBase int m_cache_nNoHiddenOffline;
int m_cache_nStatus;
- char* m_cache_cszProto;
+ char* m_pszProto;
bool m_bIsSub;
- bool isUnknown;
+ bool m_bIsUnknown;
int ApparentMode;
int NotOnList;
diff --git a/plugins/Clist_modern/src/modern_clistmod.cpp b/plugins/Clist_modern/src/modern_clistmod.cpp index fcaa43a416..dbfec61b36 100644 --- a/plugins/Clist_modern/src/modern_clistmod.cpp +++ b/plugins/Clist_modern/src/modern_clistmod.cpp @@ -89,8 +89,8 @@ int cli_IconFromStatusMode(const char *szProto, int nStatus, MCONTACT hContact) MCONTACT hMostOnlineContact = db_mc_getMostOnline(hActContact);
if (hMostOnlineContact) {
ClcCacheEntry *cacheEntry = pcli->pfnGetCacheEntry(hMostOnlineContact);
- if (cacheEntry && cacheEntry->m_cache_cszProto) {
- szActProto = cacheEntry->m_cache_cszProto;
+ if (cacheEntry && cacheEntry->m_pszProto) {
+ szActProto = cacheEntry->m_pszProto;
nActStatus = cacheEntry->m_cache_nStatus;
hActContact = hMostOnlineContact;
}
@@ -125,7 +125,7 @@ int cli_GetContactIcon(MCONTACT hContact) int GetContactIconC(ClcCacheEntry *p)
{
- return pcli->pfnIconFromStatusMode(p->m_cache_cszProto, p->m_cache_cszProto == NULL ? ID_STATUS_OFFLINE : p->m_cache_nStatus, p->hContact);
+ return pcli->pfnIconFromStatusMode(p->m_pszProto, p->m_pszProto == NULL ? ID_STATUS_OFFLINE : p->m_cache_nStatus, p->hContact);
}
//lParam
diff --git a/plugins/Clist_modern/src/modern_clistsettings.cpp b/plugins/Clist_modern/src/modern_clistsettings.cpp index 723237e800..922e2d736a 100644 --- a/plugins/Clist_modern/src/modern_clistsettings.cpp +++ b/plugins/Clist_modern/src/modern_clistsettings.cpp @@ -103,15 +103,15 @@ void CListSettings_CopyCacheItems(ClcCacheEntry *pDst, ClcCacheEntry *pSrc, DWOR CListSettings_FreeCacheItemDataOption(pDst, flag);
if (flag & CCI_NAME) {
- pDst->isUnknown = pSrc->isUnknown;
- if (pSrc->isUnknown)
+ pDst->m_bIsUnknown = pSrc->m_bIsUnknown;
+ if (pSrc->m_bIsUnknown)
pDst->tszName = pSrc->tszName;
else
pDst->tszName = mir_tstrdup(pSrc->tszName);
}
if (flag & CCI_GROUP) pDst->tszGroup = mir_tstrdup(pSrc->tszGroup);
- if (flag & CCI_PROTO) pDst->m_cache_cszProto = pSrc->m_cache_cszProto;
+ if (flag & CCI_PROTO) pDst->m_pszProto = pSrc->m_pszProto;
if (flag & CCI_STATUS) pDst->m_cache_nStatus = pSrc->m_cache_nStatus;
if (flag & CCI_LINES) {
@@ -188,9 +188,9 @@ void cliCheckCacheItem(ClcCacheEntry *pdnce) return;
}
- if (pdnce->m_cache_cszProto == NULL) {
- pdnce->m_cache_cszProto = GetContactProto(pdnce->hContact);
- if (pdnce->m_cache_cszProto && pdnce->tszName)
+ if (pdnce->m_pszProto == NULL) {
+ pdnce->m_pszProto = GetContactProto(pdnce->hContact);
+ if (pdnce->m_pszProto && pdnce->tszName)
pdnce->freeName();
}
@@ -198,7 +198,7 @@ void cliCheckCacheItem(ClcCacheEntry *pdnce) pdnce->getName();
if (pdnce->m_cache_nStatus == 0) //very strange look status sort is broken let always reread status
- pdnce->m_cache_nStatus = GetStatusForContact(pdnce->hContact, pdnce->m_cache_cszProto);
+ pdnce->m_cache_nStatus = GetStatusForContact(pdnce->hContact, pdnce->m_pszProto);
if (pdnce->tszGroup == NULL) {
pdnce->tszGroup = db_get_tsa(pdnce->hContact, "CList", "Group");
@@ -215,10 +215,10 @@ void cliCheckCacheItem(ClcCacheEntry *pdnce) pdnce->m_cache_nNoHiddenOffline = db_get_b(pdnce->hContact, "CList", "noOffline", 0);
if (pdnce->IdleTS == -1)
- pdnce->IdleTS = db_get_dw(pdnce->hContact, pdnce->m_cache_cszProto, "IdleTS", 0);
+ pdnce->IdleTS = db_get_dw(pdnce->hContact, pdnce->m_pszProto, "IdleTS", 0);
if (pdnce->ApparentMode == -1)
- pdnce->ApparentMode = db_get_w(pdnce->hContact, pdnce->m_cache_cszProto, "ApparentMode", 0);
+ pdnce->ApparentMode = db_get_w(pdnce->hContact, pdnce->m_pszProto, "ApparentMode", 0);
if (pdnce->NotOnList == -1)
pdnce->NotOnList = db_get_b(pdnce->hContact, "CList", "NotOnList", 0);
@@ -233,21 +233,10 @@ void cliCheckCacheItem(ClcCacheEntry *pdnce) }
}
-void IvalidateDisplayNameCache(DWORD mode)
+void IvalidateDisplayNameCache()
{
for (int i = 0; i < clistCache.getCount(); i++) {
ClcCacheEntry *pdnce = (ClcCacheEntry *)clistCache[i];
- if (mode & 16)
- InvalidateDNCEbyPointer(pdnce->hContact, pdnce, 16);
- }
-}
-
-void InvalidateDNCEbyPointer(MCONTACT hContact, ClcCacheEntry *pdnce, int SettingType)
-{
- if (hContact == NULL || pdnce == NULL)
- return;
-
- if (SettingType == 16) {
pdnce->ssSecondLine.DestroySmileyList();
mir_free_and_nil(pdnce->szSecondLineText);
pdnce->ssThirdLine.DestroySmileyList();
@@ -257,29 +246,14 @@ void InvalidateDNCEbyPointer(MCONTACT hContact, ClcCacheEntry *pdnce, int Settin pdnce->hTimeZone = NULL;
pdnce->dwLastMsgTime = -1;
Cache_GetTimezone(NULL, pdnce->hContact);
- SettingType &= ~16;
}
-
- if (SettingType >= DBVT_WCHAR) {
- pdnce->freeName();
- mir_free_and_nil(pdnce->tszGroup);
- return;
- }
-
- if (SettingType == -1 || SettingType == DBVT_DELETED) {
- pdnce->freeName();
- mir_free_and_nil(pdnce->tszGroup);
- }
-
- pdnce->m_bIsSub = false;
- pdnce->m_cache_nStatus = 0;
}
char* GetContactCachedProtocol(MCONTACT hContact)
{
ClcCacheEntry *cacheEntry = pcli->pfnGetCacheEntry(hContact);
- if (cacheEntry && cacheEntry->m_cache_cszProto)
- return cacheEntry->m_cache_cszProto;
+ if (cacheEntry && cacheEntry->m_pszProto)
+ return cacheEntry->m_pszProto;
return NULL;
}
@@ -291,10 +265,10 @@ int GetStatusForContact(MCONTACT hContact, char *szProto) void ClcCacheEntry::freeName()
{
- if (!isUnknown)
+ if (!m_bIsUnknown)
mir_free(tszName);
else
- isUnknown = false;
+ m_bIsUnknown = false;
tszName = NULL;
}
@@ -302,10 +276,10 @@ void ClcCacheEntry::getName() {
freeName();
- if (m_cache_cszProto == NULL) {
+ if (m_pszProto == NULL) {
LBL_Unknown:
tszName = UnknownConctactTranslatedName;
- isUnknown = true;
+ m_bIsUnknown = true;
return;
}
@@ -315,7 +289,7 @@ void ClcCacheEntry::getName() goto LBL_Unknown;
}
- isUnknown = false;
+ m_bIsUnknown = false;
}
int GetContactInfosForSort(MCONTACT hContact, char **Proto, TCHAR **Name, int *Status)
@@ -323,13 +297,12 @@ int GetContactInfosForSort(MCONTACT hContact, char **Proto, TCHAR **Name, int *S ClcCacheEntry *cacheEntry = NULL;
cacheEntry = pcli->pfnGetCacheEntry(hContact);
if (cacheEntry != NULL) {
- if (Proto != NULL) *Proto = cacheEntry->m_cache_cszProto;
+ if (Proto != NULL) *Proto = cacheEntry->m_pszProto;
if (Name != NULL) *Name = cacheEntry->tszName;
if (Status != NULL) *Status = cacheEntry->m_cache_nStatus;
}
- return (0);
-};
-
+ return 0;
+}
int GetContactCachedStatus(MCONTACT hContact)
{
@@ -354,6 +327,30 @@ int MetaStatusChanged(WPARAM hMeta, LPARAM) return 0;
}
+static void Dbwcs2tstr(DBCONTACTWRITESETTING *cws, TCHAR* &pStr)
+{
+ mir_free(pStr);
+
+ switch (cws->value.type) {
+ case -1:
+ case DBVT_DELETED:
+ pStr = NULL;
+ break;
+
+ case DBVT_UTF8:
+ pStr = mir_utf8decodeT(cws->value.pszVal);
+ break;
+
+ case DBVT_ASCIIZ:
+ pStr = mir_a2t(cws->value.pszVal);
+ break;
+
+ case DBVT_WCHAR:
+ pStr = mir_u2t(cws->value.ptszVal);
+ break;
+ }
+}
+
int ContactSettingChanged(WPARAM hContact, LPARAM lParam)
{
if (MirandaExiting() || !pcli || hContact == NULL)
@@ -365,19 +362,17 @@ int ContactSettingChanged(WPARAM hContact, LPARAM lParam) return 0;
}
- if (pdnce->m_cache_cszProto == NULL)
+ if (pdnce->m_pszProto == NULL)
return 0;
DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam;
- if (!strcmp(cws->szModule, pdnce->m_cache_cszProto)) {
- InvalidateDNCEbyPointer(hContact, pdnce, cws->value.type);
-
+ if (!strcmp(cws->szModule, pdnce->m_pszProto)) {
if (!strcmp(cws->szSetting, "Status") || wildcmp(cws->szSetting, "Status?")) {
if (!strcmp(cws->szModule, META_PROTO) && strcmp(cws->szSetting, "Status")) {
if (pcli->hwndContactTree && g_flag_bOnModulesLoadedCalled)
pcli->pfnInitAutoRebuild(pcli->hwndContactTree);
- if ((db_get_w(NULL, "CList", "SecondLineType", SETTING_SECONDLINE_TYPE_DEFAULT) == TEXT_STATUS_MESSAGE || db_get_w(NULL, "CList", "ThirdLineType", SETTING_THIRDLINE_TYPE_DEFAULT) == TEXT_STATUS_MESSAGE) && pdnce->hContact && pdnce->m_cache_cszProto)
+ if ((db_get_w(NULL, "CList", "SecondLineType", SETTING_SECONDLINE_TYPE_DEFAULT) == TEXT_STATUS_MESSAGE || db_get_w(NULL, "CList", "ThirdLineType", SETTING_THIRDLINE_TYPE_DEFAULT) == TEXT_STATUS_MESSAGE) && pdnce->hContact && pdnce->m_pszProto)
amRequestAwayMsg(hContact);
return 0;
@@ -391,7 +386,7 @@ int ContactSettingChanged(WPARAM hContact, LPARAM lParam) if (g_CluiData.bRemoveAwayMessageForOffline)
db_set_s(hContact, "CList", "StatusMsg", "");
- if ((db_get_w(NULL, "CList", "SecondLineType", 0) == TEXT_STATUS_MESSAGE || db_get_w(NULL, "CList", "ThirdLineType", 0) == TEXT_STATUS_MESSAGE) && pdnce->hContact && pdnce->m_cache_cszProto)
+ if ((db_get_w(NULL, "CList", "SecondLineType", 0) == TEXT_STATUS_MESSAGE || db_get_w(NULL, "CList", "ThirdLineType", 0) == TEXT_STATUS_MESSAGE) && pdnce->hContact && pdnce->m_pszProto)
amRequestAwayMsg(hContact);
pcli->pfnClcBroadcast(INTM_STATUSCHANGED, hContact, 0);
@@ -401,8 +396,10 @@ int ContactSettingChanged(WPARAM hContact, LPARAM lParam) pdnce->ApparentMode = cws->value.wVal;
else if (!strcmp(cws->szSetting, "IdleTS"))
pdnce->IdleTS = cws->value.dVal;
- else if (!strcmp(cws->szSetting, "IsSubcontact"))
+ else if (!strcmp(cws->szSetting, "IsSubcontact")) {
+ pdnce->m_bIsSub = (cws->value.type == DBVT_DELETED) ? false : cws->value.bVal != 0;
pcli->pfnInitAutoRebuild(pcli->hwndContactTree);
+ }
}
if (!strcmp(cws->szModule, "CList")) {
@@ -410,11 +407,11 @@ int ContactSettingChanged(WPARAM hContact, LPARAM lParam) if (!strcmp(cws->szSetting, "Rate"))
pcli->pfnClcBroadcast(CLM_AUTOREBUILD, 0, 0);
- else if (pdnce->tszName == NULL || !strcmp(cws->szSetting, "MyHandle"))
- InvalidateDNCEbyPointer(hContact, pdnce, cws->value.type);
+ else if (!strcmp(cws->szSetting, "MyHandle"))
+ pdnce->getName();
else if (!strcmp(cws->szSetting, "Group"))
- InvalidateDNCEbyPointer(hContact, pdnce, cws->value.type);
+ Dbwcs2tstr(cws, pdnce->tszGroup);
else if (!strcmp(cws->szSetting, "NotOnList"))
pdnce->NotOnList = cws->value.bVal;
@@ -438,7 +435,7 @@ int ContactSettingChanged(WPARAM hContact, LPARAM lParam) }
else if (!strcmp(cws->szModule, "Protocol")) {
if (!strcmp(cws->szSetting, "p")) {
- InvalidateDNCEbyPointer(hContact, pdnce, cws->value.type);
+ pdnce->m_pszProto = GetContactProto(hContact);
char *szProto = (cws->value.type == DBVT_DELETED) ? NULL : cws->value.pszVal;
cli_ChangeContactIcon(hContact, pcli->pfnIconFromStatusMode(szProto,
szProto == NULL ? ID_STATUS_OFFLINE : db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE), hContact), 0);
diff --git a/plugins/Clist_modern/src/modern_commonprototypes.h b/plugins/Clist_modern/src/modern_commonprototypes.h index 150d69d9a2..af25e9d41e 100644 --- a/plugins/Clist_modern/src/modern_commonprototypes.h +++ b/plugins/Clist_modern/src/modern_commonprototypes.h @@ -223,7 +223,6 @@ void Docking_GetMonitorRectFromWindow(HWND hWnd, RECT *rc); void DrawAvatarImageWithGDIp(HDC hDestDC, int x, int y, DWORD width, DWORD height, HBITMAP hbmp, int x1, int y1, DWORD width1, DWORD height1, DWORD flag, BYTE alpha); //gdiplus.cpp
void FreeRowCell(); //RowHeight
void InitGdiPlus(); //gdiplus.cpp
-void InvalidateDNCEbyPointer(MCONTACT hContact, ClcCacheEntry *pdnce, int SettingType); //clistsettings.c
void ShutdownGdiPlus(); //gdiplus.cpp
void UnloadAvatarOverlayIcon(); //clc.c
void UnLoadContactListModule(); //clistmod.c
diff --git a/plugins/Clist_modern/src/stdafx.h b/plugins/Clist_modern/src/stdafx.h index daeb6fca1d..c3b5549548 100644 --- a/plugins/Clist_modern/src/stdafx.h +++ b/plugins/Clist_modern/src/stdafx.h @@ -174,8 +174,8 @@ void MakeButtonSkinned(HWND hWnd); #define strsetA(a,b) {if (a) mir_free_and_nill(a); a=mir_strdup(b);}
#define strsetT(a,b) {if (a) mir_free_and_nill(a); a=mir_tstrdup(b);}
-extern void TRACE_ERROR();
-extern void IvalidateDisplayNameCache(DWORD mode);
+void TRACE_ERROR();
+void IvalidateDisplayNameCache();
extern LIST<ClcCacheEntry> clistCache;
|