summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/VKontakte/src')
-rw-r--r--protocols/VKontakte/src/misc.cpp165
-rw-r--r--protocols/VKontakte/src/resource.h3
-rw-r--r--protocols/VKontakte/src/version.h2
-rw-r--r--protocols/VKontakte/src/vk.h12
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp347
-rw-r--r--protocols/VKontakte/src/vk_files.cpp9
-rw-r--r--protocols/VKontakte/src/vk_history.cpp20
-rw-r--r--protocols/VKontakte/src/vk_messages.cpp235
-rw-r--r--protocols/VKontakte/src/vk_options.cpp6
-rw-r--r--protocols/VKontakte/src/vk_options.h2
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp5
-rw-r--r--protocols/VKontakte/src/vk_proto.h7
-rw-r--r--protocols/VKontakte/src/vk_struct.cpp191
-rw-r--r--protocols/VKontakte/src/vk_struct.h88
14 files changed, 85 insertions, 1007 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index d0c19ccf1d..12f5f38992 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -1098,18 +1098,18 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
res += SetBBCString(TranslateT("Attachments:"), iBBC, vkbbcB);
res.AppendChar('\n');
- for (auto &jnAttach : jnAttachments) {
+ for (auto& jnAttach : jnAttachments) {
res.AppendChar('\t');
CMStringW wszType(jnAttach["type"].as_mstring());
if (wszType == L"photo") {
- const JSONNode &jnPhoto = jnAttach["photo"];
+ const JSONNode& jnPhoto = jnAttach["photo"];
if (!jnPhoto)
continue;
res += GetVkPhotoItem(jnPhoto, iBBC);
}
else if (wszType == L"audio") {
- const JSONNode &jnAudio = jnAttach["audio"];
+ const JSONNode& jnAudio = jnAttach["audio"];
if (!jnAudio)
continue;
@@ -1119,7 +1119,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
CMStringW wszAudio(FORMAT, L"%s - %s", wszArtist.c_str(), wszTitle.c_str());
int iParamPos = wszUrl.Find(L"?");
- if (m_vkOptions.bShortenLinksForAudio && iParamPos != -1)
+ if (m_vkOptions.bShortenLinksForAudio && iParamPos != -1)
wszUrl = wszUrl.Left(iParamPos);
res.AppendFormat(L"%s: %s",
@@ -1131,11 +1131,14 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
if (!jnAudioMessage)
continue;
+ if (m_vkOptions.bFilterAudioMessages)
+ return L"== FilterAudioMessages ==";
+
CMStringW wszUrl(jnAudioMessage["link_mp3"].as_mstring());
CMStringW wszTranscriptText(jnAudioMessage["transcript"].as_mstring());
- res.AppendFormat(L"%s", SetBBCString(TranslateT("Audio message"), iBBC, vkbbcUrl, wszUrl).c_str());
- if(!wszTranscriptText.IsEmpty())
+ res.AppendFormat(L"%s", SetBBCString(TranslateT("Audio message"), iBBC, vkbbcUrl, wszUrl).c_str());
+ if (!wszTranscriptText.IsEmpty())
res.AppendFormat(L"\n%s: %s", SetBBCString(TranslateT("Transcription"), iBBC, vkbbcB).c_str(), wszTranscriptText.c_str());
}
else if (wszType == L"graffiti") {
@@ -1151,20 +1154,21 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
);
}
else if (wszType == L"video") {
- const JSONNode &jnVideo = jnAttach["video"];
+ const JSONNode& jnVideo = jnAttach["video"];
if (!jnVideo)
continue;
CMStringW wszTitle(jnVideo["title"].as_mstring());
- int vid = jnVideo["id"].as_int();
- int ownerID = jnVideo["owner_id"].as_int();
- CMStringW wszUrl(FORMAT, L"https://vk.com/video%d_%d", ownerID, vid);
+ int iVideoId = jnVideo["id"].as_int();
+ int iOwnerId = jnVideo["owner_id"].as_int();
+ CMStringW wszUrl(FORMAT, L"https://vk.com/video%d_%d", iOwnerId, iVideoId);
+
res.AppendFormat(L"%s: %s",
SetBBCString(TranslateT("Video"), iBBC, vkbbcB).c_str(),
SetBBCString(wszTitle.IsEmpty() ? TranslateT("Link") : wszTitle, iBBC, vkbbcUrl, wszUrl).c_str());
}
else if (wszType == L"doc") {
- const JSONNode &jnDoc = jnAttach["doc"];
+ const JSONNode& jnDoc = jnAttach["doc"];
if (!jnDoc)
continue;
@@ -1178,21 +1182,21 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
SetBBCString(wszTitle.IsEmpty() ? TranslateT("Link") : wszTitle, iBBC, vkbbcUrl, wszUrl).c_str());
}
else if (wszType == L"wall") {
- const JSONNode &jnWall = jnAttach["wall"];
+ const JSONNode& jnWall = jnAttach["wall"];
if (!jnWall)
continue;
CMStringW wszText(jnWall["text"].as_mstring());
- int id = jnWall["id"].as_int();
- int fromID = jnWall["from_id"].as_int();
- CMStringW wszUrl(FORMAT, L"https://vk.com/wall%d_%d", fromID, id);
+ int iWallId = jnWall["id"].as_int();
+ int iFromId = jnWall["from_id"].as_int();
+ CMStringW wszUrl(FORMAT, L"https://vk.com/wall%d_%d", iFromId, iWallId);
res.AppendFormat(L"%s: %s",
SetBBCString(TranslateT("Wall post"), iBBC, vkbbcUrl, wszUrl).c_str(),
wszText.IsEmpty() ? L" " : wszText.c_str());
- const JSONNode &jnCopyHystory = jnWall["copy_history"];
+ const JSONNode& jnCopyHystory = jnWall["copy_history"];
if (jnCopyHystory) {
- for (auto &jnCopyHystoryItem : jnCopyHystory) {
+ for (auto& jnCopyHystoryItem : jnCopyHystory) {
CMStringW wszCHText(jnCopyHystoryItem["text"].as_mstring());
int iCHid = jnCopyHystoryItem["id"].as_int();
int iCHfromID = jnCopyHystoryItem["from_id"].as_int();
@@ -1202,7 +1206,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
SetBBCString(TranslateT("Wall post"), iBBC, vkbbcUrl, wszCHUrl).c_str(),
wszCHText.IsEmpty() ? L" " : wszCHText.c_str());
- const JSONNode &jnSubAttachments = jnCopyHystoryItem["attachments"];
+ const JSONNode& jnSubAttachments = jnCopyHystoryItem["attachments"];
if (jnSubAttachments) {
debugLogA("CVkProto::GetAttachmentDescr SubAttachments");
CMStringW wszAttachmentDescr = GetAttachmentDescr(jnSubAttachments, iBBC);
@@ -1213,7 +1217,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
}
}
- const JSONNode &jnSubAttachments = jnWall["attachments"];
+ const JSONNode& jnSubAttachments = jnWall["attachments"];
if (jnSubAttachments) {
debugLogA("CVkProto::GetAttachmentDescr SubAttachments");
CMStringW wszAttachmentDescr = GetAttachmentDescr(jnSubAttachments, iBBC);
@@ -1222,8 +1226,49 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
res += L"\n\t" + wszAttachmentDescr;
}
}
+ else if (wszType == L"story") {
+ const JSONNode& jnStory = jnAttach["story"];
+ if (!jnStory)
+ continue;
+ int iStoryId = jnStory["id"].as_int();
+ int iOwnerID = jnStory["owner_id"].as_int();
+ CMStringW wszUrl(FORMAT, L"https://vk.com/story%d_%d", iOwnerID, iStoryId);
+ CMStringW wszAccessKey(jnStory["access_key"].as_mstring());
+ if (!wszAccessKey.IsEmpty())
+ wszUrl += L"_" + wszAccessKey;
+
+ res.AppendFormat(L"%s",
+ SetBBCString(TranslateT("Story"), iBBC, vkbbcUrl, wszUrl).c_str());
+
+ CMStringW wszStoryType(jnStory["type"].as_mstring());
+
+ if (wszStoryType == L"photo") {
+ const JSONNode& jnPhoto = jnStory["photo"];
+ if (!jnPhoto)
+ continue;
+
+ res += L"\n\t";
+ res += GetVkPhotoItem(jnPhoto, iBBC);
+ }
+ else if (wszStoryType == L"video") {
+ const JSONNode& jnVideo = jnStory["video"];
+ if (!jnVideo)
+ continue;
+
+ CMStringW wszTitle(jnVideo["title"].as_mstring());
+ int iVideoId = jnVideo["id"].as_int();
+ int iOwnerId = jnVideo["owner_id"].as_int();
+ CMStringW wszVideoUrl(FORMAT, L"https://vk.com/video%d_%d", iOwnerId, iVideoId);
+
+ res.AppendFormat(L"\n\t%s: %s",
+ SetBBCString(TranslateT("Video"), iBBC, vkbbcB).c_str(),
+ SetBBCString(wszTitle.IsEmpty() ? TranslateT("Link") : wszTitle, iBBC, vkbbcUrl, wszVideoUrl).c_str());
+
+ }
+
+ }
else if (wszType == L"sticker") {
- const JSONNode &jnSticker = jnAttach["sticker"];
+ const JSONNode& jnSticker = jnAttach["sticker"];
if (!jnSticker)
continue;
res.Empty(); // sticker is not really an attachment, so we don't want all that heading info
@@ -1234,9 +1279,9 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
}
else {
CMStringW wszLink, wszLink128, wszLinkLast;
- const JSONNode &jnImages = jnSticker[m_vkOptions.bStickerBackground ? "images_with_background" : "images"];
- for (auto & jnImage : jnImages) {
- if (jnImage["width"].as_int() == (int) m_vkOptions.iStickerSize) {
+ const JSONNode& jnImages = jnSticker[m_vkOptions.bStickerBackground ? "images_with_background" : "images"];
+ for (auto& jnImage : jnImages) {
+ if (jnImage["width"].as_int() == (int)m_vkOptions.iStickerSize) {
wszLink = jnImage["url"].as_mstring();
break;
}
@@ -1253,7 +1298,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
}
else if (wszType == L"link") {
- const JSONNode &jnLink = jnAttach["link"];
+ const JSONNode& jnLink = jnAttach["link"];
if (!jnLink)
continue;
@@ -1276,7 +1321,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
res.AppendFormat(L"\n\t%s", wszDescription.c_str());
}
else if (wszType == L"market") {
- const JSONNode &jnMarket = jnAttach["market"];
+ const JSONNode& jnMarket = jnAttach["market"];
int id = jnMarket["id"].as_int();
int ownerID = jnMarket["owner_id"].as_int();
@@ -1285,7 +1330,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
CMStringW wszPhoto(jnMarket["thumb_photo"].as_mstring());
CMStringW wszUrl(FORMAT, L"https://vk.com/%s%d?w=product%d_%d",
ownerID > 0 ? L"id" : L"club",
- ownerID > 0 ? ownerID : (-1)*ownerID,
+ ownerID > 0 ? ownerID : (-1) * ownerID,
ownerID,
id);
@@ -1307,13 +1352,13 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
res.AppendFormat(L"\n\t%s", wszDescription.c_str());
}
else if (wszType == L"gift") {
- const JSONNode &jnGift = jnAttach["gift"];
+ const JSONNode& jnGift = jnAttach["gift"];
if (!jnGift)
continue;
CMStringW wszLink;
- for (auto &it : szGiftTypes) {
- const JSONNode &n = jnGift[it];
+ for (auto& it : szGiftTypes) {
+ const JSONNode& n = jnGift[it];
if (n) {
wszLink = n.as_mstring();
break;
@@ -1419,7 +1464,6 @@ CMStringW CVkProto::GetFwdMessages(const JSONNode &jnMessages, const JSONNode &j
vkUsers.insert(vkUser);
}
-#if (VK_NEW_API == 1)
if (jnMessages.type() == JSON_ARRAY)
for (auto& jnMsg : jnMessages.as_array()) {
if (!res.IsEmpty())
@@ -1429,68 +1473,7 @@ CMStringW CVkProto::GetFwdMessages(const JSONNode &jnMessages, const JSONNode &j
else
res = GetFwdMessage(jnMessages, jnFUsers, vkUsers, iBBC);
-#else
- for (auto &jnMsg : jnMessages.as_array()) {
- UINT uid = jnMsg["user_id"].as_int();
- CMStringW wszBody(jnMsg["body"].as_mstring());
- CVkUserInfo *vkUser = vkUsers.find((CVkUserInfo *)&uid);
- CMStringW wszNick, wszUrl;
-
- if (vkUser) {
- wszNick = vkUser->m_wszUserNick;
- wszUrl = vkUser->m_wszLink;
- }
- else {
- MCONTACT hContact = FindUser(uid);
- if (hContact || uid == m_msgId)
- wszNick = ptrW(db_get_wsa(hContact, m_szModuleName, "Nick"));
- else
- wszNick = TranslateT("(Unknown contact)");
- wszUrl = UserProfileUrl(uid);
- }
-
- time_t datetime = (time_t)jnMsg["date"].as_int();
- wchar_t ttime[64];
- _locale_t locale = _create_locale(LC_ALL, "");
- _wcsftime_l(ttime, _countof(ttime), L"%x %X", localtime(&datetime), locale);
- _free_locale(locale);
-
- const JSONNode &jnFwdMessages = jnMsg["fwd_messages"];
- if (jnFwdMessages) {
- CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, iBBC == bbcNo ? iBBC : m_vkOptions.BBCForAttachments());
- if (!wszBody.IsEmpty())
- wszFwdMessages = L"\n" + wszFwdMessages;
- wszBody += wszFwdMessages;
- }
-
- const JSONNode &jnAttachments = jnMsg["attachments"];
- if (jnAttachments) {
- CMStringW wszAttachmentDescr = GetAttachmentDescr(jnAttachments, iBBC == bbcNo ? iBBC : m_vkOptions.BBCForAttachments());
- if (wszAttachmentDescr != L"== FilterAudioMessages ==") {
- if (!wszBody.IsEmpty())
- wszAttachmentDescr = L"\n" + wszAttachmentDescr;
-
- wszBody += wszAttachmentDescr;
- }
- }
-
- wszBody.Replace(L"\n", L"\n\t");
- wchar_t tcSplit = m_vkOptions.bSplitFormatFwdMsg ? '\n' : ' ';
- CMStringW wszMes(FORMAT, L"%s %s%c%s %s:\n\n%s\n",
- SetBBCString(TranslateT("Message from"), iBBC, vkbbcB).c_str(),
- SetBBCString(wszNick, iBBC, vkbbcUrl, wszUrl).c_str(),
- tcSplit,
- SetBBCString(TranslateT("at"), iBBC, vkbbcB).c_str(),
- ttime,
- SetBBCString(wszBody, iBBC, vkbbcCode).c_str());
-
- if (!res.IsEmpty())
- res.AppendChar('\n');
- res += wszMes;
- }
-#endif
res.AppendChar('\n');
-
vkUsers.destroy();
return res;
}
diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h
index a125e5184a..c160ca0e2a 100644
--- a/protocols/VKontakte/src/resource.h
+++ b/protocols/VKontakte/src/resource.h
@@ -113,7 +113,6 @@
#define IDC_NOTIF_MARK_VIEWED 1096
#define IDC_N_INVITES 1097
#define IDC_USENOSTDPOPUPS 1098
-#define IDC_RET_CHAT_MES 1099
#define IDC_COMBO_LANGUAGE 1100
#define IDC_SHOW_MENU0 1101
#define IDC_SHOW_MENU1 1102
@@ -133,7 +132,7 @@
#define IDC_CH_CLEARHISTORY 1116
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h
index 8a6084d743..20a34c616f 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 11
-#define __BUILD_NUM 0
+#define __BUILD_NUM 1
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk.h b/protocols/VKontakte/src/vk.h
index 284fb9e204..491343fbe0 100644
--- a/protocols/VKontakte/src/vk.h
+++ b/protocols/VKontakte/src/vk.h
@@ -88,20 +88,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define VK_USER_DEACTIVATE_ACTION 9321
-#define VK_CHAT_FLAG 2000000000
-
-#define VK_NEW_API 1
-
-#if (VK_NEW_API == 0)
- #define VK_API_VER "5.78"
-#else
- #define VK_API_VER "5.110"
-#endif
-
+#define VK_API_VER "5.110"
#define VER_API CHAR_PARAM("v", VK_API_VER)
#define VK_FEED_USER 2147483647L
#define VK_INVALID_USER 0L
+#define VK_CHAT_FLAG 2000000000
#if defined(_DEBUG)
#define VK_NODUMPHEADERS 0
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp
index 402e51744d..f6dd409c78 100644
--- a/protocols/VKontakte/src/vk_chats.cpp
+++ b/protocols/VKontakte/src/vk_chats.cpp
@@ -106,73 +106,6 @@ CVkChatInfo* CVkProto::AppendConversationChat(int iChatId, const JSONNode& jnIte
}
-#if (VK_NEW_API == 0)
-CVkChatInfo* CVkProto::AppendChat(int id, const JSONNode &jnDlg)
-{
- debugLogW(L"CVkProto::AppendChat");
- if (id == 0)
- return nullptr;
-
- if (jnDlg) {
- CMStringW action_chat = jnDlg["action"].as_mstring();
- int action_mid = _wtoi(jnDlg["action_mid"].as_mstring());
- if ((action_chat == L"chat_kick_user") && (action_mid == m_myUserId))
- return nullptr;
- }
-
- MCONTACT chatContact = FindChat(id);
- if (chatContact && getBool(chatContact, "kicked"))
- return nullptr;
-
- CVkChatInfo *c = m_chats.find((CVkChatInfo*)&id);
- if (c != nullptr)
- return c;
-
- CMStringW wszTitle;
- c = new CVkChatInfo(id);
- if (jnDlg) {
- wszTitle = jnDlg["title"].as_mstring();
- c->m_wszTopic = mir_wstrdup(!wszTitle.IsEmpty() ? wszTitle : L"");
- }
-
- CMStringW sid;
- sid.Format(L"%S_%d", m_szModuleName, id);
- c->m_wszId = mir_wstrdup(sid);
-
- SESSION_INFO *si = Chat_NewSession(GCW_CHATROOM, m_szModuleName, sid, wszTitle);
- if (si == nullptr) {
- delete c;
- return nullptr;
- }
-
- c->m_hContact = si->hContact;
- setWString(si->hContact, "Nick", wszTitle);
- m_chats.insert(c);
-
- for (int i = _countof(sttStatuses) - 1; i >= 0; i--)
- Chat_AddGroup(si, TranslateW(sttStatuses[i]));
-
- setDword(si->hContact, "vk_chat_id", id);
-
- CMStringW wszHomepage(FORMAT, L"https://vk.com/im?sel=c%d", id);
- setWString(si->hContact, "Homepage", wszHomepage);
-
- db_unset(si->hContact, m_szModuleName, "off");
-
- if (jnDlg && jnDlg["left"].as_bool()) {
- setByte(si->hContact, "off", 1);
- m_chats.remove(c);
- return nullptr;
- }
-
- Chat_Control(m_szModuleName, sid, (m_vkOptions.bHideChats) ? WINDOW_HIDDEN : SESSION_INITDONE);
- Chat_Control(m_szModuleName, sid, SESSION_ONLINE);
-
- RetrieveChatInfo(c);
- return c;
-}
-#endif
-
/////////////////////////////////////////////////////////////////////////////////////////
void CVkProto::RetrieveChatInfo(CVkChatInfo *cc)
@@ -181,7 +114,7 @@ void CVkProto::RetrieveChatInfo(CVkChatInfo *cc)
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.RetrieveChatInfo", true, &CVkProto::OnReceiveChatInfo)
<< INT_PARAM("chatid", cc->m_iChatId)
- << INT_PARAM("func_v", cc->m_bHistoryRead ? 1 : 2 + VK_NEW_API)
+ << INT_PARAM("func_v", cc->m_bHistoryRead ? 1 : 3)
)->pUserInfo = cc;
}
@@ -200,7 +133,6 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
if (m_chats.indexOf(cc) == -1)
return;
-#if (VK_NEW_API==1)
const JSONNode &jnInfo = jnResponse["info"];
if (jnInfo) {
if (jnInfo["title"])
@@ -323,125 +255,6 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
AppendChatMessage(cc, p->m_uid, p->m_date, p->m_wszBody, p->m_bHistory, p->m_bIsAction);
cc->m_msgs.destroy();
-#else
- const JSONNode& jnInfo = jnResponse["info"];
- if (jnInfo) {
- if (jnInfo["title"])
- SetChatTitle(cc, jnInfo["title"].as_mstring());
-
- if (jnInfo["left"].as_bool() || jnInfo["kicked"].as_bool()) {
- setByte(cc->m_hContact, "kicked", jnInfo["kicked"].as_bool());
- LeaveChat(cc->m_iChatId);
- return;
- }
- cc->m_iAdminId = jnInfo["admin_id"].as_int();
- }
-
- const JSONNode& jnUsers = jnResponse["users"];
- if (jnUsers) {
- for (auto& it : cc->m_users)
- it->m_bDel = true;
-
- for (auto& jnUser : jnUsers) {
- if (!jnUser)
- break;
-
- LONG uid = jnUser["id"].as_int();
- bool bIsGroup = jnUser["type"].as_mstring() == L"group";
- if (bIsGroup)
- uid *= -1;
-
- wchar_t wszId[20];
- _itow(uid, wszId, 10);
-
- bool bNew;
- CVkChatUser* cu = cc->m_users.find((CVkChatUser*)&uid);
- if (cu == nullptr) {
- cc->m_users.insert(cu = new CVkChatUser(uid));
- bNew = true;
- }
- else
- bNew = cu->m_bUnknown;
- cu->m_bDel = false;
-
- CMStringW wszNick(ptrW(db_get_wsa(cc->m_hContact, m_szModuleName, CMStringA(FORMAT, "nick%d", cu->m_uid))));
- if (wszNick.IsEmpty())
- wszNick = bIsGroup ?
- jnUser["name"].as_mstring() :
- jnUser["first_name"].as_mstring().Trim() + L" " + jnUser["last_name"].as_mstring().Trim();
-
-
- cu->m_wszNick = mir_wstrdup(wszNick);
- cu->m_bUnknown = false;
-
- if (bNew) {
- GCEVENT gce = { m_szModuleName, 0, GC_EVENT_JOIN };
- gce.pszID.w = cc->m_wszId;
- gce.bIsMe = uid == m_myUserId;
- gce.pszUID.w = wszId;
- gce.pszNick.w = wszNick;
- gce.pszStatus.w = TranslateW(sttStatuses[uid == cc->m_iAdminId]);
- gce.dwItemData = (INT_PTR)cu;
- Chat_Event(&gce);
- }
- }
-
- for (auto& cu : cc->m_users.rev_iter()) {
- if (!cu->m_bDel)
- continue;
-
- wchar_t wszId[20];
- _itow(cu->m_uid, wszId, 10);
- CMStringW wszNick(FORMAT, L"%s (%s)", cu->m_wszNick.get(), UserProfileUrl(cu->m_uid).c_str());
-
- GCEVENT gce = { m_szModuleName, 0, GC_EVENT_PART };
- gce.pszID.w = cc->m_wszId;
- gce.pszUID.w = wszId;
- gce.dwFlags = GCEF_NOTNOTIFY;
- gce.time = time(0);
- gce.pszNick.w = wszNick;
- Chat_Event(&gce);
-
- cc->m_users.removeItem(&cu);
- }
- }
-
- const JSONNode& jnMsgsUsers = jnResponse["msgs_users"];
- for (auto& jnUser : jnMsgsUsers) {
- LONG uid = jnUser["id"].as_int();
- CVkChatUser* cu = cc->m_users.find((CVkChatUser*)&uid);
- if (cu)
- continue;
-
- MCONTACT hContact = FindUser(uid);
- if (hContact)
- continue;
-
- hContact = SetContactInfo(jnUser, true, VKContactType::vkContactMUCUser);
-
- }
-
- const JSONNode& jnMsgs = jnResponse["msgs"];
- const JSONNode& jnFUsers = jnResponse["fwd_users"];
- if (jnMsgs) {
- const JSONNode& jnItems = jnMsgs["items"];
- if (jnItems) {
- for (auto& jnMsg : jnItems) {
- if (!jnMsg)
- break;
-
- AppendChatMessage(cc->m_iChatId, jnMsg, jnFUsers, true);
- }
- cc->m_bHistoryRead = true;
- }
- }
-
- for (auto& p : cc->m_msgs)
- AppendChatMessage(cc, p->m_uid, p->m_date, p->m_wszBody, p->m_bHistory, p->m_bIsAction);
-
- cc->m_msgs.destroy();
-#endif
-
}
void CVkProto::SetChatTitle(CVkChatInfo *cc, LPCWSTR wszTopic)
@@ -603,144 +416,6 @@ void CVkProto::AppendChatConversationMessage(int id, const JSONNode& jnMsg, cons
}
}
-#if (VK_NEW_API == 0)
-void CVkProto::AppendChatMessage(int id, const JSONNode &jnMsg, const JSONNode &jnFUsers, bool bIsHistory)
-{
- debugLogA("CVkProto::AppendChatMessage");
- CVkChatInfo *cc = AppendChat(id, nullNode);
- if (cc == nullptr)
- return;
-
- int mid = jnMsg["id"].as_int();
- int uid = jnMsg["user_id"].as_int();
- bool bIsAction = false;
-
- int msgTime = jnMsg["date"].as_int();
- time_t now = time(0);
- if (!msgTime || msgTime > now)
- msgTime = now;
-
- CMStringW wszBody(jnMsg["body"].as_mstring());
-
- const JSONNode &jnFwdMessages = jnMsg["fwd_messages"];
- if (jnFwdMessages) {
- CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, bbcNo);
- if (!wszBody.IsEmpty())
- wszFwdMessages = L"\n" + wszFwdMessages;
- wszBody += wszFwdMessages;
- }
-
- const JSONNode &jnAttachments = jnMsg["attachments"];
- if (jnAttachments) {
- CMStringW wszAttachmentDescr = GetAttachmentDescr(jnAttachments, bbcNo);
-
- if (wszAttachmentDescr == L"== FilterAudioMessages ==")
- return;
-
- if (!wszBody.IsEmpty())
- wszAttachmentDescr = L"\n" + wszAttachmentDescr;
- wszBody += wszAttachmentDescr;
- }
-
- if (m_vkOptions.bAddMessageLinkToMesWAtt && (jnAttachments || jnFwdMessages))
- wszBody += SetBBCString(TranslateT("Message link"), bbcNo, vkbbcUrl,
- CMStringW(FORMAT, L"https://vk.com/im?sel=c%d&msgid=%d", cc->m_iChatId, mid));
-
- if (jnMsg["action"]) {
- bIsAction = true;
- CMStringW wszAction = jnMsg["action"].as_mstring();
-
- if (wszAction == L"chat_create") {
- CMStringW wszActionText = jnMsg["action_text"].as_mstring();
- wszBody.AppendFormat(L"%s \"%s\"", TranslateT("create chat"), wszActionText.IsEmpty() ? L" " : wszActionText.c_str());
- }
- else if (wszAction == L"chat_kick_user") {
- CMStringW wszActionMid = jnMsg["action_mid"].as_mstring();
- if (wszActionMid.IsEmpty())
- wszBody = TranslateT("kick user");
- else {
- CMStringW wszUid(FORMAT, L"%d", uid);
- if (wszUid == wszActionMid) {
- if (cc->m_bHistoryRead)
- return;
- wszBody.AppendFormat(L" (%s) %s", UserProfileUrl(uid).c_str(), TranslateT("left chat"));
- }
- else {
- int a_uid = 0;
- int iReadCount = swscanf(wszActionMid, L"%d", &a_uid);
- if (iReadCount == 1) {
- CVkChatUser *cu = cc->m_users.find((CVkChatUser*)&a_uid);
- if (cu == nullptr)
- wszBody.AppendFormat(L"%s (%s)", TranslateT("kick user"), UserProfileUrl(a_uid).c_str());
- else
- wszBody.AppendFormat(L"%s %s (%s)", TranslateT("kick user"), cu->m_wszNick.get(), UserProfileUrl(a_uid).c_str());
- }
- else wszBody = TranslateT("kick user");
- }
- }
- }
- else if (wszAction == L"chat_invite_user" || wszAction == L"chat_invite_user_by_link") {
- CMStringW wszActionMid = jnMsg["action_mid"].as_mstring();
- if (wszActionMid.IsEmpty())
- wszBody = TranslateT("invite user");
- else {
- CMStringW wszUid(FORMAT, L"%d", uid);
- if (wszUid == wszActionMid)
- wszBody.AppendFormat(L" (%s) %s", UserProfileUrl(uid).c_str(), TranslateT("returned to chat"));
- else {
- int a_uid = 0;
- int iReadCount = swscanf(wszActionMid, L"%d", &a_uid);
- if (iReadCount == 1) {
- CVkChatUser *cu = cc->m_users.find((CVkChatUser*)&a_uid);
- if (cu == nullptr)
- wszBody.AppendFormat(L"%s (%s)", TranslateT("invite user"), UserProfileUrl(a_uid).c_str());
- else
- wszBody.AppendFormat(L"%s %s (%s)", TranslateT("invite user"), cu->m_wszNick.get(), UserProfileUrl(a_uid).c_str());
- }
- else wszBody = TranslateT("invite user");
- }
- }
- }
- else if (wszAction == L"chat_title_update") {
- CMStringW wszTitle = jnMsg["action_text"].as_mstring();
- wszBody.AppendFormat(L"%s \"%s\"", TranslateT("change chat title to"), wszTitle.IsEmpty() ? L" " : wszTitle.c_str());
-
- if (!bIsHistory)
- SetChatTitle(cc, wszTitle);
- }
- else if (wszAction == L"chat_pin_message")
- wszBody = TranslateT("pin message");
- else if (wszAction == L"chat_unpin_message")
- wszBody = TranslateT("unpin message");
- else if (wszAction == L"chat_photo_update")
- wszBody.Replace(TranslateT("Attachments:"), TranslateT("changed chat cover:"));
- else if (wszAction == L"chat_photo_remove")
- wszBody = TranslateT("deleted chat cover");
- else
- wszBody.AppendFormat(L": %s (%s)", TranslateT("chat action not supported"), wszAction.c_str());
- }
-
- wszBody.Replace(L"%", L"%%");
-
- if (cc->m_bHistoryRead) {
- if (jnMsg["title"])
- SetChatTitle(cc, jnMsg["title"].as_mstring());
- AppendChatMessage(cc, uid, msgTime, wszBody, bIsHistory, bIsAction);
- }
- else {
- CVkChatMessage *cm = cc->m_msgs.find((CVkChatMessage *)&mid);
- if (cm == nullptr)
- cc->m_msgs.insert(cm = new CVkChatMessage(mid));
-
- cm->m_uid = uid;
- cm->m_date = msgTime;
- cm->m_wszBody = mir_wstrdup(wszBody);
- cm->m_bHistory = bIsHistory;
- cm->m_bIsAction = bIsAction;
- }
-}
-#endif
-
void CVkProto::AppendChatMessage(CVkChatInfo *cc, LONG uid, int msgTime, LPCWSTR pwszBody, bool bIsHistory, bool bIsAction)
{
debugLogA("CVkProto::AppendChatMessage2");
@@ -930,16 +605,9 @@ INT_PTR __cdecl CVkProto::OnJoinChat(WPARAM hContact, LPARAM)
if (chat_id == VK_INVALID_USER)
return 1;
-#if (VK_NEW_API == 1)
AsyncHttpRequest* pReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.addChatUser.json", true, &CVkProto::OnReceiveSmth, AsyncHttpRequest::rpHigh);
pReq << INT_PARAM("user_id", m_myUserId);
pReq<< INT_PARAM("chat_id", chat_id);
-#else
-#define VK_API_VER "5.110"
- AsyncHttpRequest *pReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true, &CVkProto::OnSendChatMsg, AsyncHttpRequest::rpHigh);
- pReq << INT_PARAM("chat_id", chat_id) << WCHAR_PARAM("message", m_vkOptions.pwszReturnChatMessage);
- pReq->AddHeader("Content-Type", "application/x-www-form-urlencoded");
-#endif
Push(pReq);
db_unset(hContact, m_szModuleName, "off");
return 0;
@@ -1002,11 +670,7 @@ void CVkProto::KickFromChat(int chat_id, LONG user_id, const JSONNode &jnMsg, co
MCONTACT hContact = FindUser(user_id, false);
-#if (VK_NEW_API == 1)
CMStringW msg(jnMsg["text"].as_mstring());
-#else
- CMStringW msg(jnMsg["body"].as_mstring());
-#endif
if (msg.IsEmpty()) {
msg = TranslateT("You've been kicked by ");
if (hContact != 0)
@@ -1015,11 +679,8 @@ void CVkProto::KickFromChat(int chat_id, LONG user_id, const JSONNode &jnMsg, co
msg += TranslateT("(Unknown contact)");
}
else
-#if (VK_NEW_API == 1)
AppendChatConversationMessage(chat_id, jnMsg, jnFUsers, false);
-#else
- AppendChatMessage(chat_id, jnMsg, jnFUsers, false);
-#endif
+
MsgPopup(hContact, msg, TranslateT("Chat"));
setByte(cc->m_hContact, "kicked", 1);
LeaveChat(chat_id);
@@ -1277,9 +938,5 @@ void CVkProto::OnCreateNewChat(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
int chat_id = jnResponse.as_int();
if (chat_id != 0)
-#if (VK_NEW_API == 1)
AppendConversationChat(chat_id, nullNode);
-#else
- AppendChat(chat_id, nullNode);
-#endif
} \ No newline at end of file
diff --git a/protocols/VKontakte/src/vk_files.cpp b/protocols/VKontakte/src/vk_files.cpp
index 6730e4657a..02c9402f8d 100644
--- a/protocols/VKontakte/src/vk_files.cpp
+++ b/protocols/VKontakte/src/vk_files.cpp
@@ -321,7 +321,6 @@ void CVkProto::OnReciveUploadFile(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pR
return;
}
-#if (VK_NEW_API == 1)
int id, owner_id;
if (fup->GetType() == CVkFileUploadParam::typeDoc) {
CMStringA wszType(jnResponse["type"].as_mstring());
@@ -338,14 +337,6 @@ void CVkProto::OnReciveUploadFile(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pR
SendFileFiled(fup, VKERR_INVALID_PARAMETERS);
return;
}
-#else
- int id = fup->GetType() == CVkFileUploadParam::typeAudio ? jnResponse["id"].as_int() : (*jnResponse.begin())["id"].as_int();
- int owner_id = fup->GetType() == CVkFileUploadParam::typeAudio ? jnResponse["owner_id"].as_int() : (*jnResponse.begin())["owner_id"].as_int();
- if ((id == 0) || (owner_id == 0)) {
- SendFileFiled(fup, VKERR_INVALID_PARAMETERS);
- return;
- }
-#endif
CMStringW Attachment;
diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp
index f5aebd9b01..aae8acbfcd 100644
--- a/protocols/VKontakte/src/vk_history.cpp
+++ b/protocols/VKontakte/src/vk_history.cpp
@@ -130,16 +130,6 @@ void CVkProto::GetServerHistory(MCONTACT hContact, int iOffset, int iCount, int
if (VK_INVALID_USER == userID || userID == VK_FEED_USER)
return;
-#if (VK_NEW_API == 0)
- Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.GetServerHistory", true, &CVkProto::OnReceiveHistoryMessages, AsyncHttpRequest::rpLow)
- << INT_PARAM("reqcount", iCount)
- << INT_PARAM("offset", iOffset)
- << INT_PARAM("userid", userID)
- << INT_PARAM("time", iTime)
- << INT_PARAM("lastmid", iLastMsgId)
- << INT_PARAM("once", (int)once)
- )->pUserInfo = new CVkSendMsgParam(hContact, iLastMsgId, iOffset);
-#else
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.GetServerConversationHistory", true, &CVkProto::OnReceiveHistoryMessages, AsyncHttpRequest::rpLow)
<< INT_PARAM("reqcount", iCount)
<< INT_PARAM("offset", iOffset)
@@ -148,7 +138,6 @@ void CVkProto::GetServerHistory(MCONTACT hContact, int iOffset, int iCount, int
<< INT_PARAM("lastmid", iLastMsgId)
<< INT_PARAM("once", (int)once)
)->pUserInfo = new CVkSendMsgParam(hContact, iLastMsgId, iOffset);
-#endif
}
void CVkProto::GetHistoryDlg(MCONTACT hContact, int iLastMsg)
@@ -239,18 +228,11 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque
char szMid[40];
_itoa(mid, szMid, 10);
-#if (VK_NEW_API == 1)
+
CMStringW wszBody(jnMsg["text"].as_mstring());
int uid = jnMsg["peer_id"].as_int();
-
int iReadMsg = getDword(param->hContact, "in_read", 0);
int isRead = (mid <= iReadMsg);
-#else
- CMStringW wszBody(jnMsg["body"].as_mstring());
- int uid = jnMsg["user_id"].as_int();
- int isRead = jnMsg["read_state"].as_int();
-#endif
-
int datetime = jnMsg["date"].as_int();
int isOut = jnMsg["out"].as_int();
diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp
index fa91b6db23..13484b3b8c 100644
--- a/protocols/VKontakte/src/vk_messages.cpp
+++ b/protocols/VKontakte/src/vk_messages.cpp
@@ -154,18 +154,6 @@ INT_PTR CVkProto::SvcMarkMessagesAsRead(WPARAM hContact, LPARAM)
return 0;
}
-#if (VK_NEW_API == 0)
-void CVkProto::MarkMessagesRead(const CMStringA &mids)
-{
- debugLogA("CVkProto::MarkMessagesRead (mids)");
- if (!IsOnline() || mids.IsEmpty())
- return;
-
- Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/messages.markAsRead.json", true, &CVkProto::OnReceiveSmth, AsyncHttpRequest::rpLow)
- << CHAR_PARAM("message_ids", mids));
-}
-#endif
-
void CVkProto::MarkMessagesRead(const MCONTACT hContact)
{
debugLogA("CVkProto::MarkMessagesRead (hContact)");
@@ -189,15 +177,10 @@ void CVkProto::RetrieveMessagesByIds(const CMStringA &mids)
debugLogA("CVkProto::RetrieveMessagesByIds");
if (!IsOnline() || mids.IsEmpty())
return;
-#if (VK_NEW_API == 1)
+
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.RetrieveMessagesConversationByIds", true, &CVkProto::OnReceiveMessages, AsyncHttpRequest::rpHigh)
<< CHAR_PARAM("mids", mids)
);
-#else
- Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.RetrieveMessagesByIds", true, &CVkProto::OnReceiveMessages, AsyncHttpRequest::rpHigh)
- << CHAR_PARAM("mids", mids)
- );
-#endif
}
void CVkProto::RetrieveUnreadMessages()
@@ -206,11 +189,7 @@ void CVkProto::RetrieveUnreadMessages()
if (!IsOnline())
return;
-#if (VK_NEW_API == 1)
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.RetrieveUnreadConversations", true, &CVkProto::OnReceiveDlgs, AsyncHttpRequest::rpHigh));
-#else
- Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.RetrieveUnreadMessages", true, &CVkProto::OnReceiveDlgs, AsyncHttpRequest::rpHigh));
-#endif
}
void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
@@ -233,7 +212,6 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
debugLogA("CVkProto::OnReceiveMessages numMessages = %d", numMessages);
-#if (VK_NEW_API == 1)
if (jnResponse["conv"]) {
const JSONNode& jnConversation = jnResponse["conv"]["items"];
for (auto& jnItem : jnConversation) {
@@ -398,148 +376,6 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
ProtoChainRecvMsg(hContact, &recv);
}
}
-
-#else
- for (auto &jnMsg : jnMsgs) {
- if (!jnMsg) {
- debugLogA("CVkProto::OnReceiveMessages pMsg == nullptr");
- break;
- }
-
-
- UINT mid = jnMsg["id"].as_int();
- CMStringW wszBody(jnMsg["body"].as_mstring());
- UINT datetime = jnMsg["date"].as_int();
- int isOut = jnMsg["out"].as_int();
- int isRead = jnMsg["read_state"].as_int();
- int uid = jnMsg["user_id"].as_int();
-
- MCONTACT hContact = 0;
- int chat_id = jnMsg["chat_id"].as_int();
- if (chat_id == 0)
- hContact = FindUser(uid, true);
-
- char szMid[40];
- _itoa(mid, szMid, 10);
- if (m_vkOptions.iMarkMessageReadOn == MarkMsgReadOn::markOnReceive || chat_id != 0) {
- if (!mids.IsEmpty())
- mids.AppendChar(',');
- mids.Append(szMid);
- }
-
- bool bUseServerReadFlag = m_vkOptions.bSyncReadMessageStatusFromServer ? true : !m_vkOptions.bMesAsUnread;
-
- if (chat_id != 0) {
- debugLogA("CVkProto::OnReceiveMessages chat_id != 0");
- CMStringW action_chat = jnMsg["action"].as_mstring();
- int action_mid = _wtoi(jnMsg["action_mid"].as_mstring());
- if ((action_chat == L"chat_kick_user") && (action_mid == m_myUserId))
- KickFromChat(chat_id, uid, jnMsg, jnFUsers);
- else {
- MCONTACT chatContact = FindChat(chat_id);
- if (chatContact && getBool(chatContact, "kicked", true))
- db_unset(chatContact, m_szModuleName, "kicked");
- AppendChatMessage(chat_id, jnMsg, jnFUsers, false);
- }
- continue;
- }
-
- const JSONNode& jnFwdMessages = jnMsg["fwd_messages"];
- if (jnFwdMessages) {
- CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, m_vkOptions.BBCForAttachments());
- if (!wszBody.IsEmpty())
- wszFwdMessages = L"\n" + wszFwdMessages;
- wszBody += wszFwdMessages;
- }
-
- CMStringW wszBodyNoAttachments = wszBody;
-
-
- CMStringW wszAttachmentDescr;
- const JSONNode &jnAttachments = jnMsg["attachments"];
- if (jnAttachments) {
- wszAttachmentDescr = GetAttachmentDescr(jnAttachments, m_vkOptions.BBCForAttachments());
-
- if (wszAttachmentDescr == L"== FilterAudioMessages ==") {
- if (hContact && (mid > getDword(hContact, "lastmsgid", -1)))
- setDword(hContact, "lastmsgid", mid);
- continue;
- }
-
- if (!wszBody.IsEmpty())
- wszBody += L"\n";
- wszBody += wszAttachmentDescr;
- }
-
- if (m_vkOptions.bAddMessageLinkToMesWAtt && (jnAttachments || jnFwdMessages))
- wszBody += SetBBCString(TranslateT("Message link"), m_vkOptions.BBCForAttachments(), vkbbcUrl,
- CMStringW(FORMAT, L"https://vk.com/im?sel=%d&msgid=%d", uid, mid));
-
- time_t update_time = (time_t)jnMsg["update_time"].as_int();
- bool bEdited = (update_time != 0);
-
- if (bEdited) {
- wchar_t ttime[64];
- _locale_t locale = _create_locale(LC_ALL, "");
- _wcsftime_l(ttime, _countof(ttime), TranslateT("%x at %X"), localtime(&update_time), locale);
- _free_locale(locale);
-
- wszBody = SetBBCString(
- CMStringW(FORMAT, TranslateT("Edited message (updated %s):\n"), ttime),
- m_vkOptions.BBCForAttachments(), vkbbcB) +
- wszBody;
-
- CMStringW wszOldMsg;
- if (GetMessageFromDb(mid, datetime, wszOldMsg))
- wszBody += SetBBCString(TranslateT("\nOriginal message:\n"), m_vkOptions.BBCForAttachments(), vkbbcB) +
- wszOldMsg;
- }
-
- PROTORECVEVENT recv = {};
-
- if (isRead && bUseServerReadFlag)
- recv.flags |= PREF_CREATEREAD;
-
- if (isOut)
- recv.flags |= PREF_SENT;
- else if (m_vkOptions.bUserForceInvisibleOnActivity && time(0) - datetime < 60 * m_vkOptions.iInvisibleInterval)
- SetInvisible(hContact);
-
- T2Utf pszBody(wszBody);
- recv.timestamp = bEdited ? datetime : (m_vkOptions.bUseLocalTime ? time(0) : datetime);
- recv.szMessage = pszBody;
-
- debugLogA("CVkProto::OnReceiveMessages mid = %d, datetime = %d, isOut = %d, isRead = %d, uid = %d, Edited = %d", mid, datetime, isOut, isRead, uid, (int)bEdited);
-
- if (!IsMessageExist(mid, vkALL) || bEdited) {
- debugLogA("CVkProto::OnReceiveMessages new or edited message");
- recv.szMsgId = szMid;
- ProtoChainRecvMsg(hContact, &recv);
- if (mid > getDword(hContact, "lastmsgid", -1))
- setDword(hContact, "lastmsgid", mid);
- }
- else if (m_vkOptions.bLoadSentAttachments && !wszAttachmentDescr.IsEmpty()) {
- CMStringW wszOldMsg;
-
- if (GetMessageFromDb(mid, datetime, wszOldMsg) && (wszOldMsg == wszBody))
- continue;
-
- if (wszBodyNoAttachments != wszOldMsg)
- continue;
-
- debugLogA("CVkProto::OnReceiveMessages add attachments");
-
- T2Utf pszAttach(wszAttachmentDescr);
- recv.timestamp = isOut ? time(0) : datetime;
- recv.szMessage = pszAttach;
- recv.szMsgId = strcat(szMid, "_");
- ProtoChainRecvMsg(hContact, &recv);
- }
- }
-
- if (!mids.IsEmpty())
- MarkMessagesRead(mids);
-#endif
}
void CVkProto::OnReceiveDlgs(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
@@ -589,7 +425,6 @@ void CVkProto::OnReceiveDlgs(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
CMStringA szGroupIds;
-#if (VK_NEW_API == 1)
for (auto& it : jnDlgs) {
if (!it)
break;
@@ -668,74 +503,6 @@ void CVkProto::OnReceiveDlgs(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
MarkMessagesRead(hContact);
}
}
-#else
- for (auto &it : jnDlgs) {
- if (!it)
- break;
- int numUnread = it["unread"].as_int();
- const JSONNode &jnDlg = it["message"];
- if (!jnDlg)
- break;
-
- int uid = 0;
- MCONTACT hContact(0);
-
- int chatid = jnDlg["chat_id"].as_int();
-
- if (!chatid) {
- uid = jnDlg["user_id"].as_int();
- int iSearchId = (uid < 0) ? 1000000000 - uid : uid;
- int iIndex = lufUsers.indexOf((HANDLE)iSearchId);
- debugLogA("CVkProto::OnReceiveDlgs UserId = %d, iIndex = %d, numUnread = %d", uid, iIndex, numUnread);
-
- if (m_vkOptions.bLoadOnlyFriends && numUnread == 0 && iIndex == -1)
- continue;
-
- hContact = FindUser(uid, true);
- debugLogA("CVkProto::OnReceiveDlgs add UserId = %d", uid);
-
- if (IsGroupUser(hContact))
- szGroupIds.AppendFormat(szGroupIds.IsEmpty() ? "%d" : ",%d", -1 * uid);
-
- if (g_bMessageState) {
- bool isOut = jnDlg["out"].as_bool();
- bool isRead = jnDlg["read_state"].as_bool();
-
- if (isRead && isOut)
- CallService(MS_MESSAGESTATE_UPDATE, hContact, MRD_TYPE_DELIVERED);
- }
- }
-
- if (chatid) {
- debugLogA("CVkProto::OnReceiveDlgs chatid = %d", chatid);
- if (m_chats.find((CVkChatInfo*)&chatid) == nullptr)
- AppendChat(chatid, jnDlg);
- }
- else if (m_vkOptions.iSyncHistoryMetod) {
- int mid = jnDlg["id"].as_int();
- m_bNotifyForEndLoadingHistory = false;
-
- if (getDword(hContact, "lastmsgid", -1) == -1 && numUnread && !getBool(hContact, "ActiveHistoryTask")) {
- setByte(hContact, "ActiveHistoryTask", 1);
- GetServerHistory(hContact, 0, numUnread, 0, 0, true);
- }
- else
- GetHistoryDlg(hContact, mid);
-
- if (m_vkOptions.iMarkMessageReadOn == MarkMsgReadOn::markOnReceive && numUnread)
- MarkMessagesRead(hContact);
- }
- else if (numUnread && !getBool(hContact, "ActiveHistoryTask")) {
-
- m_bNotifyForEndLoadingHistory = false;
- setByte(hContact, "ActiveHistoryTask", 1);
- GetServerHistory(hContact, 0, numUnread, 0, 0, true);
-
- if (m_vkOptions.iMarkMessageReadOn == MarkMsgReadOn::markOnReceive)
- MarkMessagesRead(hContact);
- }
- }
-#endif
lufUsers.destroy();
RetrieveUsersInfo();
RetrieveGroupInfo(szGroupIds);
diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp
index 25259b7928..7ab851186b 100644
--- a/protocols/VKontakte/src/vk_options.cpp
+++ b/protocols/VKontakte/src/vk_options.cpp
@@ -255,8 +255,7 @@ CVkOptionAdvancedForm::CVkOptionAdvancedForm(CVkProto *proto) :
m_cbMusicSendOff(this, IDC_SEND_MUSIC_NONE),
m_cbMusicSendBroadcastAndStatus(this, IDC_SEND_MUSIC_BROADCAST_AND_STATUS),
m_cbSendMetodBroadcast(this, IDC_SEND_MUSIC_BROADCAST),
- m_cbMusicSendStatus(this, IDC_SEND_MUSIC_STATUS),
- m_edtReturnChatMessage(this, IDC_RET_CHAT_MES)
+ m_cbMusicSendStatus(this, IDC_SEND_MUSIC_STATUS)
{
CreateLink(m_cbHideChats, m_proto->m_vkOptions.bHideChats);
CreateLink(m_cbSyncReadMessageStatusFromServer, m_proto->m_vkOptions.bSyncReadMessageStatusFromServer);
@@ -270,9 +269,6 @@ CVkOptionAdvancedForm::CVkOptionAdvancedForm(CVkProto *proto) :
CreateLink(m_cbClearServerHistory, m_proto->m_vkOptions.bClearServerHistory);
CreateLink(m_cbRemoveFromFrendlist, m_proto->m_vkOptions.bRemoveFromFrendlist);
CreateLink(m_cbRemoveFromCList, m_proto->m_vkOptions.bRemoveFromCList);
-#if (VK_NEW_API == 0)
- CreateLink(m_edtReturnChatMessage, m_proto->m_vkOptions.pwszReturnChatMessage);
-#endif
m_cbForceInvisibleStatus.OnChange = Callback(this, &CVkOptionAdvancedForm::On_cbForceInvisibleStatusChange);
m_cbSendVKLinksAsAttachments.OnChange = Callback(this, &CVkOptionAdvancedForm::On_cbSendVKLinksAsAttachmentsChange);
diff --git a/protocols/VKontakte/src/vk_options.h b/protocols/VKontakte/src/vk_options.h
index 2e277ba503..531aa50e20 100644
--- a/protocols/VKontakte/src/vk_options.h
+++ b/protocols/VKontakte/src/vk_options.h
@@ -72,8 +72,6 @@ class CVkOptionAdvancedForm : public CVkDlgBase
CCtrlCheck m_cbSendMetodBroadcast;
CCtrlCheck m_cbMusicSendStatus;
- CCtrlEdit m_edtReturnChatMessage;
-
public:
CVkOptionAdvancedForm(CVkProto *proto);
bool OnInitDialog() override;
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index f748b371b2..6de717c1d6 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -666,13 +666,8 @@ void CVkProto::OnContactDeleted(MCONTACT hContact)
CMStringA code(FORMAT, "var userID=\"%d\";", userID);
-#if (VK_NEW_API == 1)
if (param->bDeleteDialog)
code += "API.messages.deleteConversation({\"user_id\":userID,count:10000});";
-#else
- if (param->bDeleteDialog)
- code += "API.messages.deleteDialog({\"user_id\":userID,count:10000});";
-#endif
if (param->bDeleteFromFriendlist)
code += "API.friends.delete({\"user_id\":userID});";
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index 958aa1e396..613f778f30 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -308,9 +308,6 @@ private:
void OnReceiveGroupInfo(NETLIBHTTPREQUEST * reply, AsyncHttpRequest * pReq);
void RetrieveFriends(bool bCleanNonFriendContacts = false);
void OnReceiveFriends(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
-#if (VK_NEW_API == 0)
- void MarkMessagesRead(const CMStringA &mids);
-#endif
void MarkMessagesRead(const MCONTACT hContact);
void RetrieveMessagesByIds(const CMStringA &mids);
void RetrieveUnreadMessages();
@@ -394,10 +391,6 @@ private:
CVkChatInfo* AppendConversationChat(int iChatId, const JSONNode& jnItem);
void SetChatTitle(CVkChatInfo *cc, LPCWSTR wszTopic);
void AppendChatConversationMessage(int id, const JSONNode& jnMsg, const JSONNode& jnFUsers, bool bIsHistory);
-#if (VK_NEW_API == 0)
- CVkChatInfo* AppendChat(int id, const JSONNode& jnNode);
- void AppendChatMessage(int id, const JSONNode &jnMsg, const JSONNode &jnFUsers, bool bIsHistory);
-#endif
void AppendChatMessage(CVkChatInfo *cc, LONG uid, int msgTime, LPCWSTR pwszBody, bool bIsHistory, bool bIsAction = false);
void RetrieveChatInfo(CVkChatInfo*);
void OnReceiveChatInfo(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
diff --git a/protocols/VKontakte/src/vk_struct.cpp b/protocols/VKontakte/src/vk_struct.cpp
index 39f33c22d5..ce8a288376 100644
--- a/protocols/VKontakte/src/vk_struct.cpp
+++ b/protocols/VKontakte/src/vk_struct.cpp
@@ -221,9 +221,6 @@ CVKOptions::CVKOptions(PROTO_INTERFACE* proto) :
iStickerSize(proto, "StickerSize", 128),
pwszDefaultGroup(proto, "ProtoGroup", L"VKontakte"),
-#if (VK_NEW_API == 0)
- pwszReturnChatMessage(proto, "ReturnChatMessage", TranslateT("I'm back")),
-#endif
pwszVKLang(proto, "VKLang", nullptr)
{
@@ -235,190 +232,4 @@ CVKOptions::CVKOptions(PROTO_INTERFACE* proto) :
db_unset(0, proto->m_szModuleName, "AutoClean");
}
// Note
-}
-#if (VK_NEW_API == 0)
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
-void CVkUserItem::LoadFromUserProfile(const JSONNode &jnNode)
-{
- if (!jnNode)
- return;
-
- Set(m_bIsGroup, false);
- Set(m_bIsUser, true);
- Set(m_bIsMUChat, false);
- Set(m_bIsEmail, false);
-
- Set(m_iUserId, jnNode["id"].as_int());
- Set(m_wszFirstName, jnNode["first_name"].as_mstring());
- Set(m_wszLastName, jnNode["last_name"].as_mstring());
-
- Set(m_bIsFriend, jnNode["is_friend"].as_bool());
-
- Set(m_wszUserNick, m_wszFirstName + L" " + m_wszLastName);
-
- m_bIsDeactivated = !Set(m_wszDeactivated, jnNode["deactivated"].as_mstring()).IsEmpty();
-
- Set(m_btGender, BYTE(jnNode["sex"].as_int() == 2 ? 'M' : 'F'));
- Set(m_btTimezone, BYTE(jnNode["timezone"].as_int() * -2));
-
- Set(m_wszBDate, jnNode["bdate"].as_mstring());
- Set(m_wszAvatarUrl, jnNode["photo_100"].as_mstring());
-
- Set(m_wszCellular, jnNode["mobile_phone"].as_mstring());
- Set(m_wszPhone, jnNode["home_phone"].as_mstring());
-
- const JSONNode &jnLastSeen = jnNode["last_seen"];
- if (jnLastSeen)
- Set(m_iLastSeen, jnLastSeen["time"].as_int());
-
- Set(m_iStatus, LONG((jnNode["online"].as_int() == 0) ? ID_STATUS_OFFLINE : ID_STATUS_ONLINE));
-
- const JSONNode &jnCountry = jnNode["country"];
- if (jnCountry)
- Set(m_wszCountry, jnCountry["title"].as_mstring());
-
- const JSONNode &jnCity = jnNode["city"];
- if (jnCity)
- Set(m_wszCity, jnCity["title"].as_mstring());
-
- BYTE cMaritalStatus[] = { 0, 10, 11, 12, 20, 70, 50, 60, 80 };
-
- if (jnNode["relation"] && jnNode["relation"].as_int() < _countof(cMaritalStatus))
- Set(m_btMaritalStatus, cMaritalStatus[jnNode["relation"].as_int()]);
-
- Set(m_wszAbout, jnNode["about"].as_mstring());
- Set(m_wszDomain, jnNode["domain"].as_mstring());
-}
-
-
-void CVkUserItem::LoadFromConversation(const JSONNode &jnNode)
-{
- if (!jnNode)
- return;
-
- Set(m_bIsGroup, false);
- Set(m_bIsUser, false);
- Set(m_bIsMUChat, false);
- Set(m_bIsEmail, false);
-
- Set(m_bIsFriend, false);
-
- const JSONNode &jnPeer = jnNode["peer"];
-
- CMStringW wszConversationType(jnPeer["type"].as_mstring());
-
- if (wszConversationType.IsEmpty())
- return;
-
- if (wszConversationType == L"user") {
- Set(m_bIsUser, true);
- Set(m_iUserId, jnPeer["id"].as_int());
- }
- else if (wszConversationType == L"chat") {
- Set(m_bIsMUChat, true);
- Set(m_iUserId, jnPeer["id"].as_int());
- Set(m_iChatId, jnPeer["local_id"].as_int());
-
- const JSONNode &jnChatS = jnNode["chat_settings"];
-
- Set(m_wszUserNick, jnChatS["title"].as_mstring());
- Set(m_iAdminId, jnChatS["owner_id"].as_int());
- }
- else if (wszConversationType == L"group") {
- Set(m_bIsGroup, true);
- Set(m_iUserId, jnPeer["id"].as_int());
- }
-
- Set(m_iLastMsgId, jnNode["last_message_id"].as_int());
-}
-
-void CVkUserItem::LoadFromGroup(const JSONNode & jnNode)
-{
- if (!jnNode)
- return;
-
- Set(m_bIsGroup, true);
- Set(m_bIsUser, false);
- Set(m_bIsMUChat, false);
- Set(m_bIsEmail, false);
-
- Set(m_iUserId, -1 * jnNode["id"].as_int());
-
- Set(m_bIsFriend, jnNode["is_member"].as_bool());
- Set(m_wszUserNick, jnNode["name"].as_mstring());
-
- Set(m_wszAvatarUrl, jnNode["photo_100"].as_mstring());
-
- Set(m_wszDomain, jnNode["screen_name"].as_mstring());
-}
-
-MCONTACT CVkUserItem::WriteToDB(bool bForce, VKContactType /*vkContactType*/)
-{
- if (!bForce && !m_bIsUpdated)
- return m_hContact;
-
-// Work in process...
-
-// LONG m_iUserId;
-// LONG m_iChatId;
-// LONG m_iAdminId;
-
-// LONG m_iStatus;
-// LONG m_iLastSeen;
-// LONG m_iLastMsgId;
-
-// MCONTACT m_hContact;
-
-// CMStringW m_wszFirstName;
-// CMStringW m_wszLastName;
-// CMStringW m_wszUserNick;
-// CMStringW m_wszLink;
-// CMStringW m_wszDeactivated;
-// CMStringW m_wszCellular;
-// CMStringW m_wszPhone;
-// CMStringW m_wszCountry;
-// CMStringW m_wszCity;
-// CMStringW m_wszAbout;
-// CMStringW m_wszDomain;
-// CMStringW m_wszBDate;
-// CMStringW m_wszAvatarUrl;
-
-// BYTE m_btGender;
-// BYTE m_btTimezone;
-// BYTE m_btMaritalStatus;
-
-// bool m_bIsGroup;
-// bool m_bIsFriend;
-// bool m_bIsUser;
-// bool m_bIsEmail;
-// bool m_bIsMUChat;
-// bool m_bIsDeactivated;
-
-// bool m_bIsHidden;
-// bool m_bIsUpdated;
-
- return m_hContact;
-}
-
-CVkUserItem::CVkUserItem(CVkProto* vkProto, const JSONNode &jnNode, vkJSONNodeType vkJSONType)
-{
- m_VK = vkProto;
- m_iUserId = 0;
-
- if (!jnNode)
- return;
-
- if (vkJSONTypeProfile == vkJSONType)
- LoadFromUserProfile(jnNode);
- else if (vkJSONTypeConversation == vkJSONType)
- LoadFromConversation(jnNode);
- else if (vkJSONTypeGroup == vkJSONType)
- LoadFromGroup(jnNode);
-
-
- m_hContact = m_bIsMUChat ? m_VK->FindChat(m_iChatId) : m_VK->FindUser(m_iUserId);
- m_hContact = m_hContact ? m_hContact : INVALID_CONTACT_ID;
-}
-
-#endif \ No newline at end of file
+} \ No newline at end of file
diff --git a/protocols/VKontakte/src/vk_struct.h b/protocols/VKontakte/src/vk_struct.h
index 3660165f1f..dfc718b9c0 100644
--- a/protocols/VKontakte/src/vk_struct.h
+++ b/protocols/VKontakte/src/vk_struct.h
@@ -316,9 +316,6 @@ struct CVKOptions {
CMOption<DWORD> iStickerSize;
CMOption<wchar_t*> pwszDefaultGroup;
-#if (VK_NEW_API == 0)
- CMOption<wchar_t*> pwszReturnChatMessage;
-#endif
CMOption<wchar_t*> pwszVKLang;
CVKOptions(PROTO_INTERFACE *proto);
@@ -344,87 +341,4 @@ struct CVKImageSizeItem {
iSizeH(0),
iSizeW(0)
{}
-};
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-#if (VK_NEW_API == 0)
-enum vkJSONNodeType { vkJSONTypeProfile = 0, vkJSONTypeGroup, vkJSONTypeConversation };
-
-class CVkUserItem : public MZeroedObject {
- CVkUserItem(CVkProto* vkProto, const JSONNode& jnNode, vkJSONNodeType vkJSONType = vkJSONTypeProfile);
-
- CVkUserItem(LONG _UserId) :
- m_iUserId(_UserId),
- m_bIsGroup(false)
- {}
-
- CVkUserItem(LONG _UserId, bool _bIsGroup, CMStringW& _wszUserNick, CMStringW& _wszLink, MCONTACT _hContact = 0) :
- m_iUserId(_UserId),
- m_bIsGroup(_bIsGroup),
- m_wszUserNick(_wszUserNick),
- m_wszLink(_wszLink),
- m_hContact(_hContact)
- {}
-
- /*
- "id, first_name, last_name, photo_100, bdate, sex, timezone, contacts, last_seen, online, status, country, city, relation, interests, activities, music, movies, tv, books, games, quotes, about, domain, is_friend";
- */
- LONG m_iKey;
-
- LONG m_iUserId;
- LONG m_iChatId;
-
- LONG m_iAdminId;
-
-
- LONG m_iStatus;
- LONG m_iLastSeen;
- LONG m_iLastMsgId;
-
- MCONTACT m_hContact;
-
- CMStringW m_wszFirstName;
- CMStringW m_wszLastName;
- CMStringW m_wszUserNick;
- CMStringW m_wszLink;
- CMStringW m_wszDeactivated;
- CMStringW m_wszCellular;
- CMStringW m_wszPhone;
- CMStringW m_wszCountry;
- CMStringW m_wszCity;
- CMStringW m_wszAbout;
- CMStringW m_wszDomain;
- CMStringW m_wszBDate;
- CMStringW m_wszAvatarUrl;
-
- BYTE m_btGender;
- BYTE m_btTimezone;
- BYTE m_btMaritalStatus;
-
- bool m_bIsGroup;
- bool m_bIsFriend;
- bool m_bIsUser;
- bool m_bIsEmail;
- bool m_bIsMUChat;
- bool m_bIsDeactivated;
-
- bool m_bIsHidden;
- bool m_bIsUpdated;
-
- CVkProto* m_VK;
-
- void LoadFromUserProfile(const JSONNode &jnNode);
- void LoadFromConversation(const JSONNode &jnNode);
- void LoadFromGroup(const JSONNode &jnNode);
-
- MCONTACT WriteToDB(bool bForce = false, VKContactType vkContactType = VKContactType::vkContactNormal);
-
- template <class T>
- T Set(T& PropertyName, T Value) {
- m_bIsUpdated = (PropertyName == Value);
- PropertyName = Value;
- }
-
-
-};
-#endif
+}; \ No newline at end of file