summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/VKontakte/src/version.h2
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp61
-rw-r--r--protocols/VKontakte/src/vk_feed.cpp3
-rw-r--r--protocols/VKontakte/src/vk_history.cpp23
-rw-r--r--protocols/VKontakte/src/vk_messages.cpp21
-rw-r--r--protocols/VKontakte/src/vk_status.cpp41
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp39
7 files changed, 52 insertions, 138 deletions
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h
index c5db730bcd..889fc82466 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 2
-#define __BUILD_NUM 13
+#define __BUILD_NUM 14
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp
index f26d6f061f..975bcd9fdc 100644
--- a/protocols/VKontakte/src/vk_chats.cpp
+++ b/protocols/VKontakte/src/vk_chats.cpp
@@ -93,33 +93,12 @@ CVkChatInfo* CVkProto::AppendChat(int id, const JSONNode &jnDlg)
void CVkProto::RetrieveChatInfo(CVkChatInfo *cc)
{
+ debugLogA("CVkProto::RetrieveChatInfo");
- CMStringA wszQuery(FORMAT, "var ChatId=%d;", cc->m_chatid);
- wszQuery += "var Info=API.messages.getChat({\"chat_id\":ChatId});"
- "var ChatUsers=API.messages.getChatUsers({\"chat_id\":ChatId,\"fields\":\"id,first_name,last_name\"});";
-
- if (!cc->m_bHistoryRead) {
- wszQuery += "var ChatMsg=API.messages.getHistory({\"chat_id\":ChatId,\"count\":20,\"rev\":0});var UR=parseInt(ChatMsg.unread);"
- "if(UR>20){if(UR>200)UR=200;ChatMsg=API.messages.getHistory({\"chat_id\":ChatId,\"count\":UR,\"rev\":0});};"
- "var FMsgs = ChatMsg.items@.fwd_messages;var Idx = 0;var Uids =[];while (Idx < FMsgs.length){"
- "var Jdx = 0;var CFMsgs = parseInt(FMsgs[Idx].length);while (Jdx < CFMsgs){"
- "Uids.unshift(FMsgs[Idx][Jdx].user_id);Jdx = Jdx + 1;};Idx = Idx + 1;};"
- "var FUsers = API.users.get({\"user_ids\": Uids, \"name_case\":\"gen\"});"
- "var MsgUsers=API.users.get({\"user_ids\":ChatMsg.items@.user_id,\"fields\":\"id,first_name,last_name\"});";
- }
-
- wszQuery += "return {\"info\":Info,\"users\":ChatUsers";
-
- if (!cc->m_bHistoryRead)
- wszQuery += ",\"msgs\":ChatMsg,\"fwd_users\":FUsers,\"msgs_users\":MsgUsers";
-
- wszQuery +="};";
-
- debugLogA("CVkProto::RetrieveChantInfo(%d)", cc->m_chatid);
- if (!IsOnline())
- return;
- Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveChatInfo)
- << CHAR_PARAM("code", wszQuery))->pUserInfo = cc;
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.RetrieveChatInfo", true, &CVkProto::OnReceiveChatInfo)
+ << INT_PARAM("chatid", cc->m_chatid)
+ << INT_PARAM("func_v", cc->m_bHistoryRead ? 1 : 2)
+ )->pUserInfo = cc;
}
void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
@@ -569,18 +548,13 @@ void CVkProto::LogMenuHook(CVkChatInfo *cc, GCHOOK *gch)
case IDM_DESTROY:
if (IDYES == MessageBoxW(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_YESNO | MB_ICONQUESTION))
- {
- CMStringA code;
- code.Format("API.messages.removeChatUser({\"chat_id\":%d, \"user_id\":%d});"
- "var Hist = API.messages.getHistory({\"chat_id\":%d, \"count\":200});"
- "var countMsg = Hist.count;var itemsMsg = Hist.items@.id; "
- "while (countMsg > 0) { 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, m_myUserId, cc->m_chatid, cc->m_chatid);
- Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnChatDestroy)
- << CHAR_PARAM("code", code))->pUserInfo = cc;
- }
+ TranslateT("Warning"), MB_YESNO | MB_ICONQUESTION)
+ )
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.DestroyChat", true, &CVkProto::OnChatDestroy)
+ << INT_PARAM("chatid", cc->m_chatid)
+ << INT_PARAM("userid", m_myUserId)
+ )->pUserInfo = cc;
+
break;
}
}
@@ -703,14 +677,9 @@ INT_PTR __cdecl CVkProto::SvcDestroyKickChat(WPARAM hContact, LPARAM)
if (chat_id == VK_INVALID_USER)
return 1;
- 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 > 0) { API.messages.delete({\"message_ids\":itemsMsg});"
- "Hist=API.messages.getHistory({\"chat_id\":%d, \"count\":200});"
- "countMsg = Hist.count;itemsMsg = Hist.items@.id;}; return 1;", chat_id, chat_id);
- Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveSmth)
- << CHAR_PARAM("code", code));
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.DestroyKickChat", true, &CVkProto::OnReceiveSmth)
+ << INT_PARAM("chatid", chat_id)
+ );
db_delete_contact(hContact);
diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp
index 44dc556477..1f1e496950 100644
--- a/protocols/VKontakte/src/vk_feed.cpp
+++ b/protocols/VKontakte/src/vk_feed.cpp
@@ -713,7 +713,8 @@ void CVkProto::RetrieveUnreadNotifications(time_t tLastNotificationsTime)
m_vkOptions.bNotificationFilterInvites ? L",\"groupinvates\":API.groups.getInvites({\"extended\":1})};" : L"};");
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveUnreadNotifications)
- << WCHAR_PARAM("code", code) );
+ << WCHAR_PARAM("code", code)
+ );
setDword("LastNotificationsReqTime", (DWORD)time(NULL));
}
diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp
index fd27cc8104..4f71591353 100644
--- a/protocols/VKontakte/src/vk_history.cpp
+++ b/protocols/VKontakte/src/vk_history.cpp
@@ -123,20 +123,15 @@ void CVkProto::GetServerHistory(MCONTACT hContact, int iOffset, int iCount, int
if (VK_INVALID_USER == userID || userID == VK_FEED_USER)
return;
- CMStringA code(FORMAT, "var iOffset=%d;var iReqCount=%d;var userID=%d;var iTime=%d;var lastMid=%d;"
- "var Hist=API.messages.getHistory({\"user_id\":userID,\"count\":iReqCount,\"offset\":iOffset});"
- "var ext=Hist.items.length;var index=0;"
- "while(ext!=0){if(Hist.items[index].date>iTime){if(Hist.items[index].id>lastMid)"
- "{index=index+1;ext=ext-1;}else ext=0;}else ext=0;};"
- "var ret=Hist.items.slice(0,index);"
- "var FMsgs=ret@.fwd_messages;var Idx=0;var Uids=[];while(Idx<FMsgs.length){"
- "var Jdx=0;var CFMsgs=parseInt(FMsgs[Idx].length);while(Jdx<CFMsgs){"
- "Uids.unshift(FMsgs[Idx][Jdx].user_id);Jdx=Jdx+1;};Idx=Idx+1;};"
- "var FUsers=API.users.get({\"user_ids\":Uids,\"name_case\":\"gen\"});"
- "return{\"count\":index,\"datetime\":iTime,\"items\":ret,\"fwd_users\":FUsers,\"once\":%d,\"rcount\":iReqCount};",
- iOffset, iCount, userID, iTime, iLastMsgId, (int)once);
- Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveHistoryMessages, AsyncHttpRequest::rpLow)
- << CHAR_PARAM("code", code))->pUserInfo = new CVkSendMsgParam(hContact, iLastMsgId, iOffset);
+ 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);
+
}
void CVkProto::GetHistoryDlg(MCONTACT hContact, int iLastMsg)
diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp
index 98b1a1076a..220c4d98b5 100644
--- a/protocols/VKontakte/src/vk_messages.cpp
+++ b/protocols/VKontakte/src/vk_messages.cpp
@@ -198,21 +198,9 @@ void CVkProto::RetrieveMessagesByIds(const CMStringA &mids)
if (!IsOnline() || mids.IsEmpty())
return;
- CMStringA code(FORMAT, "var Mids=\"%s\";"
- "var Msgs=API.messages.getById({\"message_ids\":Mids});"
- "var FMsgs=Msgs.items@.fwd_messages;"
- "var Idx=0;var Uids=[];"
- "while(Idx<FMsgs.length){"
- "var Jdx=0;var CFMsgs=parseInt(FMsgs[Idx].length);"
- "while(Jdx<CFMsgs){Uids.unshift(FMsgs[Idx][Jdx].user_id);"
- "Jdx=Jdx+1;};Idx=Idx+1;};"
- "var FUsers=API.users.get({\"user_ids\":Uids,\"name_case\":\"gen\"});"
- "return{\"Msgs\":Msgs,\"fwd_users\":FUsers};",
- mids
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.RetrieveMessagesByIds", true, &CVkProto::OnReceiveMessages, AsyncHttpRequest::rpHigh)
+ << CHAR_PARAM("mids", mids)
);
-
- Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveMessages, AsyncHttpRequest::rpHigh)
- << CHAR_PARAM("code", code));
}
void CVkProto::RetrieveUnreadMessages()
@@ -221,10 +209,7 @@ void CVkProto::RetrieveUnreadMessages()
if (!IsOnline())
return;
- Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveDlgs, AsyncHttpRequest::rpHigh)
- << CHAR_PARAM("code", "var dlg=API.messages.getDialogs({\"count\":200});"
- "var users=API.friends.areFriends({\"user_ids\":dlg.items@.message@.user_id});var groups=API.groups.get();"
- "return{\"dialogs\":dlg, \"users\":users, \"groups\":groups.items};"));
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.RetrieveUnreadMessages", true, &CVkProto::OnReceiveDlgs, AsyncHttpRequest::rpHigh));
}
void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
diff --git a/protocols/VKontakte/src/vk_status.cpp b/protocols/VKontakte/src/vk_status.cpp
index d7503923df..e7e335be2a 100644
--- a/protocols/VKontakte/src/vk_status.cpp
+++ b/protocols/VKontakte/src/vk_status.cpp
@@ -180,10 +180,10 @@ void CVkProto::RetrieveStatusMusic(const CMStringW &StatusMsg)
debugLogA("CVkProto::RetrieveStatusMusic");
if (!IsOnline() || m_iStatus == ID_STATUS_INVISIBLE || m_vkOptions.iMusicSendMetod == MusicSendMetod::sendNone)
return;
-
- CMStringW code;
+
CMStringW wszOldStatusMsg(db_get_wsa(0, m_szModuleName, "OldStatusMsg"));
if (StatusMsg.IsEmpty()) {
+ CMStringW code;
if (m_vkOptions.iMusicSendMetod == MusicSendMetod::sendBroadcastOnly)
code = "API.audio.setBroadcast();return null;";
else {
@@ -191,41 +191,16 @@ void CVkProto::RetrieveStatusMusic(const CMStringW &StatusMsg)
code.AppendFormat(codeformat, wszOldStatusMsg);
}
m_bSetBroadcast = false;
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveStatus)
+ << WCHAR_PARAM("code", code));
}
else {
- if (m_vkOptions.iMusicSendMetod == MusicSendMetod::sendBroadcastOnly) {
- CMStringW codeformat("var StatusMsg=\"%s\";var CntLmt=100;var OldMsg=API.status.get();"
- "var Tracks=API.audio.search({\"q\":StatusMsg,\"count\":CntLmt,\"search_own\":1});"
- "var Cnt=Tracks.count;if(Cnt>CntLmt){Cnt=CntLmt;}"
- "if(Cnt==0){API.audio.setBroadcast();}"
- "else{var i=0;var j=0;var Track=\" \";"
- "while(i<Cnt){Track=Tracks.items[i].artist+\" - \"+Tracks.items[i].title;if(Track==StatusMsg){j=i;}i=i+1;}"
- "Track=Tracks.items[j].owner_id+\"_\"+Tracks.items[j].id;API.audio.setBroadcast({\"audio\":Track});"
- "};return OldMsg;");
- code.AppendFormat(codeformat, StatusMsg);
- }
- else if (m_vkOptions.iMusicSendMetod == MusicSendMetod::sendStatusOnly) {
- CMStringW codeformat("var StatusMsg=\"&#9835; %s\";var OldMsg=API.status.get();"
- "API.status.set({\"text\":StatusMsg});"
- "return OldMsg;");
- code.AppendFormat(codeformat, StatusMsg);
- }
- else if (m_vkOptions.iMusicSendMetod == MusicSendMetod::sendBroadcastAndStatus) {
- CMStringW codeformat("var StatusMsg=\"%s\";var CntLmt=100;var Track=\" \";var OldMsg=API.status.get();"
- "var Tracks=API.audio.search({\"q\":StatusMsg,\"count\":CntLmt,\"search_own\":1});"
- "var Cnt=Tracks.count;if(Cnt>CntLmt){Cnt=CntLmt;}"
- "if(Cnt==0){Track=\"&#9835; \"+StatusMsg;API.status.set({\"text\":Track});}"
- "else{var i=0;var j=-1;"
- "while(i<Cnt){Track=Tracks.items[i].artist+\" - \"+Tracks.items[i].title;if(Track==StatusMsg){j=i;}i=i+1;}"
- "if(j==-1){Track=\"&#9835; \"+StatusMsg;API.status.set({\"text\":Track});}else{"
- "Track=Tracks.items[j].owner_id+\"_\"+Tracks.items[j].id;};API.audio.setBroadcast({\"audio\":Track});"
- "};return OldMsg;");
- code.AppendFormat(codeformat, StatusMsg);
- }
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.RetrieveStatusMusic", true, &CVkProto::OnReceiveStatus)
+ << WCHAR_PARAM("statusmsg", StatusMsg)
+ << INT_PARAM("func_v", (int)(m_vkOptions.iMusicSendMetod))
+ );
m_bSetBroadcast = true;
}
- Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveStatus)
- << WCHAR_PARAM("code", code));
}
INT_PTR __cdecl CVkProto::SvcSetListeningTo(WPARAM, LPARAM lParam)
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index a6dd0b385d..719f6b287a 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -487,10 +487,11 @@ void CVkProto::RetrieveUserInfo(LONG userID)
return;
}
- CMStringW code(FORMAT, L"var userIDs=\"%i\";var res=API.users.get({\"user_ids\":userIDs,\"fields\":\"%s\",\"name_case\":\"nom\"});return{\"freeoffline\":0,\"norepeat\":1,\"usercount\":res.length,\"users\":res};",
- userID, CMStringW(fieldsName));
- Push(new AsyncHttpRequest(this, REQUEST_POST, "/method/execute.json", true, &CVkProto::OnReceiveUserInfo)
- << WCHAR_PARAM("code", code));
+ Push(new AsyncHttpRequest(this, REQUEST_POST, "/method/execute.RetrieveUserInfo", true, &CVkProto::OnReceiveUserInfo)
+ << INT_PARAM("userid", userID)
+ << CHAR_PARAM("fields", fieldsName)
+ );
+
}
void CVkProto::RetrieveGroupInfo(LONG groupID)
@@ -521,7 +522,7 @@ void CVkProto::RetrieveUsersInfo(bool bFreeOffline, bool bRepeat)
if (!IsOnline())
return;
- CMStringW userIDs, code;
+ CMStringA userIDs;
int i = 0;
for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
LONG userID = getDword(hContact, "ID", VK_INVALID_USER);
@@ -534,33 +535,21 @@ void CVkProto::RetrieveUsersInfo(bool bFreeOffline, bool bRepeat)
if (!userIDs.IsEmpty())
userIDs.AppendChar(',');
- userIDs.AppendFormat(L"%i", userID);
+ userIDs.AppendFormat("%i", userID);
if (i == MAX_CONTACTS_PER_REQUEST)
break;
i++;
}
- CMStringW codeformat("var userIDs=\"%s\";var _fields=\"%s\";");
-
- if (m_bNeedSendOnline)
- codeformat += L"API.account.setOnline();";
-
- if (bFreeOffline && !m_vkOptions.bLoadFullCList)
- codeformat += CMStringW("var US=[];var res=API.users.get({\"user_ids\":API.friends.getOnline(),\"fields\":_fields,\"name_case\":\"nom\"});"
- "var t=10;while(t>0){"
- "US=API.users.get({\"user_ids\":userIDs,\"fields\":_fields,\"name_case\":\"nom\"});"
- "var index=US.length;while(index>0){"
- "index=index-1;if(US[index].online!=0){res.push(US[index]);};};"
- "t=t-1;if(res.length>0)t=0;};"
- "return{\"freeoffline\":1,\"norepeat\":%d,\"usercount\":res.length,\"users\":res,\"requests\":API.friends.getRequests({\"extended\":0,\"need_mutual\":0,\"out\":0})};");
- else
- codeformat += CMStringW("var res=API.users.get({\"user_ids\":userIDs,\"fields\":_fields,\"name_case\":\"nom\"});"
- "return{\"freeoffline\":0,\"norepeat\":%d,\"usercount\":res.length,\"users\":res,\"requests\":API.friends.getRequests({\"extended\":0,\"need_mutual\":0,\"out\":0})};");
- code.AppendFormat(codeformat, userIDs, CMStringW(bFreeOffline ? "online,status" : fieldsName), (int)bRepeat);
+ Push(new AsyncHttpRequest(this, REQUEST_POST, "/method/execute.RetrieveUsersInfo", true, &CVkProto::OnReceiveUserInfo)
+ << CHAR_PARAM("userids", userIDs)
+ << CHAR_PARAM("fields", (bFreeOffline ? "online,status" : fieldsName))
+ << INT_PARAM("norepeat", (int)bRepeat)
+ << INT_PARAM("setonline", (int)m_bNeedSendOnline)
+ << INT_PARAM("func_v", (bFreeOffline && !m_vkOptions.bLoadFullCList) ? 1 : 2)
+ );
- Push(new AsyncHttpRequest(this, REQUEST_POST, "/method/execute.json", true, &CVkProto::OnReceiveUserInfo)
- << WCHAR_PARAM("code", code));
}
void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)