From 74a2e42b34d8495bf1e3676d4580e1d286384722 Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Thu, 9 Apr 2015 14:38:31 +0000 Subject: SkypeWeb: Auto sync history part 2. git-svn-id: http://svn.miranda-ng.org/main/trunk@12697 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/skype_messages.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'protocols/SkypeWeb/src/skype_messages.cpp') diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp index 8f1dd3803e..ed90a8ec3a 100644 --- a/protocols/SkypeWeb/src/skype_messages.cpp +++ b/protocols/SkypeWeb/src/skype_messages.cpp @@ -34,7 +34,6 @@ MEVENT CSkypeProto::AddMessageToDb(MCONTACT hContact, DWORD timestamp, DWORD fla { if (MEVENT hDbEvent = GetMessageFromDB(hContact, messageId, timestamp)) return hDbEvent; - setDword(hContact, "LastMsgId", atoi(messageId)); size_t messageLength = mir_strlen(&content[emoteOffset]) + 1; size_t messageIdLength = mir_strlen(messageId); size_t cbBlob = messageLength + messageIdLength; @@ -52,7 +51,6 @@ int CSkypeProto::OnReceiveMessage(const char *messageId, const char *url, time_t { ptrA skypename(ContactUrlToName(url)); MCONTACT hContact = GetContact(skypename); - setDword(hContact, "LastMsgId", atoi(messageId)); PROTORECVEVENT recv = { 0 }; recv.flags = PREF_UTF; recv.timestamp = timestamp; @@ -126,7 +124,6 @@ void CSkypeProto::OnMessageSent(const NETLIBHTTPREQUEST *response, void *arg) { SendMessageParam *param = (SendMessageParam*)arg; MCONTACT hContact = param->hContact; - setDword(hContact, "LastMsgId", param->hMessage); HANDLE hMessage = (HANDLE)param->hMessage; delete param; @@ -240,15 +237,17 @@ void CSkypeProto::OnSyncHistory(const NETLIBHTTPREQUEST *response) if (lastMessage == NULL) continue; - int clientMsgId(atoi(mir_t2a(ptrT(json_as_string(json_get(lastMessage, "clientmessageid")))))); + ptrA clientMsgId(mir_t2a(ptrT(json_as_string(json_get(lastMessage, "clientmessageid"))))); ptrA conversationLink(mir_t2a(ptrT(json_as_string(json_get(lastMessage, "conversationLink"))))); + LONGLONG composeTime(IsoToUnixTime(ptrT(json_as_string(json_get(lastMessage, "conversationLink"))))); ptrA skypename(ContactUrlToName(conversationLink)); + if (skypename == NULL) + return; MCONTACT hContact = GetContact(skypename); if (hContact == NULL && !IsMe(skypename)) hContact = AddContact(skypename, true); - int lastmsgid = db_get_dw(hContact, m_szModuleName, "LastMsgId", NULL); - if (lastmsgid != clientMsgId) + if (GetMessageFromDB(hContact, clientMsgId, composeTime) == NULL) PushRequest(new GetHistoryRequest(ptrA(getStringA("registrationToken")), skypename, ptrA(getStringA("Server"))), &CSkypeProto::OnGetServerHistory); } } \ No newline at end of file -- cgit v1.2.3