Пример #1
0
MIR_CORE_DLL(int) TimeZone_SelectListItem(MCONTACT hContact, LPCSTR szModule, HWND hWnd, DWORD dwFlags)
{
	const ListMessages *lstMsg = GetListMessages(hWnd, dwFlags);
	if (lstMsg == NULL)
		return -1;

	if (szModule == NULL) szModule = "UserInfo";

	int iSelection = 0;
	ptrT tszName(db_get_tsa(hContact, szModule, "TzName"));
	if (tszName != NULL) {
		unsigned hash = mir_hashstrT(tszName);
		for (int i = 0; i < g_timezonesBias.getCount(); i++) {
			if (hash == g_timezonesBias[i]->hash) {
				iSelection = i + 1;
				break;
			}
		}
	}
	else {
		signed char cBias = db_get_b(hContact, szModule, "Timezone", -100);
		if (cBias != -100) {
			int iBias = cBias * 30;
			for (int i = 0; i < g_timezonesBias.getCount(); i++) {
				if (iBias == g_timezonesBias[i]->tzi.Bias) {
					iSelection = i + 1;
					break;
				}
			}
		}
	}

	SendMessage(hWnd, lstMsg->setSel, iSelection, 0);
	return iSelection;
}
Пример #2
0
static int timeapiSelectListItem(HANDLE hContact, HWND hWnd, DWORD dwFlags)
{
	if (hWnd == NULL)	   // nothing to do
		return -1;

	const ListMessages *lstMsg = GetListMessages(hWnd, dwFlags);
	if (lstMsg == NULL) return -1;

	int iSelection = 0;
	if (hContact)
	{
		DBVARIANT dbv;
		if (!DBGetContactSettingTString(hContact, "UserInfo", "TzName", &dbv)) 
		{
			unsigned hash = hashstr(dbv.ptszVal);
			for (int i = 0; i < g_timezonesBias.getCount(); ++i) 
			{
				if (hash == g_timezonesBias[i]->hash)
				{
					iSelection = i + 1;
					break;
				}
			}
			DBFreeVariant(&dbv);
		}
	}

	SendMessage(hWnd, lstMsg->setSel, iSelection, 0);
	return iSelection;
}
Пример #3
0
MIR_CORE_DLL(void) TimeZone_StoreListResult(MCONTACT hContact, LPCSTR szModule, HWND hWnd, DWORD dwFlags)
{
	if (szModule == NULL) szModule = "UserInfo";

	const ListMessages *lstMsg = GetListMessages(hWnd, dwFlags);
	if (lstMsg) {
		LRESULT offset = SendMessage(hWnd, lstMsg->getSel, 0, 0);
		if (offset > 0) {
			MIM_TIMEZONE *tz = (MIM_TIMEZONE*)SendMessage(hWnd, lstMsg->getData, offset, 0);
			if ((INT_PTR)tz != CB_ERR && tz != NULL)
				TimeZone_StoreByContact(hContact, szModule, tz);
		}
		else TimeZone_StoreByContact(hContact, szModule, NULL);
	}
}
Пример #4
0
static void timeapiStoreListResult(HANDLE hContact, HWND hWnd, DWORD dwFlags)
{
	const ListMessages *lstMsg = GetListMessages(hWnd, dwFlags);
	if (lstMsg == NULL) return;

	LRESULT offset = SendMessage(hWnd, lstMsg->getSel, 0, 0);
	if (offset > 0) 
	{
		MIM_TIMEZONE *tz = (MIM_TIMEZONE*)SendMessage(hWnd, lstMsg->getData, offset, 0);
		if ((INT_PTR)tz != CB_ERR && tz != NULL)
			timeapiSetInfoByContact(hContact, tz);
	} 
	else
		timeapiSetInfoByContact(hContact, NULL);
}
Пример #5
0
MIR_CORE_DLL(int) TimeZone_PrepareList(MCONTACT hContact, LPCSTR szModule, HWND hWnd, DWORD dwFlags)
{
	const ListMessages *lstMsg = GetListMessages(hWnd, dwFlags);
	if (lstMsg == NULL)
		return 0;

	SendMessage(hWnd, lstMsg->addStr, 0, (LPARAM)TranslateT("<unspecified>"));

	for (int i = 0; i < g_timezonesBias.getCount(); i++) {
		MIM_TIMEZONE *tz = g_timezonesBias[i];

		SendMessage(hWnd, lstMsg->addStr, 0, (LPARAM)tz->szDisplay);
		SendMessage(hWnd, lstMsg->setData, i + 1, (LPARAM)tz);
	}

	return TimeZone_SelectListItem(hContact, szModule, hWnd, dwFlags);
}
Пример #6
0
static int timeapiPrepareList(HANDLE hContact, HWND hWnd, DWORD dwFlags)
{
	if (hWnd == NULL)	   // nothing to do
		return 0;

	const ListMessages *lstMsg = GetListMessages(hWnd, dwFlags);
	if (lstMsg == NULL) return 0;

	SendMessage(hWnd, lstMsg->addStr, 0, (LPARAM)TranslateT("<unspecified>"));

	for (int i = 0; i < g_timezonesBias.getCount(); ++i) 
	{
		MIM_TIMEZONE *tz = g_timezonesBias[i];

		if (pfnSendMessageW)
			pfnSendMessageW(hWnd, lstMsg->addStr, 0, (LPARAM)tz->szDisplay);
		else
			SendMessage(hWnd, lstMsg->addStr, 0, (LPARAM)StrConvTu(tz->szDisplay));

		SendMessage(hWnd, lstMsg->setData, i + 1, (LPARAM)tz);
	}

	return timeapiSelectListItem(hContact, hWnd, dwFlags);
}