From 3506c2bc0bb148120db8e8c7c6a07cf3e683cc50 Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Sun, 10 May 2015 09:28:16 +0000 Subject: SkypeWeb: Mark messsges as read rework. git-svn-id: http://svn.miranda-ng.org/main/trunk@13504 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/requests/messages.h | 2 +- protocols/SkypeWeb/src/skype_events.cpp | 4 ++-- protocols/SkypeWeb/src/skype_messages.cpp | 16 ++++++++-------- protocols/SkypeWeb/src/skype_poll_processing.cpp | 18 +++++++++++++++--- protocols/SkypeWeb/src/skype_proto.cpp | 2 +- protocols/SkypeWeb/src/skype_proto.h | 2 +- protocols/SkypeWeb/src/skype_utils.cpp | 3 +++ 7 files changed, 31 insertions(+), 16 deletions(-) (limited to 'protocols') diff --git a/protocols/SkypeWeb/src/requests/messages.h b/protocols/SkypeWeb/src/requests/messages.h index 07fbfc6e61..054d682619 100644 --- a/protocols/SkypeWeb/src/requests/messages.h +++ b/protocols/SkypeWeb/src/requests/messages.h @@ -106,7 +106,7 @@ public: << FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken) << CHAR_VALUE("Content-Type", "application/json; charset=UTF-8"); - CMStringA data(::FORMAT, "{\"consumptionhorizon\":\"%lld000;%lld000;%lld000\"}", msgTimestamp, time(NULL), msgId); + CMStringA data(::FORMAT, "{\"consumptionhorizon\":\"%lld000;%lld000;0\"}", msgTimestamp, time(NULL)); Body << VALUE(data); } }; diff --git a/protocols/SkypeWeb/src/skype_events.cpp b/protocols/SkypeWeb/src/skype_events.cpp index 03297983e8..2392542bba 100644 --- a/protocols/SkypeWeb/src/skype_events.cpp +++ b/protocols/SkypeWeb/src/skype_events.cpp @@ -126,7 +126,7 @@ void CSkypeProto::InitPopups() m_hPopupClassNotify = Popup_RegisterClass(&ppc); } -/*int CSkypeProto::ProcessSrmmEvent(WPARAM, LPARAM lParam) +int CSkypeProto::ProcessSrmmEvent(WPARAM, LPARAM lParam) { debugLogA(__FUNCTION__); MessageWindowEventData *event = (MessageWindowEventData *)lParam; @@ -135,4 +135,4 @@ void CSkypeProto::InitPopups() SetSrmmReadStatus(event->hContact); return 0; -}*/ \ No newline at end of file +} \ No newline at end of file diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp index 1b65a34a9f..e47f8e248a 100644 --- a/protocols/SkypeWeb/src/skype_messages.cpp +++ b/protocols/SkypeWeb/src/skype_messages.cpp @@ -307,17 +307,17 @@ void CSkypeProto::OnPrivateMessageEvent(JSONNODE *node) } else if (!mir_strcmpi(messageType, "RichText/Contacts")){} - if (clientMsgId && (!mir_strcmpi(messageType, "Text") || !mir_strcmpi(messageType, "RichText"))) - { - PushRequest(new MarkMessageReadRequest(skypename, RegToken, _ttoi(json_as_string(json_get(node, "id"))), timestamp, false, Server)); - } + //if (clientMsgId && (!mir_strcmpi(messageType, "Text") || !mir_strcmpi(messageType, "RichText"))) + //{ + // PushRequest(new MarkMessageReadRequest(skypename, RegToken, _ttoi(json_as_string(json_get(node, "id"))), timestamp, false, Server)); + //} } -int CSkypeProto::OnDbEventRead(WPARAM, LPARAM) +int CSkypeProto::OnDbEventRead(WPARAM hContact, LPARAM hDbEvent) { debugLogA(__FUNCTION__); - //if (IsOnline() && !isChatRoom(hContact) && !mir_strcmp(GetContactProto(hContact), m_szModuleName)) - // MarkMessagesRead(hContact, hDbEvent); + if (IsOnline() && !isChatRoom(hContact) && !mir_strcmp(GetContactProto(hContact), m_szModuleName)) + MarkMessagesRead(hContact, hDbEvent); return 0; } @@ -331,5 +331,5 @@ void CSkypeProto::MarkMessagesRead(MCONTACT hContact, MEVENT hDbEvent) time_t timestamp = dbei.timestamp; - PushRequest(new MarkMessageReadRequest(username, RegToken, time(NULL)+60/*it should be rewritten*/, timestamp, false, Server)); + PushRequest(new MarkMessageReadRequest(username, RegToken, timestamp, timestamp, false, Server)); } \ No newline at end of file diff --git a/protocols/SkypeWeb/src/skype_poll_processing.cpp b/protocols/SkypeWeb/src/skype_poll_processing.cpp index 327bbaae3d..7682006a48 100644 --- a/protocols/SkypeWeb/src/skype_poll_processing.cpp +++ b/protocols/SkypeWeb/src/skype_poll_processing.cpp @@ -141,17 +141,29 @@ void CSkypeProto::ProcessConversationUpdateRes(JSONNODE *node) JSONNODE *properties = json_get(node, "properties" ); ptrA convLink(mir_t2a(json_as_string(json_get(lastMessage, "conversationLink")))); + ptrA fromLink(mir_t2a(json_as_string(json_get(lastMessage, "from")))); - if (strstr(convLink, "/8:")) + if (strstr(convLink, "/8:") && IsMe(ContactUrlToName(fromLink))) { ptrA skypename(ContactUrlToName(convLink)); MCONTACT hContact = FindContact(skypename); if (hContact != NULL) { - ptrA consumptionhorizon(mir_t2a(json_as_string(json_get(properties, "consumptionhorizon")))); + CMStringA consumptionhorizon(mir_t2a(json_as_string(json_get(properties, "consumptionhorizon")))); - //server return bad data + int iStart = 0; + CMStringA szToken1 = consumptionhorizon.Tokenize(";", iStart).Trim(); + + if (iStart != -1) + { + CMStringA szToken2 = consumptionhorizon.Tokenize(";", iStart).Trim(); + + time_t evttime = atoi(szToken2.GetBuffer()); + db_set_dw(hContact, m_szModuleName, "LastMsgReadTime", evttime); + + SetSrmmReadStatus(hContact); + } } } } diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp index 8c0b9b36d0..50990fb2af 100644 --- a/protocols/SkypeWeb/src/skype_proto.cpp +++ b/protocols/SkypeWeb/src/skype_proto.cpp @@ -43,7 +43,7 @@ PROTO(protoName, userName), password(NULL) CreateProtoService("/IncomingCallCLE", &CSkypeProto::OnIncomingCallCLE); CreateProtoService("/IncomingCallPP", &CSkypeProto::OnIncomingCallPP); - //HookProtoEvent(ME_MSG_WINDOWEVENT, &CSkypeProto::ProcessSrmmEvent); + HookProtoEvent(ME_MSG_WINDOWEVENT, &CSkypeProto::ProcessSrmmEvent); m_tszAvatarFolder = std::tstring(VARST(_T("%miranda_avatarcache%"))) + _T("\\") + m_tszUserName; DWORD dwAttributes = GetFileAttributes(m_tszAvatarFolder.c_str()); diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index f639f1d18b..c50db3aa79 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -341,7 +341,7 @@ private: //events void InitDBEvents(); - //int __cdecl ProcessSrmmEvent(WPARAM, LPARAM); + int __cdecl ProcessSrmmEvent(WPARAM, LPARAM); //services INT_PTR __cdecl OnIncomingCallCLE (WPARAM wParam, LPARAM lParam); diff --git a/protocols/SkypeWeb/src/skype_utils.cpp b/protocols/SkypeWeb/src/skype_utils.cpp index 4ef74fb50e..2d0d9dc3ae 100644 --- a/protocols/SkypeWeb/src/skype_utils.cpp +++ b/protocols/SkypeWeb/src/skype_utils.cpp @@ -758,6 +758,9 @@ void CSkypeProto::ProcessTimer() if (IsOnline()) { PushRequest(new GetContactListRequest(TokenSecret), &CSkypeProto::LoadContactList); + + if (!m_hTrouterThread) + SendRequest(new CreateTrouterRequest(), &CSkypeProto::OnCreateTrouter); } } -- cgit v1.2.3