summaryrefslogtreecommitdiff
path: root/protocols/VKontakte
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2023-01-25 18:34:51 +0300
committerGeorge Hazan <ghazan@miranda.im>2023-01-25 18:34:51 +0300
commit9885bf54f788e831a80c76001340aa68d31d2aaa (patch)
tree420ab4aa5bf868d4193c965668ae68e5855093b7 /protocols/VKontakte
parentc9d99d1525e2e9374ed0fa10837e82e76c3b9216 (diff)
Group chats: ChatRoomID setting replaced with real protocol id
Diffstat (limited to 'protocols/VKontakte')
-rw-r--r--protocols/VKontakte/src/main.cpp2
-rw-r--r--protocols/VKontakte/src/misc.cpp16
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp31
-rw-r--r--protocols/VKontakte/src/vk_files.cpp9
-rw-r--r--protocols/VKontakte/src/vk_messages.cpp2
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp1
-rw-r--r--protocols/VKontakte/src/vk_proto.h2
7 files changed, 38 insertions, 25 deletions
diff --git a/protocols/VKontakte/src/main.cpp b/protocols/VKontakte/src/main.cpp
index ee2ccc09c2..6241d8763f 100644
--- a/protocols/VKontakte/src/main.cpp
+++ b/protocols/VKontakte/src/main.cpp
@@ -40,7 +40,7 @@ PLUGININFOEX pluginInfoEx =
CMPlugin::CMPlugin() :
ACCPROTOPLUGIN<CVkProto>("VKontakte", pluginInfoEx)
{
- SetUniqueId("ID");
+ SetUniqueId("ID", DBVT_DWORD);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index c60dbb36ad..18c4b0e5be 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -117,6 +117,20 @@ char* ExpUrlEncode(const char *szUrl, bool strict)
/////////////////////////////////////////////////////////////////////////////////////////
+void CVkProto::CheckUpdate()
+{
+ if (getByte("Compatibility") < 1) {
+ for (auto &cc : AccContacts()) {
+ LONG userId = getDword(cc, "vk_chat_id", VK_INVALID_USER);
+ if (userId != VK_INVALID_USER) {
+ setDword(cc, "ID", userId);
+ delSetting(cc, "vk_chat_id");
+ }
+ }
+ setByte("Compatibility", 1);
+ }
+}
+
void CVkProto::ClearAccessToken()
{
debugLogA("CVkProto::ClearAccessToken");
@@ -183,7 +197,7 @@ MCONTACT CVkProto::FindChat(LONG dwUserid)
return 0;
for (auto &hContact : AccContacts()) {
- LONG dbUserid = getDword(hContact, "vk_chat_id", VK_INVALID_USER);
+ LONG dbUserid = getDword(hContact, "ID", VK_INVALID_USER);
if (dbUserid == VK_INVALID_USER)
continue;
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp
index 1771b5d474..3a7e2cdfe6 100644
--- a/protocols/VKontakte/src/vk_chats.cpp
+++ b/protocols/VKontakte/src/vk_chats.cpp
@@ -84,7 +84,7 @@ CVkChatInfo* CVkProto::AppendConversationChat(int iChatId, const JSONNode& jnIte
for (int i = _countof(sttStatuses) - 1; i >= 0; i--)
Chat_AddGroup(si, TranslateW(sttStatuses[i]));
- setDword(si->hContact, "vk_chat_id", iChatId);
+ setDword(si->hContact, "ID", iChatId);
CMStringW wszHomepage(FORMAT, L"https://vk.com/im?sel=c%d", iChatId);
setWString(si->hContact, "Homepage", wszHomepage);
@@ -445,6 +445,17 @@ void CVkProto::AppendChatMessage(CVkChatInfo *cc, LONG uid, int msgTime, LPCWSTR
/////////////////////////////////////////////////////////////////////////////////////////
+CVkChatInfo* CVkProto::GetChatByContact(MCONTACT hContact)
+{
+ LONG dbUserid = getDword(hContact, "ID", VK_INVALID_USER);
+ if (dbUserid == VK_INVALID_USER)
+ return nullptr;
+
+ wchar_t wszChatID[40];
+ _itow(dbUserid, wszChatID, 10);
+ return GetChatById(wszChatID);
+}
+
CVkChatInfo* CVkProto::GetChatById(LPCWSTR pwszId)
{
for (auto &it : m_chats)
@@ -458,13 +469,9 @@ CVkChatInfo* CVkProto::GetChatById(LPCWSTR pwszId)
void CVkProto::SetChatStatus(MCONTACT hContact, int iStatus)
{
- ptrW wszChatID(getWStringA(hContact, "ChatRoomID"));
- if (wszChatID == nullptr)
- return;
-
- CVkChatInfo *cc = GetChatById(wszChatID);
+ CVkChatInfo *cc = GetChatByContact(hContact);
if (cc != nullptr)
- Chat_Control(m_szModuleName, wszChatID, (iStatus == ID_STATUS_OFFLINE) ? SESSION_OFFLINE : SESSION_ONLINE);
+ Chat_Control(m_szModuleName, cc->m_wszId, (iStatus == ID_STATUS_OFFLINE) ? SESSION_OFFLINE : SESSION_ONLINE);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -601,7 +608,7 @@ INT_PTR __cdecl CVkProto::OnJoinChat(WPARAM hContact, LPARAM)
if (!IsOnline() || getBool(hContact, "kicked") || !getBool(hContact, "off"))
return 1;
- int chat_id = getDword(hContact, "vk_chat_id", VK_INVALID_USER);
+ int chat_id = getDword(hContact, "ID", VK_INVALID_USER);
if (chat_id == VK_INVALID_USER)
return 1;
@@ -619,11 +626,7 @@ INT_PTR __cdecl CVkProto::OnLeaveChat(WPARAM hContact, LPARAM)
if (!IsOnline())
return 1;
- ptrW wszChatID(getWStringA(hContact, "ChatRoomID"));
- if (wszChatID == nullptr)
- return 1;
-
- CVkChatInfo *cc = GetChatById(wszChatID);
+ CVkChatInfo *cc = GetChatByContact(hContact);
if (cc == nullptr)
return 1;
@@ -705,7 +708,7 @@ INT_PTR __cdecl CVkProto::SvcDestroyKickChat(WPARAM hContact, LPARAM)
if (!getBool(hContact, "off"))
return 1;
- int chat_id = getDword(hContact, "vk_chat_id", VK_INVALID_USER);
+ int chat_id = getDword(hContact, "ID", VK_INVALID_USER);
if (chat_id == VK_INVALID_USER)
return 1;
diff --git a/protocols/VKontakte/src/vk_files.cpp b/protocols/VKontakte/src/vk_files.cpp
index a7306c1568..7ac1b9657e 100644
--- a/protocols/VKontakte/src/vk_files.cpp
+++ b/protocols/VKontakte/src/vk_files.cpp
@@ -363,14 +363,7 @@ void CVkProto::OnReciveUploadFile(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pR
AsyncHttpRequest *pMsgReq;
if (isChatRoom(fup->hContact)) {
-
- ptrW wszChatID(getWStringA(fup->hContact, "ChatRoomID"));
- if (!wszChatID) {
- SendFileFiled(fup, VKERR_INVALID_USER);
- return;
- }
-
- CVkChatInfo *cc = GetChatById(wszChatID);
+ CVkChatInfo *cc = GetChatByContact(fup->hContact);
if (cc == nullptr) {
SendFileFiled(fup, VKERR_INVALID_USER);
return;
diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp
index e6f31c2256..7bec7a13fd 100644
--- a/protocols/VKontakte/src/vk_messages.cpp
+++ b/protocols/VKontakte/src/vk_messages.cpp
@@ -26,8 +26,8 @@ int CVkProto::SendMsg(MCONTACT hContact, int, const char *szMsg)
return 0;
bool bIsChat = isChatRoom(hContact);
- LONG iUserID = getDword(hContact, bIsChat ? "vk_chat_id" : "ID", VK_INVALID_USER);
+ LONG iUserID = getDword(hContact, "ID", VK_INVALID_USER);
if (iUserID == VK_INVALID_USER || iUserID == VK_FEED_USER) {
ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, 0);
return 0;
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index f16be722f7..b712b83eb2 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -46,6 +46,7 @@ CVkProto::CVkProto(const char *szModuleName, const wchar_t *pwszUserName) :
m_tWorkThreadTimer = m_tPoolThreadTimer = time(0);
InitQueue();
+ CheckUpdate();
CreateProtoService(PS_CREATEACCMGRUI, &CVkProto::SvcCreateAccMgrUI);
CreateProtoService(PS_GETAVATARINFO, &CVkProto::SvcGetAvatarInfo);
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index fd680580a6..43936e8c5b 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -357,6 +357,7 @@ private:
int IsHystoryMessageExist(MCONTACT hContact);
void SetSrmmReadStatus(MCONTACT hContact);
void MarkDialogAsRead(MCONTACT hContact);
+ void CheckUpdate();
char* GetStickerId(const char *Msg, int& stickerid);
CMStringA GetAttachmentsFromMessage(const char * Msg);
CMStringW SpanVKNotificationType(CMStringW& wszType, VKObjType& vkFeedback, VKObjType& vkParent);
@@ -413,6 +414,7 @@ private:
LPTSTR ChangeChatTopic(CVkChatInfo*);
void SetChatStatus(MCONTACT hContact, int iStatus);
CVkChatInfo* GetChatById(LPCWSTR pwszId);
+ CVkChatInfo* GetChatByContact(MCONTACT hContact);
INT_PTR __cdecl SvcCreateChat(WPARAM, LPARAM);
void __cdecl GetAwayMsgThread(void* p);
};