summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2015-04-15 14:03:50 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2015-04-15 14:03:50 +0000
commitb3e7101449926ca88ae21a5b435da7a2fd884320 (patch)
tree9db0018012089d913c8be1b4de60cf89e7bbc48c /protocols
parenta89e8108e444cfaa8da030f960e334729b59e2dc (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')
-rw-r--r--protocols/SkypeWeb/src/skype_history_sync.cpp22
-rw-r--r--protocols/SkypeWeb/src/skype_login.cpp1
-rw-r--r--protocols/SkypeWeb/src/skype_messages.cpp22
3 files changed, 39 insertions, 6 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
diff --git a/protocols/SkypeWeb/src/skype_login.cpp b/protocols/SkypeWeb/src/skype_login.cpp
index dc86c654dc..2e06e710fe 100644
--- a/protocols/SkypeWeb/src/skype_login.cpp
+++ b/protocols/SkypeWeb/src/skype_login.cpp
@@ -198,6 +198,7 @@ void CSkypeProto::OnSubscriptionsCreated(const NETLIBHTTPREQUEST *response)
skypenames.destroy();
m_hPollingThread = ForkThreadEx(&CSkypeProto::PollingThread, 0, NULL);
+
if (getByte("AutoSync", 1))
SyncHistory();
}
diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp
index a826d38e52..c313dec4d5 100644
--- a/protocols/SkypeWeb/src/skype_messages.cpp
+++ b/protocols/SkypeWeb/src/skype_messages.cpp
@@ -19,6 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
MEVENT CSkypeProto::GetMessageFromDb(MCONTACT hContact, const char *messageId, LONGLONG timestamp)
{
+ if(messageId == NULL)
+ return NULL;
mir_cslock lock(messageSyncLock);
size_t messageIdLength = mir_strlen(messageId);
@@ -197,7 +199,9 @@ int CSkypeProto::OnPreCreateMessage(WPARAM, LPARAM lParam)
void CSkypeProto::OnPrivateMessageEvent(JSONNODE *node)
{
ptrA clientMsgId(mir_t2a(ptrT(json_as_string(json_get(node, "clientmessageid")))));
- //ptrA skypeEditedId(mir_t2a(ptrT(json_as_string(json_get(node, "skypeeditedid")))));
+ ptrA skypeEditedId(mir_t2a(ptrT(json_as_string(json_get(node, "skypeeditedid")))));
+
+ bool isEdited = (json_get(node, "skypeeditedid") != NULL);
ptrT composeTime(json_as_string(json_get(node, "composetime")));
time_t timestamp = getByte("UseLocalTime", 0) ? time(NULL) : IsoToUnixTime(composeTime);
@@ -214,7 +218,6 @@ void CSkypeProto::OnPrivateMessageEvent(JSONNODE *node)
{
ptrA conversationLink(mir_t2a(ptrT(json_as_string(json_get(node, "conversationLink")))));
ptrA cSkypename(ContactUrlToName(conversationLink));
-
MCONTACT hContact = AddContact(cSkypename, true);
int hMessage = atoi(clientMsgId);
ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)hMessage, 0);
@@ -236,7 +239,20 @@ void CSkypeProto::OnPrivateMessageEvent(JSONNODE *node)
else if (!mir_strcmpi(messageType, "Text") || !mir_strcmpi(messageType, "RichText"))
{
debugLogA(__FUNCTION__" timestamp = %d clientmsgid = %s", timestamp, clientMsgId);
- OnReceiveMessage(clientMsgId, from, timestamp, 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);
+ }
+ OnReceiveMessage(clientMsgId, from, dbEventTimestamp + 1, message, emoteOffset);
+ }
+ else
+ OnReceiveMessage(clientMsgId, from, timestamp, message, emoteOffset);
}
else if (!mir_strcmpi(messageType, "Event/SkypeVideoMessage"))
return; //not supported