From 79f5521815e208cb694bbc814ee88429e20328b6 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Tue, 12 Aug 2014 19:29:57 +0000 Subject: Tox: getting friend request git-svn-id: http://svn.miranda-ng.org/main/trunk@10170 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_proto.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'protocols/Tox/src/tox_proto.cpp') diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index ee4c60b917..9029c54a16 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -47,7 +47,26 @@ MCONTACT __cdecl CToxProto::AddToList(int flags, PROTOSEARCHRESULT* psr) MCONTACT __cdecl CToxProto::AddToListByEvent(int flags, int iContact, HANDLE hDbEvent) { return 0; } -int __cdecl CToxProto::Authorize(HANDLE hDbEvent) { return 0; } +int __cdecl CToxProto::Authorize(HANDLE hDbEvent) +{ + if (this->IsOnline() && hDbEvent) + { + MCONTACT hContact = GetContactFromAuthEvent(hDbEvent); + if (hContact == INVALID_CONTACT_ID) + return 1; + + std::string toxId = getStringA(hContact, TOX_SETTING_ID); + std::vector clientId = HexStringToData(toxId); + + if (tox_add_friend_norequest(tox, &clientId[0]) >= 0) + { + return 0; + } + } + + return 1; +} + int __cdecl CToxProto::AuthDeny(HANDLE hDbEvent, const PROTOCHAR* szReason) { return 0; } int __cdecl CToxProto::AuthRecv(MCONTACT hContact, PROTORECVEVENT*) { return 0; } int __cdecl CToxProto::AuthRequest(MCONTACT hContact, const PROTOCHAR* szMessage) { return 0; } @@ -64,11 +83,11 @@ DWORD_PTR __cdecl CToxProto::GetCaps(int type, MCONTACT hContact) switch(type) { case PFLAGNUM_1: - return PF1_IM | PF1_AUTHREQ | PF1_BASICSEARCH | PF1_ADDSEARCHRES; + return PF1_IM | PF1_AUTHREQ; case PFLAGNUM_2: return PF2_ONLINE | PF2_SHORTAWAY | PF2_LIGHTDND; case PFLAGNUM_4: - return PF4_IMSENDUTF | PF4_SUPPORTTYPING; + return PF4_IMSENDUTF | PF4_NOAUTHDENYREASON; case PFLAG_UNIQUEIDTEXT: return (INT_PTR)"Tox ID"; case PFLAG_UNIQUEIDSETTING: -- cgit v1.2.3