summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Bolhovskoy <elzorfox@ya.ru>2014-09-25 06:03:04 +0000
committerSergey Bolhovskoy <elzorfox@ya.ru>2014-09-25 06:03:04 +0000
commit08a1f78e2cede8d75667dd321ff8589d0b7ab5a8 (patch)
tree9351711f167207057f9eb2ef7d111320169f816a
parenta7b73722232516aa22a8c00621dec72d3c18a93f (diff)
VKontakte: delete from friend list support
git-svn-id: http://svn.miranda-ng.org/main/trunk@10577 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp9
-rw-r--r--protocols/VKontakte/src/vk_proto.h4
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp47
3 files changed, 60 insertions, 0 deletions
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index 6d1a51c6bf..26d114c810 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -114,6 +114,7 @@ void CVkProto::InitMenus()
CreateProtoService(PS_VISITPROFILE, &CVkProto::SvcVisitProfile);
CreateProtoService(PS_CREATECHAT, &CVkProto::SvcCreateChat);
CreateProtoService(PS_ADDASFRIEND, &CVkProto::SvcAddAsFriend);
+ CreateProtoService(PS_DELETEFRIEND, &CVkProto::SvcDeleteFriend);
CLISTMENUITEM mi = { sizeof(mi) };
char szService[100];
@@ -158,6 +159,13 @@ void CVkProto::InitMenus()
mi.pszService = szService;
g_hContactMenuItems[CMI_ADDASFRIEND] = Menu_AddContactMenuItem(&mi);
+ mir_snprintf(szService, sizeof(szService), "%s%s", m_szModuleName, PS_DELETEFRIEND);
+ mi.position = -200001000 + CMI_DELETEFRIEND;
+ mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_DELETE);
+ mi.ptszName = LPGENT("Delete from friend list");
+ mi.pszService = szService;
+ g_hContactMenuItems[CMI_DELETEFRIEND] = Menu_AddContactMenuItem(&mi);
+
}
int CVkProto::OnPreBuildContactMenu(WPARAM hContact, LPARAM)
@@ -167,6 +175,7 @@ int CVkProto::OnPreBuildContactMenu(WPARAM hContact, LPARAM)
Menu_ShowItem(g_hContactMenuItems[CMI_GETALLSERVERHISTORY], !isChatRoom(hContact));
Menu_ShowItem(g_hContactMenuItems[CMI_VISITPROFILE], !isChatRoom(hContact));
Menu_ShowItem(g_hContactMenuItems[CMI_ADDASFRIEND], !isFriend);
+ Menu_ShowItem(g_hContactMenuItems[CMI_DELETEFRIEND], isFriend);
return 0;
}
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index a9d19234ae..dc6d3bd8d4 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define PS_GETALLSERVERHISTORY "/GetAllServerHystory"
#define PS_VISITPROFILE "/VisitProfile"
#define PS_ADDASFRIEND "/AddAsFriend"
+#define PS_DELETEFRIEND "/DeleteFriend"
#define MAXHISTORYMIDSPERONE 200
struct CVkProto;
@@ -200,6 +201,7 @@ struct CVkProto : public PROTO<CVkProto>
INT_PTR __cdecl SvcVisitProfile(WPARAM hContact, LPARAM);
INT_PTR __cdecl SvcAddAsFriend(WPARAM hContact, LPARAM);
+ INT_PTR __cdecl SvcDeleteFriend(WPARAM hContact, LPARAM);
INT_PTR __cdecl SvcGetAllServerHistory(WPARAM hContact, LPARAM);
void InitMenus();
void UnInitMenus();
@@ -239,6 +241,7 @@ struct CVkProto : public PROTO<CVkProto>
void RetrievePollingInfo();
void OnReceivePollingInfo(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
void OnReceiveAuthRequest(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
+ void OnReceiveDeleteFriend(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
void __cdecl PollingThread(void*);
int PollServer();
@@ -271,6 +274,7 @@ private:
CMI_GETALLSERVERHISTORY,
CMI_VISITPROFILE,
CMI_ADDASFRIEND,
+ CMI_DELETEFRIEND,
CMI_COUNT
};
enum ProtoMenuIndexes {
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index b577111bf5..1f4373fbd5 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -850,6 +850,53 @@ INT_PTR __cdecl CVkProto::SvcAddAsFriend(WPARAM hContact, LPARAM)
return 0;
}
+INT_PTR __cdecl CVkProto::SvcDeleteFriend(WPARAM hContact, LPARAM)
+{
+ debugLogA("CVkProto::SvcDeleteFriend");
+ LONG userID = getDword(hContact, "ID", -1);
+ if (!IsOnline() ||(userID == -1))
+ return 1;
+
+ CMString formatstr = TranslateT("Are you sure to delete %s from your friend list?"),
+ ptszNick = db_get_tsa(hContact, m_szModuleName, "Nick"),
+ ptszMsg;
+
+ ptszMsg.AppendFormat(formatstr, ptszNick.IsEmpty() ? TranslateT("(Unknown contact)") : ptszNick);
+ if (IDNO == MessageBox(NULL, ptszMsg.GetBuffer(), TranslateT("Attention!"), MB_ICONWARNING | MB_YESNO))
+ return 1;
+
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/friends.delete.json", true, &CVkProto::OnReceiveDeleteFriend)
+ << INT_PARAM("user_id", userID)
+ << VER_API)->pUserInfo = new CVkSendMsgParam(hContact);
+
+ return 0;
+}
+
+void CVkProto::OnReceiveDeleteFriend(NETLIBHTTPREQUEST* reply, AsyncHttpRequest* pReq)
+{
+ CVkSendMsgParam *param = (CVkSendMsgParam*) pReq->pUserInfo;
+ debugLogA("CVkProto::OnReceiveDeleteFriend %d", reply->resultCode);
+ if (reply->resultCode == 200){
+ JSONROOT pRoot;
+ JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot);
+ if (pResponse != NULL) {
+ int iRet = json_as_int(pResponse);
+ switch (iRet){
+ case 1:
+ MsgPopup(param->hContact, TranslateT("User was deleted from your friend list"), _T(""));
+ break;
+ case 2:
+ MsgPopup(param->hContact, TranslateT("Friend request from the user declined"), _T(""));
+ break;
+ case 3:
+ MsgPopup(param->hContact, TranslateT("Friend request suggestion for the user deleted"), _T(""));
+ break;
+ }
+ db_unset(param->hContact, m_szModuleName, "friend");
+ }
+ }
+ delete param;
+}
INT_PTR __cdecl CVkProto::SvcVisitProfile(WPARAM hContact, LPARAM)
{