Exemple #1
0
int RefreshContactListIcons(HANDLE hContact)
{
	if (hContact == 0)
		return 0;

	int count = CallService(MS_DB_CONTACT_GETCOUNT, 0, 0);
	int hidden = db_get_b(hContact, "CList", "Hidden", 0);
	int ignored = db_get_dw(hContact, "Ignore", "Mask1", 0);
	ignored = ((ignored & 0x3f) != 0) ? 1 : 0;
	int ok = 1;
	if (commonData.notifyFor & EXCLUDE_HIDDEN)
		ok &= (hidden == 0);

	if (commonData.notifyFor & EXCLUDE_IGNORED)
		ok &= (ignored == 0);

	time_t today = Today();

	int dtb = NotifyContactBirthday(hContact, today, commonData.daysInAdvance);
	int dab = NotifyMissedContactBirthday(hContact, today, commonData.daysAfter);

	if (ok && (dtb >= 0 || dab > 0)) {
		int age = GetContactAge(hContact);
		db_set_b(hContact, "UserInfo", "Age", age);

		if ((bShouldCheckBirthdays) && (commonData.bUsePopups))
		{
			if (dtb >= 0) {
				bBirthdayFound = 1; //only set it if we're called from our CheckBirthdays service
				PopupNotifyBirthday(hContact, dtb, age);
			}
			else if (dab > 0)
				PopupNotifyMissedBirthday(hContact, dab, age);
		}

		if (bShouldCheckBirthdays)
			if (dtb >= 0)
				SoundNotifyBirthday(dtb);

		if ((bShouldCheckBirthdays) && (commonData.bUseDialog)) {
			if (dtb >= 0)
				DialogNotifyBirthday(hContact, dtb, age);
			else if (dab > 0)
				DialogNotifyMissedBirthday(hContact, dab, age);
		}

		if (dtb >= 0)
			ExtraIcon_SetIcon(hWWIExtraIcons, hContact, GetDTBIconHandle(dtb));
	}
	else ExtraIcon_Clear(hWWIExtraIcons, hContact);

	return 0;
}
int OnExtraImageApply(WPARAM wParam, LPARAM lParam)
{
	HANDLE hContact = (HANDLE) wParam;
	if ((hContact))
		{
			int count = CallService(MS_DB_CONTACT_GETCOUNT, 0, 0);
			//int daysInAdvance = DBGetContactSettingWord(NULL, ModuleName, "DaysInAdvance", DAYS_TO_NOTIFY);
			//int popupTimeout = DBGetContactSettingWord(NULL, ModuleName, "PopupTimeout", POPUP_TIMEOUT);
			//DWORD foreground = DBGetContactSettingDword(NULL, ModuleName, "Foreground", FOREGROUND_COLOR);
			//DWORD background = DBGetContactSettingDword(NULL, ModuleName, "Background", BACKGROUND_COLOR);
			//int bUsePopups = DBGetContactSettingByte(NULL, ModuleName, "UsePopups", TRUE);
			//int bUseClistIcon = DBGetContactSettingByte(NULL, ModuleName, "UseClistIcon", TRUE);
			//int bUseDialog = DBGetContactSettingByte(NULL, ModuleName, "UseDialog", TRUE);
			//int clistIcon = DBGetContactSettingByte(NULL, ModuleName, "AdvancedIcon", CLIST_ICON);
			//int notifyFor = DBGetContactSettingByte(NULL, ModuleName, "NotifyFor", 0);
			int hidden = DBGetContactSettingByte(hContact, "CList", "Hidden", 0);
			int ignored = DBGetContactSettingDword(hContact, "Ignore", "Mask1", 0);
			ignored = ((ignored & 0x3f) != 0) ? 1 : 0;
			int ok = 1;
			if (commonData.notifyFor & EXCLUDE_HIDDEN)
			{
				ok &= (hidden == 0);
			}
			if (commonData.notifyFor & EXCLUDE_IGNORED)
			{
				ok &= (ignored == 0);
			}
		
			int dtb;
			int dab;
			int caps = ServiceExists(MS_CLIST_EXTRA_ADD_ICON); // CallService(MS_CLUI_GETCAPS, 0, 0);
			
			time_t today = Today();
			
			if ((ok) && (((dtb = NotifyContactBirthday(hContact, today, commonData.daysInAdvance)) >= 0) || ((dab = NotifyMissedContactBirthday(hContact, today, commonData.daysAfter)) > 0)))
			{
				int age = GetContactAge(hContact);
				DBWriteContactSettingByte(hContact, "UserInfo", "Age", age);
				
				if ((bShouldCheckBirthdays) && (commonData.bUsePopups))
				{
					if (dtb >= 0)
					{
						bBirthdayFound = 1; //only set it if we're called from our CheckBirthdays service
						PopupNotifyBirthday(hContact, dtb, age);
					}
					else if (dab > 0)
					{
						PopupNotifyMissedBirthday(hContact, dab, age);
					}
				}
					
				if (bShouldCheckBirthdays)
				{
					if (dtb >= 0)
					{
						SoundNotifyBirthday(dtb);
					}
				}
					
				if ((bShouldCheckBirthdays) && (commonData.bUseDialog))
				{
					if (dtb >= 0)
					{
						DialogNotifyBirthday(hContact, dtb, age);
					}
					else if (dab > 0)
					{
						DialogNotifyMissedBirthday(hContact, dab, age);
					}
				}
				
				if ((caps > 0) && (commonData.bUseClistIcon)) //TODO
				{
					if (dtb >= 0)
					{
						ClistIconNotifyBirthday(hContact, dtb, commonData.clistIcon);
					}
				}
			}
			else{
				if (caps > 0) //TODO
				{ //clear the icon
					ClearClistIcon(hContact, commonData.clistIcon);
				}
			}
		}
		
	return 0;
}