Esempio n. 1
0
char* ChangeInfoData::GetItemSettingText(int i, char *buf, size_t bufsize)
{
	char *text = buf;
	int alloced = 0;

	buf[0] = '\0';

	const SettingItem &si = setting[i];
	SettingItemData &sid = settingData[i];
	if (sid.value == 0 && !(si.displayType & LIF_ZEROISVALID)) {
		if (si.displayType & LIF_CHANGEONLY)
			text = ICQTranslateUtfStatic(LPGEN("<unremovable once applied>"), buf, bufsize);
		else
			text = ICQTranslateUtfStatic(LPGEN("<empty>"), buf, bufsize);
	}
	else {
		switch (si.displayType & LIM_TYPE) {
		case LI_STRING:
		case LI_LONGSTRING:
			text = BinaryToEscapes((char*)sid.value);
			alloced = 1;
			break;

		case LI_NUMBER:
			_itoa(sid.value, text, 10);
			break;

		case LI_LIST:
			if (si.dbType == DBVT_ASCIIZ)
				text = ICQTranslateUtfStatic((char*)sid.value, buf, bufsize);
			else {
				text = ICQTranslateUtfStatic(LPGEN("Unknown value"), buf, bufsize);

				FieldNamesItem *list = (FieldNamesItem*)si.pList;
				if (list == timezonesField) {
					HANDLE tz = TimeZone_CreateByContact(NULL, ppro->m_szModuleName, 0);
					text = make_utf8_string_static(TimeZone_GetDescription(TimeZone_GetName(tz)), buf, bufsize);
					break;
				}

				for (int j = 0;; j++) {
					if (list[j].code == sid.value) {
						text = ICQTranslateUtfStatic(list[j].text, buf, bufsize);
						break;
					}
					else if (!list[j].text) {
						if (list[j].code == sid.value)
							text = ICQTranslateUtfStatic("Unspecified", buf, bufsize);
						break;
					}
				}
			}
			break;
		}
	}

	if (si.displayType & LIF_PASSWORD) {
		if (sid.changed) {
			for (int j = 0; text[j]; j++)
				text[j] = '*';
		}
		else {
			if (alloced) {
				SAFE_FREE(&text);
				alloced = 0;
			}
			text = "********";
		}
	}
	if (text != buf) {
		char *tmp = text;

		text = null_strcpy(buf, text, bufsize - 1);
		if (alloced)
			SAFE_FREE(&tmp);
	}

	return text;
}
Esempio n. 2
0
char* ChangeInfoData::GetItemSettingText(int i, char *buf, size_t bufsize)
{
	char *text = buf;
	int alloced = 0;

	buf[0] = '\0';

	if (settingData[i].value == 0 && !(setting[i].displayType & LIF_ZEROISVALID))
	{
		if (setting[i].displayType & LIF_CHANGEONLY)
			text = ICQTranslateUtfStatic(LPGEN("<unremovable once applied>"), buf, bufsize);
		else
			text = ICQTranslateUtfStatic(LPGEN("<empty>"), buf, bufsize);
	}
	else 
	{
		switch (setting[i].displayType & LIM_TYPE) {
		case LI_STRING:
		case LI_LONGSTRING:
			text = BinaryToEscapes((char*)settingData[i].value);
			alloced = 1;
			break;

		case LI_NUMBER:
			_itoa(settingData[i].value, text, 10);
			break;

		case LI_LIST:
			if (setting[i].dbType == DBVT_ASCIIZ) 
				text = ICQTranslateUtfStatic((char*)settingData[i].value, buf, bufsize);
			else 
			{
				text = ICQTranslateUtfStatic(LPGEN("Unknown value"), buf, bufsize);

				FieldNamesItem *list = (FieldNamesItem*)setting[i].pList;
				for (int j=0; TRUE; j++)
					if (list[j].code == settingData[i].value) 
					{
						text = ICQTranslateUtfStatic(list[j].text, buf, bufsize);
						break;
					}
					else if (!list[j].text)
					{
						if (list[j].code == settingData[i].value)
							text = ICQTranslateUtfStatic("Unspecified", buf, bufsize);
						break;
					}
			}
			break;
		}
	}
	if (setting[i].displayType & LIF_PASSWORD) 
	{
		if (settingData[i].changed) 
			for (int j=0; text[j]; j++) text[j] = '*';
		else 
		{
			if (alloced) 
			{
				SAFE_FREE(&text);
				alloced = 0;
			}
			text = "********";
		}
	}
	if (text != buf)
	{
		char *tmp = text;

		text = null_strcpy(buf, text, bufsize - 1);
		if (alloced)
			SAFE_FREE(&tmp);
	}

	return text;
}