From e8c9fd3c802c8c2b9aa47381b1dc54c03c65b595 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 8 Jul 2012 10:40:33 +0000 Subject: structure copying replaced with the inheritance git-svn-id: http://svn.miranda-ng.org/main/trunk@842 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_mw/clc.cpp | 2 +- plugins/Clist_mw/clcitems.cpp | 22 +++++++------- plugins/Clist_mw/clist.h | 13 ++++---- plugins/Clist_mw/clistsettings.cpp | 61 +++++++++++++++++++------------------- plugins/Clist_mw/contact.cpp | 2 +- 5 files changed, 48 insertions(+), 52 deletions(-) (limited to 'plugins/Clist_mw') diff --git a/plugins/Clist_mw/clc.cpp b/plugins/Clist_mw/clc.cpp index d238f5a6bb..1b57dcf9bd 100644 --- a/plugins/Clist_mw/clc.cpp +++ b/plugins/Clist_mw/clc.cpp @@ -158,7 +158,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L else status = cacheEntry->status; - shouldShow = (GetWindowLongPtr(hwnd,GWL_STYLE)&CLS_SHOWHIDDEN || !cacheEntry->Hidden) && (!pcli->pfnIsHiddenMode(dat,status)||cacheEntry->noHiddenOffline || CallService(MS_CLIST_GETCONTACTICON,wParam,0) != LOWORD(lParam)); //this means an offline msg is flashing, so the contact should be shown + shouldShow = (GetWindowLongPtr(hwnd,GWL_STYLE)&CLS_SHOWHIDDEN || !cacheEntry->bIsHidden) && (!pcli->pfnIsHiddenMode(dat,status)||cacheEntry->noHiddenOffline || CallService(MS_CLIST_GETCONTACTICON,wParam,0) != LOWORD(lParam)); //this means an offline msg is flashing, so the contact should be shown if (!FindItem(hwnd,dat,(HANDLE)wParam,&contact,&group,NULL)) { if (shouldShow && CallService(MS_DB_CONTACT_IS, wParam, 0)) { if (dat->selection>=0 && GetRowByIndex(dat,dat->selection,&selcontact,NULL) != -1) diff --git a/plugins/Clist_mw/clcitems.cpp b/plugins/Clist_mw/clcitems.cpp index 0a483fb76d..d1d5561b90 100644 --- a/plugins/Clist_mw/clcitems.cpp +++ b/plugins/Clist_mw/clcitems.cpp @@ -61,7 +61,7 @@ void AddSubcontacts(struct ClcContact * cont) cont->subcontacts[i].iImage = CallService(MS_CLIST_GETCONTACTICON,(WPARAM)cacheEntry->hContact,0); memset(cont->subcontacts[i].iExtraImage,0xFF,SIZEOF(cont->subcontacts[i].iExtraImage)); cont->subcontacts[i].proto = cacheEntry->szProto; - lstrcpyn(cont->subcontacts[i].szText,cacheEntry->name,SIZEOF(cont->subcontacts[i].szText)); + lstrcpyn(cont->subcontacts[i].szText,cacheEntry->tszName,SIZEOF(cont->subcontacts[i].szText)); cont->subcontacts[i].type = CLCIT_CONTACT; //cont->flags = 0;//CONTACTF_ONLINE; cont->subcontacts[i].isSubcontact = 1; @@ -164,7 +164,7 @@ static struct ClcContact * AddContactToGroup(struct ClcData *dat,struct ClcGroup idleMode = szProto != NULL?cacheEntry->IdleTS:0; if (idleMode) group->cl.items[i]->flags |= CONTACTF_IDLE; - lstrcpyn(group->cl.items[i]->szText,cacheEntry->name, SIZEOF(group->cl.items[i]->szText)); + lstrcpyn(group->cl.items[i]->szText,cacheEntry->tszName, SIZEOF(group->cl.items[i]->szText)); group->cl.items[i]->proto = szProto; if (dat->style & CLS_SHOWSTATUSMESSAGES) { @@ -211,10 +211,10 @@ void AddContactToTree(HWND hwnd,struct ClcData *dat,HANDLE hContact,int updateTo } ClcGroup *group; - if (lstrlen(cacheEntry->szGroup) == 0) + if (lstrlen(cacheEntry->tszGroup) == 0) group = &dat->list; else { - group = AddGroup(hwnd,dat,cacheEntry->szGroup,(DWORD)-1,0,0); + group = AddGroup(hwnd,dat,cacheEntry->tszGroup,(DWORD)-1,0,0); if (group == NULL) { DWORD groupFlags; int i; @@ -226,7 +226,7 @@ void AddContactToTree(HWND hwnd,struct ClcData *dat,HANDLE hContact,int updateTo TCHAR *szGroupName = pcli->pfnGetGroupName(i, &groupFlags); if (szGroupName == NULL) return; //never happens - if ( !lstrcmp(szGroupName,cacheEntry->szGroup)) + if ( !lstrcmp(szGroupName,cacheEntry->tszGroup)) break; } if (groupFlags & GROUPF_HIDEOFFLINE) @@ -236,13 +236,13 @@ void AddContactToTree(HWND hwnd,struct ClcData *dat,HANDLE hContact,int updateTo TCHAR *szGroupName = pcli->pfnGetGroupName(i, &groupFlags); if (szGroupName == NULL) return; //never happens - if (!lstrcmp(szGroupName,cacheEntry->szGroup)) + if (!lstrcmp(szGroupName,cacheEntry->tszGroup)) break; size_t len = lstrlen(szGroupName); - if (!_tcsncmp(szGroupName,cacheEntry->szGroup,len) && cacheEntry->szGroup[len] == '\\') + if (!_tcsncmp(szGroupName,cacheEntry->tszGroup,len) && cacheEntry->tszGroup[len] == '\\') AddGroup(hwnd,dat,szGroupName,groupFlags,i,1); } - group = AddGroup(hwnd,dat,cacheEntry->szGroup,groupFlags,i,1); + group = AddGroup(hwnd,dat,cacheEntry->tszGroup,groupFlags,i,1); } } @@ -365,11 +365,11 @@ void RebuildEntireList(HWND hwnd,struct ClcData *dat) if (cacheEntry == NULL) MessageBoxA(0,"Fail To Get CacheEntry for hContact","!!!!!!!!",0); - if (style&CLS_SHOWHIDDEN || !cacheEntry->Hidden) { - if (lstrlen(cacheEntry->szGroup) == 0) + if (style&CLS_SHOWHIDDEN || !cacheEntry->bIsHidden) { + if (lstrlen(cacheEntry->tszGroup) == 0) group = &dat->list; else { - group = AddGroup(hwnd,dat,cacheEntry->szGroup,(DWORD)-1,0,0); + group = AddGroup(hwnd,dat,cacheEntry->tszGroup,(DWORD)-1,0,0); //mir_free(dbv.pszVal); } diff --git a/plugins/Clist_mw/clist.h b/plugins/Clist_mw/clist.h index 32effbad84..20c8a7ce80 100644 --- a/plugins/Clist_mw/clist.h +++ b/plugins/Clist_mw/clist.h @@ -31,12 +31,8 @@ void SortContacts(void); void ChangeContactIcon(HANDLE hContact,int iIcon,int add); int GetContactInfosForSort(HANDLE hContact,char **Proto,TCHAR **Name,int *Status); -typedef struct { - HANDLE hContact; - TCHAR *name; - char *szName; - TCHAR* szGroup; - int Hidden; +struct displayNameCacheEntry : public ClcCacheEntryBase +{ int noHiddenOffline; char *szProto; @@ -50,8 +46,9 @@ typedef struct { void *ClcContact; BYTE IsExpanded; boolean isUnknown; -} - displayNameCacheEntry,*pdisplayNameCacheEntry; +}; + +typedef displayNameCacheEntry *pdisplayNameCacheEntry; pdisplayNameCacheEntry GetContactFullCacheEntry(HANDLE hContact); diff --git a/plugins/Clist_mw/clistsettings.cpp b/plugins/Clist_mw/clistsettings.cpp index fcfbb58992..ecdb3d8089 100644 --- a/plugins/Clist_mw/clistsettings.cpp +++ b/plugins/Clist_mw/clistsettings.cpp @@ -62,10 +62,9 @@ void InitDisplayNameCache(SortedList *list) void FreeDisplayNameCacheItem(ClcCacheEntryBase *_p) { pdisplayNameCacheEntry p = (pdisplayNameCacheEntry)_p; - if ( p->name) { mir_free(p->name); p->name = NULL; } - if ( p->szName) { mir_free(p->szName); p->szName = NULL; } + if ( p->tszName) { mir_free(p->tszName); p->tszName = NULL; } if ( p->szProto) { mir_free(p->szProto); p->szProto = NULL; } - if ( p->szGroup) { mir_free(p->szGroup); p->szGroup = NULL; } + if ( p->tszGroup) { mir_free(p->tszGroup); p->tszGroup = NULL; } } void FreeDisplayNameCache(SortedList *list) @@ -94,46 +93,46 @@ void CheckPDNCE(ClcCacheEntryBase *_pdnce) if (CallService(MS_PROTO_ISPROTOCOLLOADED,0,(LPARAM)pdnce->szProto) == 0) pdnce->protoNotExists = TRUE; else { - if ( pdnce->szProto && pdnce->name ) { - mir_free(pdnce->name); - pdnce->name = NULL; + if ( pdnce->szProto && pdnce->tszName ) { + mir_free(pdnce->tszName); + pdnce->tszName = NULL; } } } } - if (pdnce->name == NULL) + if (pdnce->tszName == NULL) { if (pdnce->protoNotExists) - pdnce->name = mir_tstrdup(TranslateT("_NoProtocol_")); + pdnce->tszName = mir_tstrdup(TranslateT("_NoProtocol_")); else { if (OnModulesLoadedCalled) - pdnce->name = GetNameForContact(pdnce->hContact,0,&pdnce->isUnknown); + pdnce->tszName = GetNameForContact(pdnce->hContact,0,&pdnce->isUnknown); else - pdnce->name = GetNameForContact(pdnce->hContact,0,NULL); + pdnce->tszName = GetNameForContact(pdnce->hContact,0,NULL); } } else { if (pdnce->isUnknown&&pdnce->szProto&&pdnce->protoNotExists == TRUE&&OnModulesLoadedCalled) { pdnce->protoNotExists = FALSE; - mir_free(pdnce->name); - pdnce->name = GetNameForContact(pdnce->hContact,0,&pdnce->isUnknown); + mir_free(pdnce->tszName); + pdnce->tszName = GetNameForContact(pdnce->hContact,0,&pdnce->isUnknown); } } if (pdnce->status == 0) pdnce->status = GetStatusForContact(pdnce->hContact,pdnce->szProto); - if (pdnce->szGroup == NULL) + if (pdnce->tszGroup == NULL) { DBVARIANT dbv; if (!DBGetContactSettingTString(pdnce->hContact,"CList","Group",&dbv)) { - pdnce->szGroup = mir_tstrdup(dbv.ptszVal); + pdnce->tszGroup = mir_tstrdup(dbv.ptszVal); mir_free(dbv.pszVal); } - else pdnce->szGroup = mir_tstrdup( _T("")); + else pdnce->tszGroup = mir_tstrdup( _T("")); } - if (pdnce->Hidden == -1) - pdnce->Hidden = DBGetContactSettingByte(pdnce->hContact,"CList","Hidden",0); + if (pdnce->bIsHidden == -1) + pdnce->bIsHidden = DBGetContactSettingByte(pdnce->hContact,"CList","bIsHidden",0); if (pdnce->noHiddenOffline == -1) pdnce->noHiddenOffline = DBGetContactSettingByte(pdnce->hContact,"CList","noOffline",0); @@ -158,12 +157,12 @@ void InvalidateDisplayNameCacheEntryByPDNE(HANDLE hContact,pdisplayNameCacheEntr if ( SettingType == -1 || SettingType == DBVT_DELETED ) { - mir_free(pdnce->name); - pdnce->name = NULL; - mir_free(pdnce->szGroup); - pdnce->szGroup = NULL; + mir_free(pdnce->tszName); + pdnce->tszName = NULL; + mir_free(pdnce->tszGroup); + pdnce->tszGroup = NULL; - pdnce->Hidden = -1; + pdnce->bIsHidden = -1; pdnce->protoNotExists = FALSE; mir_free(pdnce->szProto); pdnce->szProto = NULL; @@ -179,17 +178,17 @@ void InvalidateDisplayNameCacheEntryByPDNE(HANDLE hContact,pdisplayNameCacheEntr if (SettingType >= DBVT_WCHAR) { - mir_free(pdnce->name); - pdnce->name = NULL; - mir_free(pdnce->szGroup); - pdnce->szGroup = NULL; + mir_free(pdnce->tszName); + pdnce->tszName = NULL; + mir_free(pdnce->tszGroup); + pdnce->tszGroup = NULL; mir_free(pdnce->szProto); pdnce->szProto = NULL; return; } // in other cases clear all binary cache - pdnce->Hidden = -1; + pdnce->bIsHidden = -1; pdnce->protoNotExists = FALSE; pdnce->status = 0; pdnce->IdleTS = -1; @@ -263,7 +262,7 @@ int GetContactInfosForSort(HANDLE hContact,char **Proto,TCHAR **Name,int *Status if (cacheEntry != NULL) { if (Proto != NULL) *Proto = cacheEntry->szProto; - if (Name != NULL) *Name = cacheEntry->name; + if (Name != NULL) *Name = cacheEntry->tszName; if (Status != NULL) *Status = cacheEntry->status; } return 0; @@ -301,7 +300,7 @@ int ContactSettingChanged(WPARAM wParam,LPARAM lParam) InvalidateDisplayNameCacheEntryByPDNE((HANDLE)wParam,pdnce,cws->value.type); if (cws->value.type == DBVT_WORD&&!strcmp(cws->szSetting, "Status")) { - if (!(pdnce->Hidden == 1)) { + if (!(pdnce->bIsHidden == 1)) { if (DBGetContactSettingByte((HANDLE)NULL,"CList","ShowStatusMsg",0)||DBGetContactSettingByte((HANDLE)wParam,"CList","StatusMsgAuto",0)) DBWriteContactSettingString((HANDLE)wParam, "CList", "StatusMsg", ""); @@ -338,13 +337,13 @@ int ContactSettingChanged(WPARAM wParam,LPARAM lParam) */ //name is null or (setting is myhandle) - if (pdnce->name == NULL||(!strcmp(cws->szSetting,"MyHandle"))) + if (pdnce->tszName == NULL||(!strcmp(cws->szSetting,"MyHandle"))) InvalidateDisplayNameCacheEntryByPDNE((HANDLE)wParam,pdnce,cws->value.type); if ((!strcmp(cws->szSetting,"Group"))) InvalidateDisplayNameCacheEntryByPDNE((HANDLE)wParam,pdnce,cws->value.type); - if (!strcmp(cws->szSetting,"Hidden")) { + if (!strcmp(cws->szSetting,"bIsHidden")) { InvalidateDisplayNameCacheEntryByPDNE((HANDLE)wParam,pdnce,cws->value.type); if (cws->value.type == DBVT_DELETED || cws->value.bVal == 0) { char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0); diff --git a/plugins/Clist_mw/contact.cpp b/plugins/Clist_mw/contact.cpp index 54474e3b85..d8cf0f37d4 100644 --- a/plugins/Clist_mw/contact.cpp +++ b/plugins/Clist_mw/contact.cpp @@ -99,7 +99,7 @@ void LoadContactTree(void) break; } status = cacheEntry->status; - if ((!hideOffline || status != ID_STATUS_OFFLINE) && !cacheEntry->Hidden) + if ((!hideOffline || status != ID_STATUS_OFFLINE) && !cacheEntry->bIsHidden) ChangeContactIcon(hContact,ExtIconFromStatusMode(hContact,(char*)cacheEntry->szProto,status),1); hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0); } -- cgit v1.2.3