diff options
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/clist/clcitems.cpp | 10 | ||||
-rw-r--r-- | src/modules/clist/clistsettings.cpp | 94 | ||||
-rw-r--r-- | src/modules/clist/groups.cpp | 6 |
3 files changed, 48 insertions, 62 deletions
diff --git a/src/modules/clist/clcitems.cpp b/src/modules/clist/clcitems.cpp index 37aa09bb46..7c0feb52ba 100644 --- a/src/modules/clist/clcitems.cpp +++ b/src/modules/clist/clcitems.cpp @@ -109,7 +109,7 @@ struct ClcGroup* fnAddGroup(HWND hwnd, struct ClcData *dat, const TCHAR *szName, HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
while (hContact) {
ClcCacheEntryBase* cache = cli.pfnGetCacheEntry(hContact);
- if ( !lstrcmp(cache->group, szName) && (style & CLS_SHOWHIDDEN || !cache->isHidden))
+ if ( !lstrcmp(cache->tszGroup, szName) && (style & CLS_SHOWHIDDEN || !cache->bIsHidden))
group->totalMembers++;
hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
@@ -209,8 +209,8 @@ int fnAddContactToGroup(struct ClcData *dat, struct ClcGroup *group, HANDLE hCon { ClcCacheEntryBase* p = cli.pfnGetCacheEntry(hContact);
if (p != NULL) {
- if (p->group) mir_free(p->group);
- p->group = NULL;
+ if (p->tszGroup) mir_free(p->tszGroup);
+ p->tszGroup = NULL;
} }
return i;
@@ -297,8 +297,8 @@ struct ClcGroup* fnRemoveItemFromGroup(HWND hwnd, struct ClcGroup *group, struct { ClcCacheEntryBase* p = cli.pfnGetCacheEntry(contact->hContact);
if (p != NULL) {
- if (p->group) mir_free(p->group);
- p->group = NULL;
+ if (p->tszGroup) mir_free(p->tszGroup);
+ p->tszGroup = NULL;
} }
cli.pfnFreeContact(group->cl.items[iContact]);
diff --git a/src/modules/clist/clistsettings.cpp b/src/modules/clist/clistsettings.cpp index 2e6f065628..8b39b3cfd9 100644 --- a/src/modules/clist/clistsettings.cpp +++ b/src/modules/clist/clistsettings.cpp @@ -65,24 +65,23 @@ ClcCacheEntryBase* fnCreateCacheItem(HANDLE hContact) void fnCheckCacheItem(ClcCacheEntryBase* p)
{
DBVARIANT dbv;
- if (p->group == NULL) {
+ if (p->tszGroup == NULL) {
if ( !DBGetContactSettingTString(p->hContact, "CList", "Group", &dbv)) {
- p->group = mir_tstrdup(dbv.ptszVal);
+ p->tszGroup = mir_tstrdup(dbv.ptszVal);
mir_free(dbv.ptszVal);
}
- else p->group = mir_tstrdup(_T(""));
+ else p->tszGroup = mir_tstrdup(_T(""));
}
- if (p->isHidden == -1)
- p->isHidden = DBGetContactSettingByte(p->hContact, "CList", "Hidden", 0);
+ if (p->bIsHidden == -1)
+ p->bIsHidden = DBGetContactSettingByte(p->hContact, "CList", "Hidden", 0);
}
void fnFreeCacheItem(ClcCacheEntryBase* p)
{
- if (p->name) { mir_free(p->name); p->name = NULL; }
- if (p->szName) { mir_free(p->szName); p->szName = NULL; }
- if (p->group) { mir_free(p->group); p->group = NULL; }
- p->isHidden = -1;
+ if (p->tszName) { mir_free(p->tszName); p->tszName = NULL; }
+ if (p->tszGroup) { mir_free(p->tszGroup); p->tszGroup = NULL; }
+ p->bIsHidden = -1;
}
ClcCacheEntryBase* fnGetCacheEntry(HANDLE hContact)
@@ -116,17 +115,17 @@ void fnInvalidateDisplayNameCacheEntry(HANDLE hContact) TCHAR* fnGetContactDisplayName(HANDLE hContact, int mode)
{
- CONTACTINFO ci;
- TCHAR *buffer;
ClcCacheEntryBase* cacheEntry = NULL;
if (mode & GCDNF_NOCACHE)
mode &= ~GCDNF_NOCACHE;
else if (mode != GCDNF_NOMYHANDLE) {
cacheEntry = cli.pfnGetCacheEntry(hContact);
- if (cacheEntry->name)
- return cacheEntry->name;
+ if (cacheEntry->tszName)
+ return cacheEntry->tszName;
}
+
+ CONTACTINFO ci;
ZeroMemory(&ci, sizeof(ci));
ci.cbSize = sizeof(ci);
ci.hContact = hContact;
@@ -135,36 +134,26 @@ TCHAR* fnGetContactDisplayName(HANDLE hContact, int mode) ci.dwFlag = ((mode == GCDNF_NOMYHANDLE) ? CNF_DISPLAYNC : CNF_DISPLAY) | CNF_TCHAR;
if ( !CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci)) {
if (ci.type == CNFT_ASCIIZ) {
- if (cacheEntry == NULL)
- return ci.pszVal;
-
- cacheEntry->name = ci.pszVal;
- cacheEntry->szName = mir_u2a(ci.pszVal);
+ if (cacheEntry != NULL)
+ cacheEntry->tszName = ci.pszVal;
return ci.pszVal;
}
if (ci.type == CNFT_DWORD) {
- if (cacheEntry == NULL) {
- buffer = (TCHAR*) mir_alloc(15 * sizeof(TCHAR));
- _ltot(ci.dVal, buffer, 10);
- return buffer;
- }
- else {
- buffer = (TCHAR*) mir_alloc(15 * sizeof(TCHAR));
- _ltot(ci.dVal, buffer, 10);
- cacheEntry->name = buffer;
- cacheEntry->szName = mir_u2a(buffer);
- return buffer;
- } } }
+ TCHAR *buffer = (TCHAR*) mir_alloc(15 * sizeof(TCHAR));
+ _ltot(ci.dVal, buffer, 10);
+ if (cacheEntry != NULL)
+ cacheEntry->tszName = buffer;
+ return buffer;
+ } }
CallContactService(hContact, PSS_GETINFO, SGIF_MINIMAL, 0);
- buffer = TranslateT("(Unknown Contact)");
+ TCHAR *buffer = TranslateT("(Unknown Contact)");
return (cacheEntry == NULL) ? mir_tstrdup(buffer) : buffer;
}
INT_PTR GetContactDisplayName(WPARAM wParam, LPARAM lParam)
{
- CONTACTINFO ci;
ClcCacheEntryBase* cacheEntry = NULL;
char *buffer;
HANDLE hContact = (HANDLE)wParam;
@@ -172,15 +161,19 @@ INT_PTR GetContactDisplayName(WPARAM wParam, LPARAM lParam) if (lParam & GCDNF_UNICODE)
return (INT_PTR)cli.pfnGetContactDisplayName(hContact, lParam & ~GCDNF_UNICODE);
- if ((int) lParam != GCDNF_NOMYHANDLE) {
+ if (lParam != GCDNF_NOMYHANDLE) {
cacheEntry = cli.pfnGetCacheEntry(hContact);
- if (cacheEntry->szName)
- return (INT_PTR)cacheEntry->szName;
+ if (cacheEntry->tszName) {
+ static char retVal[200];
+ strncpy(retVal, _T2A(cacheEntry->tszName), SIZEOF(retVal));
+ return (INT_PTR)retVal;
+ }
}
- ZeroMemory(&ci, sizeof(ci));
+
+ CONTACTINFO ci = { 0 };
ci.cbSize = sizeof(ci);
ci.hContact = hContact;
- if (ci.hContact == NULL)
+ if (ci.hContact == NULL) // killme !!!!!!!!!!
ci.szProto = "ICQ";
ci.dwFlag = ((lParam == GCDNF_NOMYHANDLE) ? CNF_DISPLAYNC : CNF_DISPLAY) | CNF_TCHAR;
if ( !CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci)) {
@@ -190,25 +183,18 @@ INT_PTR GetContactDisplayName(WPARAM wParam, LPARAM lParam) mir_free(ci.pszVal);
return (INT_PTR) buffer;
}
- else {
- cacheEntry->name = ci.pszVal;
- cacheEntry->szName = mir_u2a(ci.pszVal);
- return (INT_PTR)cacheEntry->szName;
- }
+
+ cacheEntry->tszName = ci.pszVal;
+ return (INT_PTR)cacheEntry->tszName;
}
if (ci.type == CNFT_DWORD) {
- if (cacheEntry == NULL) {
- buffer = (char*)mir_alloc(15);
- _ltoa(ci.dVal, buffer, 10);
- return (INT_PTR) buffer;
- }
- else {
- buffer = (char*)mir_alloc(15);
- _ltoa(ci.dVal, buffer, 10);
- cacheEntry->szName = buffer;
- cacheEntry->name = mir_a2u(buffer);
- return (INT_PTR) buffer;
- } } }
+ buffer = (char*)mir_alloc(15);
+ _ltoa(ci.dVal, buffer, 10);
+ if (cacheEntry != NULL)
+ cacheEntry->tszName = mir_a2u(buffer);
+ return (INT_PTR) buffer;
+ }
+ }
CallContactService(hContact, PSS_GETINFO, SGIF_MINIMAL, 0);
buffer = Translate("(Unknown Contact)");
diff --git a/src/modules/clist/groups.cpp b/src/modules/clist/groups.cpp index c3a6403fe0..740ed163a8 100644 --- a/src/modules/clist/groups.cpp +++ b/src/modules/clist/groups.cpp @@ -276,10 +276,10 @@ static int RenameGroupWithMove(int groupId, const TCHAR *szName, int move) hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
do {
ClcCacheEntryBase* cache = cli.pfnGetCacheEntry(hContact);
- if ( !lstrcmp(cache->group, oldName)) {
+ if ( !lstrcmp(cache->tszGroup, oldName)) {
DBWriteContactSettingTString(hContact, "CList", "Group", szName);
- mir_free(cache->group);
- cache->group = 0;
+ mir_free(cache->tszGroup);
+ cache->tszGroup = 0;
cli.pfnCheckCacheItem(cache);
}
}
|