void ClearClcContactCache(struct ClcData *dat,HANDLE hContact) { pdisplayNameCacheEntry cacheEntry; if (hContact==INVALID_HANDLE_VALUE) { int i,tick; tick=GetTickCount(); for(i=0;i<(dat->lCLCContactsCache.realCount);i++) { pdisplayNameCacheEntry pdnce = dat->lCLCContactsCache.items[i]; pdnce->ClcContact = NULL; } tick=GetTickCount()-tick; { char buf[256]; sprintf (buf,"Clear full cache %d ms\r\n",tick); OutputDebugStringA(buf); } } if(!IsHContactGroup(hContact)&&!IsHContactInfo(hContact)) { cacheEntry=GetCLCFullCacheEntry(dat,hContact); if (cacheEntry!=NULL) cacheEntry->ClcContact=NULL; } }
void ClearClcContactCache(struct ClcData *dat,MCONTACT hContact) { ClcCacheEntry *cacheEntry; if (hContact == INVALID_CONTACT_ID) { int i,tick; tick = GetTickCount(); for (i = 0;i<(dat->lCLCContactsCache.realCount);i++) { ClcCacheEntry *pdnce = (ClcCacheEntry *)dat->lCLCContactsCache.items[i]; pdnce->ClcContact = NULL; } tick = GetTickCount()-tick; { char buf[256]; mir_snprintf(buf, SIZEOF(buf), "Clear full cache %d ms\r\n", tick); OutputDebugStringA(buf); } } if ( !IsHContactGroup(hContact) && !IsHContactInfo(hContact)) { cacheEntry = GetCLCFullCacheEntry(dat,hContact); if (cacheEntry != NULL) cacheEntry->ClcContact = NULL; } }
void SetClcContactCacheItem(struct ClcData *dat, MCONTACT hContact, void *contact) { ClcCacheEntry *cacheEntry; if ( !IsHContactGroup(hContact) && !IsHContactInfo(hContact)) { cacheEntry = GetCLCFullCacheEntry(dat,hContact); if (cacheEntry != NULL) cacheEntry->ClcContact = contact; } }
void SetClcContactCacheItem(struct ClcData *dat,HANDLE hContact,void *contact) { pdisplayNameCacheEntry cacheEntry; if(!IsHContactGroup(hContact)&&!IsHContactInfo(hContact)) { cacheEntry=GetCLCFullCacheEntry(dat,hContact); if (cacheEntry!=NULL) { cacheEntry->ClcContact=contact; } } }
int FindItem(HWND hwnd,struct ClcData *dat,HANDLE hItem,struct ClcContact **contact,struct ClcGroup **subgroup,int *isVisible) { int index=0, i; int nowVisible=1; struct ClcGroup *group=&dat->list; group->scanIndex=0; if (isVisible==NULL&&hItem!=NULL&&subgroup==NULL&&!IsHContactGroup(hItem)&&!IsHContactInfo(hItem)) { //try use cache pdisplayNameCacheEntry cacheEntry; cacheEntry=GetCLCFullCacheEntry(dat,hItem); if (cacheEntry!=NULL) { if (cacheEntry->ClcContact==NULL) { int *isv={0}; void *z={0}; int ret; ret=FindItem(hwnd,dat,hItem,(struct ClcContact ** )&z,(struct ClcGroup** )&isv,NULL); if (ret=0) {return (0);} cacheEntry->ClcContact=(void *)z; } if (cacheEntry->ClcContact!=NULL) { if (contact!=NULL) *contact=(struct ClcContact *)cacheEntry->ClcContact; { /* void *p={0} int *isv={0} int ret; ret=FindItem(hwnd,dat,hItem,&p,&isv,NULL); if (ret=0) {return (0);} if (p!=cacheEntry->ClcContact) { MessageBox(0,"hITEM FAILEDDDDDDDD!!!!!","",0); //cacheEntry->ClcContact=p; } */ } return 1; } } } group=&dat->list; for(;;) { if(group->scanIndex==group->cl.count) { struct ClcGroup *tgroup; group=group->parent; if(group==NULL) break; nowVisible=1; for(tgroup=group;tgroup;tgroup=tgroup->parent) if(!group->expanded) {nowVisible=0; break;} group->scanIndex++; continue; } 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(isVisible) { if(!nowVisible) *isVisible=0; else { if((index+1)*dat->rowHeight<dat->yScroll) *isVisible=0; else { RECT clRect; GetClientRect(hwnd,&clRect); if(index*dat->rowHeight>=dat->yScroll+clRect.bottom) *isVisible=0; else *isVisible=1; } } } if(contact) *contact=group->cl.items[group->scanIndex]; if(subgroup) *subgroup=group; return 1; } if (group->cl.items[group->scanIndex]->type==CLCIT_CONTACT && group->cl.items[group->scanIndex]->SubAllocated>0) for (i=1; i<=group->cl.items[group->scanIndex]->SubAllocated; i++) if (IsHContactContact(hItem) && group->cl.items[group->scanIndex]->subcontacts[i-1].hContact==hItem) { if(contact) *contact=&group->cl.items[group->scanIndex]->subcontacts[i-1]; if(subgroup) *subgroup=group; return 1; } if(group->cl.items[group->scanIndex]->type==CLCIT_GROUP) { struct ClcGroup* save = group; group=group->cl.items[group->scanIndex]->group; group->scanIndex=0; nowVisible&=group->expanded; continue; } group->scanIndex++; } return 0; }
int FindItem(HWND hwnd, struct ClcData *dat, DWORD dwItem, struct ClcContact **contact, ClcGroup **subgroup, int *isVisible) { int index = 0, i; int nowVisible = 1; ClcGroup *group = &dat->list; group->scanIndex = 0; if (isVisible == NULL && dwItem != NULL && subgroup == NULL && !IsHContactGroup(dwItem) && !IsHContactInfo(dwItem)) { //try use cache ClcCacheEntry *cacheEntry = GetCLCFullCacheEntry(dat, dwItem); if (cacheEntry != NULL) { if (cacheEntry->ClcContact == NULL) { int *isv = {0}; void *z = {0}; int ret; ret = FindItem(hwnd,dat,dwItem,(struct ClcContact ** )&z,(struct ClcGroup** )&isv,NULL); if (ret == 0) {return 0;} cacheEntry->ClcContact = (void *)z; } if (cacheEntry->ClcContact != NULL) { if (contact != NULL) *contact = (struct ClcContact *)cacheEntry->ClcContact; return 1; } } } group = &dat->list; for (;;) { if (group->scanIndex == group->cl.count) { ClcGroup *tgroup; group = group->parent; if (group == NULL) break; nowVisible = 1; for (tgroup = group;tgroup;tgroup = tgroup->parent) if ( !group->expanded) { nowVisible = 0; break; } group->scanIndex++; continue; } if (nowVisible) index++; if ((IsHContactGroup(dwItem) && group->cl.items[group->scanIndex]->type == CLCIT_GROUP && (dwItem & ~HCONTACT_ISGROUP) == group->cl.items[group->scanIndex]->groupId) || (IsHContactContact(dwItem) && group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && group->cl.items[group->scanIndex]->hContact == dwItem) || (IsHContactInfo(dwItem) && group->cl.items[group->scanIndex]->type == CLCIT_INFO && group->cl.items[group->scanIndex]->hContact == (dwItem & ~HCONTACT_ISINFO))) { if (isVisible) { if ( !nowVisible) *isVisible = 0; else { if ((index+1)*dat->rowHeight<dat->yScroll) *isVisible = 0; else { RECT clRect; GetClientRect(hwnd,&clRect); if (index*dat->rowHeight>=dat->yScroll+clRect.bottom) *isVisible = 0; else *isVisible = 1; } } } if (contact) *contact = group->cl.items[group->scanIndex]; if (subgroup) *subgroup = group; return 1; } if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && group->cl.items[group->scanIndex]->SubAllocated>0) for (i = 1; i<=group->cl.items[group->scanIndex]->SubAllocated; i++) if (IsHContactContact(dwItem) && group->cl.items[group->scanIndex]->subcontacts[i-1].hContact == dwItem) { if (contact) *contact = &group->cl.items[group->scanIndex]->subcontacts[i-1]; if (subgroup) *subgroup = group; return 1; } if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) { ClcGroup* save = group; group = group->cl.items[group->scanIndex]->group; group->scanIndex = 0; nowVisible &= group->expanded; continue; } group->scanIndex++; } if (isVisible) *isVisible = FALSE; if (contact) *contact = NULL; if (subgroup) *subgroup = NULL; return 0; }