summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src/vk_thread.cpp
diff options
context:
space:
mode:
authorSergey Bolhovskoy <elzorfox@ya.ru>2014-11-24 06:14:59 +0000
committerSergey Bolhovskoy <elzorfox@ya.ru>2014-11-24 06:14:59 +0000
commit52ffa352fee96307e376c7852580ea04f01e2f70 (patch)
tree2cdfb0c4c59656ff8e5c828e1b6626ae46b9db82 /protocols/VKontakte/src/vk_thread.cpp
parent4865736f1afacd6e25807ada8b85fc0c76a4d0ec (diff)
VKontakte: move history functions to vk_history.cpp
git-svn-id: http://svn.miranda-ng.org/main/trunk@11046 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src/vk_thread.cpp')
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp139
1 files changed, 0 insertions, 139 deletions
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index 8a9653affc..b96d55ea2e 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -714,117 +714,6 @@ void CVkProto::OnReceiveDlgs(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
/////////////////////////////////////////////////////////////////////////////////////////
-void CVkProto::GetHistoryDlg(MCONTACT hContact, int iLastMsg)
-{
- debugLogA("CVkProto::GetHistoryDlg %d", iLastMsg);
- int lastmsgid = getDword(hContact, "lastmsgid", -1);
- if (lastmsgid == -1 || !IsOnline()) {
- setDword(hContact, "lastmsgid", iLastMsg);
- return;
- }
- int maxOffset = iLastMsg - lastmsgid;
- setDword(hContact, "new_lastmsgid", iLastMsg);
- GetHistoryDlgMessages(hContact, 0, maxOffset, -1);
-}
-
-void CVkProto::GetHistoryDlgMessages(MCONTACT hContact, int iOffset, int iMaxCount, int lastcount)
-{
- debugLogA("CVkProto::GetHistoryDlgMessages");
- LONG userID = getDword(hContact, "ID", -1);
- if (-1 == userID)
- return;
-
- if (lastcount == 0 || iMaxCount < 1 || !IsOnline()) {
- setDword(hContact, "lastmsgid", getDword(hContact, "new_lastmsgid", -1));
- db_unset(hContact, m_szModuleName, "new_lastmsgid");
- if (getBool(hContact, "ImportHistory", false))
- MsgPopup(hContact, TranslateT("History import is complete"), TranslateT("History import"));
- db_unset(hContact, m_szModuleName, "ImportHistory");
- return;
- }
-
- int iReqCount = iMaxCount > MAXHISTORYMIDSPERONE ? MAXHISTORYMIDSPERONE : iMaxCount;
-
- debugLogA("CVkProto::GetHistoryDlgMessages %d %d %d", userID, iOffset, iReqCount);
- AsyncHttpRequest *pReq = new AsyncHttpRequest(this, REQUEST_GET, "/method/messages.getHistory.json", true, &CVkProto::OnReceiveHistoryMessages)
- << INT_PARAM("offset", iOffset)
- << INT_PARAM("count", iReqCount)
- << INT_PARAM("user_id", userID)
- << VER_API;
-
- pReq->pUserInfo = new CVkSendMsgParam(hContact, iOffset, iMaxCount);
- Push(pReq);
-}
-
-void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
-{
- debugLogA("CVkProto::OnReceiveHistoryMessages %d", reply->resultCode);
- if (reply->resultCode != 200)
- return;
-
- JSONROOT pRoot;
- JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot);
- if (pResponse == NULL)
- return;
-
- CMStringA mids;
- CVkSendMsgParam *param = (CVkSendMsgParam*)pReq->pUserInfo;
- int numMessages = json_as_int(json_get(pResponse, "count")),
- i = 0,
- lastmsgid = getDword(param->hContact, "lastmsgid", -1),
- mid = -1;
-
- JSONNODE *pMsgs = json_get(pResponse, "items");
-
- int new_lastmsgid = getDword(param->hContact, "new_lastmsgid", -1);
- int his = getByte(param->hContact, "ImportHistory", 0);
-
- for (i = 0; i < numMessages; i++) {
- JSONNODE *pMsg = json_at(pMsgs, i);
- if (pMsg == NULL)
- break;
-
- mid = json_as_int(json_get(pMsg, "id"));
- if (his && new_lastmsgid == -1) {
- new_lastmsgid = mid;
- setDword(param->hContact, "new_lastmsgid", mid);
- }
- if (mid <= lastmsgid)
- break;
-
- char szMid[40];
- _itoa(mid, szMid, 10);
-
- ptrT ptszBody(json_as_string(json_get(pMsg, "body")));
- int datetime = json_as_int(json_get(pMsg, "date"));
- int isOut = json_as_int(json_get(pMsg, "out"));
- int isRead = json_as_int(json_get(pMsg, "read_state"));
- int uid = json_as_int(json_get(pMsg, "user_id"));
-
- JSONNODE *pAttachments = json_get(pMsg, "attachments");
- if (pAttachments != NULL)
- ptszBody = mir_tstrdup(CMString(ptszBody) + GetAttachmentDescr(pAttachments));
-
- MCONTACT hContact = FindUser(uid, true);
- PROTORECVEVENT recv = { 0 };
- recv.flags = PREF_TCHAR;
- if (isRead)
- recv.flags |= PREF_CREATEREAD;
- if (isOut)
- recv.flags |= PREF_SENT;
- recv.timestamp = datetime;
- recv.tszMessage = ptszBody;
- recv.lParam = isOut;
- recv.pCustomData = szMid;
- recv.cbCustomDataSize = (int)strlen(szMid);
- ProtoChainRecvMsg(hContact, &recv);
- }
- GetHistoryDlgMessages(param->hContact, param->iMsgID + i, param->iCount - i, i);
- delete param;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
void CVkProto::RetrievePollingInfo()
{
debugLogA("CVkProto::RetrievePollingInfo");
@@ -1322,34 +1211,6 @@ INT_PTR __cdecl CVkProto::SvcVisitProfile(WPARAM hContact, LPARAM)
return 0;
}
-INT_PTR __cdecl CVkProto::SvcGetAllServerHistory(WPARAM hContact, LPARAM)
-{
- debugLogA("CVkProto::SvcGetAllServerHistory");
- if (!IsOnline())
- return 0;
- LPCTSTR str = TranslateT("Are you sure to reload all messages from vk.com?\nLocal contact history will be deleted and reloaded from the server.\nIt may take a long time.\nDo you want to continue?");
- if (IDNO == MessageBox(NULL, str, TranslateT("Attention!"), MB_ICONWARNING | MB_YESNO))
- return 0;
-
- LONG userID = getDword(hContact, "ID", -1);
- if (userID == -1)
- return 0;
-
- setByte(hContact, "ImportHistory", 1);
- setDword(hContact, "lastmsgid", 0);
-
- HANDLE hDBEvent = db_event_first(hContact);
- while (hDBEvent) {
- HANDLE hDBEventNext = db_event_next(hContact, hDBEvent);
- db_event_delete(hContact, hDBEvent);
- hDBEvent = hDBEventNext;
- }
-
- debugLogA("CVkProto::SvcGetAllServerHistory");
- GetHistoryDlgMessages(hContact, 0, INT_MAX, -1);
- return 1;
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
CMString CVkProto::GetAttachmentDescr(JSONNODE *pAttachments)