Example #1
0
// Авторизация
DWORD CMraProto::MraLogin2W(const CMStringA &szLogin, const CMStringA &szPassword, DWORD dwStatus, const CMStringA &szStatusUri, CMStringW &wszStatusTitle, CMStringW &wszStatusDesc, DWORD dwFutureFlags, CMStringA &szUserAgentFormatted, CMStringA &szUserAgent)
{
	if (wszStatusTitle.GetLength() > STATUS_TITLE_MAX)     wszStatusTitle.Truncate(STATUS_TITLE_MAX);
	if (wszStatusDesc.GetLength() > STATUS_DESC_MAX)       wszStatusDesc.Truncate(STATUS_DESC_MAX);
	if (szUserAgentFormatted.GetLength() > USER_AGENT_MAX) szUserAgentFormatted.Truncate(USER_AGENT_MAX);
	if (szUserAgent.GetLength() > MAX_CLIENT_DESCRIPTION)  szUserAgent.Truncate(MAX_CLIENT_DESCRIPTION);

	OutBuffer buf;
	buf.SetLPS(szLogin);
	buf.SetLPS(szPassword);
	buf.SetUL(dwStatus);
	buf.SetLPS(szStatusUri);
	buf.SetLPSW(wszStatusTitle);
	buf.SetLPSW(wszStatusDesc);
	buf.SetUL(dwFutureFlags);
	buf.SetLPS(szUserAgentFormatted);
	buf.SetLPS("ru");
	buf.SetLPS("");
	buf.SetLPS("");
	buf.SetLPS(szUserAgent);// LPS client description /max 256

	return MraSendCMD(MRIM_CS_LOGIN2, buf.Data(), buf.Len());
}
Example #2
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());
}