예제 #1
0
	// This method clears the list and adds contacts again, according to the current filter settings.
	void RebuildList()
	{
		LPSTR pszProto;
		MTime mtNow;
		MAnnivDate ad;
		int i = 0;
		DWORD age = 0;
		WORD wDaysBefore = db_get_w(NULL, MODNAME, SET_REMIND_OFFSET, DEFVAL_REMIND_OFFSET);
		WORD numMale = 0;
		WORD numFemale = 0;
		WORD numContacts = 0;
		WORD numBirthContacts = 0;

		ShowWindow(_hList, SW_HIDE);
		DeleteAllItems();
		mtNow.GetLocalTime();

		// insert the items into the list
		for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
			// ignore meta subcontacts here, as they are not interesting.
			if (!db_mc_isSub(hContact)) {
				// filter protocol
				pszProto = Proto_GetBaseAccountName(hContact);
				if (pszProto) {
					numContacts++;
					switch (GenderOf(hContact, pszProto)) {
					case 'M':
						numMale++;
						break;
					case 'F':
						numFemale++;
					}

					if (!ad.DBGetBirthDate(hContact, pszProto)) {
						age += ad.Age(&mtNow);
						numBirthContacts++;

						// add birthday
						if ((_filter.bFilterIndex != FILTER_ANNIV) && (!_filter.pszProto || !_strcmpi(pszProto, _filter.pszProto)))
							AddRow(hContact, pszProto, ad, mtNow, wDaysBefore);
					}

					// add anniversaries
					if (_filter.bFilterIndex != FILTER_BIRTHDAY && (!_filter.pszProto || !_strcmpi(pszProto, _filter.pszProto))) 
						for (i = 0; !ad.DBGetAnniversaryDate(hContact, i); i++)
							if (!_filter.pszAnniv || !mir_tstrcmpi(_filter.pszAnniv, ad.Description()))
								AddRow(hContact, pszProto, ad, mtNow, wDaysBefore);
				}
			}
		}
		ListView_SortItemsEx(_hList, (CMPPROC)cmpProc, this);
		ShowWindow(_hList, SW_SHOW);

		// display statistics
		SetDlgItemInt(_hDlg, TXT_NUMBIRTH, numBirthContacts, FALSE);
		SetDlgItemInt(_hDlg, TXT_NUMCONTACT, numContacts, FALSE);
		SetDlgItemInt(_hDlg, TXT_FEMALE, numFemale, FALSE);
		SetDlgItemInt(_hDlg, TXT_MALE, numMale, FALSE);
		SetDlgItemInt(_hDlg, TXT_AGE, numBirthContacts > 0 ? (age - (age % numBirthContacts)) / numBirthContacts : 0, FALSE);
	}
예제 #2
0
WORD	MTime::DateFormatAlt(LPTSTR ptszTimeFormat, WORD cchTimeFormat)
{
	if (!ptszTimeFormat || !cchTimeFormat)
		return 0;

	WORD wRes = DateFormat(ptszTimeFormat, cchTimeFormat);
	if (wRes != 0)
		return wRes;

	SYSTEMTIME AltSysTime = _SysTime;
	MTime mtNow;
	mtNow.GetLocalTime();
	AltSysTime.wYear=mtNow.Year();

	if ((cchTimeFormat = GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &AltSysTime, NULL, ptszTimeFormat, cchTimeFormat)) == 0) {
		*ptszTimeFormat = 0;
		return 0;
	}
	
	TCHAR tszText[10];
	_itot(mtNow.Year(), tszText, 10);
	TCHAR * tszYear = _tcsstr(ptszTimeFormat, tszText);

	if (tszYear && mir_tstrlen(tszYear) == 4)
		mir_tstrcpy(tszYear, _T("????"));
	else {
		*ptszTimeFormat = 0;
		return 0;
	}
	
	return cchTimeFormat;
}
예제 #3
0
/**
 * This is a notification handler for changed contact settings.
 * If any anniversary setting has changed for a meta sub contact,
 * the parental meta contact is rescanned.
 *
 * @param	hContact		- handle of the contect the notification was fired for
 * @param	pdbcws			- pointer to a DBCONTACTWRITESETTING structure
 *
 * @return	This function must return 0 in order to continue in the notification chain.
 **/
static INT OnContactSettingChanged(HANDLE hContact, DBCONTACTWRITESETTING* pdbcws)
{
    if (hContact &&										// valid contact not owner!
            ghCListIA &&								// extraicons active
            pdbcws && pdbcws->szSetting &&				// setting structure valid
            (pdbcws->value.type < DBVT_DWORD) &&		// anniversary datatype
            (gRemindOpts.RemindState != REMIND_OFF) &&	// reminder active
            (!strncmp(pdbcws->szSetting, "Birth", 5) ||
             !strncmp(pdbcws->szSetting, "Anniv", 5) ||
             !strncmp(pdbcws->szSetting, "DOB", 3)))
    {
        HANDLE hMeta = DB::MetaContact::GetMeta(hContact);
        WORD LastAnswer = IDNONE;
        CEvent evt;
        MTime now;

        // check metacontact instead of subcontact
        if (hMeta)
        {
            hContact = hMeta;
        }
        now.GetLocalTime();
        if (!strcmp(pdbcws->szModule, SvcReminderGetMyBirthdayModule()))
        {
            CheckContact(hContact, now, evt, FALSE, &LastAnswer);
        }
        else
        {
            CheckContact(hContact, now, evt, FALSE, 0);
        }
    }
    return 0;
}
예제 #4
0
INT_PTR GetContactLocalTime_old(WPARAM wParam, LPARAM lParam)
{
    MTime	now;
    now.GetLocalTime(wParam);

    LPSYSTEMTIME pSystemTime = (LPSYSTEMTIME)lParam;
    *pSystemTime = now.SystemTime();
    return 0;
}
예제 #5
0
/**
 * Timer procedure, called if date changed. This updates clist icons.
 *
 * @param	hwnd			- not used
 * @param	uMsg			- not used
 * @param	idEvent			- not used
 * @param	dwTime			- not used
 * @return	nothing
 **/
static VOID CALLBACK TimerProc_DateChanged(HWND, UINT, UINT_PTR, DWORD)
{
    static MTime last;
    MTime now;

    now.GetLocalTime();
    if (now.Day() > last.Day() || now.Month() > last.Month() || now.Year() > last.Year()) {
        SvcReminderCheckAll(NOTIFY_CLIST);
        last = now;
    }
}
예제 #6
0
/**
 * This function is the notification handler for clist extra icons to be applied for a contact.
 *
 * @param	hContact		- handle to the contact whose extra icon is to apply
 * @param	lParam			- not used
 *
 * @return	This function must return 0 in order to continue in the notification chain.
 **/
INT OnCListApplyIcon(HANDLE hContact, LPARAM)
{
    if (gRemindOpts.RemindState != REMIND_OFF)
    {
        CEvent evt;
        MTime now;

        now.GetLocalTime();
        CheckContact(hContact, now, evt, FALSE);
    }
    return 0;
}
예제 #7
0
/**
 * This function checks all contacts.
 *
 * @param	notify			- notification type
 *
 * @return	nothing
 **/
VOID SvcReminderCheckAll(const ENotify notify)
{
    if (gRemindOpts.RemindState != REMIND_OFF)
    {
        HANDLE hContact;
        CEvent evt;
        MTime now;
        WORD a1 = 0;

        now.GetLocalTime();

        //walk through all the contacts stored in the DB
        for (hContact = DB::Contact::FindFirst();
                hContact != NULL;
                hContact = DB::Contact::FindNext(hContact))
        {
            CheckContact(hContact, now, evt, notify != NOTIFY_CLIST, &a1);
        }

        if (notify != NOTIFY_CLIST)
        {
            // play sound for the next anniversary
            NotifyWithSound(evt);

            // popup anniversary list
            if (DB::Setting::GetByte(SET_ANNIVLIST_POPUP, FALSE))
            {
                DlgAnniversaryListShow(0, 0);
            }

            if (evt._wDaysLeft > gRemindOpts.wDaysEarlier && notify == NOTIFY_NOANNIV)
            {
                NotifyWithPopup(NULL, CEvent::NONE, 0, NULL, TranslateT("No anniversaries to remind of"));
            }
        }
        UpdateTimer(FALSE);
    }
}