diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-09-26 06:03:01 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-09-26 06:03:01 +0000 |
commit | 54cdf9dca636ade5a476d9a056d04c5e37188ace (patch) | |
tree | 0ae7c30e550aea50e12bf11bad079fa6c606d368 /protocols/VKontakte/src/vk_proto.cpp | |
parent | d1981d7b364f8c184143a81e8edcd7d8672386d6 (diff) |
VKontakte:
work with friends.getRequests part 2 – complete
add Authorize and AuthDeny support
git-svn-id: http://svn.miranda-ng.org/main/trunk@10595 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src/vk_proto.cpp')
-rw-r--r-- | protocols/VKontakte/src/vk_proto.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
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)
|