From 66357371399956ad19ab667d3c2d49bfc7ea0095 Mon Sep 17 00:00:00 2001 From: Alexander Gluzsky Date: Sun, 29 Jul 2012 18:49:17 +0000 Subject: ICQ: ported icq custom capabilities api from icq plus mod NEW_GPG: many memmory corruption fixes NEW_GPG: improoved auto key exchange git-svn-id: http://svn.miranda-ng.org/main/trunk@1243 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/IcqOscarJ/fam_01service.cpp | 8 ++++++++ protocols/IcqOscarJ/fam_02location.cpp | 18 +++++++++++++++++ protocols/IcqOscarJ/icq_proto.cpp | 8 ++++++++ protocols/IcqOscarJ/icq_proto.h | 4 ++++ protocols/IcqOscarJ/icqosc_svcs.cpp | 35 ++++++++++++++++++++++++++++++++++ protocols/IcqOscarJ/icqoscar.h | 5 +++++ 6 files changed, 78 insertions(+) mode change 100644 => 100755 protocols/IcqOscarJ/fam_01service.cpp mode change 100644 => 100755 protocols/IcqOscarJ/fam_02location.cpp mode change 100644 => 100755 protocols/IcqOscarJ/icq_proto.cpp mode change 100644 => 100755 protocols/IcqOscarJ/icq_proto.h mode change 100644 => 100755 protocols/IcqOscarJ/icqosc_svcs.cpp mode change 100644 => 100755 protocols/IcqOscarJ/icqoscar.h (limited to 'protocols') diff --git a/protocols/IcqOscarJ/fam_01service.cpp b/protocols/IcqOscarJ/fam_01service.cpp old mode 100644 new mode 100755 index cba344a195..58860481ca --- a/protocols/IcqOscarJ/fam_01service.cpp +++ b/protocols/IcqOscarJ/fam_01service.cpp @@ -683,6 +683,8 @@ void CIcqProto::setUserInfo() wAdditionalData += 16; #endif + wAdditionalData += CustomCapList.size() * 16; + //MIM/PackName bool bHasPackName = false; DBVARIANT dbv; @@ -771,6 +773,12 @@ void CIcqProto::setUserInfo() ICQFreeVariant(&dbv); } + if(!CustomCapList.empty()) + { + for(std::list::iterator it = CustomCapList.begin(), end = CustomCapList.end(); it != end; ++it) + packBuffer(&packet, (BYTE*)(*it)->caps, 0x10); + } + sendServPacket(&packet); } diff --git a/protocols/IcqOscarJ/fam_02location.cpp b/protocols/IcqOscarJ/fam_02location.cpp old mode 100644 new mode 100755 index b7f0163917..2398cf18c6 --- a/protocols/IcqOscarJ/fam_02location.cpp +++ b/protocols/IcqOscarJ/fam_02location.cpp @@ -182,6 +182,24 @@ void CIcqProto::handleLocationUserInfoReply(BYTE* buf, WORD wLen, DWORD dwCookie char *szEncoding = NULL; // Get Profile encoding TLV + + pTLV = pChain->getTLV(0x05, 1); + if (pTLV && (pTLV->wLen > 0)) + { + // store client capabilities + BYTE* capBuf = pTLV->pData; + WORD capLen = pTLV->wLen; + DBCONTACTWRITESETTING dbcws; + dbcws.value.type = DBVT_BLOB; + dbcws.value.cpbVal = capLen; + dbcws.value.pbVal = capBuf; + dbcws.szModule = m_szModuleName; + dbcws.szSetting = "CapBuf"; + CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)hContact, (LPARAM)&dbcws); + } + else + deleteSetting(hContact, "CapBuf"); + pTLV = pChain->getTLV(0x01, 1); if (pTLV && (pTLV->wLen >= 1)) { diff --git a/protocols/IcqOscarJ/icq_proto.cpp b/protocols/IcqOscarJ/icq_proto.cpp old mode 100644 new mode 100755 index 69b8ed8e61..7df3c037d3 --- a/protocols/IcqOscarJ/icq_proto.cpp +++ b/protocols/IcqOscarJ/icq_proto.cpp @@ -126,6 +126,7 @@ cheekySearchId( -1 ) CreateResidentSetting("AwayTS"); CreateResidentSetting("LogonTS"); CreateResidentSetting("DCStatus"); + CreateResidentSetting("CapBuf"); //capabilities bufer CreateResidentSetting(DBSETTING_STATUS_NOTE_TIME); CreateResidentSetting(DBSETTING_STATUS_MOOD); @@ -164,6 +165,11 @@ cheekySearchId( -1 ) CreateProtoService(MS_REVOKE_AUTH, &CIcqProto::RevokeAuthorization); CreateProtoService(MS_XSTATUS_SHOWDETAILS, &CIcqProto::ShowXStatusDetails); + + // Custom caps + CreateProtoService(PS_ICQ_ADDCAPABILITY, &CIcqProto::IcqAddCapability); + CreateProtoService(PS_ICQ_CHECKCAPABILITY, &CIcqProto::IcqCheckCapability); + HookProtoEvent(ME_SKIN2_ICONSCHANGED, &CIcqProto::OnReloadIcons); @@ -270,6 +276,8 @@ CIcqProto::~CIcqProto() UninitContactsCache(); + CustomCapList.clear(); + SAFE_DELETE(&m_ratesMutex); SAFE_DELETE(&servlistMutex); diff --git a/protocols/IcqOscarJ/icq_proto.h b/protocols/IcqOscarJ/icq_proto.h old mode 100644 new mode 100755 index 7293763d65..ec1eabb338 --- a/protocols/IcqOscarJ/icq_proto.h +++ b/protocols/IcqOscarJ/icq_proto.h @@ -805,6 +805,10 @@ struct CIcqProto : public PROTO_INTERFACE, public MZeroedObject HANDLE AddToListByUID(const char *szUID, DWORD dwFlags); void ICQAddRecvEvent(HANDLE hContact, WORD wType, PROTORECVEVENT* pre, DWORD cbBlob, PBYTE pBlob, DWORD flags); + INT_PTR __cdecl IcqAddCapability(WPARAM wParam, LPARAM lParam); + INT_PTR __cdecl IcqCheckCapability(WPARAM wParam, LPARAM lParam); + + std::list CustomCapList; //----| icq_uploadui.cpp |------------------------------------------------------------ void ShowUploadContactsDialog(void); diff --git a/protocols/IcqOscarJ/icqosc_svcs.cpp b/protocols/IcqOscarJ/icqosc_svcs.cpp old mode 100644 new mode 100755 index 15a8b17013..ee6dd1731c --- a/protocols/IcqOscarJ/icqosc_svcs.cpp +++ b/protocols/IcqOscarJ/icqosc_svcs.cpp @@ -727,6 +727,41 @@ void CIcqProto::ICQAddRecvEvent(HANDLE hContact, WORD wType, PROTORECVEVENT* pre AddEvent(hContact, wType, pre->timestamp, flags, cbBlob, pBlob); } +INT_PTR __cdecl CIcqProto::IcqAddCapability(WPARAM wParam, LPARAM lParam) +{ + ICQ_CUSTOMCAP *icqCustomCapIn = (ICQ_CUSTOMCAP *)lParam; + ICQ_CUSTOMCAP *icqCustomCap = (ICQ_CUSTOMCAP *)malloc(sizeof(ICQ_CUSTOMCAP)); + memcpy(icqCustomCap, icqCustomCapIn, sizeof(ICQ_CUSTOMCAP)); + CustomCapList.push_back(icqCustomCap); +// MessageBoxA(NULL, ((ICQ_CUSTOMCAP *)(lstCustomCaps->items[lstCustomCaps->realCount-1]))->name, "custom cap", MB_OK); + return 0; +} + + +INT_PTR __cdecl CIcqProto::IcqCheckCapability(WPARAM wParam, LPARAM lParam) +{ + int res = 0; + DBCONTACTGETSETTING dbcgs; + DBVARIANT dbvariant; + HANDLE hContact = (HANDLE)wParam; + ICQ_CUSTOMCAP *icqCustomCap = (ICQ_CUSTOMCAP *)lParam; + dbcgs.pValue = &dbvariant; + dbcgs.szModule = m_szModuleName; + dbcgs.szSetting = "CapBuf"; + + CallService(MS_DB_CONTACT_GETSETTING, (WPARAM)hContact, (LPARAM)&dbcgs); + + if (dbvariant.type == DBVT_BLOB) + { + res = MatchCapability(dbvariant.pbVal, dbvariant.cpbVal, (const capstr*)&icqCustomCap->caps, 0x10)?1:0; // FIXME: Why icqCustomCap->caps is not capstr? + } + + CallService(MS_DB_CONTACT_FREEVARIANT,0,(LPARAM)(DBVARIANT*)&dbvariant); + + return res; +} + + ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/protocols/IcqOscarJ/icqoscar.h b/protocols/IcqOscarJ/icqoscar.h old mode 100644 new mode 100755 index a004e6793f..ef0e32a6fd --- a/protocols/IcqOscarJ/icqoscar.h +++ b/protocols/IcqOscarJ/icqoscar.h @@ -48,6 +48,10 @@ #include #include #include + +//C++ +#include + #ifndef _DEBUG #ifdef _MSC_VER #include @@ -115,6 +119,7 @@ #include "channels.h" #include "families.h" #include "m_icq.h" +#include "m_icqplus.h" #include "icq_advsearch.h" #include "log.h" -- cgit v1.2.3