From 9b7b378a1e13a21311718aa7fceb55982442b10d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 26 Jul 2012 07:16:41 +0000 Subject: fix for Miranda NG detection in ICQ git-svn-id: http://svn.miranda-ng.org/main/trunk@1187 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/IcqOscarJ/UI/userinfotab.cpp | 7 +++---- protocols/IcqOscarJ/fam_01service.cpp | 12 ++++++++---- protocols/IcqOscarJ/icq_clients.cpp | 27 ++++++++++++++++++-------- protocols/IcqOscarJ/init.cpp | 35 ++++------------------------------ 4 files changed, 34 insertions(+), 47 deletions(-) diff --git a/protocols/IcqOscarJ/UI/userinfotab.cpp b/protocols/IcqOscarJ/UI/userinfotab.cpp index c5a516d24c..033fdd4a9a 100644 --- a/protocols/IcqOscarJ/UI/userinfotab.cpp +++ b/protocols/IcqOscarJ/UI/userinfotab.cpp @@ -222,9 +222,8 @@ static INT_PTR CALLBACK IcqDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM case PSN_INFOCHANGED: { CIcqProto* ppro = (CIcqProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - - if (!ppro) - break; + if (!ppro) + break; char* szProto; HANDLE hContact = (HANDLE)((LPPSHNOTIFY)lParam)->lParam; @@ -259,7 +258,7 @@ static INT_PTR CALLBACK IcqDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM SetValue(ppro, hwndDlg, IDC_PORT, hContact, (char*)DBVT_WORD, (char*)ppro->wListenPort, SVS_ZEROISUNSPEC); SetValue(ppro, hwndDlg, IDC_VERSION, hContact, (char*)DBVT_WORD, (char*)ICQ_VERSION, SVS_ICQVERSION); - SetValue(ppro, hwndDlg, IDC_MIRVER, hContact, (char*)DBVT_ASCIIZ, MirandaVersionToString(str, TRUE, ICQ_PLUG_VERSION, MIRANDA_VERSION), SVS_ZEROISUNSPEC); + SetValue(ppro, hwndDlg, IDC_MIRVER, hContact, (char*)DBVT_ASCIIZ, MirandaVersionToString(str, TRUE, ICQ_PLUG_VERSION, MIRANDA_VERSION_DWORD), SVS_ZEROISUNSPEC); SetDlgItemTextUtf(hwndDlg, IDC_SUPTIME, ICQTranslateUtfStatic(LPGEN("Member since:"), str, MAX_PATH)); SetValue(ppro, hwndDlg, IDC_SYSTEMUPTIME, hContact, szProto, "MemberTS", SVS_TIMESTAMP); SetValue(ppro, hwndDlg, IDC_STATUS, hContact, (char*)DBVT_WORD, (char*)ppro->m_iStatus, SVS_STATUSID); diff --git a/protocols/IcqOscarJ/fam_01service.cpp b/protocols/IcqOscarJ/fam_01service.cpp index 69d49a7e17..cba344a195 100644 --- a/protocols/IcqOscarJ/fam_01service.cpp +++ b/protocols/IcqOscarJ/fam_01service.cpp @@ -755,11 +755,15 @@ void CIcqProto::setUserInfo() #ifdef DBG_CAPHTML packShortCapability(&packet, 0x0002); // CAP_HTMLMSGS #endif - + packDWord(&packet, 0x4D697261); // Miranda Signature - packDWord(&packet, 0x6E64614D); - packDWord(&packet, MIRANDA_VERSION); - packDWord(&packet, ICQ_PLUG_VERSION); + packDWord(&packet, 0x6E64614E); + + WORD ver[4] = { MIRANDA_VERSION_FILEVERSION }; + packWord(&packet, ver[0]); + packWord(&packet, ver[1]); + packWord(&packet, ver[2]); + packWord(&packet, ver[3]); //MIM/PackName if ( bHasPackName ) { diff --git a/protocols/IcqOscarJ/icq_clients.cpp b/protocols/IcqOscarJ/icq_clients.cpp index 9e82bea7b8..bb1ebb5621 100644 --- a/protocols/IcqOscarJ/icq_clients.cpp +++ b/protocols/IcqOscarJ/icq_clients.cpp @@ -29,8 +29,7 @@ // ----------------------------------------------------------------------------- #include "icqoscar.h" - -const capstr capShortCaps = {0x09, 0x46, 0x00, 0x00, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}; // CAP_AIM_BUDDYICON +const capstr capShortCaps = {0x09, 0x46, 0x00, 0x00, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}; // CAP_AIM_BUDDYICON static const char* makeClientVersion(char *szBuf, const char *szClient, unsigned v1, unsigned v2, unsigned v3, unsigned v4) { @@ -103,6 +102,7 @@ char* MirandaModToString(char* szStr, capstr* capId, int bUnicode, const char* s } const capstr capMirandaIm = {'M', 'i', 'r', 'a', 'n', 'd', 'a', 'M', 0, 0, 0, 0, 0, 0, 0, 0}; +const capstr capMirandaNg = {'M', 'i', 'r', 'a', 'n', 'd', 'a', 'N', 0, 0, 0, 0, 0, 0, 0, 0}; const capstr capIcqJs7 = {'i', 'c', 'q', 'j', ' ', 'S', 'e', 'c', 'u', 'r', 'e', ' ', 'I', 'M', 0, 0}; const capstr capIcqJSin = {'s', 'i', 'n', 'j', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // Miranda ICQJ S!N const capstr capIcqJp = {'i', 'c', 'q', 'p', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; @@ -344,20 +344,18 @@ const char* CIcqProto::detectUserClient(HANDLE hContact, int nIsICQ, WORD wUserC if (nIsICQ && caps) { // check capabilities for client identification - if (capId = MatchCapability(caps, wLen, &capMirandaIm, 8)) - { // new Miranda Signature + if (capId = MatchCapability(caps, wLen, &capMirandaIm, 8)) { + // new Miranda Signature DWORD iver = (*capId)[0xC] << 0x18 | (*capId)[0xD] << 0x10 | (*capId)[0xE] << 8 | (*capId)[0xF]; DWORD mver = (*capId)[0x8] << 0x18 | (*capId)[0x9] << 0x10 | (*capId)[0xA] << 8 | (*capId)[0xB]; szClient = MirandaVersionToString(szClientBuf, dwFT1 == 0x7fffffff, iver, mver); - if (MatchCapability(caps, wLen, &capIcqJs7, 0x4)) - { // detect mod + if (MatchCapability(caps, wLen, &capIcqJs7, 0x4)) { + // detect mod strcat(szClientBuf, " (s7 & sss)"); if (MatchCapability(caps, wLen, &capIcqJs7, 0xE)) - { strcat(szClientBuf, " + SecureIM"); - } } else if ((dwFT1 & 0x7FFFFFFF) == 0x7FFFFFFF) { @@ -370,6 +368,19 @@ const char* CIcqProto::detectUserClient(HANDLE hContact, int nIsICQ, WORD wUserC *bClientId = CLID_MIRANDA; bMirandaIM = TRUE; } + else if (capId = MatchCapability(caps, wLen, &capMirandaNg, 8)) { + WORD v[4]; + BYTE *buf = *capId + 8; + unpackWord(&buf, &v[0]); unpackWord(&buf, &v[1]); unpackWord(&buf, &v[2]); unpackWord(&buf, &v[3]); + mir_snprintf(szClientBuf, MAX_PATH, "Miranda NG ICQ %d.%d.%d.%d", v[0], v[1], v[2], v[3]); + + szClient = szClientBuf; + if ((dwFT1 & 0x7FFFFFFF) == 0x7FFFFFFF && dwFT3 == 0x5AFEC0DE) + strcat(szClientBuf, " + SecureIM"); + + *bClientId = CLID_MIRANDA; + bMirandaIM = TRUE; + } else if (capId = MatchCapability(caps, wLen, &capIcqJs7, 4)) { // detect newer icqj mod szClient = MirandaModToString(szClientBuf, capId, dwFT3 == 0x80000000, "ICQ S7 & SSS"); diff --git a/protocols/IcqOscarJ/init.cpp b/protocols/IcqOscarJ/init.cpp index 89016553ee..2210a6fb0b 100644 --- a/protocols/IcqOscarJ/init.cpp +++ b/protocols/IcqOscarJ/init.cpp @@ -33,8 +33,6 @@ HINSTANCE hInst; int hLangpack; -DWORD MIRANDA_VERSION; - HANDLE hStaticServices[1]; IcqIconHandle hStaticIcons[4]; HANDLE hStaticHooks[1];; @@ -93,37 +91,12 @@ static int OnModulesLoaded( WPARAM, LPARAM ) extern "C" int __declspec(dllexport) Load(void) { - mir_getLP( &pluginInfo ); - // Get Miranda version - MIRANDA_VERSION = (DWORD)CallService(MS_SYSTEM_GETVERSION, 0, 0); - - { // Are we running under unicode Miranda core ? - char szVer[MAX_PATH]; - - CallService(MS_SYSTEM_GETVERSIONTEXT, MAX_PATH, (LPARAM)szVer); - _strlwr(szVer); // make sure it is lowercase - - if (strstrnull(szVer, "alpha") != NULL) - { // Are we running under Alpha Core - MIRANDA_VERSION |= 0x80000000; - } - else if (strstrnull(szVer, "preview") == NULL) - { // for Final Releases of Miranda 0.5+ clear build number - MIRANDA_VERSION &= 0xFFFFFF00; - } - - // Check if _UNICODE matches Miranda's _UNICODE - if (strstrnull(szVer, "unicode") == NULL) - { - char szMsg[MAX_PATH], szCaption[100]; - - MessageBoxUtf(NULL, ICQTranslateUtfStatic("You cannot use Unicode version of ICQ Protocol plug-in with Ansi version of Miranda IM.", szMsg, MAX_PATH), - ICQTranslateUtfStatic("ICQ Plugin", szCaption, 100), MB_OK|MB_ICONWARNING|MB_SETFOREGROUND|MB_TOPMOST); - return 1; // Failure - } - } + // Are we running under unicode Miranda core ? + char szVer[MAX_PATH]; + CallService(MS_SYSTEM_GETVERSIONTEXT, MAX_PATH, (LPARAM)szVer); + _strlwr(szVer); // make sure it is lowercase srand(time(NULL)); _tzset(); -- cgit v1.2.3