diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2015-04-15 14:03:50 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2015-04-15 14:03:50 +0000 |
commit | b3e7101449926ca88ae21a5b435da7a2fd884320 (patch) | |
tree | 9db0018012089d913c8be1b4de60cf89e7bbc48c /protocols/SkypeWeb/src/skype_history_sync.cpp | |
parent | a89e8108e444cfaa8da030f960e334729b59e2dc (diff) |
SkypeWeb: Edited messages support.
git-svn-id: http://svn.miranda-ng.org/main/trunk@12838 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src/skype_history_sync.cpp')
-rw-r--r-- | protocols/SkypeWeb/src/skype_history_sync.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/protocols/SkypeWeb/src/skype_history_sync.cpp b/protocols/SkypeWeb/src/skype_history_sync.cpp index 66415497d5..3f781d236e 100644 --- a/protocols/SkypeWeb/src/skype_history_sync.cpp +++ b/protocols/SkypeWeb/src/skype_history_sync.cpp @@ -41,6 +41,7 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response) ptrT composeTime(json_as_string(json_get(message, "composetime")));
ptrA conversationLink(mir_t2a(ptrT(json_as_string(json_get(message, "conversationLink")))));
time_t timestamp = IsoToUnixTime(composeTime);
+ bool isEdited = (json_get(message, "skypeeditedid") != NULL);
if (conversationLink != NULL && strstr(conversationLink, "/8:"))
{
int emoteOffset = json_as_int(json_get(message, "skypeemoteoffset"));
@@ -56,8 +57,21 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response) MCONTACT hContact = FindContact(ptrA(ContactUrlToName(conversationLink)));
ptrA message(RemoveHtml(content));
-
- AddMessageToDb(hContact, timestamp, flags, clientMsgId, message, emoteOffset);
+ MEVENT dbevent = GetMessageFromDb(hContact, skypeEditedId);
+
+ if (isEdited && dbevent != NULL)
+ {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ db_event_get(dbevent, &dbei);
+ time_t dbEventTimestamp = dbei.timestamp;
+ if (!getByte("SaveEditedMessage", 0))
+ {
+ db_event_delete(hContact, dbevent);
+ }
+ AddMessageToDb(hContact, dbEventTimestamp + 1, flags, clientMsgId, message, emoteOffset);
+ }
+ else
+ AddMessageToDb(hContact, timestamp, flags, clientMsgId, message, emoteOffset);
}
}
}
@@ -89,6 +103,8 @@ void CSkypeProto::OnSyncHistory(const NETLIBHTTPREQUEST *response) continue;
char *clientMsgId = mir_t2a(json_as_string(json_get(lastMessage, "clientmessageid")));
+ char *skypeEditedId = mir_t2a(json_as_string(json_get(lastMessage, "skypeeditedid")));
+ bool isEdited = (skypeEditedId != NULL);
char *conversationLink = mir_t2a(json_as_string(json_get(lastMessage, "conversationLink")));
time_t composeTime(IsoToUnixTime(ptrT(json_as_string(json_get(lastMessage, "conversationLink")))));
@@ -98,7 +114,7 @@ void CSkypeProto::OnSyncHistory(const NETLIBHTTPREQUEST *response) MCONTACT hContact = FindContact(skypename);
if (hContact == NULL && !IsMe(skypename))
hContact = AddContact(skypename, true);
- if (GetMessageFromDb(hContact, clientMsgId, composeTime) == NULL)
+ if (GetMessageFromDb(hContact, clientMsgId, composeTime) == NULL && !isEdited)
PushRequest(new GetHistoryRequest(ptrA(getStringA("registrationToken")), skypename, ptrA(getStringA("Server"))), &CSkypeProto::OnGetServerHistory);
}
}
\ No newline at end of file |