Beispiel #1
0
static INT_PTR TimestampToString(WPARAM wParam,LPARAM lParam)
{
    DBTIMETOSTRING *tts=(DBTIMETOSTRING*)lParam;
    LARGE_INTEGER liFiletime;
    FILETIME filetime;
    SYSTEMTIME st;
    char dateTimeStr[64];
    char *pDest,*pFormat;
    size_t destCharsLeft, dateTimeStrLen;

    //this huge number is the difference between 1970 and 1601 in seconds
    liFiletime.QuadPart=((__int64)11644473600+(__int64)(DWORD)TimestampToLocal(wParam,0))*10000000;
    filetime.dwHighDateTime=liFiletime.HighPart;
    filetime.dwLowDateTime=liFiletime.LowPart;
    FileTimeToSystemTime(&filetime,&st);
    destCharsLeft=tts->cbDest;
    for(pFormat=tts->szFormat,pDest=tts->szDest; *pFormat; pFormat++) {
        switch(*pFormat) {
        case 't':
            GetTimeFormatA(LOCALE_USER_DEFAULT,TIME_NOSECONDS,&st,NULL,dateTimeStr,SIZEOF(dateTimeStr));
            break;
        case 's':
            GetTimeFormatA(LOCALE_USER_DEFAULT,0,&st,NULL,dateTimeStr,SIZEOF(dateTimeStr));
            break;
        case 'm':
            GetTimeFormatA(LOCALE_USER_DEFAULT,TIME_NOMINUTESORSECONDS,&st,NULL,dateTimeStr,SIZEOF(dateTimeStr));
            break;
        case 'd':
            GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&st,NULL,dateTimeStr,SIZEOF(dateTimeStr));
            break;
        case 'D':
            GetDateFormatA(LOCALE_USER_DEFAULT,DATE_LONGDATE,&st,NULL,dateTimeStr,SIZEOF(dateTimeStr));
            break;
        default:
            if(destCharsLeft) {
                *pDest++=*pFormat;
                destCharsLeft--;
            }
            continue;
        }
        dateTimeStrLen=strlen(dateTimeStr);
        if(destCharsLeft<dateTimeStrLen) dateTimeStrLen=destCharsLeft;
        CopyMemory(pDest,dateTimeStr,dateTimeStrLen);
        destCharsLeft-=dateTimeStrLen;
        pDest+=dateTimeStrLen;
    }
    if(destCharsLeft) *pDest=0;
    else tts->szDest[tts->cbDest-1]=0;
    return 0;
}
Beispiel #2
0
bool CDateTime::getWeekDay (char *cBuffer)
{
	if (GetDateFormatA (0, 0, &systemTime, "dddd", cBuffer, DT_STRING_LEN) > 0)
		return true;
	else
		return false;
}
Beispiel #3
0
/*------------------------------------------------
  GetDateFormat() for 95/NT
--------------------------------------------------*/
int MyGetDateFormatW(int ilang, int codepage,
	DWORD dwFlags, CONST SYSTEMTIME *t,
	wchar_t* fmt, wchar_t* dst, int n)
{
	int r;
	LCID Locale;
	
	*dst = 0;
	Locale = MAKELCID((WORD)ilang, SORT_DEFAULT);
	if(GetVersion() & 0x80000000) // 95
	{
		char buf[80], afmt[40];
		if(fmt)
			WideCharToMultiByte(codepage, 0, fmt, -1,
				afmt, 39, NULL, NULL);
		r = GetDateFormatA(Locale, dwFlags, t, fmt ? afmt : NULL, buf, 79);
		if(r)
			r = MultiByteToWideChar(codepage, 0, buf, -1, dst, n);
	}
	else  // NT
	{
		r = GetDateFormatW(Locale, dwFlags, t, fmt, dst, n);
	}
	return r;
}
Beispiel #4
0
/**********************************************************************
 *		_strdate (MSVCRT.@)
 */
char* CDECL _strdate(char* date)
{
  static const char format[] = "MM'/'dd'/'yy";

  GetDateFormatA(LOCALE_NEUTRAL, 0, NULL, format, date, 9);

  return date;
}
Beispiel #5
0
static LPCSTR filetime_to_str(const FILETIME *time)
{
    static char date[80];
    char dateFmt[80]; /* sufficient for all versions of LOCALE_SSHORTDATE */
    SYSTEMTIME sysTime;

    if (!time) return NULL;

    GetLocaleInfoA(LOCALE_SYSTEM_DEFAULT, LOCALE_SSHORTDATE, dateFmt,
     sizeof(dateFmt) / sizeof(dateFmt[0]));
    FileTimeToSystemTime(time, &sysTime);
    GetDateFormatA(LOCALE_SYSTEM_DEFAULT, 0, &sysTime, dateFmt, date,
     sizeof(date) / sizeof(date[0]));
    return date;
}
Beispiel #6
0
// Превратить время/дату файла в строку в соответствии с настройками locale или заданными форматами времени и даты
void GuiFormatDateTime (time_t t, char *buf, int bufsize, char *date_format, char *time_format)
{
  if (t<0)  t=INT_MAX;  // Иначе получаем вылет :(

  FILETIME ft1, ft2;
  UnixTimeToFileTime (t, &ft1);
  FileTimeToLocalFileTime (&ft1, &ft2);
  SYSTEMTIME datetime;
  FileTimeToSystemTime (&ft2, &datetime);

  GetDateFormatA(LOCALE_USER_DEFAULT, 0, &datetime, date_format, buf, bufsize);
  char *p = str_end(buf);
  *p++ = ' ';
  GetTimeFormatA(LOCALE_USER_DEFAULT, 0, &datetime, time_format, p, bufsize - (p-buf));
}
Beispiel #7
0
static UINT WINAPI ExtCabCallback(PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2)
{
    FILE_IN_CABINET_INFO_W *pInfo;
    FILEPATHS_W *pFilePaths;

    switch(Notification)
    {
        case SPFILENOTIFY_FILEINCABINET:
            pInfo = (FILE_IN_CABINET_INFO_W*)Param1;
            if(show_content)
            {
                FILETIME ft;
                SYSTEMTIME st;
                CHAR date[12], time[12], buf[2 * MAX_PATH];
                int count;
                DWORD dummy;

                /* DosDate and DosTime already represented at local time */
                DosDateTimeToFileTime(pInfo->DosDate, pInfo->DosTime, &ft);
                FileTimeToSystemTime(&ft, &st);
                GetDateFormatA(0, 0, &st, "MM'-'dd'-'yyyy", date, sizeof date);
                GetTimeFormatA(0, 0, &st, "HH':'mm':'ss", time, sizeof time);
                count = wsprintfA(buf, "%s %s %c%c%c%c %15u %S\n", date, time,
                        pInfo->DosAttribs & FILE_ATTRIBUTE_ARCHIVE  ? 'A' : '-',
                        pInfo->DosAttribs & FILE_ATTRIBUTE_HIDDEN   ? 'H' : '-',
                        pInfo->DosAttribs & FILE_ATTRIBUTE_READONLY ? 'R' : '-',
                        pInfo->DosAttribs & FILE_ATTRIBUTE_SYSTEM   ? 'S' : '-',
                        pInfo->FileSize, pInfo->NameInCabinet);
                WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), buf, count, &dummy, NULL);
                return FILEOP_SKIP;
            }
            else
            {
                lstrcpyW(pInfo->FullTargetName, (LPCWSTR)Context);
                lstrcatW(pInfo->FullTargetName, pInfo->NameInCabinet);
                /* SetupIterateCabinet() doesn't create full path to target by itself,
                   so we should do it manually */
                create_target_directory(pInfo->FullTargetName);
                return FILEOP_DOIT;
            }
        case SPFILENOTIFY_FILEEXTRACTED:
            pFilePaths = (FILEPATHS_W*)Param1;
            WINE_TRACE("Extracted %s\n", wine_dbgstr_w(pFilePaths->Target));
            return NO_ERROR;
    }
    return NO_ERROR;
}
void kull_m_string_displayFileTime(IN PFILETIME pFileTime)
{
	SYSTEMTIME st;
	char buffer[0xff];
	if(pFileTime)
	{
		if(FileTimeToSystemTime(pFileTime, &st ))
		{
			if(GetDateFormatA(LOCALE_USER_DEFAULT, 0, &st, NULL, buffer, sizeof(buffer)))
			{
				dprintf("%s ", buffer);
				if(GetTimeFormatA(LOCALE_USER_DEFAULT, 0, &st, NULL, buffer, sizeof(buffer)))
					dprintf("%s", buffer);
			}
		}
	}
}
Beispiel #9
0
/**
 * Generates a timestamp of the current time.
 * @return String in D-M-Y_H-M-S format.
 */
std::string now()
{
	const int MAX_LEN = 25, MAX_RESULT = 80;
	char result[MAX_RESULT] = { 0 };
#ifdef _WIN32
	char date[MAX_LEN], time[MAX_LEN];
	if (GetDateFormatA(LOCALE_INVARIANT, 0, 0, "dd'-'MM'-'yyyy", date, MAX_LEN) == 0)
		return "00-00-0000";
	if (GetTimeFormatA(LOCALE_INVARIANT, TIME_FORCE24HOURFORMAT, 0, "HH'-'mm'-'ss", time, MAX_LEN) == 0)
		return "00-00-00";
	sprintf(result, "%s_%s", date, time);
#else
	char buffer[MAX_LEN];
	time_t rawtime;
	struct tm *timeinfo;
	time(&rawtime);
	timeinfo = localtime(&rawtime);
	strftime(buffer, MAX_LEN, "%d-%m-%Y_%H-%M-%S", timeinfo);
	sprintf(result, "%s", buffer);
#endif
	return result;
}
Beispiel #10
0
static void test_wm_set_get_text(void)
{
    static const CHAR a_str[] = "a";
    CHAR buff[16], time[16], caltype[3];
    HWND hWnd;
    LRESULT ret;

    hWnd = create_datetime_control(0);

    ret = SendMessageA(hWnd, WM_SETTEXT, 0, (LPARAM)a_str);
    ok(CB_ERR == ret ||
       broken(0 == ret) || /* comctl32 <= 4.72 */
       broken(1 == ret), /* comctl32 <= 4.70 */
       "Expected CB_ERR, got %ld\n", ret);

    buff[0] = 0;
    ret = SendMessageA(hWnd, WM_GETTEXT, sizeof(buff), (LPARAM)buff);
    ok(strcmp(buff, a_str) != 0, "Expected text to change, got %s\n", buff);
    ok(ret != 0, "Expected non-zero return value\n");

    SetLastError(0xdeadbeef);
    ret = GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_ICALENDARTYPE, caltype, 3);
    if (ret == 0)
        skip("Must know local calendar type (%x)\n", GetLastError());
    else if (atoi(caltype) != CAL_GREGORIAN)
        skip("DateTimePicker Control only supports Gregorian calendar (type: %s)\n", caltype);
    else {
        SetLastError(0xdeadbeef);
        ret = GetDateFormatA(LOCALE_USER_DEFAULT, 0, NULL, NULL, time, sizeof(time));
        if (ret == 0)
            skip("GetDateFormat failed, returned %ld, error %d\n", ret, GetLastError());
        else
            ok(!strcmp(buff, time), "Expected %s, got %s\n", time, buff);
    }

    DestroyWindow(hWnd);
}
static void JabberSendPresenceTo(TlenProtocol *proto, int status, char *to)
{
	char *showBody, *statusMsg, *presenceType;
	char *ptr = NULL;

	if (!proto->isOnline) return;

	// Send <presence/> update for status (we won't handle ID_STATUS_OFFLINE here)
	// Note: jabberModeMsg is already encoded using JabberTextEncode()
	EnterCriticalSection(&proto->modeMsgMutex);

	showBody = NULL;
	statusMsg = NULL;
	presenceType = NULL;
	switch (status) {
	case ID_STATUS_ONLINE:
		showBody = "available";
		statusMsg = proto->modeMsgs.szOnline;
		break;
	case ID_STATUS_AWAY:
	case ID_STATUS_ONTHEPHONE:
	case ID_STATUS_OUTTOLUNCH:
		showBody = "away";
		statusMsg = proto->modeMsgs.szAway;
		break;
	case ID_STATUS_NA:
		showBody = "xa";
		statusMsg = proto->modeMsgs.szNa;
		break;
	case ID_STATUS_DND:
	case ID_STATUS_OCCUPIED:
		showBody = "dnd";
		statusMsg = proto->modeMsgs.szDnd;
		break;
	case ID_STATUS_FREECHAT:
		showBody = "chat";
		statusMsg = proto->modeMsgs.szFreechat;
		break;
	case ID_STATUS_INVISIBLE:
		presenceType = "invisible";
		statusMsg = proto->modeMsgs.szInvisible;
		break;
	case ID_STATUS_OFFLINE:
		presenceType = "unavailable";
		if (DBGetContactSettingByte(NULL, proto->iface.m_szModuleName, "LeaveOfflineMessage", FALSE)) {
			int offlineMessageOption = DBGetContactSettingWord(NULL, proto->iface.m_szModuleName, "OfflineMessageOption", 0);
			if (offlineMessageOption == 0) {
				switch (proto->iface.m_iStatus) {
					case ID_STATUS_ONLINE:
						ptr = mir_strdup(proto->modeMsgs.szOnline);
						break;
					case ID_STATUS_AWAY:
					case ID_STATUS_ONTHEPHONE:
					case ID_STATUS_OUTTOLUNCH:
						ptr = mir_strdup(proto->modeMsgs.szAway);
						break;
					case ID_STATUS_NA:
						ptr = mir_strdup(proto->modeMsgs.szNa);
						break;
					case ID_STATUS_DND:
					case ID_STATUS_OCCUPIED:
						ptr = mir_strdup(proto->modeMsgs.szDnd);
						break;
					case ID_STATUS_FREECHAT:
						ptr = mir_strdup(proto->modeMsgs.szFreechat);
						break;
					case ID_STATUS_INVISIBLE:
						ptr = mir_strdup(proto->modeMsgs.szInvisible);
						break;
				}
			} else if (offlineMessageOption == 99) {

			} else if (offlineMessageOption < 7) {
				DBVARIANT dbv;
				const char *statusNames[] = {"OnDefault", "AwayDefault", "NaDefault", "DndDefault", "FreeChatDefault", "InvDefault"};
				if (!DBGetContactSetting(NULL, "SRAway", statusNames[offlineMessageOption-1], &dbv)) {
					int i;
					char substituteStr[128];
					ptr = mir_strdup(dbv.pszVal);
					DBFreeVariant(&dbv);
					for(i=0;ptr[i];i++) {
						if(ptr[i]!='%') continue;
						if(!_strnicmp(ptr+i,"%time%",6))
							GetTimeFormatA(LOCALE_USER_DEFAULT,TIME_NOSECONDS,NULL,NULL,substituteStr,sizeof(substituteStr));
						else if(!_strnicmp(ptr+i,"%date%",6))
							GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,NULL,NULL,substituteStr,sizeof(substituteStr));
						else continue;
						if(strlen(substituteStr)>6) ptr=(char*)mir_realloc(ptr,strlen(ptr)+1+strlen(substituteStr)-6);
						MoveMemory(ptr+i+strlen(substituteStr),ptr+i+6,strlen(ptr)-i-5);
						CopyMemory(ptr+i,substituteStr,strlen(substituteStr));
					}
				}
			}
		}
		statusMsg = ptr;
		break;
	default:
		// Should not reach here
		break;
	}
	proto->iface.m_iStatus = status;
	if (presenceType) {
		if (statusMsg)
			JabberSend(proto, "<presence type='%s'><status>%s</status></presence>", presenceType, statusMsg);
		else
			JabberSend(proto, "<presence type='%s'></presence>", presenceType);
	} else {
		if (statusMsg)
			JabberSend(proto, "<presence><show>%s</show><status>%s</status></presence>", showBody, statusMsg);
		else
			JabberSend(proto, "<presence><show>%s</show></presence>", showBody);
	}
	if (ptr) {
		mir_free(ptr);
	}
	LeaveCriticalSection(&proto->modeMsgMutex);
}
Beispiel #12
0
///////////////////////////////////////////////////////////////////////////////
// Skype ACL KeyGen
// Input: 
//		lpUserName	: skype accountname
//		lpFileName	: full path of plugin
// Output: All fields are encrypted!
//		lpOutKey1	: Key1
//		lpOutKey2	: Key2
//		lpOutKey3	: Key3
//		lpOutKey4	: Key4
//		lpOutPath	: Path
//
BOOL SkypeACLKeyGen(char *lpUserName, char *lpFileName, char *lpOutKey1, char *lpOutKey2, char *lpOutKey3, char *lpOutKey4, char *lpOutKey5, char *lpOutKey6, char *lpOutPath, BOOL isOld)
{
	char szPluginDigest_SHA256[(32*2) * 2];
	char szPluginDigest_MD5[17 * 2];
	char *szPassphrase1 = "Element'ry!penguiNs;-)SingingHarekrishna_";
	char *szPassphrase2 = "Element'ry!penguiNs;-)SingingHareKrishna_";

	const int username_len = strlen(lpUserName);

	SHA256_Plugin(lpFileName, szPluginDigest_SHA256, isOld);
	MD5_Plugin(lpFileName, szPluginDigest_MD5);
	
	char *szUSERNAME = (char *) malloc(strlen(lpUserName)+1);
	char *szFILENAME = (char *) malloc(strlen(lpFileName)+1);

	RtlZeroMemory(szUSERNAME, strlen(lpUserName)+1);
	RtlZeroMemory(szFILENAME, strlen(lpFileName)+1);

	StrToUpperCase(szFILENAME, lpFileName);
	StrToUpperCase(szUSERNAME, lpUserName);

	char *result = NULL;
	char temp[512];

	char tmp[1024];

	// /Client/Key1
	char _md5_filename[MD5_DIGEST_SIZE * 2 + 1];

	char _md5_key1_0[MD5_DIGEST_SIZE * 2 + 1];
	char _md5_key1_1[MD5_DIGEST_SIZE * 2 + 1];
	char _md5_key1[MD5_DIGEST_SIZE * 4 + 1];

	char passSBOX[4][MD5_DIGEST_SIZE*2+1];

	RtlZeroMemory(_md5_filename, MD5_DIGEST_SIZE * 2 + 1);

	MD5_Array(_md5_filename, szFILENAME, strlen(szFILENAME));

	if(isOld) {
		sprintf(tmp, "%s%s", _md5_filename, szPassphrase1);
		MD5_Array(_md5_key1_0, tmp, strlen(tmp));
		sprintf(tmp, "%s%s", szPluginDigest_MD5, szPassphrase1);
		MD5_Array(_md5_key1_1, tmp, strlen(tmp));
	} else {
		sprintf(tmp, "%s%s", _md5_filename, szPassphrase2);
		MD5_Array(_md5_key1_0, tmp, strlen(tmp));
		sprintf(tmp, "%s%s", szPluginDigest_MD5, szPassphrase2);
		MD5_Array(_md5_key1_1, tmp, strlen(tmp));
	}
	sprintf(_md5_key1, "%s%s", _md5_key1_0, _md5_key1_1);

	// Encrypt sha256 /Client/Key1
	result = Encrypt(lpUserName, _md5_key1);
	RtlCopyMemory(lpOutKey1, result, strlen(result));
	free(result);

	//// Encrypt sha256 /Client/Key2
	//sprintf(tmp, "%s%s%s%s", szUSERNAME, "ke:", szFILENAME, "1a");
	//RtlZeroMemory(temp, sizeof(temp));
	//MD5_Array(temp, tmp, strlen(tmp));
	//result = Encrypt(lpUserName, temp);
	//RtlCopyMemory(lpOutKey2, result, strlen(result));
	//free(result);

	// generate all keys to find correct!
	sprintf(tmp, "%s%s%s%s", szUSERNAME, "ke:", szFILENAME, "1a");
	RtlZeroMemory(temp, sizeof(temp));
	MD5_Array(passSBOX[0], tmp, strlen(tmp));
	
	sprintf(tmp, "%s%s%s%s", "1u", szFILENAME, "ba", szUSERNAME);
	RtlZeroMemory(temp, sizeof(temp));
	MD5_Array(passSBOX[1], tmp, strlen(tmp));

	sprintf(tmp, "%s%s%s%s", "ky", szUSERNAME, "s1", szFILENAME);
	RtlZeroMemory(temp, sizeof(temp));
	MD5_Array(passSBOX[2], tmp, strlen(tmp));

	sprintf(tmp, "%s%s%s%s", "p0", szUSERNAME, "1e", szFILENAME);
	RtlZeroMemory(temp, sizeof(temp));
	MD5_Array(passSBOX[3], tmp, strlen(tmp));

	// Encrypt sha256 /Client/Key2
	result = Encrypt(lpUserName, passSBOX[1]);
	RtlCopyMemory(lpOutKey2, result, strlen(result));
	free(result);

	// Encrypt sha256 /Client/Key3
	result = Encrypt(lpUserName, passSBOX[3]);
	RtlCopyMemory(lpOutKey3, result, strlen(result));
	free(result);

	// Encrypt sha256 /Client/Key4
	RtlZeroMemory(temp, sizeof(temp));
	StrToUpperCase(temp, szPluginDigest_SHA256);
	result = Encrypt(lpUserName, temp);
	RtlCopyMemory(lpOutKey4, result, strlen(result)+1);
	free(result);

	// Encrypt path	//Client/Path
	result = Encrypt(lpUserName, lpFileName);
	RtlCopyMemory(lpOutPath, result, strlen(result));
	free(result);

	// encrypt date
	char today[32];
	SYSTEMTIME sys_time;
	GetSystemTime(&sys_time);
	GetDateFormatA(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &sys_time, NULL, today, sizeof(today));

	char count[4];
	count[0] = '3';
	count[1] = 0x00;
	count[2] = 0x00;
	count[3] = 0x00;

	result = Encrypt(lpUserName, today);
	RtlCopyMemory(lpOutKey5, result, strlen(result));
	free(result);

	result = Encrypt(lpUserName, count);
	RtlCopyMemory(lpOutKey6, result, strlen(result));
	free(result);

	free(szUSERNAME);
	free(szFILENAME);

	return TRUE;
}
/**
 * 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;
}