Пример #1
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;
}
Пример #2
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]);
}
Пример #3
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();
}
Пример #4
0
void LayerGroupsCreate::OnAdd() 
{
   GroupOrLayer *add, *addTo;
   
   // get selected from list
   {
      int count = m_list.GetItemCount();

      if (!count)    
      {  ErrorMessage("No Layers", "Nothing Selected to Add"); return;  }

      BOOL Selected = FALSE;
		int selItem=0; 
      for (selItem=0; selItem < count; selItem++)
      {
         if (m_list.GetItemState(selItem, LVIS_SELECTED))
         {  
            Selected = TRUE;  
            break;   
         }
      }

      if (!Selected)    
      {  ErrorMessage("Select a group or layer from left box to add", "Nothing Selected to Add");  return;  }

      add = (GroupOrLayer*)m_list.GetItemData(selItem);
   }

   // get selected group from tree
   {
      HTREEITEM item = m_tree.GetSelectedItem();
      if (item == NULL) {  ErrorMessage("Select a group from right box to add item to", "No Group Selected");  return; } // nothing selected

      addTo = (GroupOrLayer*)m_tree.GetItemData(item); 
      if (!addTo->IsAGroup)   {  ErrorMessage("Select a group from right box to add item to", "No Group Selected");  return; } // nothing selected
   }  

   AddItemToGroup(addTo->group, add);
}
Пример #5
0
struct ClcGroup *AddGroup(HWND hwnd,struct ClcData *dat,const TCHAR *szName,DWORD flags,int groupId,int calcTotalMembers)
{
	TCHAR *pBackslash,*pNextField,szThisField[120-MAXEXTRACOLUMNS];
  TCHAR *HiddenGroup=NULL;
	struct ClcGroup *group=&dat->list;
	int i,compareResult;

	ClearRowByIndexCache();	
	dat->NeedResort=1;

    if (GetWindowLong(hwnd,GWL_STYLE)&CLS_USEGROUPS)                            //groups is using
        if (ServiceExists(MS_MC_GETDEFAULTCONTACT))                             //metacontacts dll is loaded  
            if (DBGetContactSettingByte(NULL,"MetaContacts","Enabled",1));      //and enabled
        {
            HiddenGroup=DBGetStringT(NULL,"MetaContacts","HiddenGroupName");   //TODO: UNICODE + Hidden groupname
           // if (!HiddenGroup) strdup("MetaContacts Hidden Group"); 
            if (szName && HiddenGroup)
            if (!lstrcmp(HiddenGroup,szName))                                    //group is metahidden
            {   
                if (HiddenGroup) mir_free(HiddenGroup);
                return NULL;
            }
        }
    if (HiddenGroup) mir_free(HiddenGroup);
            

	if(!(GetWindowLong(hwnd,GWL_STYLE)&CLS_USEGROUPS)) return &dat->list;
	pNextField=(TCHAR*)szName;
	do {
		pBackslash=_tcschr(pNextField,'\\');
		if(pBackslash==NULL) {
			lstrcpyn(szThisField,pNextField,sizeof(szThisField));
			pNextField=NULL;
		}
		else {
			lstrcpyn(szThisField,pNextField,min(sizeof(szThisField),pBackslash-pNextField+1));
			pNextField=pBackslash+1;
		}
		compareResult=1;
		for(i=0;i<group->contactCount;i++) {
			if(group->contact[i].type==CLCIT_CONTACT) break;
			if(group->contact[i].type!=CLCIT_GROUP) continue;
			compareResult=lstrcmp(szThisField,group->contact[i].szText);
			if(compareResult==0) {
				if(pNextField==NULL && flags!=(DWORD)-1) {
					group->contact[i].groupId=(WORD)groupId;
					group=group->contact[i].group;
					group->expanded=(flags&GROUPF_EXPANDED)!=0;
					group->hideOffline=(flags&GROUPF_HIDEOFFLINE)!=0;
					group->groupId=groupId;
				}
				else group=group->contact[i].group;
				break;
			}
			if(pNextField==NULL && group->contact[i].groupId==0) break;
			if(groupId && group->contact[i].groupId>groupId) break;
		}
		if(compareResult) {
            if(groupId==0) 
                {
                  return NULL;
                  groupId=lastGroupId++;      
                }//return NULL;
			i=AddItemToGroup(group,i);
			group->contact[i].type=CLCIT_GROUP;
      if (group->contact[i].szText) mir_free(group->contact[i].szText);
			group->contact[i].szText=mir_strdupT(szThisField);
			group->contact[i].groupId=(WORD)(pNextField?0:groupId);
			group->contact[i].group=(struct ClcGroup*)mir_alloc(sizeof(struct ClcGroup));
			ZeroMemory(group->contact[i].group, sizeof(struct ClcGroup));
			group->contact[i].group->parent=group;
			group=group->contact[i].group;
			group->allocedCount=group->contactCount=0;
			group->contact=NULL;
			if(flags==(DWORD)-1 || pNextField!=NULL) {
				group->expanded=0;
				group->hideOffline=0;
			}
			else {
				group->expanded=(flags&GROUPF_EXPANDED)!=0;
				group->hideOffline=(flags&GROUPF_HIDEOFFLINE)!=0;
			}
			group->groupId=pNextField?0:groupId;
			group->totalMembers=0;
			if(flags!=(DWORD)-1 && pNextField==NULL && calcTotalMembers) {
				HANDLE hContact;
				//DBVARIANT dbv;
				int tick;
				DWORD style=GetWindowLong(hwnd,GWL_STYLE);
				hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);
				tick=GetTickCount();
				while(hContact) {
					pdisplayNameCacheEntry cacheEntry;
					cacheEntry=GetContactFullCacheEntry(hContact);

					if(cacheEntry->szGroup!=NULL&&lstrlen(cacheEntry->szGroup)!=0) {
						if(!lstrcmp(cacheEntry->szGroup,szName) && (style&CLS_SHOWHIDDEN || !cacheEntry->Hidden))
							group->totalMembers++;
						//mir_free(dbv.pszVal);
					}
					hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0);
				}
#ifdef _DEBUG
        {
          char buf[255];
				tick=GetTickCount()-tick;
				sprintf(buf,"AddGroup Finds %d\r\n",tick);
				TRACE(buf);
        }
#endif
			}
		}
	} while(pNextField);
	
	ClearRowByIndexCache();
	return group;
}
Пример #6
0
static struct ClcContact* AddContactToGroup(struct ClcData *dat,ClcGroup *group,ClcCacheEntry *cacheEntry)
{
	char *szProto;
	WORD apparentMode;
	DWORD idleMode;
	HANDLE hContact;
	DBVARIANT dbv;
	int i;
	int img  = -1;
	int basicIcon = 0;

	if (cacheEntry == NULL || group == NULL || dat == NULL)
		return NULL;

	hContact = cacheEntry->hContact;

	dat->needsResort = 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 = 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;

	if (ProtoServiceExists(cacheEntry->szProto, PS_GETADVANCEDSTATUSICON))
		img = ProtoCallService(cacheEntry->szProto, PS_GETADVANCEDSTATUSICON, (WPARAM)hContact, 0);

	if (img == -1 || !(LOWORD(img)))
		img = pcli->pfnGetContactIcon(hContact);

	group->cl.items[i]->iImage = img;

	cacheEntry = GetContactFullCacheEntry(hContact);
	group->cl.items[i]->hContact = hContact;

	//cacheEntry->ClcContact = &(group->cl.items[i]);
	//SetClcContactCacheItem(dat,hContact,&(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;

	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) {
		if ( !db_get_ts(hContact, "CList", "StatusMsg", &dbv)) {
			int j;
			lstrcpyn(group->cl.items[i]->szStatusMsg, dbv.ptszVal, SIZEOF(group->cl.items[i]->szStatusMsg));
			for (j = (int)_tcslen(group->cl.items[i]->szStatusMsg)-1;j>=0;j--) {
				if (group->cl.items[i]->szStatusMsg[j] == '\r' || group->cl.items[i]->szStatusMsg[j] == '\n' || group->cl.items[i]->szStatusMsg[j] == '\t') {
					group->cl.items[i]->szStatusMsg[j] = ' ';
				}
			}
			db_free(&dbv);
			if (group->cl.items[i]->szStatusMsg[0] != 0) {
				group->cl.items[i]->flags |= CONTACTF_STATUSMSG;
			}
		}
	}

	ClearRowByIndexCache();
	return group->cl.items[i];
}