示例#1
0
void DeleteItemFromTree(HWND hwnd,HANDLE hItem)
{
	struct ClcContact *contact;
	struct ClcGroup *group;
	struct ClcData *dat=(struct ClcData*)GetWindowLong(hwnd,0);
	ClearRowByIndexCache();
	if(!FindItem(hwnd,dat,hItem,&contact,&group,NULL,TRUE)) {
		DBVARIANT dbv;
		int i,nameOffset;
		if(!IsHContactContact(hItem)) return;
		ClearClcContactCache(dat,hItem);

    if(DBGetContactSettingTString(hItem,"CList","Group",&dbv)) {DBFreeVariant(&dbv); return;}

		//decrease member counts of all parent groups too
		group=&dat->list;
		nameOffset=0;
		for(i=0;;i++) {
			if(group->scanIndex==group->contactCount) break;
			if(group->contact[i].type==CLCIT_GROUP) {
				int len=lstrlen(group->contact[i].szText);
        //TODO unicode to dbv.pszVal
				if(!_tcsncmp(group->contact[i].szText,(TCHAR*)dbv.pszVal+nameOffset,len) && ((TCHAR)dbv.pszVal[nameOffset+len]==TEXT('\\') || (TCHAR)dbv.pszVal[nameOffset+len]==TEXT('\0'))) {
					group->totalMembers--;
					if((TCHAR)dbv.pszVal[nameOffset+len]==TEXT('\0')) break;
				}
			}
		}
		mir_free(dbv.pszVal);
    DBFreeVariant(&dbv);
	}
	else RemoveItemFromGroup(hwnd,group,contact,1);
	dat->NeedResort=1;
	ClearRowByIndexCache();
}
示例#2
0
ClcGroup *AddGroup(HWND hwnd,struct ClcData *dat,const TCHAR *szName,DWORD flags,int groupId,int calcTotalMembers)
{
	ClearRowByIndexCache();
	dat->needsResort = 1;
	ClcGroup *result = saveAddGroup( hwnd, dat, szName, flags, groupId, calcTotalMembers);
	ClearRowByIndexCache();
	return result;
}
示例#3
0
void cli_DeleteItemFromTree(HWND hwnd,HANDLE hItem)
{
	struct ClcData *dat = (struct ClcData *) GetWindowLong(hwnd, 0);
	ClearRowByIndexCache();
	saveDeleteItemFromTree(hwnd, hItem);

	pcli->pfnFreeCacheItem(pcli->pfnGetCacheEntry(hItem)); //TODO should be called in core

	dat->NeedResort=1;
	ClearRowByIndexCache();
}
示例#4
0
void cli_DeleteItemFromTree(HWND hwnd, MCONTACT hItem)
{
	ClcData *dat = (ClcData *)GetWindowLongPtr(hwnd, 0);
	ClearRowByIndexCache();
	corecli.pfnDeleteItemFromTree(hwnd, hItem);

	// check here contacts are not resorting
	if (hwnd == pcli->hwndContactTree)
		pcli->pfnFreeCacheItem(pcli->pfnGetCacheEntry(hItem));
	dat->needsResort = 1;
	ClearRowByIndexCache();
}
示例#5
0
ClcGroup* cli_AddGroup(HWND hwnd, ClcData *dat, const TCHAR *szName, DWORD flags, int groupId, int calcTotalMembers)
{
	ClearRowByIndexCache();
	if (!dat->force_in_dialog && !(GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_SHOWHIDDEN))
		if (!mir_tstrcmp(_T("-@-HIDDEN-GROUP-@-"), szName)) { //group is hidden
			ClearRowByIndexCache();
			return NULL;
		}

	ClcGroup *result = corecli.pfnAddGroup(hwnd, dat, szName, flags, groupId, calcTotalMembers);
	ClearRowByIndexCache();
	return result;
}
示例#6
0
ClcGroup *RemoveItemFromGroup(HWND hwnd,ClcGroup *group,struct ClcContact *contact,int updateTotalCount)
{
	ClearRowByIndexCache();
	if (contact->type == CLCIT_CONTACT) {
		struct ClcData* dat = (struct ClcData*)GetWindowLongPtr(hwnd,0);
		ClearClcContactCache(dat,contact->hContact);
	}

	group = saveRemoveItemFromGroup(hwnd, group, contact, updateTotalCount);

	ClearRowByIndexCache();
	return group;
}
示例#7
0
int AddInfoItemToGroup(struct ClcGroup *group,int flags,const TCHAR *pszText)
{
	int i=0;

	if(flags&CLCIIF_BELOWCONTACTS)
		i=group->contactCount;
	else if(flags&CLCIIF_BELOWGROUPS) {
		for(;i<group->contactCount;i++)
			if(group->contact[i].type==CLCIT_CONTACT) break;
	}
	else
		for(;i<group->contactCount;i++)
			if(group->contact[i].type!=CLCIT_INFO) break;
	i=AddItemToGroup(group,i);
	iInfoItemUniqueHandle=(iInfoItemUniqueHandle+1)&0xFFFF;
	if(iInfoItemUniqueHandle==0) ++iInfoItemUniqueHandle;
	group->contact[i].type=CLCIT_INFO;
	group->contact[i].flags=(BYTE)flags;
	group->contact[i].hContact=(HANDLE)++iInfoItemUniqueHandle;
  if (group->contact[i].szText) mir_free(group->contact[i].szText);
  group->contact[i].szText=pszText?mir_strdupT(pszText):NULL; 
	//lstrcpynA(group->contact[i].szText,pszText,sizeof(group->contact[i].szText));
	ClearRowByIndexCache();
	return i;
}
示例#8
0
static int AddItemToGroup(struct ClcGroup *group,int iAboveItem)
{
	if (group==NULL) return 0;

	if(++group->contactCount>group->allocedCount) {
		group->allocedCount+=GROUP_ALLOCATE_STEP;
      //  if (group->contact) mir_free(group->contact);
		if(group->contact)	
		group->contact=(struct ClcContact*)mir_realloc(group->contact,sizeof(struct ClcContact)*group->allocedCount);
			else 
			group->contact=(struct ClcContact*)mir_alloc(sizeof(struct ClcContact)*group->allocedCount);
			
		if (group->contact==NULL||IsBadCodePtr((FARPROC)group->contact))
		{
			TRACE("!!!Bad Realloc AddItemToGroup");
			DebugBreak();
		}
	}
	memmove(group->contact+iAboveItem+1,group->contact+iAboveItem,sizeof(struct ClcContact)*(group->contactCount-iAboveItem-1));
    memset(&(group->contact[iAboveItem]),0,sizeof((group->contact[iAboveItem])));
	group->contact[iAboveItem].type=CLCIT_DIVIDER;
	//group->contact[iAboveItem].flags=0;
	memset(group->contact[iAboveItem].iExtraImage,0xFF,sizeof(group->contact[iAboveItem].iExtraImage));
  group->contact[iAboveItem].szText=NULL;
  group->contact[iAboveItem].szSecondLineText=NULL;
  group->contact[iAboveItem].szThirdLineText=NULL;
  group->contact[iAboveItem].SubAllocated=0;
  group->contact[iAboveItem].subcontacts=NULL;
	group->contact[iAboveItem].SubExpanded=0;
	
	ClearRowByIndexCache();
	return iAboveItem;
}
示例#9
0
static struct ClcContact * AddContactToGroup(struct ClcData *dat,struct ClcGroup *group,pdisplayNameCacheEntry cacheEntry)
{
	char *szProto;
	WORD apparentMode;
	DWORD idleMode;
	HANDLE hContact;
	int i;
//	DBVARIANT dbv;
	if (cacheEntry==NULL) return NULL;
	if (group==NULL) return NULL;
	if (dat==NULL) return NULL;
	hContact=cacheEntry->hContact;
	//ClearClcContactCache(hContact);

//ShowTracePopup("AddContactToGroup");

	dat->NeedResort=1;
	for(i=group->contactCount-1;i>=0;i--)
		if(group->contact[i].type!=CLCIT_INFO || !(group->contact[i].flags&CLCIIF_BELOWCONTACTS)) break;
	i=AddItemToGroup(group,i+1);
	group->contact[i].type=CLCIT_CONTACT;
	group->contact[i].SubAllocated=0;
	group->contact[i].isSubcontact=0;
	group->contact[i].subcontacts=NULL;
  group->contact[i].szText=NULL;
  group->contact[i].szSecondLineText=NULL;
  group->contact[i].szThirdLineText=NULL;
	group->contact[i].image_is_special=FALSE;
	group->contact[i].status=cacheEntry->status;
	
	group->contact[i].iImage=CallService(MS_CLIST_GETCONTACTICON,(WPARAM)hContact,0);
	cacheEntry=GetContactFullCacheEntry(hContact);
	group->contact[i].hContact=hContact;

	group->contact[i].avatar_pos = AVATAR_POS_DONT_HAVE;
	Cache_GetAvatar(dat, &group->contact[i]);

	
	//cacheEntry->ClcContact=&(group->contact[i]);
	//SetClcContactCacheItem(dat,hContact,&(group->contact[i]));

	szProto=cacheEntry->szProto;
	if(szProto!=NULL&&!IsHiddenMode(dat,cacheEntry->status))
		group->contact[i].flags|=CONTACTF_ONLINE;
	apparentMode=szProto!=NULL?cacheEntry->ApparentMode:0;
	if(apparentMode==ID_STATUS_OFFLINE)	group->contact[i].flags|=CONTACTF_INVISTO;
	else if(apparentMode==ID_STATUS_ONLINE) group->contact[i].flags|=CONTACTF_VISTO;
	else if(apparentMode) group->contact[i].flags|=CONTACTF_VISTO|CONTACTF_INVISTO;
	if(cacheEntry->NotOnList) group->contact[i].flags|=CONTACTF_NOTONLIST;
	idleMode=szProto!=NULL?cacheEntry->IdleTS:0;
	if (idleMode) group->contact[i].flags|=CONTACTF_IDLE;

	//lstrcpynA(group->contact[i].szText,cacheEntry->name,sizeof(group->contact[i].szText));
	group->contact[i].proto = szProto;
	
	Cache_GetText(dat, &group->contact[i]);
	ClearRowByIndexCache();
	return &(group->contact[i]);
}
示例#10
0
int cli_AddItemToGroup(struct ClcGroup *group,int iAboveItem)
{
	if ( group == NULL ) return 0;

	iAboveItem = saveAddItemToGroup( group, iAboveItem );
	ClearRowByIndexCache();
	return iAboveItem;
}
示例#11
0
int cli_AddItemToGroup(ClcGroup *group, int iAboveItem)
{
	if (group == NULL)
		return 0;

	iAboveItem = corecli.pfnAddItemToGroup(group, iAboveItem);
	ClearRowByIndexCache();
	return iAboveItem;
}
struct ClcGroup *cli_AddGroup(HWND hwnd,struct ClcData *dat,const TCHAR *szName,DWORD flags,int groupId,int calcTotalMembers)
{
	struct ClcGroup* result;
	ClearRowByIndexCache();	
	if (!dat->force_in_dialog && !(GetWindowLong(hwnd, GWL_STYLE) & CLS_SHOWHIDDEN))
		if (!lstrcmp(_T("-@-HIDDEN-GROUP-@-"),szName))        //group is hidden
		{   	
			ClearRowByIndexCache();
			return NULL;
		}
		result = corecli.pfnAddGroup( hwnd, dat, szName, flags, groupId, calcTotalMembers);
		/* ToDo: fix some times valid contact with valid group are placed to root
		if ( result == NULL )
		{
			result = &dat->list;
		}
		*/
		ClearRowByIndexCache();
		return result;
}
示例#13
0
void DeleteItemFromTree(HWND hwnd,HANDLE hItem)
{
	struct ClcContact *contact;
	ClcGroup *group;
	struct ClcData *dat = (struct ClcData*)GetWindowLongPtr(hwnd,0);

	ClearRowByIndexCache();
	dat->needsResort = 1;

	if ( !FindItem(hwnd,dat,hItem,&contact,&group,NULL)) {
		DBVARIANT dbv;
		int i,nameOffset;
		if ( !IsHContactContact(hItem)) return;
		ClearClcContactCache(dat,hItem);

		if (db_get_ts(hItem,"CList","Group",&dbv)) return;

		//decrease member counts of all parent groups too
		group = &dat->list;
		nameOffset = 0;
		for (i = 0;;i++) {
			if (group->scanIndex == group->cl.count)
				break;

			if (group->cl.items[i]->type == CLCIT_GROUP) {
				int len = lstrlen(group->cl.items[i]->szText);
				if ( !_tcsncmp(group->cl.items[i]->szText,dbv.ptszVal+nameOffset,len) && (dbv.ptszVal[nameOffset+len] == '\\' || dbv.pszVal[nameOffset+len] == '\0')) {
					group->totalMembers--;
					if (dbv.pszVal[nameOffset+len] == '\0')
						break;
				}
			}
		}
		mir_free(dbv.pszVal);
	}
	else RemoveItemFromGroup(hwnd,group,contact,1);

	ClearRowByIndexCache();
}
示例#14
0
static void SortGroup(struct ClcData *dat,struct ClcGroup *group,int useInsertionSort)
{
	int i,sortCount;

	for(i=group->contactCount-1;i>=0;i--) {
		if(group->contact[i].type==CLCIT_DIVIDER) {
			group->contactCount--;
			memmove(&group->contact[i],&group->contact[i+1],sizeof(struct ClcContact)*(group->contactCount-i));
		}
	}
	for(i=0;i<group->contactCount;i++)
		if(group->contact[i].type!=CLCIT_INFO) break;
	if(i>group->contactCount-2) return;
	if(group->contact[i].type==CLCIT_GROUP) {
		if(dat->exStyle&CLS_EX_SORTGROUPSALPHA) {
			for(sortCount=0;i+sortCount<group->contactCount;sortCount++)
				if(group->contact[i+sortCount].type!=CLCIT_GROUP) break;
			qsort(group->contact+i,sortCount,sizeof(struct ClcContact),GroupSortProc);
			i=i+sortCount;
		}
		for(;i<group->contactCount;i++)
			if(group->contact[i].type==CLCIT_CONTACT) break;
		if(group->contactCount-i<2) return;
	}
	for(sortCount=0;i+sortCount<group->contactCount;sortCount++)
		if(group->contact[i+sortCount].type!=CLCIT_CONTACT) break;
	if(useInsertionSort) InsertionSort(group->contact+i,sortCount,ContactSortProc);
	else qsort(group->contact+i,sortCount,sizeof(struct ClcContact),ContactSortProc);
	if(dat->exStyle&CLS_EX_DIVIDERONOFF) {
		int prevContactOnline=0;
		for(i=0;i<group->contactCount;i++) 
        {
			if(group->contact[i].type!=CLCIT_CONTACT && group->contact[i].type!=CLCIT_GROUP) continue;
            if ((group->contact[i].type==CLCIT_GROUP) &&  DBGetContactSettingByte(NULL,"CList","PlaceOfflineToRoot",0)) prevContactOnline=1;
            if (group->contact[i].type==CLCIT_CONTACT)
                if(group->contact[i].flags&CONTACTF_ONLINE) prevContactOnline=1;
			    else 
                {
    				if(prevContactOnline) 
                    {
	    				i=AddItemToGroup(group,i);
		        		group->contact[i].type=CLCIT_DIVIDER;
                if (group->contact[i].szText) mir_free(group->contact[i].szText);
				    	  group->contact[i].szText=mir_strdupT(TranslateT("Offline"));
				    }
				    break;
			    }
        }           
	}
	ClearRowByIndexCache();
}
示例#15
0
void FreeGroup(struct ClcGroup *group)
{
	int i;
	if (group==NULL||IsBadCodePtr((FARPROC)group)) return;

	for(i=0;i<group->contactCount;i++) {
		if(group->contact && group->contact[i].type==CLCIT_GROUP) {
			FreeGroup(group->contact[i].group);
			mir_free(group->contact[i].group);      //**//
		}
	}
	if(group->allocedCount)
	{	
		if (group->contact->SubAllocated)
		{
			if (group->contact->subcontacts && !group->contact->isSubcontact) 
			{
				int i;
				for ( i = 0 ; i < group->contact->SubAllocated ; i++ )
				{
					Cache_DestroySmileyList(group->contact->subcontacts[i].plText);
					Cache_DestroySmileyList(group->contact->subcontacts[i].plSecondLineText);
					Cache_DestroySmileyList(group->contact->subcontacts[i].plThirdLineText);
          if (group->contact->subcontacts[i].szText) mir_free(group->contact->subcontacts[i].szText);
          if (group->contact->subcontacts[i].szSecondLineText) mir_free(group->contact->subcontacts[i].szSecondLineText);
          if (group->contact->subcontacts[i].szThirdLineText) mir_free(group->contact->subcontacts[i].szThirdLineText);
				}

				mir_free(group->contact->subcontacts);
			}
		}

		if(group->contact) 
		{
			Cache_DestroySmileyList(group->contact->plText);
			Cache_DestroySmileyList(group->contact->plSecondLineText);
			Cache_DestroySmileyList(group->contact->plThirdLineText);
      if (group->contact->szText) mir_free(group->contact->szText);
      if (group->contact->szSecondLineText) mir_free(group->contact->szSecondLineText);
      if (group->contact->szThirdLineText) mir_free(group->contact->szThirdLineText);
			mir_free(group->contact);
		}
	}
	group->allocedCount=0;
    //mir_free(group->contact);
	group->contact=NULL;
	group->contactCount=0;   
	ClearRowByIndexCache();
}
示例#16
0
struct ClcGroup *RemoveItemFromGroup(HWND hwnd,struct ClcGroup *group,struct ClcContact *contact,int updateTotalCount)
{
	int iContact;
	struct ClcData* dat=(struct ClcData*)GetWindowLong(hwnd,0);

	
	ClearRowByIndexCache();
	if(contact->type==CLCIT_CONTACT) ClearClcContactCache(dat,contact->hContact);

	iContact=((unsigned)contact-(unsigned)group->contact)/sizeof(struct ClcContact);
	if(iContact>=group->contactCount) return group;
	if(contact->type==CLCIT_GROUP) {
		FreeGroup(contact->group);
		mir_free(contact->group);
	}
	group->contactCount--;
	if(updateTotalCount && contact->type==CLCIT_CONTACT) group->totalMembers--;
	// free on contact deletion)
	if (contact->szText) mir_free(contact->szText);
	if (contact->szSecondLineText) mir_free(contact->szSecondLineText);
	if (contact->szThirdLineText) mir_free(contact->szThirdLineText);
	memmove(group->contact+iContact,group->contact+iContact+1,sizeof(struct ClcContact)*(group->contactCount-iContact));
	if((GetWindowLong(hwnd,GWL_STYLE)&CLS_HIDEEMPTYGROUPS) && group->contactCount==0) {
		int i;
		if(group->parent==NULL) return group;
		for(i=0;i<group->parent->contactCount;i++)
			if(group->parent->contact[i].type==CLCIT_GROUP 
				&& group->parent->contact[i].groupId==group->groupId) break;
		if(i==group->parent->contactCount) return group;  //never happens
		return RemoveItemFromGroup(hwnd,group->parent,&group->parent->contact[i],0);
	}

	
	ClearRowByIndexCache();
	return group;
}
示例#17
0
static ClcContact* AddContactToGroup(ClcData *dat, ClcGroup *group, ClcCacheEntry *cacheEntry)
{
	if (cacheEntry == NULL) return NULL;
	if (group == NULL) return NULL;
	if (dat == NULL) return NULL;
	MCONTACT hContact = cacheEntry->hContact;
	dat->needsResort = 1;
	int i;
	for (i = group->cl.count - 1; i >= 0; i--)
		if (group->cl.items[i]->type != CLCIT_INFO || !(group->cl.items[i]->flags&CLCIIF_BELOWCONTACTS)) break;
	i = cli_AddItemToGroup(group, i + 1);

	_LoadDataToContact(group->cl.items[i], group, dat, hContact);
	cacheEntry = pcli->pfnGetCacheEntry(hContact);
	ClearRowByIndexCache();
	return group->cl.items[i];
}
static struct ClcContact * AddContactToGroup(struct ClcData *dat,struct ClcGroup *group, pdisplayNameCacheEntry cacheEntry)
{
	HANDLE hContact;
	int i;
	if (cacheEntry==NULL) return NULL;
	if (group==NULL) return NULL;
	if (dat==NULL) return NULL;
	hContact=cacheEntry->m_cache_hContact;
	dat->NeedResort=1;
	for(i=group->cl.count-1;i>=0;i--)
		if(group->cl.items[i]->type!=CLCIT_INFO || !(group->cl.items[i]->flags&CLCIIF_BELOWCONTACTS)) break;
	i=cli_AddItemToGroup(group,i+1);

	_LoadDataToContact(group->cl.items[i], group, dat, hContact);
	cacheEntry=(pdisplayNameCacheEntry)pcli->pfnGetCacheEntry(hContact);
	ClearRowByIndexCache();
	return group->cl.items[i];
}
示例#19
0
void SortCLC(HWND hwnd,struct ClcData *dat,int useInsertionSort)
{
#ifdef _DEBUG
	DWORD tick = GetTickCount();
#endif
	int oldSort = dat->needsResort;
	saveSortCLC(hwnd, dat, useInsertionSort);
	if ( oldSort )
		ClearRowByIndexCache();

#ifdef _DEBUG
	{
		char buf[255];
		//sprintf(buf,"%s %s took %i ms",__FILE__,__LINE__,tick);
		tick = GetTickCount()-tick;
		if (tick > 5) {
			mir_snprintf(buf, SIZEOF(buf), "SortCLC %d \r\n", tick);
			OutputDebugStringA(buf);
			db_set_dw((HANDLE)0,"CLUI","PF:Last SortCLC Time:",tick);
		}
	}
#endif
}
示例#20
0
int cli_AddInfoItemToGroup(struct ClcGroup *group,int flags,const TCHAR *pszText)
{
	int i = saveAddInfoItemToGroup( group, flags, pszText );
	ClearRowByIndexCache();
	return i;
}
示例#21
0
void RebuildEntireList(HWND hwnd,struct ClcData *dat)
{
//	char *szProto;
	DWORD style=GetWindowLong(hwnd,GWL_STYLE);
	HANDLE hContact;
	struct ClcContact * cont;
	struct ClcGroup *group;
	//DBVARIANT dbv;
	int tick=GetTickCount();
    KillTimer(hwnd,TIMERID_REBUILDAFTER);
    
    //EnterCriticalSection(&(dat->lockitemCS));
//ShowTracePopup("RebuildEntireList");

#ifdef _DEBUG
	{
		static int num_calls = 0;
		char tmp[128];
		mir_snprintf(tmp, sizeof(tmp), "*********************   RebuildEntireList (%d)\r\n", num_calls);
		num_calls++;
		TRACE(tmp);
	}
#endif 

	ClearRowByIndexCache();
	ClearClcContactCache(dat,INVALID_HANDLE_VALUE);
	ImageArray_Clear(&dat->avatar_cache);
	RowHeights_Clear(dat);
	RowHeights_GetMaxRowHeight(dat, hwnd);

	dat->list.expanded=1;
	dat->list.hideOffline=DBGetContactSettingByte(NULL,"CLC","HideOfflineRoot",0);
	dat->list.contactCount=0;
	dat->list.totalMembers=0;
	dat->NeedResort=1;
	dat->selection=-1;
	dat->HiLightMode=DBGetContactSettingByte(NULL,"CLC","HiLightMode",0);
	{
		int i;
		TCHAR *szGroupName;
		DWORD groupFlags;

		for(i=1;;i++) {
			szGroupName=(TCHAR*)CallService(MS_CLIST_GROUPGETNAMET,i,(LPARAM)&groupFlags); //UNICODE
			if(szGroupName==NULL) break;
			AddGroup(hwnd,dat,szGroupName,groupFlags,i,0);
		}
        lastGroupId=i;
        
	}

	hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);
	while(hContact) {
		
		pdisplayNameCacheEntry cacheEntry;
		cont=NULL;
		cacheEntry=GetContactFullCacheEntry(hContact);
		//cacheEntry->ClcContact=NULL;
		ClearClcContactCache(dat,hContact);

		

		if((dat->IsMetaContactsEnabled||MyStrCmp(cacheEntry->szProto,"MetaContacts"))&&(style&CLS_SHOWHIDDEN || !cacheEntry->Hidden) && (!cacheEntry->HiddenSubcontact || !dat->IsMetaContactsEnabled )) {
			if(lstrlen(cacheEntry->szGroup)==0)
				group=&dat->list;
			else {
				group=AddGroup(hwnd,dat,cacheEntry->szGroup,(DWORD)-1,0,0);
//                if (!group) group=AddTempGroup(hwnd,dat,cacheEntry->szGroup,(DWORD)-1,0,0);
				//mir_free(dbv.pszVal);
			}
            if(group!=NULL) {
                if (cacheEntry->status==ID_STATUS_OFFLINE)
                    if (DBGetContactSettingByte(NULL,"CList","PlaceOfflineToRoot",0))
                        group=&dat->list;
				group->totalMembers++;
				if(!(style&CLS_NOHIDEOFFLINE) && (style&CLS_HIDEOFFLINE || group->hideOffline)) {
					//szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
					if(cacheEntry->szProto==NULL) {
						if(!IsHiddenMode(dat,ID_STATUS_OFFLINE)||cacheEntry->noHiddenOffline)
							cont=AddContactToGroup(dat,group,cacheEntry);
					}
					else
						if(!IsHiddenMode(dat,cacheEntry->status)||cacheEntry->noHiddenOffline)
							cont=AddContactToGroup(dat,group,cacheEntry);
				}
				else cont=AddContactToGroup(dat,group,cacheEntry);
			}
		}
		if (cont)	
		{	
			cont->SubAllocated=0;
			if (cont->proto && strcmp(cont->proto,"MetaContacts")==0)
				AddSubcontacts(dat,cont);
		}
		hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0);
	}

	if(style&CLS_HIDEEMPTYGROUPS) {
		group=&dat->list;
		group->scanIndex=0;
		for(;;) {
			if(group->scanIndex==group->contactCount) {
				group=group->parent;
				if(group==NULL) break;
			}
			else if(group->contact[group->scanIndex].type==CLCIT_GROUP) {
				if(group->contact[group->scanIndex].group->contactCount==0) {
					group=RemoveItemFromGroup(hwnd,group,&group->contact[group->scanIndex],0);
				}
				else {
					group=group->contact[group->scanIndex].group;
					group->scanIndex=0;
				}
				continue;
			}
			group->scanIndex++;
		}
	}

	SortCLC(hwnd,dat,0);
  // LOCK_IMAGE_UPDATING=0;
  //LeaveCriticalSection(&(dat->lockitemCS));
#ifdef _DEBUG
	tick=GetTickCount()-tick;
	{
	char buf[255];
	//sprintf(buf,"%s %s took %i ms",__FILE__,__LINE__,tick);
	sprintf(buf,"RebuildEntireList %d \r\n",tick);

	TRACE(buf);
	DBWriteContactSettingDword((HANDLE)0,"CLUI","PF:Last RebuildEntireList Time:",tick);
	}	
#endif
}
示例#22
0
int cli_AddInfoItemToGroup(ClcGroup *group, int flags, const TCHAR *pszText)
{
	int i = corecli.pfnAddInfoItemToGroup(group, flags, pszText);
	ClearRowByIndexCache();
	return i;
}
示例#23
0
void cli_FreeGroup(ClcGroup* group)
{
	corecli.pfnFreeGroup(group);
	ClearRowByIndexCache();
}
示例#24
0
void SaveStateAndRebuildList(HWND hwnd,struct ClcData *dat)
{
	NMCLISTCONTROL nm;
	int i,j;
	struct SavedGroupState_t *savedGroup=NULL;
	int savedGroupCount=0,savedGroupAlloced=0;
	struct SavedContactState_t *savedContact=NULL;
	int savedContactCount=0,savedContactAlloced=0;
	struct SavedInfoState_t *savedInfo=NULL;
	int savedInfoCount=0,savedInfoAlloced=0;
	struct ClcGroup *group;
	struct ClcContact *contact;

	int tick=GetTickCount();
	int allocstep=1024;

  TRACE("SaveStateAndRebuildList\n");

	HideInfoTip(hwnd,dat);
	KillTimer(hwnd,TIMERID_INFOTIP);
  KillTimer(hwnd,TIMERID_REBUILDAFTER);
	KillTimer(hwnd,TIMERID_RENAME);
	EndRename(hwnd,dat,1);

	group=&dat->list;
	group->scanIndex=0;
	for(;;) {
		if(group->scanIndex==group->contactCount) {
			group=group->parent;
			if(group==NULL) break;
		}
		else if(group->contact[group->scanIndex].type==CLCIT_GROUP) {
			group=group->contact[group->scanIndex].group;
			group->scanIndex=0;
			if(++savedGroupCount>savedGroupAlloced) {
				savedGroupAlloced+=allocstep;
				savedGroup=(struct SavedGroupState_t*)mir_realloc(savedGroup,sizeof(struct SavedGroupState_t)*savedGroupAlloced);
			}
			savedGroup[savedGroupCount-1].groupId=group->groupId;
			savedGroup[savedGroupCount-1].expanded=group->expanded;
			continue;
		}
		else if(group->contact[group->scanIndex].type==CLCIT_CONTACT) {			
			if(++savedContactCount>savedContactAlloced) {
				savedContactAlloced+=allocstep;
				savedContact=(struct SavedContactState_t*)mir_realloc(savedContact,sizeof(struct SavedContactState_t)*savedContactAlloced);
			}
			savedContact[savedContactCount-1].hContact=group->contact[group->scanIndex].hContact;
			CopyMemory(savedContact[savedContactCount-1].iExtraImage,group->contact[group->scanIndex].iExtraImage,sizeof(group->contact[group->scanIndex].iExtraImage));
			savedContact[savedContactCount-1].checked=group->contact[group->scanIndex].flags&CONTACTF_CHECKED;
			if (group->contact[group->scanIndex].SubAllocated>0)
			{
				int l;
				for (l=0; l<group->contact[group->scanIndex].SubAllocated; l++)
				{
					if(++savedContactCount>savedContactAlloced) {
						savedContactAlloced+=allocstep;
						savedContact=(struct SavedContactState_t*)mir_realloc(savedContact,sizeof(struct SavedContactState_t)*savedContactAlloced);
					}
					savedContact[savedContactCount-1].hContact=group->contact[group->scanIndex].subcontacts[l].hContact;
					CopyMemory(savedContact[savedContactCount-1].iExtraImage ,group->contact[group->scanIndex].subcontacts[l].iExtraImage,sizeof(group->contact[group->scanIndex].iExtraImage));
					savedContact[savedContactCount-1].checked=group->contact[group->scanIndex].subcontacts[l].flags&CONTACTF_CHECKED;
                    

				}
			}

		}
		else if(group->contact[group->scanIndex].type==CLCIT_INFO) {
			if(++savedInfoCount>savedInfoAlloced) {
				savedInfoAlloced+=allocstep;
				savedInfo=(struct SavedInfoState_t*)mir_realloc(savedInfo,sizeof(struct SavedInfoState_t)*savedInfoAlloced);
			}
			if(group->parent==NULL) savedInfo[savedInfoCount-1].parentId=-1;
			else savedInfo[savedInfoCount-1].parentId=group->groupId;
			savedInfo[savedInfoCount-1].contact=group->contact[group->scanIndex];
			{
				TCHAR * name=NULL;
				if(savedInfo[savedInfoCount-1].contact.szText)
				{
					name=mir_strdupT(savedInfo[savedInfoCount-1].contact.szText);
					mir_free(savedInfo[savedInfoCount-1].contact.szText);
					savedInfo[savedInfoCount-1].contact.szText=name;
					group->contact[group->scanIndex].szText=NULL;
				}
			}
		}
		group->scanIndex++;
	}

	FreeGroup(&dat->list);
	RebuildEntireList(hwnd,dat);

	group=&dat->list;
	group->scanIndex=0;
	for(;;) {
		if(group->scanIndex==group->contactCount) {
			group=group->parent;
			if(group==NULL) break;
		}
		else if(group->contact[group->scanIndex].type==CLCIT_GROUP) {
			group=group->contact[group->scanIndex].group;
			group->scanIndex=0;
			for(i=0;i<savedGroupCount;i++)
				if(savedGroup[i].groupId==group->groupId) {
					group->expanded=savedGroup[i].expanded;
					break;
				}
			continue;
		}
		else if(group->contact[group->scanIndex].type==CLCIT_CONTACT) {
			for(i=0;i<savedContactCount;i++)
				if(savedContact[i].hContact==group->contact[group->scanIndex].hContact) {
					CopyMemory(group->contact[group->scanIndex].iExtraImage,savedContact[i].iExtraImage,sizeof(group->contact[group->scanIndex].iExtraImage));
					if(savedContact[i].checked) group->contact[group->scanIndex].flags|=CONTACTF_CHECKED;
					break;	
				}
			if (group->contact[group->scanIndex].SubAllocated>0)
			{
				int l;
				for (l=0; l<group->contact[group->scanIndex].SubAllocated; l++)
					for(i=0;i<savedContactCount;i++)
						if(savedContact[i].hContact==group->contact[group->scanIndex].subcontacts[l].hContact) {

							CopyMemory(group->contact[group->scanIndex].subcontacts[l].iExtraImage,savedContact[i].iExtraImage,sizeof(group->contact[group->scanIndex].iExtraImage));
							if(savedContact[i].checked) group->contact[group->scanIndex].subcontacts[l].flags|=CONTACTF_CHECKED;
                            group->contact[group->scanIndex].subcontacts[l].subcontacts=&(group->contact[group->scanIndex]);
							break;	
						}	
			}
		}
		group->scanIndex++;
	}
	if(savedGroup) mir_free(savedGroup);
	if(savedContact) mir_free(savedContact);
	for(i=0;i<savedInfoCount;i++) {
		if(savedInfo[i].parentId==-1) group=&dat->list;
		else {
			if(!FindItem(hwnd,dat,(HANDLE)(savedInfo[i].parentId|HCONTACT_ISGROUP),&contact,NULL,NULL,TRUE)) continue;
			group=contact->group;
		}
		j=AddInfoItemToGroup(group,savedInfo[i].contact.flags,NULL);
		group->contact[j]=savedInfo[i].contact;
	}
	if(savedInfo) mir_free(savedInfo);
	RecalculateGroupCheckboxes(hwnd,dat);

	RecalcScrollBar(hwnd,dat);
	nm.hdr.code=CLN_LISTREBUILT;
	nm.hdr.hwndFrom=hwnd;
	nm.hdr.idFrom=GetDlgCtrlID(hwnd);


	//srand(GetTickCount());
	
	tick=GetTickCount()-tick;
#ifdef _DEBUG
	{
	char buf[255];
	sprintf(buf,"SaveStateAndRebuildList %d \r\n",tick);
	TRACE(buf);
	}	
#endif

	ClearRowByIndexCache();
       // SetAllExtraIcons(hwnd,0);
	SendMessage(GetParent(hwnd),WM_NOTIFY,0,(LPARAM)&nm);
}
示例#25
0
void cliRebuildEntireList(HWND hwnd,struct ClcData *dat)
{
	DWORD style=GetWindowLong(hwnd,GWL_STYLE);
	HANDLE hContact;
	struct ClcContact * cont;
	struct ClcGroup *group;
  static int rebuildCounter=0;
	BOOL GroupShowOfflineHere=FALSE;
	int tick=GetTickCount();
	KillTimer(hwnd,TIMERID_REBUILDAFTER);
	lockdat;
	ClearRowByIndexCache();
	ImageArray_Clear(&dat->avatar_cache);
	RowHeights_Clear(dat);
	RowHeights_GetMaxRowHeight(dat, hwnd);
  TRACEVAR("Rebuild Entire List %d times\n",++rebuildCounter);
  
	dat->list.expanded=1;
	dat->list.hideOffline=DBGetContactSettingByte(NULL,"CLC","HideOfflineRoot",0);
	dat->list.cl.count = dat->list.cl.limit = 0;
	dat->list.cl.increment = 50;
	dat->NeedResort=1;
	dat->selection=-1;
	dat->HiLightMode=DBGetContactSettingByte(NULL,"CLC","HiLightMode",0);
	{
		int i;
		TCHAR *szGroupName;
		DWORD groupFlags;

		for(i=1;;i++) {
			szGroupName=pcli->pfnGetGroupName(i,&groupFlags); //UNICODE
			if(szGroupName==NULL) break;
			cli_AddGroup(hwnd,dat,szGroupName,groupFlags,i,0);
		}
	}

	hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);
	while(hContact) {
		pdisplayNameCacheEntry cacheEntry=NULL;
		cont=NULL;
		cacheEntry=(pdisplayNameCacheEntry)pcli->pfnGetCacheEntry(hContact);

		if( (cacheEntry->szProto||style&CLS_SHOWHIDDEN) &&
			(
			 (dat->IsMetaContactsEnabled||mir_strcmp(cacheEntry->szProto,"MetaContacts"))
			 &&(style&CLS_SHOWHIDDEN || (!cacheEntry->Hidden && !cacheEntry->isUnknown)) 
			 &&(!cacheEntry->HiddenSubcontact || !dat->IsMetaContactsEnabled)
			)
		  )
		{

			if(lstrlen(cacheEntry->szGroup)==0)
				group=&dat->list;
			else {
				group=cli_AddGroup(hwnd,dat,cacheEntry->szGroup,(DWORD)-1,0,0);
			}
			if(group!=NULL) 
			{
				if (cacheEntry->status==ID_STATUS_OFFLINE)
					if (DBGetContactSettingByte(NULL,"CList","PlaceOfflineToRoot",0))
						group=&dat->list;
				group->totalMembers++;

				if(!(style&CLS_NOHIDEOFFLINE) && (style&CLS_HIDEOFFLINE || group->hideOffline)) 
				{
					if(cacheEntry->szProto==NULL) {
						if(!pcli->pfnIsHiddenMode(dat,ID_STATUS_OFFLINE)||cacheEntry->noHiddenOffline || IsShowOfflineGroup(group))
							cont=AddContactToGroup(dat,group,cacheEntry);
					}
					else
						if(!pcli->pfnIsHiddenMode(dat,cacheEntry->status)||cacheEntry->noHiddenOffline || IsShowOfflineGroup(group))
							cont=AddContactToGroup(dat,group,cacheEntry);
				}
				else cont=AddContactToGroup(dat,group,cacheEntry);
			}
		}
		if (cont)	
		{	
			cont->SubAllocated=0;
			if (cont->proto && strcmp(cont->proto,"MetaContacts")==0)
				AddSubcontacts(dat,cont,IsShowOfflineGroup(group));
		}
		hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0);
	}

	if(style&CLS_HIDEEMPTYGROUPS) {
		group=&dat->list;
		group->scanIndex=0;
		for(;;) {
			if(group->scanIndex==group->cl.count) {
				group=group->parent;
				if(group==NULL) break;
			}
			else if(group->cl.items[group->scanIndex]->type==CLCIT_GROUP) {
				if(group->cl.items[group->scanIndex]->group->cl.count==0) {
					group=pcli->pfnRemoveItemFromGroup(hwnd,group,group->cl.items[group->scanIndex],0);
				}
				else {
					group=group->cl.items[group->scanIndex]->group;
					group->scanIndex=0;
				}
				continue;
			}
			group->scanIndex++;
		}
	}
	ulockdat;

	pcli->pfnSortCLC(hwnd,dat,0);

}
示例#26
0
void AddContactToTree(HWND hwnd,struct ClcData *dat,HANDLE hContact,int updateTotalCount,int checkHideOffline)
{
	struct ClcGroup *group;
	struct ClcContact * cont;
	pdisplayNameCacheEntry cacheEntry;
	DWORD style=GetWindowLong(hwnd,GWL_STYLE);
	WORD status;
	char *szProto;
	
	if (FindItem(hwnd,dat,hContact,NULL,NULL,NULL,FALSE)==1){return;};	
	cacheEntry=GetContactFullCacheEntry(hContact);
	if (cacheEntry==NULL) return;
    if (dat->IsMetaContactsEnabled && cacheEntry->HiddenSubcontact) return;   ///-----
	szProto=cacheEntry->szProto;


	//char *szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
	
	dat->NeedResort=1;
	ClearRowByIndexCache();
	ClearClcContactCache(dat,hContact);
	
	if(style&CLS_NOHIDEOFFLINE) checkHideOffline=0;
	if(checkHideOffline) {
		if(szProto==NULL) status=ID_STATUS_OFFLINE;
		else status=cacheEntry->status;
	}

	if(lstrlen(cacheEntry->szGroup)==0)
		group=&dat->list;
	else {
		group=AddGroup(hwnd,dat,cacheEntry->szGroup,(DWORD)-1,0,0);
		if(group==NULL) {
			int i,len;
			DWORD groupFlags;
			TCHAR *szGroupName;
			if(!(style&CLS_HIDEEMPTYGROUPS)) {
			//	/*mir_free(dbv.pszVal);*/AddTempGroup(hwnd,dat,cacheEntry->szGroup,(DWORD)-1,0,0);
				return;
			}
			if(checkHideOffline && IsHiddenMode(dat,status)) {
				for(i=1;;i++) {
					szGroupName=(TCHAR*)CallService(MS_CLIST_GROUPGETNAMET,i,(LPARAM)&groupFlags); //UNICODE
					if(szGroupName==NULL) {/*mir_free(dbv.pszVal);*/ return;}   //never happens
					if(!lstrcmp(szGroupName,cacheEntry->szGroup)) break;
				}
				if(groupFlags&GROUPF_HIDEOFFLINE) {/*mir_free(dbv.pszVal);*/ return;}
			}
			for(i=1;;i++) {
				szGroupName=(TCHAR*)CallService(MS_CLIST_GROUPGETNAMET,i,(LPARAM)&groupFlags); //UNICODE
				if(szGroupName==NULL) {/*mir_free(dbv.pszVal);*/ return;}   //never happens
				if(!lstrcmp(szGroupName,cacheEntry->szGroup)) break;
				len=lstrlen(szGroupName);
				if(!_tcsncmp(szGroupName,cacheEntry->szGroup,len) && cacheEntry->szGroup[len]=='\\')
					AddGroup(hwnd,dat,szGroupName,groupFlags,i,1);
			}
			group=AddGroup(hwnd,dat,cacheEntry->szGroup,groupFlags,i,1);
		}
	//	mir_free(dbv.pszVal);
	}
    if (cacheEntry->status==ID_STATUS_OFFLINE)
           if (DBGetContactSettingByte(NULL,"CList","PlaceOfflineToRoot",0))
                        group=&dat->list;
	if(checkHideOffline) {
		if(IsHiddenMode(dat,status) && (style&CLS_HIDEOFFLINE || group->hideOffline)) {
			if(updateTotalCount) group->totalMembers++;
			return;
		}
	}
    if(dat->IsMetaContactsEnabled &&  cacheEntry->HiddenSubcontact) return;
    if(!dat->IsMetaContactsEnabled && !MyStrCmp(cacheEntry->szProto,"MetaContacts")) return;
	cont=AddContactToGroup(dat,group,cacheEntry);
	if (cont)	
			if (cont->proto)
		{	
			cont->SubAllocated=0;
			if (MyStrCmp(cont->proto,"MetaContacts")==0)
				AddSubcontacts(dat,cont);
		}
	if(updateTotalCount && group) group->totalMembers++;
	ClearRowByIndexCache();
}
示例#27
0
void cliRebuildEntireList(HWND hwnd, ClcData *dat)
{
	DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE);
	ClcGroup *group = NULL;
	static int rebuildCounter = 0;

	BOOL PlaceOfflineToRoot = db_get_b(NULL, "CList", "PlaceOfflineToRoot", SETTING_PLACEOFFLINETOROOT_DEFAULT);
	KillTimer(hwnd, TIMERID_REBUILDAFTER);
	pcli->bAutoRebuild = false;

	ClearRowByIndexCache();
	ImageArray_Clear(&dat->avatar_cache);
	RowHeights_Clear(dat);
	RowHeights_GetMaxRowHeight(dat, hwnd);
	TRACEVAR("Rebuild Entire List %d times\n", ++rebuildCounter);

	dat->list.expanded = 1;
	dat->list.hideOffline = db_get_b(NULL, "CLC", "HideOfflineRoot", SETTING_HIDEOFFLINEATROOT_DEFAULT) && style&CLS_USEGROUPS;
	dat->list.cl.count = dat->list.cl.limit = 0;
	dat->list.cl.increment = 50;
	dat->needsResort = 1;

	MCONTACT hSelected = SaveSelection(dat);
	dat->selection = -1;
	dat->HiLightMode = db_get_b(NULL, "CLC", "HiLightMode", SETTING_HILIGHTMODE_DEFAULT);

	for (int i = 1;; i++) {
		DWORD groupFlags;
		TCHAR *szGroupName = pcli->pfnGetGroupName(i, &groupFlags); //UNICODE
		if (szGroupName == NULL)
			break;
		cli_AddGroup(hwnd, dat, szGroupName, groupFlags, i, 0);
	}

	for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
		ClcContact *cont = NULL;
		ClcCacheEntry *cacheEntry = pcli->pfnGetCacheEntry(hContact);

		int nHiddenStatus = CLVM_GetContactHiddenStatus(hContact, NULL, dat);
		if ((style & CLS_SHOWHIDDEN && nHiddenStatus != -1) || !nHiddenStatus) {
			if (mir_tstrlen(cacheEntry->tszGroup) == 0)
				group = &dat->list;
			else
				group = cli_AddGroup(hwnd, dat, cacheEntry->tszGroup, (DWORD)-1, 0, 0);

			if (group != NULL) {
				WORD wStatus = pdnce___GetStatus(cacheEntry);
				if (wStatus == ID_STATUS_OFFLINE && PlaceOfflineToRoot)
					group = &dat->list;

				group->totalMembers++;

				if (!(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->hideOffline)) {
					if (cacheEntry->m_cache_cszProto == NULL) {
						if (!pcli->pfnIsHiddenMode(dat, ID_STATUS_OFFLINE) || cacheEntry->m_cache_nNoHiddenOffline || CLCItems_IsShowOfflineGroup(group))
							cont = AddContactToGroup(dat, group, cacheEntry);
					}
					else if (!pcli->pfnIsHiddenMode(dat, wStatus) || cacheEntry->m_cache_nNoHiddenOffline || CLCItems_IsShowOfflineGroup(group))
						cont = AddContactToGroup(dat, group, cacheEntry);
				}
				else cont = AddContactToGroup(dat, group, cacheEntry);
			}
		}
		if (cont) {
			cont->SubAllocated = 0;
			if (cont->proto && dat->IsMetaContactsEnabled  && mir_strcmp(cont->proto, META_PROTO) == 0)
				AddSubcontacts(dat, cont, CLCItems_IsShowOfflineGroup(group));
		}
	}

	if (style & CLS_HIDEEMPTYGROUPS) {
		group = &dat->list;
		group->scanIndex = 0;
		for (;;) {
			if (group->scanIndex == group->cl.count) {
				group = group->parent;
				if (group == NULL)
					break;
			}
			else if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) {
				if (group->cl.items[group->scanIndex]->group->cl.count == 0)
					group = pcli->pfnRemoveItemFromGroup(hwnd, group, group->cl.items[group->scanIndex], 0);
				else {
					group = group->cl.items[group->scanIndex]->group;
					group->scanIndex = 0;
				}
				continue;
			}
			group->scanIndex++;
		}
	}

	pcli->pfnSortCLC(hwnd, dat, 0);

	RestoreSelection(dat, hSelected);
}
示例#28
0
void cli_FreeGroup( struct ClcGroup* group )
{
	saveFreeGroup( group );
	ClearRowByIndexCache();
}
示例#29
0
void SortCLC(HWND hwnd,struct ClcData *dat,int useInsertionSort)
{
	struct ClcContact *selcontact;
	struct ClcGroup *group=&dat->list,*selgroup;
	int dividers=dat->exStyle&CLS_EX_DIVIDERONOFF;
	HANDLE hSelItem;
	int tick=GetTickCount();
	if (dat->NeedResort==1 &&1)
	{

		if(GetRowByIndex(dat,dat->selection,&selcontact,NULL)==-1) hSelItem=NULL;
		else hSelItem=ContactToHItem(selcontact);
		group->scanIndex=0;
		
		SortGroup(dat,group,useInsertionSort);
		
		for(;;) {
			if(group->scanIndex==group->contactCount) {
				group=group->parent;
				if(group==NULL) break;
			}
			else if(group->contact[group->scanIndex].type==CLCIT_GROUP) {
				group=group->contact[group->scanIndex].group;
				group->scanIndex=0;
				SortGroup(dat,group,useInsertionSort);
				continue;
			}
			group->scanIndex++;
		}
		
		ClearClcContactCache(dat,INVALID_HANDLE_VALUE);

		if(hSelItem)
			if(FindItem(hwnd,dat,hSelItem,&selcontact,&selgroup,NULL,FALSE))
				dat->selection=GetRowsPriorTo(&dat->list,selgroup,selcontact-selgroup->contact);
		
		
		RecalcScrollBar(hwnd,dat);
		ClearRowByIndexCache();
	}else
	{
		//TRACE("Not need to sort\r\n");
	};
    
	InvalidateRectZ(hwnd,NULL,FALSE);
	dat->NeedResort=0;
   // LOCK_IMAGE_UPDATING=1;
   // RecalcScrollBar(hwnd,dat);
#ifdef _DEBUG
	tick=GetTickCount()-tick;
	{
	char buf[255];
	//sprintf(buf,"%s %s took %i ms",__FILE__,__LINE__,tick);
		if (tick>5) 
		{
			sprintf(buf,"SortCLC %d \r\n",tick);
			TRACE(buf);
			DBWriteContactSettingDword((HANDLE)0,"CLUI","PF:Last SortCLC Time:",tick);
		}
	}
#endif	
}
示例#30
0
static struct ClcContact * AddContactToGroup(struct ClcData *dat,struct ClcGroup *group,pdisplayNameCacheEntry cacheEntry)
{
	char *szProto;
	WORD apparentMode;
	DWORD idleMode;
	HANDLE hContact;
	int i;
	if (cacheEntry==NULL) return NULL;
	if (group==NULL) return NULL;
	if (dat==NULL) return NULL;
	hContact=cacheEntry->hContact;
	//ClearClcContactCache(hContact);

	dat->NeedResort=1;
	for(i=group->cl.count-1;i>=0;i--)
		if(group->cl.items[i]->type!=CLCIT_INFO || !(group->cl.items[i]->flags&CLCIIF_BELOWCONTACTS)) break;
	i=cli_AddItemToGroup(group,i+1);
	group->cl.items[i]->type=CLCIT_CONTACT;
	group->cl.items[i]->SubAllocated=0;
	group->cl.items[i]->isSubcontact=0;
	group->cl.items[i]->subcontacts=NULL;
	group->cl.items[i]->szText[0]=0;
//	group->cl.items[i]->szSecondLineText=NULL;
//	group->cl.items[i]->szThirdLineText=NULL;
	group->cl.items[i]->image_is_special=FALSE;
//	group->cl.items[i]->status=cacheEntry->status;

	group->cl.items[i]->iImage=CallService(MS_CLIST_GETCONTACTICON,(WPARAM)hContact,0);
	cacheEntry=(pdisplayNameCacheEntry)pcli->pfnGetCacheEntry(hContact);
	group->cl.items[i]->hContact=hContact;

	group->cl.items[i]->avatar_pos = AVATAR_POS_DONT_HAVE;
	Cache_GetAvatar(dat, group->cl.items[i]);

	szProto=cacheEntry->szProto;
	if(szProto!=NULL&&!pcli->pfnIsHiddenMode(dat,cacheEntry->status))
		group->cl.items[i]->flags |= CONTACTF_ONLINE;
	apparentMode=szProto!=NULL?cacheEntry->ApparentMode:0;
	if(apparentMode==ID_STATUS_OFFLINE)	group->cl.items[i]->flags|=CONTACTF_INVISTO;
	else if(apparentMode==ID_STATUS_ONLINE) group->cl.items[i]->flags|=CONTACTF_VISTO;
	else if(apparentMode) group->cl.items[i]->flags|=CONTACTF_VISTO|CONTACTF_INVISTO;
	if(cacheEntry->NotOnList) group->cl.items[i]->flags|=CONTACTF_NOTONLIST;
	idleMode=szProto!=NULL?cacheEntry->IdleTS:0;
	if (idleMode) 
		group->cl.items[i]->flags|=CONTACTF_IDLE;
	group->cl.items[i]->proto = szProto;

//	group->cl.items[i]->timezone = (DWORD)DBGetContactSettingByte(hContact,"UserInfo","Timezone", DBGetContactSettingByte(hContact, szProto,"Timezone",-1));
/*
if (group->cl.items[i]->timezone != -1)
	{
		int contact_gmt_diff = group->cl.items[i]->timezone;
		contact_gmt_diff = contact_gmt_diff > 128 ? 256 - contact_gmt_diff : 0 - contact_gmt_diff;
		contact_gmt_diff *= 60*60/2;

		if (contact_gmt_diff == dat->local_gmt_diff)
			group->cl.items[i]->timediff = 0;
		else
			group->cl.items[i]->timediff = (int)dat->local_gmt_diff_dst - contact_gmt_diff;
	}
*/
	pcli->pfnInvalidateDisplayNameCacheEntry(hContact);	
	Cache_GetTimezone(dat, group->cl.items[i]->hContact);
	Cache_GetText(dat, group->cl.items[i],1);
	ClearRowByIndexCache();
	return group->cl.items[i];
}