示例#1
0
int CSItemsList::compareItems(const StatusItem* p1, const StatusItem* p2)
{
	int favRes = 0, icoRes = 0, ttlRes = 0, msgRes = 0;

	if (p1->m_bFavourite < p2->m_bFavourite)
		favRes = 1;
	else if (p1->m_bFavourite > p2->m_bFavourite)
		favRes = -1;

	int result;
	if (p1->m_iIcon > p2->m_iIcon)
		icoRes = 1;
	else if (p1->m_iIcon < p2->m_iIcon)
		icoRes = -1;

	result = mir_wstrcmp(p1->m_tszTitle, p2->m_tszTitle);
	ttlRes = result;

	result = mir_wstrcmp(p1->m_tszMessage, p2->m_tszMessage);
	msgRes = result;

	if (!icoRes && !ttlRes && !msgRes)
		return 0;

	if (favRes != 0)
		return favRes;
	if (icoRes != 0)
		return icoRes;
	if (ttlRes != 0)
		return ttlRes;
	if (msgRes != 0)
		return msgRes;

	return 0;
}
示例#2
0
void RecalculateTime(void)
{
	GetTimeZoneInformation(&myInfo.myTZ.tzi);
	myInfo.timestamp = time(NULL);
	myInfo.myTZ.offset = INT_MIN;

	bool found = false;
	DYNAMIC_TIME_ZONE_INFORMATION dtzi;

	if (pfnGetDynamicTimeZoneInformation && pfnGetDynamicTimeZoneInformation(&dtzi) != TIME_ZONE_ID_INVALID) {
		TCHAR *myTzKey = mir_u2t(dtzi.TimeZoneKeyName);
		_tcsncpy_s(myInfo.myTZ.tszName, myTzKey, _TRUNCATE);
		mir_free(myTzKey);
		found = true;
	}

	for (int i = 0; i < g_timezones.getCount(); i++) {
		MIM_TIMEZONE &tz = g_timezones[i];
		if (tz.offset != INT_MIN)
			tz.offset = INT_MIN;

		if (!found) {
			if (!mir_wstrcmp(tz.tzi.StandardName, myInfo.myTZ.tzi.StandardName) || !mir_wstrcmp(tz.tzi.DaylightName, myInfo.myTZ.tzi.DaylightName)) {
				_tcsncpy_s(myInfo.myTZ.tszName, tz.tszName, _TRUNCATE);
				found = true;
			}
		}
	}
}
示例#3
0
OtrlPolicy policy_from_string(const wchar_t *polstring) {
	if (mir_wstrcmp(polstring, TranslateW(LANG_POLICY_NEVER)) == 0)
		return OTRL_POLICY_NEVER;
	else if (mir_wstrcmp(polstring, TranslateW(LANG_POLICY_OPP)) == 0)
		return OTRL_POLICY_OPPORTUNISTIC;
	else if (mir_wstrcmp(polstring, TranslateW(LANG_POLICY_MANUAL)) == 0)
		return OTRL_POLICY_MANUAL_MOD;
	else if (mir_wstrcmp(polstring, TranslateW(LANG_POLICY_ALWAYS)) == 0)
		return OTRL_POLICY_ALWAYS;
	else 
		return CONTACT_DEFAULT_POLICY;
}
示例#4
0
STDMETHODIMP IEView::ProcessUrlAction(LPCWSTR pwszUrl, DWORD dwAction, BYTE *pPolicy, DWORD cbPolicy, BYTE *, DWORD, DWORD, DWORD)
{
	DWORD dwPolicy = URLPOLICY_ALLOW;
	if (pwszUrl != NULL && !mir_wstrcmp(pwszUrl, L"about:blank")) {
		if (dwAction <= URLACTION_ACTIVEX_MAX && dwAction >= URLACTION_ACTIVEX_MIN) {
			//dwPolicy = URLPOLICY_DISALLOW;
			//dwPolicy = URLPOLICY_ALLOW;
		}
		else if ((dwAction <= URLACTION_JAVA_MAX && dwAction >= URLACTION_JAVA_MIN) || URLACTION_HTML_JAVA_RUN == dwAction) {
			// dwPolicy = URLPOLICY_JAVA_PROHIBIT;
			return INET_E_DEFAULT_ACTION;
		}
		else if (dwAction <= URLACTION_SCRIPT_MAX && dwAction >= URLACTION_SCRIPT_MIN) {
			//dwPolicy = URLPOLICY_DISALLOW;
			//dwPolicy = URLPOLICY_ALLOW;
		}
		else if (dwAction <= URLACTION_HTML_MIN && dwAction >= URLACTION_HTML_MAX) {
			//dwPolicy = URLPOLICY_DISALLOW;
			//dwPolicy = URLPOLICY_ALLOW;
		}
		else return INET_E_DEFAULT_ACTION;

		if (cbPolicy >= sizeof(DWORD)) {
			*(DWORD*)pPolicy = dwPolicy;
			return S_OK;
		}

		return S_FALSE;
	}
	return INET_E_DEFAULT_ACTION;
}
示例#5
0
void CSAMWindow::checkItemValidity()
{
	COMBOBOXEXITEM cbi = { 0 };
	cbi.mask = CBEIF_IMAGE;
	cbi.iItem = SendDlgItemMessage(m_handle, IDC_COMBO, CB_GETCURSEL, 0, 0);
	SendDlgItemMessage(m_handle, IDC_COMBO, CBEM_GETITEM, 0, (LPARAM)&cbi);

	if (m_item->m_iIcon != cbi.iImage)
		m_item->m_iIcon = cbi.iImage, m_bChanged = TRUE;

	wchar_t tszInputMessage[EXTRASTATUS_MESSAGE_LIMIT];

	GetDlgItemText(m_handle, IDC_MESSAGE, tszInputMessage, _countof(tszInputMessage));

	PROTOACCOUNT *pdescr = Proto_GetAccount(m_parent->m_protoName);
	if (pdescr == nullptr)
		return;

	WPARAM i = SendMessage(m_hCombo, CB_GETCURSEL, 0, 0) + 1;
	wchar_t tszTitle[100];

	CUSTOM_STATUS cs = { sizeof(cs) };
	cs.flags = CSSF_MASK_NAME | CSSF_DEFAULT_NAME | CSSF_UNICODE;
	cs.ptszName = tszTitle;
	cs.wParam = &i;
	if (CallProtoService(pdescr->szModuleName, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&cs) == 0)
		mir_wstrncpy(m_item->m_tszTitle, TranslateW(tszTitle), _countof(m_item->m_tszTitle));

	if (mir_wstrcmp(m_item->m_tszMessage, tszInputMessage))
		mir_wstrcpy(m_item->m_tszMessage, tszInputMessage), m_bChanged = true;
}
示例#6
0
STDMETHODIMP IEView::MapUrlToZone(LPCWSTR pwszUrl, DWORD *pdwZone, DWORD)
{
	if (pdwZone != NULL && pwszUrl != NULL && !mir_wstrcmp(pwszUrl, L"about:blank")) {
		*pdwZone = URLZONE_LOCAL_MACHINE;
		return S_OK;
	}
	return INET_E_DEFAULT_ACTION;
}
示例#7
0
static INT_PTR ServiceGetClientDescrW(WPARAM wParam, LPARAM)
{
	LPWSTR wszMirVer = (LPWSTR)wParam;  // MirVer value to get client for.
	if (wszMirVer == NULL)
		return 0;

	LPWSTR wszMirVerUp = NEWWSTR_ALLOCA(wszMirVer); _wcsupr(wszMirVerUp);
	if (mir_wstrcmp(wszMirVerUp, L"?") == 0)
		return (INT_PTR)def_kn_fp_mask[UNKNOWN_MASK_NUMBER].szClientDescription;

	for (int index = 0; index < DEFAULT_KN_FP_MASK_COUNT; index++)
		if (WildCompareW(wszMirVerUp, def_kn_fp_mask[index].szMaskUpper))
			return (INT_PTR)def_kn_fp_mask[index].szClientDescription;

	return NULL;
}
示例#8
0
void __fastcall GetIconsIndexesW(LPWSTR wszMirVer, short *base, short *overlay, short *overlay2, short *overlay3, short *overlay4)
{
	if (mir_wstrcmp(wszMirVer, L"?") == 0)
	{
		*base = UNKNOWN_MASK_NUMBER;
		*overlay = -1;
		*overlay2 = -1;
		*overlay3 = -1;
		*overlay4 = -1;
		return;
	}

	LPWSTR wszMirVerUp = NEWWSTR_ALLOCA(wszMirVer);
	_wcsupr(wszMirVerUp);
	MatchMasks(wszMirVerUp, base, overlay, overlay2, overlay3, overlay4);
}
示例#9
0
//---------------------------------------------------------------------------
BOOL GetEncoderClsid(wchar_t *wchMimeType, CLSID& clsidEncoder)
{
	UINT uiNum = 0;
	UINT uiSize = 0;
	BOOL bOk = FALSE;
	Gdiplus::GetImageEncodersSize(&uiNum, &uiSize);
	if (uiSize > 0) {
		Gdiplus::ImageCodecInfo* pImageCodecInfo = (Gdiplus::ImageCodecInfo*)mir_alloc(uiSize);
		if (pImageCodecInfo) {
			Gdiplus::GetImageEncoders(uiNum, uiSize, pImageCodecInfo);
			for (UINT i = 0; i < uiNum; ++i) {
				if (!mir_wstrcmp(pImageCodecInfo[i].MimeType, wchMimeType)) {
					clsidEncoder = pImageCodecInfo[i].Clsid;
					bOk = TRUE;
				}
			}
			mir_free(pImageCodecInfo);
		}
	}
	return bOk;
}
示例#10
0
wchar_t* GetStr(STATUSMSGINFO *n, const wchar_t *tmplt)
{
	if (n == nullptr || tmplt == nullptr || tmplt[0] == '\0')
		return nullptr;

	CMStringW res;
	size_t len = mir_wstrlen(tmplt);

	for (size_t i = 0; i < len; i++) {
		if (tmplt[i] == '%') {
			i++;
			switch (tmplt[i]) {
			case 'n':
				if (n->compare == COMPARE_DEL || mir_wstrcmp(n->newstatusmsg, TranslateT("<no status message>")) == 0)
					res.Append(TranslateT("<no status message>"));
				else
					AddCR(res, n->newstatusmsg);
				break;

			case 'o':
				if (n->oldstatusmsg == nullptr || n->oldstatusmsg[0] == '\0' || mir_wstrcmp(n->oldstatusmsg, TranslateT("<no status message>")) == 0)
					res.Append(TranslateT("<no status message>"));
				else
					AddCR(res, n->oldstatusmsg);
				break;

			case 'c':
				if (n->hContact == NULL)
					res.Append(TranslateT("Contact"));
				else
					res.Append(Clist_GetContactDisplayName(n->hContact));
				break;

			case 's':
				if (n->hContact == NULL)
					res.Append(TranslateT("<unknown>"));
				else
					res.Append(StatusList[Index(db_get_w(n->hContact, n->proto, "Status", ID_STATUS_ONLINE))].lpzStandardText);
				break;

			default:
				i--;
				res.AppendChar(tmplt[i]);
				break;
			}
		}
		else if (tmplt[i] == '\\') {
			i++;
			switch (tmplt[i]) {
			case 'n':
				res.AppendChar('\r');
				res.AppendChar('\n');
				break;
			case 't':
				res.AppendChar('\t');
				break;
			default:
				i--;
				res.AppendChar(tmplt[i]);
				break;
			}
		}
		else res.AppendChar(tmplt[i]);
	}

	if (res.GetLength() > 2044) {
		res.Truncate(2044);
		res.Append(L"...");
	}

	return mir_wstrndup(res, res.GetLength());
}
示例#11
0
static int CompareStatusMsg(STATUSMSGINFO *smi, DBCONTACTWRITESETTING *cws_new, char *szSetting)
{
	DBVARIANT dbv_old;
	int ret = -1;

	switch (cws_new->value.type) {
	case DBVT_ASCIIZ:
		smi->newstatusmsg = (CheckStr(cws_new->value.pszVal, 0, 1) ? nullptr : mir_a2u_cp(cws_new->value.pszVal, CP_ACP));
		break;
	case DBVT_UTF8:
		smi->newstatusmsg = (CheckStr(cws_new->value.pszVal, 0, 1) ? nullptr : mir_a2u_cp(cws_new->value.pszVal, CP_UTF8));
		break;
	case DBVT_WCHAR:
		smi->newstatusmsg = (CheckStrW(cws_new->value.pwszVal, 0, 1) ? nullptr : mir_wstrdup(cws_new->value.pwszVal));
		break;
	case DBVT_DELETED:
	default:
		smi->newstatusmsg = nullptr;
		break;
	}

	if (!db_get_s(smi->hContact, "UserOnline", szSetting, &dbv_old, 0)) {
		switch (dbv_old.type) {
		case DBVT_ASCIIZ:
			smi->oldstatusmsg = (CheckStr(dbv_old.pszVal, 0, 1) ? nullptr : mir_a2u_cp(dbv_old.pszVal, CP_ACP));
			break;
		case DBVT_UTF8:
			smi->oldstatusmsg = (CheckStr(dbv_old.pszVal, 0, 1) ? nullptr : mir_a2u_cp(dbv_old.pszVal, CP_UTF8));
			break;
		case DBVT_WCHAR:
			smi->oldstatusmsg = (CheckStrW(dbv_old.pwszVal, 0, 1) ? nullptr : mir_wstrdup(dbv_old.pwszVal));
			break;
		default:
			smi->oldstatusmsg = nullptr;
			break;
		}

		if (cws_new->value.type == DBVT_DELETED) {
			if (dbv_old.type == DBVT_WCHAR)
				ret = CheckStrW(dbv_old.pwszVal, COMPARE_DEL, COMPARE_SAME);
			else if (dbv_old.type == DBVT_UTF8 || dbv_old.type == DBVT_ASCIIZ)
				ret = CheckStr(dbv_old.pszVal, COMPARE_DEL, COMPARE_SAME);
			else
				ret = COMPARE_DEL;
		}
		else if (dbv_old.type != cws_new->value.type)
			ret = (mir_wstrcmp(smi->newstatusmsg, smi->oldstatusmsg) ? CheckStrW(smi->newstatusmsg, COMPARE_DIFF, COMPARE_DEL) : COMPARE_SAME);

		else if (dbv_old.type == DBVT_ASCIIZ)
			ret = (mir_strcmp(cws_new->value.pszVal, dbv_old.pszVal) ? CheckStr(cws_new->value.pszVal, COMPARE_DIFF, COMPARE_DEL) : COMPARE_SAME);

		else if (dbv_old.type == DBVT_UTF8)
			ret = (mir_strcmp(cws_new->value.pszVal, dbv_old.pszVal) ? CheckStr(cws_new->value.pszVal, COMPARE_DIFF, COMPARE_DEL) : COMPARE_SAME);

		else if (dbv_old.type == DBVT_WCHAR)
			ret = (mir_wstrcmp(cws_new->value.pwszVal, dbv_old.pwszVal) ? CheckStrW(cws_new->value.pwszVal, COMPARE_DIFF, COMPARE_DEL) : COMPARE_SAME);

		db_free(&dbv_old);
	}
	else {
		if (cws_new->value.type == DBVT_DELETED)
			ret = COMPARE_SAME;
		else if (cws_new->value.type == DBVT_WCHAR)
			ret = CheckStrW(cws_new->value.pwszVal, COMPARE_DIFF, COMPARE_SAME);
		else if (cws_new->value.type == DBVT_UTF8 || cws_new->value.type == DBVT_ASCIIZ)
			ret = CheckStr(cws_new->value.pszVal, COMPARE_DIFF, COMPARE_SAME);
		else
			ret = COMPARE_DIFF;

		smi->oldstatusmsg = nullptr;
	}

	return ret;
}