// Авторизация 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()); }
DWORD CMraProto::MraMessage(BOOL bAddToQueue, MCONTACT hContact, DWORD dwAckType, DWORD dwFlags, const CMStringA &szEmail, const CMStringW &lpwszMessage, LPBYTE lpbMultiChatData, size_t dwMultiChatDataSize) { debugLogA("Sending message: flags %08x, to '%S', message '%S'\n", dwFlags, szEmail, lpwszMessage); DWORD dwRet = 0; LPSTR lpszMessageConverted = (LPSTR)lpwszMessage.GetString(); LPSTR lpszMessageRTF = NULL; size_t dwMessageConvertedSize = lpwszMessage.GetLength()*sizeof(WCHAR), dwMessageRTFSize = 0; if (MraIsMessageFlashAnimation(lpwszMessage)) dwFlags |= MESSAGE_FLAG_FLASH; // pack auth message if (dwFlags & MESSAGE_FLAG_AUTHORIZE) { OutBuffer buf; buf.SetUL(2); buf.SetLPSW(_T(""));//***deb possible nick here buf.SetLPSW(lpwszMessage); lpszMessageConverted = mir_base64_encode(buf.Data(), (int)buf.Len()); dwMessageConvertedSize = mir_strlen(lpszMessageConverted); } // messages with Flash else if (dwFlags & MESSAGE_FLAG_FLASH) { dwFlags |= MESSAGE_FLAG_RTF; CMStringA lpszBuf(mir_u2a(lpwszMessage)); OutBuffer buf; buf.SetUL(4); buf.SetLPS(lpszBuf);// сообщение что у собеседника плохая версия :) buf.SetUL(4); buf.SetUL(getDword("RTFBackgroundColour", MRA_DEFAULT_RTF_BACKGROUND_COLOUR)); buf.SetLPS(lpszBuf);// сам мульт ANSI buf.SetLPSW(lpwszMessage);// сам мульт UNICODE DWORD dwBufSize = DWORD(buf.Len() + 128); lpszBuf.Truncate(dwBufSize); if (compress2((LPBYTE)(LPCSTR)lpszBuf, &dwBufSize, buf.Data(), (int)buf.Len(), Z_BEST_COMPRESSION) == Z_OK) { lpszMessageRTF = mir_base64_encode((LPBYTE)(LPCSTR)lpszBuf, dwBufSize); dwMessageRTFSize = mir_strlen(lpszMessageRTF); } } // standart message else if ((dwFlags & (MESSAGE_FLAG_CONTACT | MESSAGE_FLAG_NOTIFY | MESSAGE_FLAG_SMS)) == 0) { // Only if message is simple text message or RTF or ALARM if (dwFlags & MESSAGE_FLAG_RTF) { // add RFT part CMStringA lpbRTFData; lpbRTFData.Truncate(lpwszMessage.GetLength() * 16 + 4096); if (!MraConvertToRTFW(lpwszMessage, lpbRTFData)) { DWORD dwBackColour = getDword("RTFBackgroundColour", MRA_DEFAULT_RTF_BACKGROUND_COLOUR); OutBuffer buf; buf.SetUL(2); buf.SetLPS(lpbRTFData); buf.SetUL(4); buf.SetUL(dwBackColour); DWORD dwRTFDataSize = lpbRTFData.GetLength(); if (compress2((LPBYTE)(LPCSTR)lpbRTFData, &dwRTFDataSize, buf.Data(), (int)buf.Len(), Z_BEST_COMPRESSION) == Z_OK) { lpszMessageRTF = mir_base64_encode((LPBYTE)(LPCSTR)lpbRTFData, dwRTFDataSize); dwMessageRTFSize = mir_strlen(lpszMessageRTF); } } } } if (lpszMessageRTF == NULL || dwMessageRTFSize == 0) dwFlags &= ~(MESSAGE_FLAG_RTF | MESSAGE_FLAG_FLASH); if (lpbMultiChatData == NULL || dwMultiChatDataSize == 0) dwFlags &= ~MESSAGE_FLAG_MULTICHAT; OutBuffer buf; buf.SetUL(dwFlags); buf.SetLPSLowerCase(szEmail); buf.SetLPS(CMStringA(lpszMessageConverted, (int)dwMessageConvertedSize)); buf.SetLPS(lpszMessageRTF); if (dwFlags & MESSAGE_FLAG_MULTICHAT) buf.SetLPS(CMStringA((LPSTR)lpbMultiChatData, (int)dwMultiChatDataSize)); if (bAddToQueue) dwRet = MraSendQueueCMD(hSendQueueHandle, 0, hContact, dwAckType, NULL, 0, MRIM_CS_MESSAGE, buf.Data(), buf.Len()); else dwRet = MraSendCMD(MRIM_CS_MESSAGE, buf.Data(), buf.Len()); return dwRet; }