diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-11-25 10:25:24 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-11-25 10:25:24 +0000 |
commit | cba2ad851f1b6cd106c2fdb9f805fcd46c9fa57d (patch) | |
tree | 6dcf9e2b2b3013d694315f9d0f4a72920e040e02 /protocols/VKontakte | |
parent | 217bc5d69c56712b7e5792fb1b0a8189b259c074 (diff) |
VKontakte:
full rework for sunc and load history
version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@11051 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte')
-rw-r--r-- | protocols/VKontakte/src/version.h | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_history.cpp | 170 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.cpp | 74 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 34 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_thread.cpp | 11 |
5 files changed, 216 insertions, 75 deletions
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index 011a23b197..64f4821f58 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 0
-#define __BUILD_NUM 27
+#define __BUILD_NUM 28
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp index f7e70a8c88..2c85626843 100644 --- a/protocols/VKontakte/src/vk_history.cpp +++ b/protocols/VKontakte/src/vk_history.cpp @@ -32,9 +32,6 @@ INT_PTR __cdecl CVkProto::SvcGetAllServerHistory(WPARAM hContact, LPARAM) 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);
@@ -42,53 +39,119 @@ INT_PTR __cdecl CVkProto::SvcGetAllServerHistory(WPARAM hContact, LPARAM) hDBEvent = hDBEventNext;
}
- debugLogA("CVkProto::SvcGetAllServerHistory");
- GetHistoryDlgMessages(hContact, 0, INT_MAX, -1);
+ db_unset(hContact, m_szModuleName, "lastmsgid");
+ GetServerHistory(hContact, 0, MAXHISTORYMIDSPERONE, 0, 0);
+ return 1;
+}
+
+INT_PTR __cdecl CVkProto::SvcGetServerHistoryLast1Day(WPARAM hContact, LPARAM)
+{
+ debugLogA("CVkProto::SvcGetServerHistoryLast1Day");
+ if (!IsOnline())
+ return 0;
+
+ GetServerHistoryLastNDay(hContact, 1);
+ return 1;
+}
+
+INT_PTR __cdecl CVkProto::SvcGetServerHistoryLast3Day(WPARAM hContact, LPARAM)
+{
+ debugLogA("CVkProto::SvcGetServerHistoryLast3Day");
+ if (!IsOnline())
+ return 0;
+
+ GetServerHistoryLastNDay(hContact, 3);
+ return 1;
+}
+
+INT_PTR __cdecl CVkProto::SvcGetServerHistoryLast7Day(WPARAM hContact, LPARAM)
+{
+ debugLogA("CVkProto::SvcGetServerHistoryLast7Day");
+ if (!IsOnline())
+ return 0;
+
+ GetServerHistoryLastNDay(hContact, 7);
+ return 1;
+}
+
+INT_PTR __cdecl CVkProto::SvcGetServerHistoryLast30Day(WPARAM hContact, LPARAM)
+{
+ debugLogA("CVkProto::SvcGetServerHistoryLast30Day");
+ if (!IsOnline())
+ return 0;
+
+ GetServerHistoryLastNDay(hContact, 30);
+ return 1;
+}
+
+INT_PTR __cdecl CVkProto::SvcGetServerHistoryLast90Day(WPARAM hContact, LPARAM)
+{
+ debugLogA("CVkProto::SvcGetServerHistoryLast90Day");
+ if (!IsOnline())
+ return 0;
+
+ GetServerHistoryLastNDay(hContact, 90);
return 1;
}
/////////////////////////////////////////////////////////////////////////////////////////
-void CVkProto::GetHistoryDlg(MCONTACT hContact, int iLastMsg)
+void CVkProto::GetServerHistoryLastNDay(MCONTACT hContact, int NDay)
{
- debugLogA("CVkProto::GetHistoryDlg %d", iLastMsg);
- int lastmsgid = getDword(hContact, "lastmsgid", -1);
- if (lastmsgid == -1 || !IsOnline()) {
- setDword(hContact, "lastmsgid", iLastMsg);
+ debugLogA("CVkProto::SvcGetServerHistoryLastNDay %d", NDay);
+ if (!IsOnline())
return;
+
+ UINT iTime = time(0) - 60 * 60 * 24 * NDay;
+
+ HANDLE hDBEvent = db_event_first(hContact);
+ while (hDBEvent) {
+ HANDLE hDBEventNext = db_event_next(hContact, hDBEvent);
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get(hDBEvent, &dbei);
+ if (dbei.timestamp > iTime)
+ db_event_delete(hContact, hDBEvent);
+ hDBEvent = hDBEventNext;
}
- int maxOffset = iLastMsg - lastmsgid;
- setDword(hContact, "new_lastmsgid", iLastMsg);
- GetHistoryDlgMessages(hContact, 0, maxOffset, -1);
+
+ db_unset(hContact, m_szModuleName, "lastmsgid");
+ GetServerHistory(hContact, 0, MAXHISTORYMIDSPERONE, iTime, 0);
}
-void CVkProto::GetHistoryDlgMessages(MCONTACT hContact, int iOffset, int iMaxCount, int lastcount)
+void CVkProto::GetServerHistory(MCONTACT hContact, int iOffset, int iCount, int iTime, int iLastMsgId, bool once)
{
- debugLogA("CVkProto::GetHistoryDlgMessages");
+ debugLogA("CVkProto::GetServerHistory %d %d %d %d %d", iOffset, iCount, iTime, iLastMsgId, (int)once);
+ if (!IsOnline())
+ return;
+
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;
- }
+ CMStringA code, formatcode = "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 allCount=Hist.count;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); return{\"count\":index,\"datetime\":iTime,\"items\":ret,\"once\":%d,\"rcount\":iReqCount};";
+
+ code.AppendFormat(formatcode, iOffset, iCount, userID, iTime, iLastMsgId, (int)once);
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveHistoryMessages)
+ << CHAR_PARAM("code", code)
+ << VER_API)->pUserInfo = new CVkSendMsgParam(hContact, iLastMsgId, iOffset);
+}
- int iReqCount = iMaxCount > MAXHISTORYMIDSPERONE ? MAXHISTORYMIDSPERONE : iMaxCount;
+void CVkProto::GetHistoryDlg(MCONTACT hContact, int iLastMsg)
+{
+ debugLogA("CVkProto::GetHistoryDlg %d", iLastMsg);
- 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;
+ int lastmsgid = getDword(hContact, "lastmsgid", -1);
+ if (lastmsgid == -1 || !IsOnline()) {
+ setDword(hContact, "lastmsgid", iLastMsg);
+ return;
+ }
- pReq->pUserInfo = new CVkSendMsgParam(hContact, iOffset, iMaxCount);
- Push(pReq);
+ GetServerHistory(hContact, 0, MAXHISTORYMIDSPERONE, 0, lastmsgid);
}
void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
@@ -102,30 +165,22 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque 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;
-
+ int iCount = json_as_int(json_get(pResponse, "count"));
+ int iTime = json_as_int(json_get(pResponse, "datetime"));
JSONNODE *pMsgs = json_get(pResponse, "items");
+ int iLastMsgId = getDword(param->hContact, "lastmsgid", -1);
+ int iIndex = iCount;
+ int count = 0;
- 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);
+ for (iIndex = (iCount - 1); iIndex >= 0; iIndex--) {
+ JSONNODE *pMsg = json_at(pMsgs, iIndex);
if (pMsg == NULL)
- break;
+ continue;
- 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;
+ int mid = json_as_int(json_get(pMsg, "id"));
+ if (iLastMsgId < mid)
+ iLastMsgId = mid;
char szMid[40];
_itoa(mid, szMid, 10);
@@ -153,9 +208,14 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque recv.pCustomData = szMid;
recv.cbCustomDataSize = (int)strlen(szMid);
ProtoChainRecvMsg(hContact, &recv);
+ count++;
}
- GetHistoryDlgMessages(param->hContact, param->iMsgID + i, param->iCount - i, i);
- delete param;
-}
+ setDword(param->hContact, "lastmsgid", iLastMsgId);
-/////////////////////////////////////////////////////////////////////////////////////////
\ No newline at end of file + int once = json_as_int(json_get(pResponse, "once"));
+ int iRCount = json_as_int(json_get(pResponse, "rcount"));
+ if (count == iRCount && once == 0)
+ GetServerHistory(param->hContact, param->iCount + count, iRCount, iTime, param->iMsgID);
+
+ delete param;
+}
\ No newline at end of file diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 9b433c10ce..27001486c7 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -129,6 +129,11 @@ void CVkProto::InitMenus() HookProtoEvent(ME_CLIST_PREBUILDCONTACTMENU, &CVkProto::OnPreBuildContactMenu);
//Contact Menu Services
+ CreateProtoService(PS_GETSERVERHISTORYLAST1DAY, &CVkProto::SvcGetServerHistoryLast1Day);
+ CreateProtoService(PS_GETSERVERHISTORYLAST3DAY, &CVkProto::SvcGetServerHistoryLast3Day);
+ CreateProtoService(PS_GETSERVERHISTORYLAST7DAY, &CVkProto::SvcGetServerHistoryLast7Day);
+ CreateProtoService(PS_GETSERVERHISTORYLAST30DAY, &CVkProto::SvcGetServerHistoryLast30Day);
+ CreateProtoService(PS_GETSERVERHISTORYLAST90DAY, &CVkProto::SvcGetServerHistoryLast90Day);
CreateProtoService(PS_GETALLSERVERHISTORY, &CVkProto::SvcGetAllServerHistory);
CreateProtoService(PS_VISITPROFILE, &CVkProto::SvcVisitProfile);
CreateProtoService(PS_CREATECHAT, &CVkProto::SvcCreateChat);
@@ -168,13 +173,6 @@ void CVkProto::InitMenus() mi.ptszName = LPGENT("Visit profile");
g_hContactMenuItems[CMI_VISITPROFILE] = Menu_AddContactMenuItem(&mi);
- mir_snprintf(szService, sizeof(szService), "%s%s", m_szModuleName, PS_GETALLSERVERHISTORY);
- mi.position = -200001000 + CMI_GETALLSERVERHISTORY;
- mi.icolibItem = Skin_GetIconByHandle(GetIconHandle(IDI_HISTORY));
- mi.ptszName = LPGENT("Reload all messages from vk.com");
- mi.pszService = szService;
- g_hContactMenuItems[CMI_GETALLSERVERHISTORY] = Menu_AddContactMenuItem(&mi);
-
mir_snprintf(szService, sizeof(szService), "%s%s", m_szModuleName, PS_ADDASFRIEND);
mi.position = -200001000 + CMI_ADDASFRIEND;
mi.icolibItem = Skin_GetIconByHandle(GetIconHandle(IDI_FRIENDADD));
@@ -216,14 +214,66 @@ void CVkProto::InitMenus() mi.ptszName = LPGENT("Open broadcast");
mi.pszService = szService;
g_hContactMenuItems[CMI_OPENBROADCAST] = Menu_AddContactMenuItem(&mi);
+
+ // Sync history menu
+ mir_snprintf(szService, sizeof(szService), "%s%s", m_szModuleName, PS_GETSERVERHISTORY);
+ mi.position = -200001000 + CMI_GETSERVERHISTORY;
+ mi.icolibItem = Skin_GetIconByHandle(GetIconHandle(IDI_HISTORY));
+ mi.ptszName = LPGENT("Reload messages from vk.com...");
+ mi.pszService = szService;
+ g_hContactMenuItems[CMI_GETSERVERHISTORY] = Menu_AddContactMenuItem(&mi);
+
+ mi.flags |= CMIF_CHILDPOPUP;
+ mi.hParentMenu = g_hContactMenuItems[CMI_GETSERVERHISTORY];
+
+ mir_snprintf(szService, sizeof(szService), "%s%s", m_szModuleName, PS_GETSERVERHISTORYLAST1DAY);
+ mi.position = -200001000 + CMI_GETSERVERHISTORY + 100 + CHMI_GETSERVERHISTORYLAST1DAY;
+ mi.icolibItem = Skin_GetIconByHandle(GetIconHandle(IDI_HISTORY));
+ mi.ptszName = LPGENT("for last 1 day");
+ mi.pszService = szService;
+ g_hContactHistoryMenuItems[CHMI_GETSERVERHISTORYLAST1DAY] = Menu_AddContactMenuItem(&mi);
+
+ mir_snprintf(szService, sizeof(szService), "%s%s", m_szModuleName, PS_GETSERVERHISTORYLAST3DAY);
+ mi.position = -200001000 + CMI_GETSERVERHISTORY + 100 + CHMI_GETSERVERHISTORYLAST3DAY;
+ mi.icolibItem = Skin_GetIconByHandle(GetIconHandle(IDI_HISTORY));
+ mi.ptszName = LPGENT("for last 3 days");
+ mi.pszService = szService;
+ g_hContactHistoryMenuItems[CHMI_GETSERVERHISTORYLAST3DAY] = Menu_AddContactMenuItem(&mi);
+
+ mir_snprintf(szService, sizeof(szService), "%s%s", m_szModuleName, PS_GETSERVERHISTORYLAST7DAY);
+ mi.position = -200001000 + CMI_GETSERVERHISTORY + 100 + CHMI_GETSERVERHISTORYLAST7DAY;
+ mi.icolibItem = Skin_GetIconByHandle(GetIconHandle(IDI_HISTORY));
+ mi.ptszName = LPGENT("for last week");
+ mi.pszService = szService;
+ g_hContactHistoryMenuItems[CHMI_GETSERVERHISTORYLAST7DAY] = Menu_AddContactMenuItem(&mi);
+
+ mir_snprintf(szService, sizeof(szService), "%s%s", m_szModuleName, PS_GETSERVERHISTORYLAST30DAY);
+ mi.position = -200001000 + CMI_GETSERVERHISTORY + 100 + CHMI_GETSERVERHISTORYLAST30DAY;
+ mi.icolibItem = Skin_GetIconByHandle(GetIconHandle(IDI_HISTORY));
+ mi.ptszName = LPGENT("for last 30 days");
+ mi.pszService = szService;
+ g_hContactHistoryMenuItems[CHMI_GETSERVERHISTORYLAST30DAY] = Menu_AddContactMenuItem(&mi);
+
+ mir_snprintf(szService, sizeof(szService), "%s%s", m_szModuleName, PS_GETSERVERHISTORYLAST90DAY);
+ mi.position = -200001000 + CMI_GETSERVERHISTORY + 100 + CHMI_GETSERVERHISTORYLAST90DAY;
+ mi.icolibItem = Skin_GetIconByHandle(GetIconHandle(IDI_HISTORY));
+ mi.ptszName = LPGENT("for last 90 days");
+ mi.pszService = szService;
+ g_hContactHistoryMenuItems[CHMI_GETSERVERHISTORYLAST90DAY] = Menu_AddContactMenuItem(&mi);
+
+ mir_snprintf(szService, sizeof(szService), "%s%s", m_szModuleName, PS_GETALLSERVERHISTORY);
+ mi.position = -200001000 + CMI_GETSERVERHISTORY + 100 + CHMI_GETALLSERVERHISTORY;
+ mi.icolibItem = Skin_GetIconByHandle(GetIconHandle(IDI_HISTORY));
+ mi.ptszName = LPGENT("for all time");
+ mi.pszService = szService;
+ g_hContactHistoryMenuItems[CHMI_GETALLSERVERHISTORY] = Menu_AddContactMenuItem(&mi);
+
}
int CVkProto::OnPreBuildContactMenu(WPARAM hContact, LPARAM)
{
bool bisFriend = getByte(hContact, "Auth", -1)==0;
bool bisBroadcast = !(CMString(db_get_tsa(hContact, m_szModuleName, "AudioUrl")).IsEmpty());
-
- Menu_ShowItem(g_hContactMenuItems[CMI_GETALLSERVERHISTORY], !isChatRoom(hContact));
Menu_ShowItem(g_hContactMenuItems[CMI_VISITPROFILE], !isChatRoom(hContact));
Menu_ShowItem(g_hContactMenuItems[CMI_ADDASFRIEND], !bisFriend && !isChatRoom(hContact));
Menu_ShowItem(g_hContactMenuItems[CMI_DELETEFRIEND], bisFriend);
@@ -231,6 +281,9 @@ int CVkProto::OnPreBuildContactMenu(WPARAM hContact, LPARAM) Menu_ShowItem(g_hContactMenuItems[CMI_REPORTABUSE], !isChatRoom(hContact));
Menu_ShowItem(g_hContactMenuItems[CMI_DESTROYKICKCHAT], isChatRoom(hContact) && getBool(hContact, "off", false));
Menu_ShowItem(g_hContactMenuItems[CMI_OPENBROADCAST], !isChatRoom(hContact) && bisBroadcast);
+ Menu_ShowItem(g_hContactMenuItems[CMI_GETSERVERHISTORY], !isChatRoom(hContact));
+ for (int i = 0; i < CHMI_COUNT; i++)
+ Menu_ShowItem(g_hContactHistoryMenuItems[i], !isChatRoom(hContact));
return 0;
}
@@ -238,6 +291,9 @@ void CVkProto::UnInitMenus() {
for (int i = 0; i < PMI_COUNT; i++)
CallService(MO_REMOVEMENUITEM, (WPARAM)g_hProtoMenuItems[i], 0);
+
+ for (int i = 0; i < CHMI_COUNT; i++)
+ CallService(MO_REMOVEMENUITEM, (WPARAM)g_hContactHistoryMenuItems[i], 0);
for (int i = 0; i < CMI_COUNT; i++)
CallService(MO_REMOVEMENUITEM, (WPARAM)g_hContactMenuItems[i], 0);
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 786bd082b6..e20d33cbf2 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -16,6 +16,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#define PS_CREATECHAT "/CreateNewChat"
+#define PS_GETSERVERHISTORY "/SyncHistory"
+#define PS_GETSERVERHISTORYLAST1DAY "/GetServerHystoryLast1Day"
+#define PS_GETSERVERHISTORYLAST3DAY "/GetServerHystoryLast3Day"
+#define PS_GETSERVERHISTORYLAST7DAY "/GetServerHystoryLast7Day"
+#define PS_GETSERVERHISTORYLAST30DAY "/GetServerHystoryLast30Day"
+#define PS_GETSERVERHISTORYLAST90DAY "/GetServerHystoryLast90Day"
#define PS_GETALLSERVERHISTORY "/GetAllServerHystory"
#define PS_VISITPROFILE "/VisitProfile"
#define PS_ADDASFRIEND "/AddAsFriend"
@@ -238,9 +244,17 @@ struct CVkProto : public PROTO<CVkProto> INT_PTR __cdecl SvcDeleteFriend(WPARAM hContact, LPARAM);
INT_PTR __cdecl SvcBanUser(WPARAM hContact, LPARAM);
INT_PTR __cdecl SvcReportAbuse(WPARAM hContact, LPARAM);
- INT_PTR __cdecl SvcGetAllServerHistory(WPARAM hContact, LPARAM);
INT_PTR __cdecl SvcDestroyKickChat(WPARAM hContact, LPARAM);
INT_PTR __cdecl SvcOpenBroadcast(WPARAM hContact, LPARAM);
+
+ //==== History Menus ==================================================================
+
+ INT_PTR __cdecl SvcGetServerHistoryLast1Day(WPARAM hContact, LPARAM);
+ INT_PTR __cdecl SvcGetServerHistoryLast3Day(WPARAM hContact, LPARAM);
+ INT_PTR __cdecl SvcGetServerHistoryLast7Day(WPARAM hContact, LPARAM);
+ INT_PTR __cdecl SvcGetServerHistoryLast30Day(WPARAM hContact, LPARAM);
+ INT_PTR __cdecl SvcGetServerHistoryLast90Day(WPARAM hContact, LPARAM);
+ INT_PTR __cdecl SvcGetAllServerHistory(WPARAM hContact, LPARAM);
void InitMenus();
void UnInitMenus();
int __cdecl OnPreBuildContactMenu(WPARAM hContact, LPARAM);
@@ -255,6 +269,7 @@ struct CVkProto : public PROTO<CVkProto> int __cdecl OnProcessSrmmEvent(WPARAM, LPARAM);
int __cdecl OnDbEventRead(WPARAM, LPARAM);
int __cdecl OnDbSettingChanged(WPARAM, LPARAM);
+
//==== Search ========================================================================
void __cdecl SearchBasicThread(void* id);
@@ -270,6 +285,7 @@ struct CVkProto : public PROTO<CVkProto> void OnReciveUploadServer(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
void OnReciveUpload(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
void OnReciveUploadFile(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
+
//==== Misc ==========================================================================
TCHAR* GetUserStoredPassword(void);
@@ -298,9 +314,10 @@ struct CVkProto : public PROTO<CVkProto> void OnSendMessage(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
+ void GetServerHistoryLastNDay(MCONTACT hContact, int NDay);
+ void GetServerHistory(MCONTACT hContact, int iOffset, int iCount, int iTime, int iLastMsgId, bool once = false);
void OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq);
void GetHistoryDlg(MCONTACT hContact, int iLastMsg);
- void GetHistoryDlgMessages(MCONTACT hContact, int iOffset, int iMaxCount, int lastcount);
void RetrievePollingInfo();
void OnReceivePollingInfo(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
@@ -342,7 +359,6 @@ private: CMStringA m_prevUrl;
enum CLMenuIndexes {
- CMI_GETALLSERVERHISTORY,
CMI_VISITPROFILE,
CMI_ADDASFRIEND,
CMI_DELETEFRIEND,
@@ -350,8 +366,19 @@ private: CMI_REPORTABUSE,
CMI_DESTROYKICKCHAT,
CMI_OPENBROADCAST,
+ CMI_GETSERVERHISTORY,
CMI_COUNT
};
+ enum CLMenuHistoruIndexes {
+ CHMI_GETSERVERHISTORY,
+ CHMI_GETSERVERHISTORYLAST1DAY,
+ CHMI_GETSERVERHISTORYLAST3DAY,
+ CHMI_GETSERVERHISTORYLAST7DAY,
+ CHMI_GETSERVERHISTORYLAST30DAY,
+ CHMI_GETSERVERHISTORYLAST90DAY,
+ CHMI_GETALLSERVERHISTORY,
+ CHMI_COUNT
+ };
enum ProtoMenuIndexes {
PMI_CREATECHAT,
PMI_VISITPROFILE,
@@ -359,6 +386,7 @@ private: };
HGENMENU g_hContactMenuItems[CMI_COUNT];
+ HGENMENU g_hContactHistoryMenuItems[CHMI_COUNT];
HGENMENU g_hProtoMenuItems[PMI_COUNT];
struct Cookie
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index b96d55ea2e..ae4d84fb9f 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -686,22 +686,19 @@ void CVkProto::OnReceiveDlgs(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) int uid = json_as_int(json_get(pDlg, "user_id"));
MCONTACT hContact = FindUser(uid, true);
- if (getDword(hContact, "lastmsgid", -1) == -1 && numUnread){
- setDword(hContact, "new_lastmsgid", mid);
- GetHistoryDlgMessages(hContact, 0, numUnread, -1);
- }
+ if (getDword(hContact, "lastmsgid", -1) == -1 && numUnread)
+ GetServerHistory(hContact, 0, numUnread, 0, 0, true);
else
GetHistoryDlg(hContact, mid);
- if (m_iMarkMessageReadOn == markOnReceive&&numUnread)
+ if (m_iMarkMessageReadOn == markOnReceive && numUnread)
MarkMessagesRead(hContact);
}
else if (numUnread) {
int mid = json_as_int(json_get(pDlg, "id"));
int uid = json_as_int(json_get(pDlg, "user_id"));
MCONTACT hContact = FindUser(uid, true);
- setDword(hContact, "new_lastmsgid", mid);
- GetHistoryDlgMessages(hContact, 0, numUnread, -1);
+ GetServerHistory(hContact, 0, numUnread, 0, 0, true);
if (m_iMarkMessageReadOn == markOnReceive)
MarkMessagesRead(hContact);
|