// 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);
	}
		static void SetZodiacAvatar(HANDLE hContact)
		{
			MAnnivDate mtb;

			// try to load birthday for contact
			if (!mtb.DBGetBirthDate(hContact))
			{
				MZodiac zodiac;
				//ICONINFO iinfo;
				CHAR szFileName[MAX_PATH];

				// get zodiac for birthday
				zodiac = mtb.Zodiac();

				if (!GetContactAvatarFileName(zodiac.pszName, szFileName, SIZEOF(szFileName)))
				{
					// extract the bitmap from the icon
					//GetIconInfo(zodiac.hIcon, &iinfo);

					// save the bitmap to a file used as avatar later
					if (!CallService(MS_AV_SETAVATAR, (WPARAM)hContact, (LPARAM)szFileName))
						db_set_b(hContact, "ContactPhoto", "IsZodiac", 1);
				}
			}
		}
Beispiel #3
0
/**
 * name:	DateCtrl_DBGetBirthDay
 * desc:
 * param:
 * return:	0 on success 1 otherwise
 **/
INT_PTR CAnnivEditCtrl::DBGetBirthDay(MCONTACT hContact, LPCSTR pszProto)
{
	MAnnivDate mdb;

	if (!mdb.DBGetBirthDate(hContact, (char *)pszProto)) {
		mdb.DBGetReminderOpts(hContact);
		return AddDate(mdb) > 0;
	}
	return 0;
}
Beispiel #4
0
/**
 * This is the service function for MS_USERINFO_REMINDER_AGGRASIVEBACKUP.
 *
 * @param	hContact		- handle to single contact or NULL to backup all
 * @param	lParam			- if 1, the messagebox will not be displayed
 *
 * return:	0
 **/
static INT_PTR BackupBirthdayService(WPARAM wParam, LPARAM lParam)
{
    HANDLE hContact	= (HANDLE)wParam;
    MAnnivDate mdb;

    if (hContact)
    {
        if (!mdb.DBGetBirthDate(hContact))
        {
            mdb.BackupBirthday(hContact, NULL, TRUE);
        }
    }
    else
    {
        WORD a1 = 0;

        //walk through all the contacts stored in the DB
        for (hContact = DB::Contact::FindFirst();
                hContact != NULL;
                hContact = DB::Contact::FindNext(hContact))
        {
            if (!DB::MetaContact::IsSub(hContact) && !mdb.DBGetBirthDate(hContact))
            {
                mdb.BackupBirthday(hContact, NULL, TRUE, &a1);
            }
        }
    }

    if (lParam != TRUE)
    {
        MSGBOX mBox;

        mBox.cbSize = sizeof(MSGBOX);
        mBox.hParent = NULL;
        mBox.hiLogo = IcoLib_GetIcon(ICO_COMMON_BIRTHDAY);
        mBox.uType = MB_ICON_INFO;
        mBox.ptszTitle = TranslateT("Update custom birthday");
        mBox.ptszMsg = TranslateT("Backing up and syncing all birthdays complete!");
        MsgBoxService(NULL, (LPARAM)&mBox);
    }
    return 0;
}
Beispiel #5
0
/**
 * This function checks, whether a contact has a birthday and it is within the period of time to remind of or not.
 *
 * @param	hContact		- the contact to check
 * @param	Now				- current time
 * @param	evt				- the reference to a structure, which retrieves the resulting DTB
 * @param	bNotify			- if TRUE, a popup will be displayed for a contact having birthday within the next few days.
 * @param	LastAnswer		- this parameter is used for the automatic backup function
 *
 * @retval	TRUE			- contact has a birthday to remind of
 * @retval	FALSE			- contact has no birthday or it is not within the desired period of time.
 **/
static BOOLEAN CheckBirthday(HANDLE hContact, MTime &Now, CEvent &evt, BOOLEAN bNotify, PWORD LastAnwer)
{
    BOOLEAN result = FALSE;

    if (gRemindOpts.RemindState == REMIND_BIRTH || gRemindOpts.RemindState == REMIND_ALL)
    {
        MAnnivDate mtb;

        if (!mtb.DBGetBirthDate(hContact))
        {
            INT Diff;
            WORD wDaysEarlier;

            mtb.DBGetReminderOpts(hContact);

            // make backup of each protocol based birthday
            if (DB::Setting::GetByte(SET_REMIND_SECUREBIRTHDAY, TRUE))
            {
                mtb.BackupBirthday(hContact, NULL, 0, LastAnwer);
            }

            if (mtb.RemindOption() != BST_UNCHECKED)
            {
                wDaysEarlier = (mtb.RemindOption() == BST_CHECKED) ? mtb.RemindOffset() : -1;
                if (wDaysEarlier == (WORD)-1)
                {
                    wDaysEarlier = gRemindOpts.wDaysEarlier;
                }

                Diff = mtb.CompareDays(Now);
                if ((Diff >= 0) && (Diff <= wDaysEarlier))
                {
                    if (evt._wDaysLeft > Diff)
                    {
                        evt._wDaysLeft = Diff;
                        evt._eType = CEvent::BIRTHDAY;
                    }

                    if (bNotify)
                    {
                        TCHAR szMsg[MAXDATASIZE];
                        WORD cchMsg = 0;

                        switch (Diff)
                        {
                        case 0:
                        {
                            cchMsg = mir_sntprintf(szMsg, SIZEOF(szMsg),
                                                   TranslateT("%s has birthday today."),
                                                   DB::Contact::DisplayName(hContact));
                        }
                        break;

                        case 1:
                        {
                            cchMsg = mir_sntprintf(szMsg, SIZEOF(szMsg),
                                                   TranslateT("%s has birthday tomorrow."),
                                                   DB::Contact::DisplayName(hContact));
                        }
                        break;

                        default:
                        {
                            cchMsg = mir_sntprintf(szMsg, SIZEOF(szMsg),
                                                   TranslateT("%s has birthday in %d days."),
                                                   DB::Contact::DisplayName(hContact), Diff);
                        }
                        }
                        mir_sntprintf(szMsg + cchMsg, SIZEOF(szMsg) - cchMsg,
                                      TranslateT("\n%s becomes %d years old."),
                                      ContactGender(hContact), mtb.Age(&Now) + (Diff > 0));

                        NotifyWithPopup(hContact, CEvent::BIRTHDAY, Diff, mtb.Description(), szMsg);
                    }
                    result = TRUE;
                }
            }
        }
    }
    return result;
}
Beispiel #6
0
/**
 * name:	Export
 * desc:	export the contacts information
 * param:	none
 * return	TRUE or FALSE
 **/
BYTE CVCardFileVCF::Export(BYTE bExportUtf)
{
	size_t cbRew = 0;

	_useUtf8 = bExportUtf;

	fputs("BEGIN:VCARD\nVERSION:2.1\n", _pFile);

	//
	// naming
	//
	packDB(USERINFO, SET_CONTACT_LASTNAME, &cbRew);
	_clVal + DELIM;
	packDB(USERINFO, SET_CONTACT_FIRSTNAME, &cbRew);
	_clVal + DELIM;
	packDB(USERINFO, SET_CONTACT_SECONDNAME, &cbRew);
	_clVal + DELIM;
	packDB(USERINFO, SET_CONTACT_TITLE, &cbRew);
	_clVal + DELIM;
	packDBList(USERINFO, SET_CONTACT_PREFIX, (MIRANDASERVICE)GetNamePrefixList, FALSE, &cbRew);
	writeLine("N", &cbRew);

	if (packDB(USERINFO, SET_CONTACT_TITLE))
		_clVal + " ";

	if (packDB(USERINFO, SET_CONTACT_FIRSTNAME))
		_clVal + " ";
	else
		cbRew = 1;

	if (packDB(USERINFO, SET_CONTACT_SECONDNAME))
		_clVal + " ";
	else
		cbRew = 1;

	if (packDB(USERINFO, SET_CONTACT_LASTNAME))
		_clVal + " ";
	else
		cbRew = 1;

	packDBList(USERINFO, SET_CONTACT_PREFIX, (MIRANDASERVICE)GetNamePrefixList, FALSE, &cbRew);
	writeLine("FN");

	packDB(USERINFO, SET_CONTACT_NICK);
	writeLine("NICKNAME");

	//
	// organisation
	//
	packDB(USERINFO, SET_CONTACT_COMPANY, &cbRew);
	_clVal + DELIM;
	packDB(USERINFO, SET_CONTACT_COMPANY_DEPARTMENT, &cbRew);
	writeLine("ORG", &cbRew);
	packDB(USERINFO, SET_CONTACT_COMPANY_POSITION);
	writeLine("TITLE");
	packDBList(USERINFO, SET_CONTACT_COMPANY_OCCUPATION, (MIRANDASERVICE)GetOccupationList, FALSE);
	writeLine("ROLE");

	//
	// phone numbers
	//
	if (packDB(USERINFO, SET_CONTACT_PHONE)) {
		_clVal.TruncateSMS();
		writeLine("TEL;HOME;VOICE");
	}
	if (packDB(USERINFO, SET_CONTACT_FAX)) {
		_clVal.TruncateSMS();
		writeLine("TEL;HOME;FAX");
	}
	if (packDB(USERINFO, SET_CONTACT_CELLULAR)) {
		_clVal.TruncateSMS();
		writeLine("TEL;CELL;VOICE");
	}
	if (packDB(USERINFO, SET_CONTACT_COMPANY_PHONE)) {
		_clVal.TruncateSMS();
		writeLine("TEL;WORK;VOICE");
	}
	if (packDB(USERINFO, SET_CONTACT_COMPANY_FAX)) {
		_clVal.TruncateSMS();
		writeLine("TEL;WORK;FAX");
	}
	if (packDB(USERINFO, SET_CONTACT_COMPANY_CELLULAR)) {
		_clVal.TruncateSMS();
		writeLine("TEL;PAGER;VOICE");
	}

	//
	// private address
	//
	_clVal + ";;"; 
	cbRew = 1;
	packDB(USERINFO, SET_CONTACT_STREET, &cbRew);
	_clVal + DELIM;
	packDB(USERINFO, SET_CONTACT_CITY, &cbRew);
	_clVal + DELIM;
	packDB(USERINFO, SET_CONTACT_STATE, &cbRew);
	_clVal + DELIM;
	packDB(USERINFO, SET_CONTACT_ZIP, &cbRew);
	_clVal + DELIM;
	packDBList(USERINFO, SET_CONTACT_COUNTRY, (MIRANDASERVICE)GetCountryList, FALSE, &cbRew);
	writeLine("ADR;HOME", &cbRew);

	//
	// company address
	//
	_clVal + DELIM;
	packDB(USERINFO, SET_CONTACT_COMPANY_OFFICE, &cbRew);
	_clVal + DELIM;
	packDB(USERINFO, SET_CONTACT_COMPANY_STREET, &cbRew);
	_clVal + DELIM;
	packDB(USERINFO, SET_CONTACT_COMPANY_CITY, &cbRew);
	_clVal + DELIM;
	packDB(USERINFO, SET_CONTACT_COMPANY_STATE, &cbRew);
	_clVal + DELIM;
	packDB(USERINFO, SET_CONTACT_COMPANY_ZIP, &cbRew);
	_clVal + DELIM;
	packDBList(USERINFO, SET_CONTACT_COMPANY_COUNTRY, (MIRANDASERVICE)GetCountryList, FALSE, &cbRew);
	writeLine("ADR;WORK", &cbRew);

	//
	// origin address
	//
	_clVal + ";;";
	cbRew = 1;
	packDB(USERINFO, SET_CONTACT_ORIGIN_STREET, &cbRew);
	_clVal + DELIM;
	packDB(USERINFO, SET_CONTACT_ORIGIN_CITY, &cbRew);
	_clVal + DELIM;
	packDB(USERINFO, SET_CONTACT_ORIGIN_STATE, &cbRew);
	_clVal + DELIM;
	packDB(USERINFO, SET_CONTACT_ORIGIN_ZIP, &cbRew);
	_clVal + DELIM;
	packDBList(USERINFO, SET_CONTACT_ORIGIN_COUNTRY, (MIRANDASERVICE)GetCountryList, FALSE, &cbRew);
	writeLine("ADR;POSTAL", &cbRew);

	//
	// homepages
	//
	if (packDB(USERINFO, SET_CONTACT_HOMEPAGE))
		writeLine("URL;HOME");
	if (packDB(USERINFO, SET_CONTACT_COMPANY_HOMEPAGE))
		writeLine("URL;WORK");

	//
	// e-mails
	//
	if (packDB(USERINFO, SET_CONTACT_EMAIL))
		writeLine("EMAIL;PREF;intERNET");
	if (packDB(USERINFO, SET_CONTACT_EMAIL0))
		writeLine("EMAIL;intERNET");
	if (packDB(USERINFO, SET_CONTACT_EMAIL1))
		writeLine("EMAIL;intERNET");

	//
	// gender
	//
	{
		BYTE gender = db_get_b(_hContact, USERINFO, SET_CONTACT_GENDER, 0);
		if (!gender) gender = db_get_b(_hContact, _pszBaseProto, SET_CONTACT_GENDER, 0);
		switch (gender) {
			case 'F':
				fputs("X-WAB-GENDER:1\n", _pFile);
				break;
			case 'M':
				fputs("X-WAB-GENDER:2\n", _pFile);
				break;
		}
	}

	//
	// birthday
	//
	{
		MAnnivDate mdb;

		if (!mdb.DBGetBirthDate(_hContact, NULL))
			fprintf(_pFile, "BDAY:%d%02d%02d\n", mdb.Year(), mdb.Month(), mdb.Day());
	}
	
	//
	// notes
	//
	if (packDB(USERINFO, SET_CONTACT_MYNOTES))
		writeLineEncoded("NOTE");

	//
	// about
	//
	if (packDB(USERINFO, SET_CONTACT_ABOUT))
		writeLineEncoded("ABOUT");

	//
	// contacts protocol, uin setting, uin value
	//
	{
		CHAR szUID[MAXUID];
		LPCSTR uid;

		uid = (LPCSTR)CallProtoService(_pszBaseProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
		if ((INT_PTR)uid != CALLSERVICE_NOTFOUND && uid) {
			if (!db_get_static(_hContact, _pszBaseProto, uid, szUID, sizeof(szUID)))
				fprintf(_pFile, "IM;%s;%s:%s\n", _pszBaseProto, uid, szUID);
		}
	}
	
	//
	// time of creation
	//
	{
		SYSTEMTIME	st;
	
		GetLocalTime(&st);
		fprintf(_pFile, "REV:%04d%02d%02dD%02d%02d%02dT\n", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
	}

	fputs("END:VCARD", _pFile);
	return 0;
}
/**
 * This is the service procedure to retrieve contact information
 *
 * @param	wParam		- not used
 * @param	lParam		- pointer to a CONTACTINFO structure which tells what information is desired
 *
 * @retval	0 - if contact information was found and read correctly 
 * @retval	1 - if any error occured or setting was not found
 **/
INT_PTR GetContactInfo(WPARAM wParam, LPARAM lParam) 
{
	CONTACTINFO *ci = (CONTACTINFO*) lParam;
	INT_PTR result;

	if (ci && ci->cbSize == sizeof(CONTACTINFO) && (ci->szProto != NULL || (ci->szProto = DB::Contact::Proto(ci->hContact)) != NULL))
	{
		switch (ci->dwFlag & 0x7F) {

		//
		// contact name
		//
		case CNF_FIRSTNAME:		{
				result = GCIVarEx(ci, SET_CONTACT_FIRSTNAME);
			} break;

		case CNF_LASTNAME:		{
				result = GCIVarEx(ci, SET_CONTACT_LASTNAME);
			} break;

		case CNF_FIRSTLAST:		{
				result = GCIVarEx(ci, SET_CONTACT_FIRSTLASTNAME);	//first try to read "FullName"
				if(result) result = GCIFirstLast(ci);				//fallback to "FirstName" + "LastName"
			} break;

		case CNF_NICK:			{
				result = GCIVarEx(ci, SET_CONTACT_NICK);
			} break;

		case CNF_CUSTOMNICK:	{
				LPSTR s = ci->szProto;
				ci->szProto = MOD_CLIST;
				result = GCIVar(ci, SET_CONTACT_MYHANDLE);
				ci->szProto = s;
			} break;

		case CNF_LANGUAGE1:			{
				result = GCILangEx(ci, SET_CONTACT_LANG1);
			} break;

		case CNF_LANGUAGE2:			{
				result = GCILangEx(ci, SET_CONTACT_LANG2);
			} break;

		case CNF_LANGUAGE3:			{
				result = GCILangEx(ci, SET_CONTACT_LANG3);
			} break;

		//
		// private contact
		//
		case CNF_STREET:		{
				result = GCIVarEx(ci, SET_CONTACT_STREET);
			} break;

		case CNF_ZIP:			{
				result = GCIVarEx(ci, SET_CONTACT_ZIP); 
			} break;

		case CNF_CITY:			{
				result = GCIVarEx(ci, SET_CONTACT_CITY);
			} break;

		case CNF_STATE:			{
				result = GCIVarEx(ci, SET_CONTACT_STATE);
			} break;

		case CNF_COUNTRY:		{
				result = GCICountry(ci, SET_CONTACT_COUNTRY);
			} break;

		case CNF_PHONE:			{
				result = GCIVarEx(ci, SET_CONTACT_PHONE);
			} break;

		case CNF_FAX:			{
				result = GCIVarEx(ci, SET_CONTACT_FAX);
			} break;

		case CNF_CELLULAR:		{
				result = GCIVarEx(ci, SET_CONTACT_CELLULAR);
			} break;

		case CNF_EMAIL:			{
				result = GCIVarEx(ci, SET_CONTACT_EMAIL);
			} break;

		case CNF_HOMEPAGE:		{
				result = GCIVarEx(ci, SET_CONTACT_HOMEPAGE);
			} break;

		//
		// company information
		//
		case CNF_CONAME:		{
				result = GCIVarEx(ci, SET_CONTACT_COMPANY);
			} break;

		case CNF_CODEPT:		{
				result = GCIVarEx(ci, SET_CONTACT_COMPANY_DEPARTMENT);
			} break;

		case CNF_COPOSITION:	{
				result = GCIVarEx(ci, SET_CONTACT_COMPANY_POSITION);
			} break;

		case CNF_COSTREET:		{
				result = GCIVarEx(ci, SET_CONTACT_COMPANY_STREET);
			} break;

		case CNF_COZIP:			{
				result = GCIVarEx(ci, SET_CONTACT_COMPANY_ZIP);
			} break;

		case CNF_COCITY:		{
				result = GCIVarEx(ci, SET_CONTACT_COMPANY_CITY);
			} break;

		case CNF_COSTATE:		{
				result = GCIVarEx(ci, SET_CONTACT_COMPANY_STATE);
			} break;

		case CNF_COCOUNTRY:		{
				result = GCICountry(ci, SET_CONTACT_COMPANY_COUNTRY);
			} break;

		case CNF_COPHONE:		{
				result = GCIVarEx(ci, SET_CONTACT_COMPANY_PHONE);
			} break;

		case CNF_COFAX:			{
				result = GCIVarEx(ci, SET_CONTACT_COMPANY_FAX);
			} break;

		case CNF_COCELLULAR:	{
				result = GCIVarEx(ci, SET_CONTACT_COMPANY_CELLULAR);
			} break;

		case CNF_COEMAIL:		{
				result = GCIVarEx(ci, SET_CONTACT_COMPANY_EMAIL);
			} break;

		case CNF_COHOMEPAGE:	{
				result = GCIVarEx(ci, SET_CONTACT_COMPANY_HOMEPAGE);
			} break;

		//
		// personal information
		//
		case CNF_ABOUT:			{
				result = GCIVarEx(ci, SET_CONTACT_ABOUT);
			} break;

		case CNF_MYNOTES:		{
				result = GCIVarEx(ci, SET_CONTACT_MYNOTES);
			} break;

		case CNF_AGE:			{
				result = GCIVarEx(ci, SET_CONTACT_AGE);
			} break;	  // returns age (byte, 0==unspecified) ??

		case CNF_GENDER:		{
				ci->bVal = GenderOf(ci->hContact, ci->szProto);
				ci->type = (ci->bVal != 0) ? CNFT_BYTE : 0;
				result = ci->type == 0;
			} break;

		case CNF_BIRTHDAY:		{
				MAnnivDate mda;
				result = mda.DBGetBirthDate(ci->hContact, ci->szProto);
				if (result == 0) {
					ci->bVal = (BYTE) mda.Day();
					ci->type = CNFT_BYTE;
				}
			} break;

		case CNF_BIRTHMONTH:	{
				MAnnivDate mda;
				result = mda.DBGetBirthDate(ci->hContact, ci->szProto);
				if (result == 0) {
					ci->bVal = (BYTE) mda.Month();
					ci->type = CNFT_BYTE;
				}
			} break;

		case CNF_BIRTHYEAR:		{
				MAnnivDate mda;
				result = mda.DBGetBirthDate(ci->hContact, ci->szProto);
				if (result == 0) {
					ci->wVal = (WORD) mda.Year();
					ci->type = CNFT_WORD;
				}
			} break;

		case CNF_BIRTHDATE:		{
				MAnnivDate mda;
				result = mda.DBGetBirthDate(ci->hContact, ci->szProto);
				if (result == 0) {
					SYSTEMTIME st = mda.SystemTime();
					ci->pszVal = NULL;
					if (ci->dwFlag & CNF_UNICODE) {
						WCHAR wszDate[80];
						if (GetDateFormatW(LOCALE_USER_DEFAULT, wParam == 1 ? DATE_LONGDATE : DATE_SHORTDATE, &st, NULL, wszDate, SIZEOF(wszDate))) {
							ci->pszVal = (LPTSTR)mir_wcsdup(wszDate);
						}
					}
					else {
						CHAR szDate[80];
						if (GetDateFormatA(LOCALE_USER_DEFAULT, wParam == 1 ? DATE_LONGDATE : DATE_SHORTDATE, &st, NULL, szDate, SIZEOF(szDate))) {
							ci->pszVal = (LPTSTR)mir_strdup(szDate);
						}
					}
					ci->type = (ci->pszVal != NULL) ? CNFT_ASCIIZ : 0;
					result = ci->type == 0;
				}
			} break;

		case CNF_TIMEZONE:		{
				//use new core tz interface
				if(tmi.prepareList) {
					HANDLE hTz = tmi.createByContact(ci->hContact, TZF_KNOWNONLY);
					if (hTz) {
						LPTIME_ZONE_INFORMATION tzi = tmi.getTzi(hTz);
						int offset = tzi->Bias + tzi->StandardBias;

						char str[80];
						mir_snprintf(str, SIZEOF(str), offset ? "UTC%+d:%02d" : "UTC", offset / -60, abs(offset % 60));
						ci->pszVal =	ci->dwFlag & CNF_UNICODE
										? (TCHAR*)mir_a2u(str) 
										: (TCHAR*)mir_strdup(str);
						ci->type = CNFT_ASCIIZ;
						return 0;
					}
					else {
						ci->pszVal = NULL;
					}
				}
				//fallback use old UIEX method
				else {
					CTimeZone* ptz = GetContactTimeZone(ci->hContact, ci->szProto);
					if (ptz) {
						if (ci->dwFlag & CNF_UNICODE) {
							ci->pszVal = (LPTSTR) mir_t2u(ptz->ptszDisplay);
						}
						else {
							ci->pszVal = (LPTSTR) mir_t2a(ptz->ptszDisplay);
						}
					}
					else {
						/* If a timezone does not exist in CTzMgr, it is a invalid timezone,
						because Windows and CTzMgr know all existing timezones and it
						would not be shown anywhere anyway as UserInfoEx displays only 
						known windows timezones in the details dialog!
						*/
						ci->pszVal = NULL;
					}
				}
				ci->type = (ci->pszVal != NULL) ? CNFT_ASCIIZ : 0;
				result = ci->type == 0;
			} break;

		//
		// information about IM specific stuff
		//
		case CNF_UNIQUEID:		{
				// protocol must define a PFLAG_UNIQUEIDSETTING
				result = CallProtoService(ci->szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
				if (result != CALLSERVICE_NOTFOUND && result != NULL) {
					result = GCIVar(ci, (LPCSTR) result);
				}
			} break;

		case CNF_DISPLAYUID:	{
				if (!GCIVar(ci, "display_uid"))
					result=0;
				else {
					result = CallProtoService(ci->szProto,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0);
					if (result != CALLSERVICE_NOTFOUND && result != NULL) {
						result = GCIVar(ci, (LPCSTR) result);
					}
				}
			} break;

		case CNF_DISPLAYNC:
		case CNF_DISPLAY:		{
				INT i;
				for (i = 0; i < NAMEORDERCOUNT; i++) {
					switch (gNameOrder[i]) {
					case 0: // custom name
						{
							// make sure we aren't in CNF_DISPLAYNC mode
							// don't get custom name for NULL contact
							if (ci->hContact != NULL && (ci->dwFlag & 0x7F) == CNF_DISPLAY) {
								BYTE dwFlag = ci->dwFlag;
								ci->dwFlag = (ci->dwFlag & CNF_UNICODE) | CNF_CUSTOMNICK;
								if (!GetContactInfo(NULL, (LPARAM)ci)) {
									ci->dwFlag = dwFlag;
									return 0;
								}
								ci->dwFlag = dwFlag;
							}
						} break;
					case 1: // nick
						{
							if (!GCIVarEx(ci, SET_CONTACT_NICK))
								return 0;
						} break;
					case 2: // First Name
						{
							if (!GCIVarEx(ci, SET_CONTACT_FIRSTNAME))
								return 0;
						} break;
					case 3: // E-mail
						{
							if (!GCIVarEx(ci, SET_CONTACT_EMAIL))
								return 0;
						} break;
					case 4: // Last Name
						{
							if (!GCIVarEx(ci, SET_CONTACT_LASTNAME))
								return 0;
						} break;
					case 5: // Unique id
						{
							// protocol must define a PFLAG_UNIQUEIDSETTING
							result = CallProtoService(ci->szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
							if (result != CALLSERVICE_NOTFOUND && result != NULL) {
								if (!GCIStr(ci, (LPCSTR) result))
									return 0;
							}
						} break;
					case 6: // first + last name
						{
							if (!GCIFirstLast(ci))
								return 0;
						} break;
					default: // unknown contact
						{
							if (ci->dwFlag & CNF_UNICODE) {
								ci->pszVal = (LPTSTR) mir_wcsdup(TranslateW(L"'(Unknown Contact)'"));
							}
							else {
								ci->pszVal = (LPTSTR) mir_strdup(Translate("'(Unknown Contact)'"));
							}
							ci->type = (ci->pszVal != NULL) ? CNFT_ASCIIZ : 0;
							return ci->type == 0;
						}
					}
				}
			}

		default:				{
				result = 1;
			}
		}
	}
	else
	{
		result = 1;
	}
	return result;
}