summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2015-04-18 19:59:12 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2015-04-18 19:59:12 +0000
commitb739a42cd7a428562844387ac3be305d0ce66b64 (patch)
treecbaf8886f24a04647d7f20c4b52d07edfed900f2 /protocols/SkypeWeb
parentf81791fba68eb251a6425a40daa86854e42c6d4b (diff)
SkypeWeb: Mark messages as readed rewritted.
git-svn-id: http://svn.miranda-ng.org/main/trunk@12921 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb')
-rw-r--r--protocols/SkypeWeb/src/requests/capabilities.h2
-rw-r--r--protocols/SkypeWeb/src/requests/messages.h9
-rw-r--r--protocols/SkypeWeb/src/skype_messages.cpp21
-rw-r--r--protocols/SkypeWeb/src/skype_proto.h2
4 files changed, 24 insertions, 10 deletions
diff --git a/protocols/SkypeWeb/src/requests/capabilities.h b/protocols/SkypeWeb/src/requests/capabilities.h
index 912da59e34..573cec1673 100644
--- a/protocols/SkypeWeb/src/requests/capabilities.h
+++ b/protocols/SkypeWeb/src/requests/capabilities.h
@@ -34,7 +34,7 @@ public:
#ifdef _WIN64
bitness = 64;
#endif
- data.AppendFormat("{\"id\":\"messagingService\",\"type\":\"EndpointPresenceDoc\",\"selfLink\":\"uri\",\"privateInfo\":{\"epname\":\"Miranda\"},\"publicInfo\":{\"capabilities\":\"\",\"typ\":125,\"skypeNameVersion\":\"Miranda NG Skype\",\"nodeInfo\":\"xx\",\"version\":\"%s x%d\"}}", MIRANDA_VERSION_STRING, bitness);
+ data.AppendFormat("{\"id\":\"messagingService\",\"type\":\"EndpointPresenceDoc\",\"selfLink\":\"uri\",\"privateInfo\":{\"epname\":\"Miranda\"},\"publicInfo\":{\"capabilities\":\"Audio|Video\",\"typ\":125,\"skypeNameVersion\":\"Miranda NG Skype\",\"nodeInfo\":\"xx\",\"version\":\"%s x%d\"}}", MIRANDA_VERSION_STRING, bitness);
Body <<
VALUE(data);
diff --git a/protocols/SkypeWeb/src/requests/messages.h b/protocols/SkypeWeb/src/requests/messages.h
index 9a87361990..7706bd9ae2 100644
--- a/protocols/SkypeWeb/src/requests/messages.h
+++ b/protocols/SkypeWeb/src/requests/messages.h
@@ -98,13 +98,18 @@ public:
class MarkMessageReadRequest : public HttpRequest
{
public:
- MarkMessageReadRequest(const char *regToken, LONGLONG msgId = 0, const char *server = SKYPE_ENDPOINTS_HOST) :
- HttpRequest(REQUEST_POST, FORMAT, "%s/v1/users/ME/conversations/ALL/messages/%lld/ack", server, msgId)
+ MarkMessageReadRequest(const char *username, const char *regToken, LONGLONG msgId = 0, LONGLONG msgTimestamp = 0, bool isChat = false, const char *server = SKYPE_ENDPOINTS_HOST) :
+ HttpRequest(REQUEST_PUT, FORMAT, "%s/v1/users/ME/conversations/%s:%s/properties?name=consumptionhorizon", server, !isChat?"8":"19", username)
{
Headers
<< CHAR_VALUE("Accept", "application/json, text/javascript")
<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken)
<< CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
+
+ CMStringA data;
+ data.AppendFormat("{\"consumptionhorizon\":\"%lld;%lld000;%lld\"}", msgTimestamp, time(NULL), msgId);
+ Body << VALUE(data);
}
};
+
#endif //_SKYPE_REQUEST_MESSAGES_H_
diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp
index 882da1c212..51cc116d0d 100644
--- a/protocols/SkypeWeb/src/skype_messages.cpp
+++ b/protocols/SkypeWeb/src/skype_messages.cpp
@@ -260,24 +260,33 @@ void CSkypeProto::OnPrivateMessageEvent(JSONNODE *node)
else
OnReceiveMessage(clientMsgId, from, timestamp, message, emoteOffset);
}
- else if (!mir_strcmpi(messageType, "Event/SkypeVideoMessage"))
- return; //not supported
+ else if (!mir_strcmpi(messageType, "Event/SkypeVideoMessage")){}
}
+
}
-int CSkypeProto::OnDbEventRead(WPARAM, LPARAM hDbEvent)
+int CSkypeProto::OnDbEventRead(WPARAM hContact, LPARAM hDbEvent)
{
debugLogA(__FUNCTION__);
if (IsOnline())
- MarkMessagesRead(hDbEvent);
+ MarkMessagesRead(hContact, hDbEvent);
return 0;
}
-void CSkypeProto::MarkMessagesRead(MEVENT hDbEvent)
+void CSkypeProto::MarkMessagesRead(MCONTACT hContact, MEVENT hDbEvent)
{
debugLogA(__FUNCTION__);
+ ptrA username(db_get_sa(hContact, m_szModuleName, SKYPE_SETTINGS_ID));
+
DBEVENTINFO dbei = { sizeof(dbei) };
+
+ dbei.cbBlob = db_event_getBlobSize(hDbEvent);
+ mir_ptr<BYTE> blob((PBYTE)mir_alloc(dbei.cbBlob));
+ dbei.pBlob = blob;
+
db_event_get(hDbEvent, &dbei);
+
time_t timestamp = dbei.timestamp;
- PushRequest(new MarkMessageReadRequest(RegToken, timestamp, Server));
+
+ PushRequest(new MarkMessageReadRequest(username, RegToken, time(NULL)/*it should be rewritten*/, timestamp, false, Server));
} \ No newline at end of file
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h
index 0520bbd594..6de18d45aa 100644
--- a/protocols/SkypeWeb/src/skype_proto.h
+++ b/protocols/SkypeWeb/src/skype_proto.h
@@ -206,7 +206,7 @@ private:
void OnMessageSent(const NETLIBHTTPREQUEST *response, void *arg);
int __cdecl OnPreCreateMessage(WPARAM, LPARAM lParam);
- void MarkMessagesRead(MEVENT hDbEvent);
+ void MarkMessagesRead(MCONTACT hContact, MEVENT hDbEvent);
void OnPrivateMessageEvent(JSONNODE *node);