예제 #1
0
void InitDisplayNameCache(SortedList *list)
{
	int i;
	HANDLE hContact;

	memset(list,0,sizeof(SortedList));
	list->dumpFunc =DumpElem;
	list->sortFunc=handleCompare;
	list->sortQsortFunc=handleQsortCompare;
	list->increment=CallService(MS_DB_CONTACT_GETCOUNT,0,0)+1;

	hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);
	i=0;
	while (hContact!=0)
	{
		displayNameCacheEntry *pdnce;
		pdnce=mir_calloc(1,sizeof(displayNameCacheEntry));
		pdnce->hContact=hContact;
		InvalidateDisplayNameCacheEntryByPDNE(hContact,pdnce,0);
		List_Insert(list,pdnce,i);
		hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0);
		i++;
	}


	//List_Dump(list);
	List_Sort(list);
	//	List_Dump(list);
}
예제 #2
0
void InitDisplayNameCache(SortedList *list)
{
	int i, idx;

	memset(list,0,sizeof(SortedList));
	list->sortFunc = (FSortFunc)handleCompare;
	list->increment = CallService(MS_DB_CONTACT_GETCOUNT,0,0)+1;

	i = 0;
	for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
		ClcCacheEntry *pdnce = (ClcCacheEntry *)mir_calloc(sizeof(ClcCacheEntry));
		pdnce->hContact = hContact;
		InvalidateDisplayNameCacheEntryByPDNE(hContact,pdnce,0);
		List_GetIndex(list,pdnce,&idx);
		List_Insert(list,pdnce,idx);
		i++;
}	}
void InitDisplayNameCache(SortedList *list)
{
	int i, idx;
	HANDLE hContact;

	memset(list,0,sizeof(SortedList));
	list->sortFunc=handleCompare;
	list->increment=CallService(MS_DB_CONTACT_GETCOUNT,0,0)+1;

	hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);
	i=0;
	while (hContact!=0)
	{
		displayNameCacheEntry *pdnce = mir_calloc(sizeof(displayNameCacheEntry));
		pdnce->hContact = hContact;
		InvalidateDisplayNameCacheEntryByPDNE(hContact,pdnce,0);
		li.List_GetIndex(list,pdnce,&idx);
		li.List_Insert(list,pdnce,idx);
		hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0);
		i++;
}	}
예제 #4
0
int ContactSettingChanged(WPARAM wParam,LPARAM lParam)
{
	DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam;
	HANDLE hContact = (HANDLE)wParam;

	// Early exit
	if (hContact == NULL)
		return 0;

	__try
	{
		ClcCacheEntry *pdnce = (ClcCacheEntry *)pcli->pfnGetCacheEntry(hContact);
		if (pdnce == NULL) {
			OutputDebugStringA("!!! Very bad pdnce not found.");
			return 0;
		}

		if (pdnce && pdnce->protoNotExists == FALSE && pdnce->szProto) {
			if ( !strcmp(cws->szModule,pdnce->szProto)) {
				InvalidateDisplayNameCacheEntryByPDNE(hContact,pdnce,cws->value.type);

				if (cws->value.type == DBVT_WORD && !strcmp(cws->szSetting, "Status")) {
					if ( !(pdnce->bIsHidden == 1)) {

						if ( db_get_b((HANDLE)NULL,"CList","ShowStatusMsg",0)||db_get_b(hContact,"CList","StatusMsgAuto",0))
							db_set_s(hContact, "CList", "StatusMsg", "");

						if ( db_get_b(NULL, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT))	{
							// User's state is changing, and we are hideOffline-ing
							if (cws->value.wVal == ID_STATUS_OFFLINE) {
								ChangeContactIcon(hContact, ExtIconFromStatusMode(hContact,cws->szModule, cws->value.wVal), 0); //by FYR
								return 0;
							}
							ChangeContactIcon(hContact, ExtIconFromStatusMode(hContact,cws->szModule, cws->value.wVal), 0); //by FYR
						}
						else ChangeContactIcon(hContact, ExtIconFromStatusMode(hContact,cws->szModule, cws->value.wVal), 0); //by FYR
					}
				}
				else if ( !strcmp(cws->szModule,"MetaContacts")) {
					PostMessage(pcli->hwndContactTree,CLM_AUTOREBUILD,0,0);
					return 0;
				}
				else return 0;

				SortContacts();
			}
		}

		if ( !strcmp(cws->szModule,"CList")) {
			if (pdnce->tszName == NULL || !strcmp(cws->szSetting,"MyHandle"))
				InvalidateDisplayNameCacheEntryByPDNE(hContact,pdnce,cws->value.type);

			if ((!strcmp(cws->szSetting,"Group")))
				InvalidateDisplayNameCacheEntryByPDNE(hContact,pdnce,cws->value.type);

			if ( !strcmp(cws->szSetting,"Hidden")) {
				InvalidateDisplayNameCacheEntryByPDNE(hContact,pdnce,cws->value.type);
				if (cws->value.type == DBVT_DELETED || cws->value.bVal == 0) {
					char *szProto = GetContactProto((HANDLE)wParam);
					ChangeContactIcon(hContact,ExtIconFromStatusMode(hContact, szProto, szProto == NULL ? ID_STATUS_OFFLINE : db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE)), 1);  //by FYR
				}
			}

			if ( !strcmp(cws->szSetting, "noOffline"))
				InvalidateDisplayNameCacheEntryByPDNE(hContact, pdnce, cws->value.type);
		}

		if ( !strcmp(cws->szModule, "Protocol")) {
			if ( !strcmp(cws->szSetting,"p")) {
				OutputDebugStringA("CHANGE: proto\r\n");
				InvalidateDisplayNameCacheEntryByPDNE(hContact, pdnce, cws->value.type);
				char *szProto = (cws->value.type == DBVT_DELETED) ? NULL : cws->value.pszVal;
				ChangeContactIcon(hContact, ExtIconFromStatusMode(hContact, szProto, szProto == NULL?ID_STATUS_OFFLINE:db_get_w(hContact,szProto,"Status",ID_STATUS_OFFLINE)),0); //by FYR
			}
		}
	}
	__except (exceptFunction(GetExceptionInformation()))
	{
	}

	return 0;
}
int ContactSettingChanged(WPARAM wParam,LPARAM lParam)
{
	DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam;
	pdisplayNameCacheEntry pdnce;

	// Early exit
	if ((HANDLE)wParam == NULL)
		return 0;

	__try  
	{
		pdnce = (pdisplayNameCacheEntry)pcli->pfnGetCacheEntry((HANDLE)wParam);
		if (pdnce == NULL)
		{
			OutputDebugStringA("!!! Very bad pdnce not found.");
			return 0;
		}

		if (pdnce&&(pdnce->protoNotExists == FALSE)&&pdnce->szProto)
		{
			if (!strcmp(cws->szModule,pdnce->szProto))
			{
				InvalidateDisplayNameCacheEntryByPDNE((HANDLE)wParam,pdnce,cws->value.type);

				if (cws->value.type == DBVT_WORD&&!strcmp(cws->szSetting, "Status")) {				
					if (!(pdnce->Hidden == 1)) {

						if(DBGetContactSettingByte((HANDLE)NULL,"CList","ShowStatusMsg",0)||DBGetContactSettingByte((HANDLE)wParam,"CList","StatusMsgAuto",0))
							DBWriteContactSettingString((HANDLE)wParam, "CList", "StatusMsg", "");	

						if (DBGetContactSettingByte(NULL, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT))	{
							// User's state is changing, and we are hideOffline-ing

							if (cws->value.wVal == ID_STATUS_OFFLINE) {
								ChangeContactIcon((HANDLE)wParam, ExtIconFromStatusMode((HANDLE)wParam,cws->szModule, cws->value.wVal), 0); //by FYR
								return 0;
							}
							ChangeContactIcon((HANDLE)wParam, ExtIconFromStatusMode((HANDLE)wParam,cws->szModule, cws->value.wVal), 0); //by FYR
						}
						else
						{
							ChangeContactIcon((HANDLE)wParam, ExtIconFromStatusMode((HANDLE)wParam,cws->szModule, cws->value.wVal), 0); //by FYR
						}
					}
				}
				else if (!strcmp(cws->szModule,"MetaContacts"))
				{
					PostMessage(pcli->hwndContactTree,CLM_AUTOREBUILD,0,0);
					return 0;
				}
				else return 0;

				SortContacts();
		}	}

		if(!strcmp(cws->szModule,"CList")) {
			/*
			sprintf(buf,"CHANGE: module:CList setting:%s %s\r\n",cws->szSetting,cws->value.pszVal);
			OutputDebugStringA(buf);
			*/

			//name is null or (setting is myhandle)
			if(pdnce->name == 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")) {
				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);
					ChangeContactIcon((HANDLE)wParam,ExtIconFromStatusMode((HANDLE)wParam,szProto,szProto == NULL?ID_STATUS_OFFLINE:DBGetContactSettingWord((HANDLE)wParam,szProto,"Status",ID_STATUS_OFFLINE)),1);  //by FYR
			}	}

			if(!strcmp(cws->szSetting,"noOffline"))
				InvalidateDisplayNameCacheEntryByPDNE((HANDLE)wParam,pdnce,cws->value.type);
		}

		if(!strcmp(cws->szModule,"Protocol")) {
			if(!strcmp(cws->szSetting,"p")) {
				char *szProto;

				OutputDebugStringA("CHANGE: proto\r\n");
				InvalidateDisplayNameCacheEntryByPDNE((HANDLE)wParam,pdnce,cws->value.type);	
				if(cws->value.type == DBVT_DELETED) szProto=NULL;
				else szProto=cws->value.pszVal;
				ChangeContactIcon((HANDLE)wParam,ExtIconFromStatusMode((HANDLE)wParam,szProto,szProto == NULL?ID_STATUS_OFFLINE:DBGetContactSettingWord((HANDLE)wParam,szProto,"Status",ID_STATUS_OFFLINE)),0); //by FYR
			}
		}
	} 
	__except (exceptFunction(GetExceptionInformation()) ) 
	{ 
	} 

	return 0;
}