From 22bdf4d623a3e37f8b32dbcca437df37906a9ae5 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 21 Sep 2012 19:27:41 +0000 Subject: fix for the version detection git-svn-id: http://svn.miranda-ng.org/main/trunk@1627 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/MRA/Mra.h | 2 +- protocols/MRA/MraProto.h | 2 +- protocols/MRA/MraSendCommand.cpp | 8 ++--- protocols/MRA/Mra_functions.cpp | 74 +++++++++++++++++++--------------------- protocols/MRA/Mra_proto.cpp | 10 +++--- 5 files changed, 46 insertions(+), 50 deletions(-) (limited to 'protocols/MRA') diff --git a/protocols/MRA/Mra.h b/protocols/MRA/Mra.h index 0374b4afa2..d47c967fa8 100644 --- a/protocols/MRA/Mra.h +++ b/protocols/MRA/Mra.h @@ -241,7 +241,7 @@ void MraAddrListFree(MRA_ADDR_LIST *pmalAddrList); DWORD MraAddrListGetFromBuff(LPSTR lpszAddreses, size_t dwAddresesSize, MRA_ADDR_LIST *pmalAddrList); DWORD MraAddrListGetToBuff(MRA_ADDR_LIST *pmalAddrList, LPSTR lpszBuff, size_t dwBuffSize, size_t *pdwBuffSizeRet); -DWORD MraGetVersionStringFromFormatted (LPSTR lpszUserAgentFormated, size_t dwUserAgentFormatedSize, LPSTR lpszVersion, size_t dwVersionSize, size_t *pdwVersionSizeRet); +DWORD MraGetVersionStringFromFormatted (LPSTR dwUserAgentFormatted, size_t dwUserAgentFormattedSize, LPSTR lpszVersion, size_t dwVersionSize, size_t *pdwVersionSizeRet); BOOL IsUnicodeEnv (); BOOL IsHTTPSProxyUsed (HANDLE hNetlibUser); BOOL IsContactMraProto (HANDLE hContact); diff --git a/protocols/MRA/MraProto.h b/protocols/MRA/MraProto.h index 5b9eccf903..852a58911c 100644 --- a/protocols/MRA/MraProto.h +++ b/protocols/MRA/MraProto.h @@ -252,7 +252,7 @@ struct CMraProto : public PROTO_INTERFACE, public MZeroedObject HANDLE MraWPRequestA(HANDLE hContact, DWORD dwAckType, DWORD dwRequestFlags, LPSTR lpszUser, size_t dwUserSize, LPSTR lpszDomain, size_t dwDomainSize, LPSTR lpszNickName, size_t dwNickNameSize, LPSTR lpszFirstName, size_t dwFirstNameSize, LPSTR lpszLastName, size_t dwLastNameSize, DWORD dwSex, DWORD dwDate1, DWORD dwDate2, DWORD dwCityID, DWORD dwZodiak, DWORD dwBirthdayMonth, DWORD dwBirthdayDay, DWORD dwCountryID, DWORD dwOnline); HANDLE MraWPRequestByEMail(HANDLE hContact, DWORD dwAckType, LPCSTR lpszEMail, size_t dwEMailSize); DWORD MraGame(LPSTR lpszEMail, size_t dwEMailSize, DWORD dwGameSessionID, DWORD dwGameMsg, DWORD dwGameMsgID, LPSTR lpszData, size_t dwDataSize); - DWORD MraLogin2W(LPSTR lpszLogin, size_t dwLoginSize, LPSTR lpszPassword, size_t dwPasswordSize, DWORD dwStatus, LPSTR lpszStatusUri, size_t dwStatusUriSize, LPWSTR lpwszStatusTitle, size_t dwStatusTitleSize, LPWSTR lpwszStatusDesc, size_t dwStatusDescSize, DWORD dwFutureFlags, LPSTR lpszUserAgentFormated, size_t dwUserAgentFormatedSize, LPSTR lpszUserAgent, size_t dwUserAgentSize); + DWORD MraLogin2W(LPSTR lpszLogin, size_t dwLoginSize, LPSTR lpszPassword, size_t dwPasswordSize, DWORD dwStatus, LPSTR lpszStatusUri, size_t dwStatusUriSize, LPWSTR lpwszStatusTitle, size_t dwStatusTitleSize, LPWSTR lpwszStatusDesc, size_t dwStatusDescSize, DWORD dwFutureFlags, LPSTR dwUserAgentFormatted, size_t dwUserAgentFormattedSize, LPSTR lpszUserAgent, size_t dwUserAgentSize); DWORD MraSMSW(HANDLE hContact, LPSTR lpszPhone, size_t dwPhoneSize, LPWSTR lpwszMessage, size_t dwMessageSize); DWORD MraProxy(LPSTR lpszEMail, size_t dwEMailSize, DWORD dwIDRequest, DWORD dwDataType, LPSTR lpszData, size_t dwDataSize, LPSTR lpszAddreses, size_t dwAddresesSize, MRA_GUID mguidSessionID); DWORD MraProxyAck(DWORD dwStatus, LPSTR lpszEMail, size_t dwEMailSize, DWORD dwIDRequest, DWORD dwDataType, LPSTR lpszData, size_t dwDataSize, LPSTR lpszAddreses, size_t dwAddresesSize, MRA_GUID mguidSessionID); diff --git a/protocols/MRA/MraSendCommand.cpp b/protocols/MRA/MraSendCommand.cpp index 13bf18e557..67db1e499f 100644 --- a/protocols/MRA/MraSendCommand.cpp +++ b/protocols/MRA/MraSendCommand.cpp @@ -518,17 +518,17 @@ DWORD CMraProto::MraGame(LPSTR lpszEMail, size_t dwEMailSize, DWORD dwGameSessio } // Авторизация -DWORD CMraProto::MraLogin2W(LPSTR lpszLogin, size_t dwLoginSize, LPSTR lpszPassword, size_t dwPasswordSize, DWORD dwStatus, LPSTR lpszStatusUri, size_t dwStatusUriSize, LPWSTR lpwszStatusTitle, size_t dwStatusTitleSize, LPWSTR lpwszStatusDesc, size_t dwStatusDescSize, DWORD dwFutureFlags, LPSTR lpszUserAgentFormated, size_t dwUserAgentFormatedSize, LPSTR lpszUserAgent, size_t dwUserAgentSize) +DWORD CMraProto::MraLogin2W(LPSTR lpszLogin, size_t dwLoginSize, LPSTR lpszPassword, size_t dwPasswordSize, DWORD dwStatus, LPSTR lpszStatusUri, size_t dwStatusUriSize, LPWSTR lpwszStatusTitle, size_t dwStatusTitleSize, LPWSTR lpwszStatusDesc, size_t dwStatusDescSize, DWORD dwFutureFlags, LPSTR dwUserAgentFormatted, size_t dwUserAgentFormattedSize, LPSTR lpszUserAgent, size_t dwUserAgentSize) { DWORD dwRet = 0; if (dwStatusUriSize>SPEC_STATUS_URI_MAX) dwStatusUriSize = SPEC_STATUS_URI_MAX; if (dwStatusTitleSize>STATUS_TITLE_MAX) dwStatusTitleSize = STATUS_TITLE_MAX; if (dwStatusDescSize>STATUS_DESC_MAX) dwStatusDescSize = STATUS_DESC_MAX; - if (dwUserAgentFormatedSize>USER_AGENT_MAX) dwUserAgentFormatedSize = USER_AGENT_MAX; + if (dwUserAgentFormattedSize>USER_AGENT_MAX) dwUserAgentFormattedSize = USER_AGENT_MAX; if (dwUserAgentSize>MAX_CLIENT_DESCRIPTION) dwUserAgentSize = MAX_CLIENT_DESCRIPTION; - LPBYTE lpbData = (LPBYTE)mir_calloc((dwLoginSize+dwPasswordSize+sizeof(DWORD)+dwStatusUriSize+(dwStatusTitleSize*sizeof(WCHAR))+(dwStatusDescSize*sizeof(WCHAR))+2+sizeof(DWORD)+(sizeof(DWORD)*2)+dwUserAgentFormatedSize+dwUserAgentSize+32)); + LPBYTE lpbData = (LPBYTE)mir_calloc((dwLoginSize+dwPasswordSize+sizeof(DWORD)+dwStatusUriSize+(dwStatusTitleSize*sizeof(WCHAR))+(dwStatusDescSize*sizeof(WCHAR))+2+sizeof(DWORD)+(sizeof(DWORD)*2)+dwUserAgentFormattedSize+dwUserAgentSize+32)); if (lpbData) { LPBYTE lpbDataCurrent = lpbData; SetLPS(&lpbDataCurrent, lpszLogin, dwLoginSize); @@ -538,7 +538,7 @@ DWORD CMraProto::MraLogin2W(LPSTR lpszLogin, size_t dwLoginSize, LPSTR lpszPassw SetLPSW(&lpbDataCurrent, lpwszStatusTitle, dwStatusTitleSize); SetLPSW(&lpbDataCurrent, lpwszStatusDesc, dwStatusDescSize); SetUL(&lpbDataCurrent, dwFutureFlags); - SetLPS(&lpbDataCurrent, lpszUserAgentFormated, dwUserAgentFormatedSize); + SetLPS(&lpbDataCurrent, dwUserAgentFormatted, dwUserAgentFormattedSize); SetLPS(&lpbDataCurrent, "ru", 2); SetLPS(&lpbDataCurrent, NULL, 0); SetLPS(&lpbDataCurrent, NULL, 0); diff --git a/protocols/MRA/Mra_functions.cpp b/protocols/MRA/Mra_functions.cpp index 8cca94b907..45ee8b9a2d 100644 --- a/protocols/MRA/Mra_functions.cpp +++ b/protocols/MRA/Mra_functions.cpp @@ -45,7 +45,7 @@ DWORD MraGetSelfVersionString(LPSTR lpszSelfVersion, size_t dwSelfVersionSize, s lpszSecIM = ( ServiceExists("SecureIM/IsContactSecured")? " + SecureIM":""); size_t dwSelfVersionSizeRet; - dwSelfVersionSizeRet = mir_snprintf(lpszSelfVersion, dwSelfVersionSize, "Miranda IM %lu.%lu.%lu.%lu%s (MRA v%lu.%lu.%lu.%lu)%s, version: %lu.%lu", + dwSelfVersionSizeRet = mir_snprintf(lpszSelfVersion, dwSelfVersionSize, "Miranda NG %lu.%lu.%lu.%lu%s (MRA v%lu.%lu.%lu.%lu)%s, version: %lu.%lu", v[0], v[1], v[2], v[3], lpszUnicode, __FILEVERSION_STRING, lpszSecIM, PROTO_VERSION_MAJOR, PROTO_VERSION_MINOR); @@ -79,57 +79,53 @@ DWORD GetParamValue(LPSTR lpszData, size_t dwDataSize, LPSTR lpszParamName, size return ERROR_NOT_FOUND; } -DWORD MraGetVersionStringFromFormatted(LPSTR lpszUserAgentFormated, size_t dwUserAgentFormatedSize, LPSTR lpszVersion, size_t dwVersionSize, size_t *pdwVersionSizeRet) +DWORD MraGetVersionStringFromFormatted(LPSTR dwUserAgentFormatted, size_t dwUserAgentFormattedSize, LPSTR lpszVersion, size_t dwVersionSize, size_t *pdwVersionSizeRet) { - if (!lpszUserAgentFormated || !dwUserAgentFormatedSize || !lpszVersion || !dwVersionSize) + if (!dwUserAgentFormatted || !dwUserAgentFormattedSize || !lpszVersion || !dwVersionSize) return ERROR_INVALID_HANDLE; char szBuff[4096]; size_t dwBuffSize, dwVersionSizeRet; - if (GetParamValue(lpszUserAgentFormated, dwUserAgentFormatedSize, "name", 4, szBuff, SIZEOF(szBuff), &dwBuffSize) == NO_ERROR && CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, szBuff, ((dwBuffSize<10)? dwBuffSize:10), "Miranda IM", 10) == CSTR_EQUAL) - {// Miranda IM - GetParamValue(lpszUserAgentFormated, dwUserAgentFormatedSize, "title", 5, lpszVersion, dwVersionSize, pdwVersionSizeRet); - } - else { - dwVersionSizeRet = 0; - - if (GetParamValue(lpszUserAgentFormated, dwUserAgentFormatedSize, "client", 6, lpszVersion, dwVersionSize, &dwBuffSize) == NO_ERROR) - { - dwVersionSizeRet += dwBuffSize; - (*((BYTE*)(lpszVersion+dwVersionSizeRet))) = ' '; + if ( !GetParamValue(dwUserAgentFormatted, dwUserAgentFormattedSize, "name", 4, szBuff, SIZEOF(szBuff), &dwBuffSize)) + if ( !_strnicmp(szBuff, "Miranda IM", dwBuffSize) || !_strnicmp(szBuff, "Miranda NG", dwBuffSize)) { + GetParamValue(dwUserAgentFormatted, dwUserAgentFormattedSize, "title", 5, lpszVersion, dwVersionSize, pdwVersionSizeRet); + return 0; } - if (GetParamValue(lpszUserAgentFormated, dwUserAgentFormatedSize, "name", 4, lpszVersion, dwVersionSize, &dwBuffSize) == NO_ERROR) - { - dwVersionSizeRet += dwBuffSize; - (*((BYTE*)(lpszVersion+dwVersionSizeRet))) = ' '; - } + dwVersionSizeRet = 0; + if ( !GetParamValue(dwUserAgentFormatted, dwUserAgentFormattedSize, "client", 6, lpszVersion, dwVersionSize, &dwBuffSize)) { + dwVersionSizeRet += dwBuffSize; + *((BYTE*)(lpszVersion+dwVersionSizeRet)) = ' '; + } - if (GetParamValue(lpszUserAgentFormated, dwUserAgentFormatedSize, "title", 5, lpszVersion, dwVersionSize, &dwBuffSize) == NO_ERROR) - { - dwVersionSizeRet += dwBuffSize; - (*((BYTE*)(lpszVersion+dwVersionSizeRet))) = ' '; - } + if ( !GetParamValue(dwUserAgentFormatted, dwUserAgentFormattedSize, "name", 4, lpszVersion, dwVersionSize, &dwBuffSize)) { + dwVersionSizeRet += dwBuffSize; + *((BYTE*)(lpszVersion+dwVersionSizeRet)) = ' '; + } - if (GetParamValue(lpszUserAgentFormated, dwUserAgentFormatedSize, "version", 7, (lpszVersion+dwVersionSizeRet+1), (dwVersionSize-dwVersionSizeRet), &dwBuffSize) == NO_ERROR) - { - dwVersionSizeRet += (dwBuffSize+1); - (*((BYTE*)(lpszVersion+dwVersionSizeRet))) = '.'; - if (GetParamValue(lpszUserAgentFormated, dwUserAgentFormatedSize, "build", 5, (lpszVersion+dwVersionSizeRet+1), (dwVersionSize-dwVersionSizeRet), &dwBuffSize) == NO_ERROR) - dwVersionSizeRet += (dwBuffSize+1); - } + if ( !GetParamValue(dwUserAgentFormatted, dwUserAgentFormattedSize, "title", 5, lpszVersion, dwVersionSize, &dwBuffSize)) { + dwVersionSizeRet += dwBuffSize; + *((BYTE*)(lpszVersion+dwVersionSizeRet)) = ' '; + } - // no data extracted, copy raw - if (dwVersionSizeRet == 0) { - dwVersionSizeRet = ((dwUserAgentFormatedSize