diff options
author | George Hazan <george.hazan@gmail.com> | 2012-09-21 19:27:41 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-09-21 19:27:41 +0000 |
commit | 22bdf4d623a3e37f8b32dbcca437df37906a9ae5 (patch) | |
tree | 2eded34f50b161620505480aae52073dfe128a70 /protocols/MRA | |
parent | 6754be273927935a574fa2b60b9ac1446966e55f (diff) |
fix for the version detection
git-svn-id: http://svn.miranda-ng.org/main/trunk@1627 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/MRA')
-rw-r--r-- | protocols/MRA/Mra.h | 2 | ||||
-rw-r--r-- | protocols/MRA/MraProto.h | 2 | ||||
-rw-r--r-- | protocols/MRA/MraSendCommand.cpp | 8 | ||||
-rw-r--r-- | protocols/MRA/Mra_functions.cpp | 74 | ||||
-rw-r--r-- | protocols/MRA/Mra_proto.cpp | 10 |
5 files changed, 46 insertions, 50 deletions
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<dwVersionSize)? dwUserAgentFormatedSize:dwVersionSize);
- memmove(lpszVersion, lpszUserAgentFormated, dwVersionSizeRet);
- }
+ if ( !GetParamValue(dwUserAgentFormatted, dwUserAgentFormattedSize, "version", 7, (lpszVersion+dwVersionSizeRet+1), (dwVersionSize-dwVersionSizeRet), &dwBuffSize)) {
+ dwVersionSizeRet += (dwBuffSize+1);
+ *((BYTE*)(lpszVersion+dwVersionSizeRet)) = '.';
+ if ( !GetParamValue(dwUserAgentFormatted, dwUserAgentFormattedSize, "build", 5, (lpszVersion+dwVersionSizeRet+1), (dwVersionSize-dwVersionSizeRet), &dwBuffSize))
+ dwVersionSizeRet += (dwBuffSize+1);
+ }
- if (pdwVersionSizeRet)
- *pdwVersionSizeRet = dwVersionSizeRet;
+ // no data extracted, copy raw
+ if (dwVersionSizeRet == 0) {
+ dwVersionSizeRet = (dwUserAgentFormattedSize < dwVersionSize) ? dwUserAgentFormattedSize : dwVersionSize;
+ memmove(lpszVersion, dwUserAgentFormatted, dwVersionSizeRet);
}
- return NO_ERROR;
+
+ if (pdwVersionSizeRet)
+ *pdwVersionSizeRet = dwVersionSizeRet;
+
+ return 0;
}
DWORD MraAddrListGetFromBuff(LPSTR lpszAddreses, size_t dwAddresesSize, MRA_ADDR_LIST *pmalAddrList)
diff --git a/protocols/MRA/Mra_proto.cpp b/protocols/MRA/Mra_proto.cpp index 638f61d8f0..710672d458 100644 --- a/protocols/MRA/Mra_proto.cpp +++ b/protocols/MRA/Mra_proto.cpp @@ -396,7 +396,7 @@ DWORD CMraProto::MraCommandDispatcher(mrim_packet_header_t *pmaHeader, DWORD *pd WCHAR wszStatusTitle[STATUS_TITLE_MAX+4], wszStatusDesc[STATUS_DESC_MAX+4];
DWORD dwStatus, dwXStatus, dwXStatusMir, dwFutureFlags;
LPWSTR lpwszStatusTitle, lpwszStatusDesc;
- size_t dwEMailSize, dwSelfVersionSize, dwStatusTitleSize, dwStatusDescSize, dwUserAgentFormatedSize;
+ size_t dwEMailSize, dwSelfVersionSize, dwStatusTitleSize, dwStatusDescSize, dwUserAgentFormattedSize;
dwXStatusMir = m_iXStatus;
dwStatus = GetMraStatusFromMiradaStatus(m_iDesiredStatus, dwXStatusMir, &dwXStatus);
@@ -425,16 +425,16 @@ DWORD CMraProto::MraCommandDispatcher(mrim_packet_header_t *pmaHeader, DWORD *pd }
MraGetSelfVersionString(szSelfVersionString, SIZEOF(szSelfVersionString), &dwSelfVersionSize);
- if ( mraGetStaticStringA(NULL, "MirVerCustom", szUserAgentFormated, SIZEOF(szUserAgentFormated), &dwUserAgentFormatedSize) == FALSE) {
- dwUserAgentFormatedSize = mir_snprintf(szUserAgentFormated, SIZEOF(szUserAgentFormated),
- "client=\"magent\" name=\"Miranda IM\" title=\"%s\" version=\"777.%lu.%lu.%lu\" build=\"%lu\" protocol=\"%lu.%lu\"",
+ if ( mraGetStaticStringA(NULL, "MirVerCustom", szUserAgentFormated, SIZEOF(szUserAgentFormated), &dwUserAgentFormattedSize) == FALSE) {
+ dwUserAgentFormattedSize = mir_snprintf(szUserAgentFormated, SIZEOF(szUserAgentFormated),
+ "client=\"magent\" name=\"Miranda NG\" title=\"%s\" version=\"777.%lu.%lu.%lu\" build=\"%lu\" protocol=\"%lu.%lu\"",
szSelfVersionString, __FILEVERSION_STRING, PROTO_VERSION_MAJOR, PROTO_VERSION_MINOR);
}
dwFutureFlags = ((mraGetByte(NULL, "RTFReceiveEnable", MRA_DEFAULT_RTF_RECEIVE_ENABLE)? FEATURE_FLAG_RTF_MESSAGE:0)|MRA_FEATURE_FLAGS);
if (mraGetStaticStringA(NULL, "e-mail", szEMail, SIZEOF(szEMail), &dwEMailSize))
- MraLogin2W(szEMail, dwEMailSize, (LPSTR)szBuff, dwStringSize, dwStatus, lpcszStatusUri[dwXStatus], lstrlenA(lpcszStatusUri[dwXStatus]), lpwszStatusTitle, dwStatusTitleSize, lpwszStatusDesc, dwStatusDescSize, dwFutureFlags, szUserAgentFormated, dwUserAgentFormatedSize, szSelfVersionString, dwSelfVersionSize);
+ MraLogin2W(szEMail, dwEMailSize, (LPSTR)szBuff, dwStringSize, dwStatus, lpcszStatusUri[dwXStatus], lstrlenA(lpcszStatusUri[dwXStatus]), lpwszStatusTitle, dwStatusTitleSize, lpwszStatusDesc, dwStatusDescSize, dwFutureFlags, szUserAgentFormated, dwUserAgentFormattedSize, szSelfVersionString, dwSelfVersionSize);
else
*pbContinue = FALSE;
|