diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-10-11 13:40:24 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-10-11 13:40:24 +0000 |
commit | e8cfaff4970726c7f15c0241e0c6b210ead2f0bd (patch) | |
tree | 6ddda89e8756ba7af349a46c9a6f689b68cfb8d9 /protocols/VKontakte | |
parent | 16836ea77582da49b82c9b95332762f7135c76ea (diff) |
VKontakte:
fix for leave chat menuitem on clist contact’s menu
fix for mark messages as read for chat messages
git-svn-id: http://svn.miranda-ng.org/main/trunk@10764 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte')
-rw-r--r-- | protocols/VKontakte/src/vk_chats.cpp | 29 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.cpp | 3 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 1 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_thread.cpp | 7 |
4 files changed, 36 insertions, 4 deletions
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp index 8ddfaa201a..d559450383 100644 --- a/protocols/VKontakte/src/vk_chats.cpp +++ b/protocols/VKontakte/src/vk_chats.cpp @@ -465,6 +465,35 @@ void CVkProto::LogMenuHook(CVkChatInfo *cc, GCHOOK *gch) }
}
+INT_PTR __cdecl CVkProto::OnLeaveChat(WPARAM hContact, LPARAM)
+{
+ debugLogA("CVkProto::OnLeaveChat");
+ ptrT tszChatID(getTStringA(hContact, "ChatRoomID"));
+ if (tszChatID == NULL)
+ return 1;
+
+ CVkChatInfo *cc = GetChatById(tszChatID);
+ if (cc == NULL)
+ return 1;
+
+ if (IDYES == MessageBox(NULL,
+ TranslateT("This chat is going to be destroyed forever with all its contents. This action cannot be undone. Are you sure?"),
+ TranslateT("Warning"), MB_YESNOCANCEL | MB_ICONQUESTION))
+ {
+ CMStringA code;
+ code.Format("var Hist = API.messages.getHistory({\"chat_id\":%d, \"count\":200});"
+ "var countMsg = Hist.count;var itemsMsg = Hist.items@.id; "
+ "while (countMsg > 1) { API.messages.delete({\"message_ids\":itemsMsg});"
+ "Hist=API.messages.getHistory({\"chat_id\":%d, \"count\":200});"
+ "countMsg = Hist.count;itemsMsg = Hist.items@.id;}; return 1;", cc->m_chatid, cc->m_chatid);
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnChatDestroy)
+ << CHAR_PARAM("code", code)
+ << VER_API)->pUserInfo = cc;
+ return 0;
+ }
+ return 1;
+}
+
void CVkProto::OnChatDestroy(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
{
debugLogA("CVkProto::OnChatDestroy %d", reply->resultCode);
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 910c79b0f4..f1706d2659 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -102,9 +102,10 @@ int CVkProto::OnModulesLoaded(WPARAM wParam, LPARAM lParam) gcr.nColors = SIZEOF(sttColors);
gcr.pColors = sttColors;
CallServiceSync(MS_GC_REGISTER, NULL, (LPARAM)&gcr);
-
+ CreateProtoService(PS_LEAVECHAT, &CVkProto::OnLeaveChat);
HookProtoEvent(ME_GC_EVENT, &CVkProto::OnChatEvent);
HookProtoEvent(ME_GC_BUILDMENU, &CVkProto::OnGcMenuHook);
+ // Other hooks
HookProtoEvent(ME_MSG_WINDOWEVENT, &CVkProto::OnProcessSrmmEvent);
HookProtoEvent(ME_DB_EVENT_MARKED_READ, &CVkProto::OnDbEventRead);
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 2aabbe2abe..5381a7b37d 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -445,6 +445,7 @@ private: void OnChatDestroy(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
int __cdecl OnChatEvent(WPARAM, LPARAM);
int __cdecl OnGcMenuHook(WPARAM, LPARAM);
+ INT_PTR __cdecl OnLeaveChat(WPARAM, LPARAM);
void LogMenuHook(CVkChatInfo*, GCHOOK*);
void NickMenuHook(CVkChatInfo*, GCHOOK*);
LPTSTR ChangeChatTopic(CVkChatInfo*);
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index e9e8bb035a..5d36024b34 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -562,15 +562,16 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe ptszBody = mir_tstrdup(CMString(ptszBody) + GetAttachmentDescr(pAttachments));
MCONTACT hContact = FindUser(uid, true);
+ int chat_id = json_as_int(json_get(pMsg, "chat_id"));
+
char szMid[40];
_itoa(mid, szMid, 10);
- if (m_iMarkMessageReadOn == markOnReceive){
+ if ((m_iMarkMessageReadOn == markOnReceive) || (chat_id != 0)){
if (!mids.IsEmpty())
mids.AppendChar(',');
mids.Append(szMid);
}
- int chat_id = json_as_int(json_get(pMsg, "chat_id"));
if (chat_id != 0) {
AppendChatMessage(chat_id, pMsg, false);
continue;
@@ -598,7 +599,7 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe }
}
- if (m_iMarkMessageReadOn == markOnReceive)
+ if (!mids.IsEmpty())
MarkMessagesRead(mids);
}
|