From 54cdf9dca636ade5a476d9a056d04c5e37188ace Mon Sep 17 00:00:00 2001 From: Sergey Bolhovskoy Date: Fri, 26 Sep 2014 06:03:01 +0000 Subject: =?UTF-8?q?VKontakte:=20work=20with=20friends.getRequests=20part?= =?UTF-8?q?=202=20=E2=80=93=20complete=20add=20Authorize=20and=20AuthDeny?= =?UTF-8?q?=20support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.miranda-ng.org/main/trunk@10595 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/vk_proto.cpp | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'protocols/VKontakte/src/vk_proto.cpp') diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 3f19416433..54196d9dff 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -436,9 +436,9 @@ MCONTACT CVkProto::AddToList(int flags, PROTOSEARCHRESULT* psr) if (!uid) return NULL; - MCONTACT hConnact = FindUser(uid, true); + MCONTACT hContact = FindUser(uid, true); RetrieveUserInfo(uid); - return hConnact; + return hContact; } int CVkProto::AuthRequest(MCONTACT hContact,const PROTOCHAR* message) @@ -448,11 +448,12 @@ int CVkProto::AuthRequest(MCONTACT hContact,const PROTOCHAR* message) return 1; bool bIsFriend = getByte(hContact, "Auth", -1)==0; LONG userID = getDword(hContact, "ID", -1); - if (bIsFriend || (userID == -1) || !hContact) + if ((userID == -1) || !hContact) return 1; - TCHAR msg[501]; - _tcsncpy_s(msg, 500, message, _TRUNCATE); + TCHAR msg[501] = {0}; + if (message) + _tcsncpy_s(msg, 500, message, _TRUNCATE); Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/friends.add.json", true, &CVkProto::OnReceiveAuthRequest) << INT_PARAM("user_id", userID) @@ -471,10 +472,9 @@ void CVkProto::OnReceiveAuthRequest(NETLIBHTTPREQUEST *reply, AsyncHttpRequest * JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot); if (pResponse != NULL) { int iRet = json_as_int(pResponse); - if (iRet == 2){ - setByte(param->hContact, "Auth", 0); - MsgPopup(param->hContact, TranslateT("User added as friend"), _T("")); - } + setByte(param->hContact, "Auth", 0); + if (iRet == 2) + MsgPopup(param->hContact, TranslateT("User added as friend"), _T("")); } else{ switch (param->iCount){ @@ -495,12 +495,20 @@ void CVkProto::OnReceiveAuthRequest(NETLIBHTTPREQUEST *reply, AsyncHttpRequest * int CVkProto::Authorize(HANDLE hDbEvent) { - return 1; + MCONTACT hContact = MContactFromDbEvent(hDbEvent); + if (hContact == -1) + return 1; + + return AuthRequest(hContact, NULL); } int CVkProto::AuthDeny(HANDLE hDbEvent, const PROTOCHAR *reason) { - return 1; + MCONTACT hContact = MContactFromDbEvent(hDbEvent); + if (hContact == -1) + return 1; + + return SvcDeleteFriend(hContact,(LPARAM)true); } int CVkProto::UserIsTyping(MCONTACT hContact, int type) -- cgit v1.2.3