diff options
author | ElzorFox <elzorfox@ya.ru> | 2017-01-25 13:42:57 +0500 |
---|---|---|
committer | ElzorFox <elzorfox@ya.ru> | 2017-01-25 13:42:57 +0500 |
commit | 9d92a46105e5203c829a0e1958285e74a984a7f4 (patch) | |
tree | 87ae6991ede2fb54452a5cc910e40204d31d7a4f /protocols/VKontakte/src | |
parent | f9c61d93a14c89c89f234d978fb4264a3b271266 (diff) |
VKontakte:
fix autoloading history on open message window
fix cleaning lastmsgid key on ‘empty’ sync history
Diffstat (limited to 'protocols/VKontakte/src')
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 38 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_history.cpp | 5 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_options.cpp | 4 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 1 |
4 files changed, 39 insertions, 9 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 885f00f9a1..7f81cdf53e 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -132,8 +132,8 @@ char* ExpUrlEncode(const char *szUrl, bool strict) *d++ = szHexDigits[*s & 0xF];
}
- *d = '\0';
- return szOutput;
+ *d = '\0';
+ return szOutput;
}
@@ -670,21 +670,47 @@ void CVkProto::ContactTypingThread(void *p) }
}
+int CVkProto::IsHystoryMessageExist(MCONTACT hContact)
+{
+ if (!hContact)
+ return 0;
+
+ MEVENT hDBEvent = db_event_first(hContact);
+
+ if (!hDBEvent)
+ return 0;
+
+ do {
+ DBEVENTINFO dbei = {};
+ db_event_get(hDBEvent, &dbei);
+ if (dbei.eventType != VK_USER_DEACTIVATE_ACTION)
+ return 1;
+
+ hDBEvent = db_event_next(hContact, hDBEvent);
+ } while (hDBEvent);
+
+ return -1;
+}
+
int CVkProto::OnProcessSrmmEvent(WPARAM, LPARAM lParam)
{
debugLogA("CVkProto::OnProcessSrmmEvent");
MessageWindowEventData *event = (MessageWindowEventData *)lParam;
+
+ CMStringA szProto(GetContactProto(event->hContact));
+ if (szProto.IsEmpty() || szProto != m_szModuleName)
+ return 0;
+
if (event->uType == MSG_WINDOW_EVT_OPENING && !ServiceExists(MS_MESSAGESTATE_UPDATE))
SetSrmmReadStatus(event->hContact);
- if (event->uType == MSG_WINDOW_EVT_OPENING && m_vkOptions.bLoadLastMessageOnMsgWindowsOpen
- && getDword(event->hContact, "lastmsgid", -1) == -1 && !isChatRoom(event->hContact)) {
+ if (event->uType == MSG_WINDOW_EVT_OPENING && m_vkOptions.bLoadLastMessageOnMsgWindowsOpen
+ && !isChatRoom(event->hContact) && IsHystoryMessageExist(event->hContact) != 1) {
m_bNotifyForEndLoadingHistory = false;
- GetServerHistory(event->hContact, 0, 100, 0, 0, true);
+ GetServerHistory(event->hContact, 0, MAXHISTORYMIDSPERONE, 0, 0, true);
}
-
return 0;
}
diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp index 8883238694..794ac8e465 100644 --- a/protocols/VKontakte/src/vk_history.cpp +++ b/protocols/VKontakte/src/vk_history.cpp @@ -108,6 +108,7 @@ void CVkProto::GetServerHistoryLastNDay(MCONTACT hContact, int NDay) m_bNotifyForEndLoadingHistory = true;
}
+ setDword(hContact, "oldlastmsgid", getDword(hContact, "lastmsgid", -1));
db_unset(hContact, m_szModuleName, "lastmsgid");
GetServerHistory(hContact, 0, MAXHISTORYMIDSPERONE, tTime, 0);
}
@@ -264,6 +265,7 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque count++;
}
+
setDword(param->hContact, "lastmsgid", iLastMsgId);
if (ServiceExists(MS_MESSAGESTATE_UPDATE)) {
@@ -280,6 +282,9 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque if (m_iLoadHistoryTask > 0)
m_iLoadHistoryTask--;
+ setDword(param->hContact, "lastmsgid", iLastMsgId == -1 ? getDword(param->hContact, "oldlastmsgid", -1) : iLastMsgId);
+ db_unset(param->hContact, m_szModuleName, "oldlastmsgid");
+
ptrW pwszNick(db_get_wsa(param->hContact, m_szModuleName, "Nick"));
CMStringW str(FORMAT, TranslateT("Loading messages for %s is completed."), pwszNick);
debugLogW(L"CVkProto::OnReceiveHistoryMessages for %s m_iLoadHistoryTask=%d", pwszNick, m_iLoadHistoryTask);
diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp index 2f6f6e0b29..a3033d3ed3 100644 --- a/protocols/VKontakte/src/vk_options.cpp +++ b/protocols/VKontakte/src/vk_options.cpp @@ -505,6 +505,4 @@ void CVkOptionMenuForm::OnApply() TranslateT("These changes will take effect after Miranda NG restart.\nWould you like to restart it now?"),
TranslateT("VKontakte protocol"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2) == IDYES)
CallServiceSync(MS_SYSTEM_RESTART, 1, 0);
-}
-
-
+}
\ No newline at end of file diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 86e09413f8..9845c1487f 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -342,6 +342,7 @@ private: MCONTACT MContactFromDbEvent(MEVENT hDbEvent);
void SetMirVer(MCONTACT hContact, int platform);
void __cdecl ContactTypingThread(void *p);
+ int IsHystoryMessageExist(MCONTACT hContact);
void SetSrmmReadStatus(MCONTACT hContact);
void MarkDialogAsRead(MCONTACT hContact);
char* GetStickerId(const char *Msg, int& stickerid);
|