summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorElzorFox <elzorfox@ya.ru>2024-04-19 12:50:35 +0500
committerElzorFox <elzorfox@ya.ru>2024-04-19 12:50:35 +0500
commitc17216f6a79994adc290a93846c25c4713754d3e (patch)
tree373059ab71338c6aaf198705bdd411d7d62f63fb /protocols
parent0335de2d5f5621c70db4eaa0abf97ec0d3fa7ead (diff)
VKontakte:
db_event_delivered support fix server id for groupchat message code optimization and clean add ‘reload messages’ menu item in NS context menu version bump
Diffstat (limited to 'protocols')
-rw-r--r--protocols/VKontakte/res/reload.icobin0 -> 3262 bytes
-rw-r--r--protocols/VKontakte/res/resource.rc6
-rw-r--r--protocols/VKontakte/src/misc.cpp3
-rw-r--r--protocols/VKontakte/src/resource.h3
-rw-r--r--protocols/VKontakte/src/version.h2
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp20
-rw-r--r--protocols/VKontakte/src/vk_files.cpp12
-rw-r--r--protocols/VKontakte/src/vk_messages.cpp45
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp41
-rw-r--r--protocols/VKontakte/src/vk_proto.h4
10 files changed, 81 insertions, 55 deletions
diff --git a/protocols/VKontakte/res/reload.ico b/protocols/VKontakte/res/reload.ico
new file mode 100644
index 0000000000..df2f388ffe
--- /dev/null
+++ b/protocols/VKontakte/res/reload.ico
Binary files differ
diff --git a/protocols/VKontakte/res/resource.rc b/protocols/VKontakte/res/resource.rc
index c57615afb4..932fd654d2 100644
--- a/protocols/VKontakte/res/resource.rc
+++ b/protocols/VKontakte/res/resource.rc
@@ -51,6 +51,8 @@ IDI_MARKMESSAGESASREAD ICON "markread.ico"
IDI_FORWARD ICON "forward.ico"
+IDI_RELOADMESSAGE ICON "reload.ico"
+
/////////////////////////////////////////////////////////////////////////////
//
@@ -182,7 +184,7 @@ EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
CONTROL "Support BBC for NewStory",IDC_BBC_NEWSTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,10,278,10
- GROUPBOX "[img] BBCode support for image",IDC_STATIC,13,20,280,33,WS_GROUP
+ GROUPBOX "[img] BBCode support for image",IDC_STATIC,13,20,280,33,WS_GROUP
CONTROL "off",IDC_IMG_OFF,"Button",BS_AUTORADIOBUTTON,21,29,129,10
CONTROL "for original size images",IDC_IMG_FULLSIZE,"Button",BS_AUTORADIOBUTTON,21,40,129,10
CONTROL "for preview max 130*130 px",IDC_IMG_130,"Button",BS_AUTORADIOBUTTON,163,29,127,10
@@ -209,7 +211,7 @@ BEGIN
CONTROL "Add message link to messages with attachments",IDC_ADD_MES_LINK_MES_ATT,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,186,278,10
CONTROL "Add original message version in edited message",IDC_ADD_ORIG_VER_IN_EDITED_MES,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,197,278,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,197,278,10
END
IDD_OPT_FEEDS DIALOGEX 0, 0, 304, 232
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index 88c3fdde0e..e568ea9c04 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -63,7 +63,8 @@ static IconItem iconList[] =
{ LPGEN("Status icon"), "status", IDI_STATUS },
{ LPGEN("Wall message icon"), "wall", IDI_WALL },
{ LPGEN("Mark messages as read icon"), "markread", IDI_MARKMESSAGESASREAD },
- { LPGEN("Forward icon"), "forward", IDI_FORWARD }
+ { LPGEN("Forward icon"), "forward", IDI_FORWARD },
+ { LPGEN("Reload messages icon"), "reload", IDI_RELOADMESSAGE }
};
void InitIcons()
diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h
index 3d2a2211d0..a846e8968d 100644
--- a/protocols/VKontakte/src/resource.h
+++ b/protocols/VKontakte/src/resource.h
@@ -27,6 +27,7 @@
#define IDD_CONTACTDELETE 123
#define IDD_VKUSERFORM 124
#define IDI_FORWARD 126
+#define IDI_RELOADMESSAGE 130
#define IDC_LOGIN 1001
#define IDC_PASSWORD 1002
#define IDC_URL 1003
@@ -142,7 +143,7 @@
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
-#define _APS_NEXT_RESOURCE_VALUE 127
+#define _APS_NEXT_RESOURCE_VALUE 131
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1121
#define _APS_NEXT_SYMED_VALUE 101
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h
index 28f3eb1c43..30c7a10457 100644
--- a/protocols/VKontakte/src/version.h
+++ b/protocols/VKontakte/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 16
-#define __BUILD_NUM 5
+#define __BUILD_NUM 6
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp
index ce8af5ae93..13cf9f7b73 100644
--- a/protocols/VKontakte/src/vk_chats.cpp
+++ b/protocols/VKontakte/src/vk_chats.cpp
@@ -680,26 +680,6 @@ int CVkProto::OnChatEvent(WPARAM, LPARAM lParam)
return 1;
}
-void CVkProto::OnSendChatMsg(MHttpResponse *reply, AsyncHttpRequest *pReq)
-{
- debugLogA("CVkProto::OnSendChatMsg %d", reply->resultCode);
- int iResult = ACKRESULT_FAILED;
- if (reply->resultCode == 200) {
- JSONNode jnRoot;
- CheckJsonResponse(pReq, reply, jnRoot);
- iResult = ACKRESULT_SUCCESS;
- }
- if (!pReq->pUserInfo)
- return;
-
- CVkFileUploadParam *fup = (CVkFileUploadParam *)pReq->pUserInfo;
- ProtoBroadcastAck(fup->hContact, ACKTYPE_FILE, iResult, (HANDLE)(fup));
- if (!pReq->bNeedsRestart || m_bTerminated) {
- delete fup;
- pReq->pUserInfo = nullptr;
- }
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
LPTSTR CVkProto::ChangeChatTopic(CVkChatInfo *cc)
diff --git a/protocols/VKontakte/src/vk_files.cpp b/protocols/VKontakte/src/vk_files.cpp
index c742ec78cd..d5d13b5ba8 100644
--- a/protocols/VKontakte/src/vk_files.cpp
+++ b/protocols/VKontakte/src/vk_files.cpp
@@ -473,7 +473,7 @@ void CVkProto::OnReciveUploadFile(MHttpResponse *reply, AsyncHttpRequest *pReq)
return;
}
- AsyncHttpRequest *pMsgReq;
+ AsyncHttpRequest *pMsgReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true, &CVkProto::OnSendMessage, AsyncHttpRequest::rpHigh);
if (isChatRoom(fup->hContact)) {
CVkChatInfo *cc = GetChatByContact(fup->hContact);
@@ -482,7 +482,6 @@ void CVkProto::OnReciveUploadFile(MHttpResponse *reply, AsyncHttpRequest *pReq)
return;
}
- pMsgReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true, &CVkProto::OnSendChatMsg, AsyncHttpRequest::rpHigh);
pMsgReq << INT_PARAM("chat_id", cc->m_iChatId);
pMsgReq->pUserInfo = pReq->pUserInfo;
@@ -494,15 +493,16 @@ void CVkProto::OnReciveUploadFile(MHttpResponse *reply, AsyncHttpRequest *pReq)
return;
}
- pMsgReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true, &CVkProto::OnSendMessage, AsyncHttpRequest::rpHigh);
pMsgReq << INT_PARAM("peer_id", iUserId);
pMsgReq->pUserInfo = new CVkSendMsgParam(fup->hContact, fup);
}
ULONG uMsgId = ::InterlockedIncrement(&m_iMsgId);
- pMsgReq << WCHAR_PARAM("message", fup->wszDesc) << WCHAR_PARAM("attachment", Attachment);
- pMsgReq << INT_PARAM("random_id", ((long)time(0)) * 100 + uMsgId % 100);
- pMsgReq->AddHeader("Content-Type", "application/x-www-form-urlencoded");
+ pMsgReq
+ << WCHAR_PARAM("message", fup->wszDesc)
+ << WCHAR_PARAM("attachment", Attachment)
+ << INT_PARAM("random_id", ((long)time(0)) * 100 + uMsgId % 100);
+ pMsgReq->AddHeader("Content-Type", "application/x-www-form-urlencoded");
Push(pMsgReq);
} \ No newline at end of file
diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp
index b77cc65629..5ce9ad0b1e 100644
--- a/protocols/VKontakte/src/vk_messages.cpp
+++ b/protocols/VKontakte/src/vk_messages.cpp
@@ -84,8 +84,14 @@ int CVkProto::ForwardMsg(MCONTACT hContact, std::vector<MEVENT>& vForvardEvents,
}
ULONG uMsgId = ::InterlockedIncrement(&m_iMsgId);
- AsyncHttpRequest* pReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true,
- bIsChat ? &CVkProto::OnSendChatMsg : &CVkProto::OnSendMessage, AsyncHttpRequest::rpHigh);
+ AsyncHttpRequest* pReq = new AsyncHttpRequest(
+ this,
+ REQUEST_POST,
+ "/method/messages.send.json",
+ true,
+ &CVkProto::OnSendMessage,
+ AsyncHttpRequest::rpHigh
+ );
pReq
<< INT_PARAM(bIsChat ? "chat_id" : "peer_id", iUserId)
@@ -107,12 +113,10 @@ int CVkProto::ForwardMsg(MCONTACT hContact, std::vector<MEVENT>& vForvardEvents,
}
}
- if (!bIsChat)
- pReq->pUserInfo = new CVkSendMsgParam(hContact, uMsgId);
-
+ pReq->pUserInfo = new CVkSendMsgParam(hContact, uMsgId);
Push(pReq);
- if (!m_vkOptions.bServerDelivery && !bIsChat)
+ if (!m_vkOptions.bServerDelivery)
ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)uMsgId);
if (vForvardEvents.size() > VK_MAX_FORWARD_MESSAGES) {
@@ -145,9 +149,19 @@ int CVkProto::SendMsg(MCONTACT hContact, MEVENT hReplyEvent, const char *szMsg)
ptrA pszRetMsg(GetStickerId(szMsg, StickerId));
ULONG uMsgId = ::InterlockedIncrement(&m_iMsgId);
- AsyncHttpRequest *pReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true,
- bIsChat ? &CVkProto::OnSendChatMsg : &CVkProto::OnSendMessage, AsyncHttpRequest::rpHigh);
- pReq << INT_PARAM(bIsChat ? "chat_id" : "peer_id", iUserId) << INT_PARAM("random_id", ((long)time(0)) * 100 + uMsgId % 100);
+ AsyncHttpRequest *pReq = new AsyncHttpRequest(
+ this,
+ REQUEST_POST,
+ "/method/messages.send.json",
+ true,
+ &CVkProto::OnSendMessage,
+ AsyncHttpRequest::rpHigh
+ );
+
+ pReq
+ << INT_PARAM(bIsChat ? "chat_id" : "peer_id", iUserId)
+ << INT_PARAM("random_id", ((long)time(0)) * 100 + uMsgId % 100);
+
pReq->AddHeader("Content-Type", "application/x-www-form-urlencoded");
@@ -170,12 +184,11 @@ int CVkProto::SendMsg(MCONTACT hContact, MEVENT hReplyEvent, const char *szMsg)
}
}
- if (!bIsChat)
- pReq->pUserInfo = new CVkSendMsgParam(hContact, uMsgId);
-
+
+ pReq->pUserInfo = new CVkSendMsgParam(hContact, uMsgId);
Push(pReq);
- if (!m_vkOptions.bServerDelivery && !bIsChat)
+ if (!m_vkOptions.bServerDelivery)
ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)uMsgId);
if (!IsEmpty(pszRetMsg))
@@ -237,6 +250,12 @@ void CVkProto::OnSendMessage(MHttpResponse *reply, AsyncHttpRequest *pReq)
}
else if (m_vkOptions.bServerDelivery)
ProtoBroadcastAck(param->hContact, ACKTYPE_MESSAGE, iResult, (HANDLE)(param->iMsgID), (LPARAM)szMid);
+
+
+ MEVENT hDbEvent;
+ if ((iResult == ACKRESULT_SUCCESS) && (hDbEvent = db_event_getById(m_szModuleName, szMid)))
+ db_event_delivered(param->hContact, hDbEvent);
+
if (!pReq->bNeedsRestart || m_bTerminated) {
delete param;
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index b1559c40ae..11e8c59015 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -222,6 +222,11 @@ void CVkProto::InitMenus()
mi.position = NS_PROTO_MENU_POS + NSMI_FORWARD;
mi.name.a = LPGEN("Forward");
m_hNewStoryMenuItems[NSMI_FORWARD] = Menu_AddNewStoryMenuItem(&mi, NSMI_FORWARD);
+
+ mi.hIcolibItem = g_plugin.getIconHandle(IDI_RELOADMESSAGE);
+ mi.position = NS_PROTO_MENU_POS + NSMI_RELOADMESSAGE;
+ mi.name.a = LPGEN("Reload messages");
+ m_hNewStoryMenuItems[NSMI_RELOADMESSAGE] = Menu_AddNewStoryMenuItem(&mi, NSMI_RELOADMESSAGE);
};
//Contact Menu Services
@@ -419,6 +424,7 @@ int CVkProto::OnPrebuildNSMenu(WPARAM hContact, LPARAM lParam)
{
auto &dbei = *(DB::EventInfo *)lParam;
Menu_ShowItem(m_hNewStoryMenuItems[NSMI_FORWARD], hContact != 0 && dbei);
+ Menu_ShowItem(m_hNewStoryMenuItems[NSMI_RELOADMESSAGE], Proto_IsProtoOnContact(hContact, m_szModuleName) && hContact != 0 && dbei);
return 0;
}
@@ -428,13 +434,18 @@ INT_PTR CVkProto::SvcNSExecMenu(WPARAM iCommand, LPARAM pHandle)
if (hCurrentEvent == -1)
return 1;
+ std::vector<MEVENT> vIds = NS_GetSelection(HANDLE(pHandle));
+ if (vIds.empty())
+ return 1;
+
+ if (!vIds.size())
+ vIds.push_back(hCurrentEvent);
+
+ std::sort(vIds.begin(), vIds.end());
+
switch (iCommand) {
case NSMI_FORWARD:
{
- std::vector<MEVENT> vIds = NS_GetSelection(HANDLE(pHandle));
- if (vIds.empty())
- break;
-
wchar_t wszMsg[2048] = L"";
if (auto *pDlg = NS_GetSrmm((HANDLE)pHandle))
GetWindowText(pDlg->GetInput(), wszMsg, 2048);
@@ -451,17 +462,29 @@ INT_PTR CVkProto::SvcNSExecMenu(WPARAM iCommand, LPARAM pHandle)
if (!dlg.DoModal())
break;
- if (!vIds.size())
- vIds.push_back(hCurrentEvent);
-
- std::sort(vIds.begin(), vIds.end());
-
T2Utf pszMsg(dlg.wszMessage.c_str());
for (auto &hContact : dlg.lContacts)
ForwardMsg((UINT_PTR)hContact, vIds, pszMsg);
}
break;
+ case NSMI_RELOADMESSAGE:
+ {
+ CMStringA szIds;
+ for (auto& mEvnt : vIds) {
+ DB::EventInfo dbei(mEvnt);
+ if (!dbei || dbei.eventType != EVENTTYPE_MESSAGE)
+ continue;
+
+ if (!szIds.IsEmpty())
+ szIds.AppendChar(',');
+ szIds += dbei.szId;
+ }
+
+ if (!szIds.IsEmpty())
+ RetrieveMessagesByIds(szIds);
+ }
+ break;
}
return 0;
}
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index 901408c1b9..359bb01f74 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -195,6 +195,7 @@ private:
enum NewStoryMenuIndexes {
NSMI_FORWARD,
+ NSMI_RELOADMESSAGE,
NSMI_COUNT
};
@@ -430,8 +431,7 @@ private:
void AppendChatConversationMessage(VKUserID_t iChatId, const JSONNode& jnMsg, const JSONNode& jnFUsers, bool bIsHistory);
void AppendChatMessage(CVkChatInfo* vkChatInfo, VKMessageID_t iMessageId, VKMessageID_t iReplyMsgId, VKUserID_t iUserId, time_t tMsgTime, LPCWSTR pwszBody, bool bIsHistory, bool bIsRead, bool bIsAction = false);
void RetrieveChatInfo(CVkChatInfo*);
- void OnReceiveChatInfo(MHttpResponse*, AsyncHttpRequest*);
- void OnSendChatMsg(MHttpResponse*, AsyncHttpRequest*);
+ void OnReceiveChatInfo(MHttpResponse*, AsyncHttpRequest*);
void OnChatLeave(MHttpResponse*, AsyncHttpRequest *);
void OnChatDestroy(MHttpResponse*, AsyncHttpRequest*);
int __cdecl OnChatEvent(WPARAM, LPARAM);