summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/SkypeWeb/src/skype_history_sync.cpp53
-rw-r--r--protocols/SkypeWeb/src/skype_messages.cpp86
2 files changed, 69 insertions, 70 deletions
diff --git a/protocols/SkypeWeb/src/skype_history_sync.cpp b/protocols/SkypeWeb/src/skype_history_sync.cpp
index d633dfe8a3..2322ecb930 100644
--- a/protocols/SkypeWeb/src/skype_history_sync.cpp
+++ b/protocols/SkypeWeb/src/skype_history_sync.cpp
@@ -53,42 +53,45 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response)
bool isEdited = (json_get(message, "skypeeditedid") != NULL);
if (conversationLink != NULL && strstr(conversationLink, "/8:"))
{
- int emoteOffset = json_as_int(json_get(message, "skypeemoteoffset"));
+ if (!mir_strcmpi(messageType, "Text") || !mir_strcmpi(messageType, "RichText"))
+ {
+ int emoteOffset = json_as_int(json_get(message, "skypeemoteoffset"));
- int flags = DBEF_UTF | DBEF_READ;
+ int flags = DBEF_UTF | DBEF_READ;
- ptrA skypename(ContactUrlToName(from));
+ ptrA skypename(ContactUrlToName(from));
- bool isMe = IsMe(skypename);
- if (isMe)
- flags |= DBEF_SENT;
+ bool isMe = IsMe(skypename);
+ if (isMe)
+ flags |= DBEF_SENT;
- MCONTACT hContact = FindContact(ptrA(ContactUrlToName(conversationLink)));
+ MCONTACT hContact = FindContact(ptrA(ContactUrlToName(conversationLink)));
- ptrA message(RemoveHtml(content));
- MEVENT dbevent = GetMessageFromDb(hContact, skypeEditedId);
+ ptrA message(RemoveHtml(content));
+ MEVENT dbevent = GetMessageFromDb(hContact, skypeEditedId);
- if (isEdited && dbevent != NULL)
- {
- DBEVENTINFO dbei = { sizeof(dbei) };
- CMStringA msg;
+ if (isEdited && dbevent != NULL)
+ {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ CMStringA msg;
- dbei.cbBlob = db_event_getBlobSize(dbevent);
- mir_ptr<BYTE> blob((PBYTE)mir_alloc(dbei.cbBlob));
- dbei.pBlob = blob;
+ dbei.cbBlob = db_event_getBlobSize(dbevent);
+ mir_ptr<BYTE> blob((PBYTE)mir_alloc(dbei.cbBlob));
+ dbei.pBlob = blob;
- db_event_get(dbevent, &dbei);
- time_t dbEventTimestamp = dbei.timestamp;
- ptrA dbMsgText((char *)mir_alloc(dbei.cbBlob));
+ db_event_get(dbevent, &dbei);
+ time_t dbEventTimestamp = dbei.timestamp;
+ ptrA dbMsgText((char *)mir_alloc(dbei.cbBlob));
- mir_strcpy(dbMsgText, (char*)dbei.pBlob);
+ mir_strcpy(dbMsgText, (char*)dbei.pBlob);
- msg.AppendFormat("%s\n%s [%s]:\n%s", dbMsgText, Translate("Edited at"), ptrA(mir_t2a(composeTime)), message);
- db_event_delete(hContact, dbevent);
- AddMessageToDb(hContact, dbEventTimestamp, flags, clientMsgId, msg.GetBuffer(), emoteOffset);
+ msg.AppendFormat("%s\n%s [%s]:\n%s", dbMsgText, Translate("Edited at"), ptrA(mir_t2a(composeTime)), message);
+ db_event_delete(hContact, dbevent);
+ AddMessageToDb(hContact, dbEventTimestamp, flags, clientMsgId, msg.GetBuffer(), emoteOffset);
+ }
+ else
+ AddMessageToDb(hContact, timestamp, flags, clientMsgId, message, emoteOffset);
}
- else
- AddMessageToDb(hContact, timestamp, flags, clientMsgId, message, emoteOffset);
}
else if (conversationLink != NULL && strstr(conversationLink, "/19:"))
{
diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp
index cb414899fd..474d23a502 100644
--- a/protocols/SkypeWeb/src/skype_messages.cpp
+++ b/protocols/SkypeWeb/src/skype_messages.cpp
@@ -204,64 +204,60 @@ void CSkypeProto::OnPrivateMessageEvent(JSONNODE *node)
ptrT composeTime(json_as_string(json_get(node, "composetime")));
time_t timestamp = getByte("UseLocalTime", 0) ? time(NULL) : IsoToUnixTime(composeTime);
- ptrA from(mir_t2a(ptrT(json_as_string(json_get(node, "from")))));
- ptrA skypename(ContactUrlToName(from));
+ ptrA conversationLink(mir_t2a(ptrT(json_as_string(json_get(node, "conversationLink")))));
+ ptrA fromLink(mir_t2a(ptrT(json_as_string(json_get(node, "from")))));
+
+ ptrA skypename(ContactUrlToName(conversationLink));
+ ptrA from(ContactUrlToName(fromLink));
ptrA content(mir_t2a(ptrT(json_as_string(json_get(node, "content")))));
int emoteOffset = json_as_int(json_get(node, "skypeemoteoffset"));
ptrA message(RemoveHtml(content));
- if (IsMe(skypename))
+
+ ptrA messageType(mir_t2a(ptrT(json_as_string(json_get(node, "messagetype")))));
+ MCONTACT hContact = AddContact(skypename, true);
+
+ if (!mir_strcmpi(messageType, "Control/Typing"))
+ CallService(MS_PROTO_CONTACTISTYPING, hContact, PROTOTYPE_CONTACTTYPING_INFINITE);
+ else if (!mir_strcmpi(messageType, "Control/ClearTyping"))
+ CallService(MS_PROTO_CONTACTISTYPING, hContact, PROTOTYPE_CONTACTTYPING_OFF);
+
+ else if (!mir_strcmpi(messageType, "Text") || !mir_strcmpi(messageType, "RichText"))
{
- 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);
+ if (IsMe(from))
+ {
+ int hMessage = atoi(clientMsgId);
+ ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)hMessage, 0);
+ debugLogA(__FUNCTION__" timestamp = %d clientmsgid = %s", timestamp, clientMsgId);
+ AddMessageToDb(hContact, timestamp, DBEF_UTF | DBEF_SENT, clientMsgId, message, emoteOffset);
+ }
debugLogA(__FUNCTION__" timestamp = %d clientmsgid = %s", timestamp, clientMsgId);
- AddMessageToDb(hContact, timestamp, DBEF_UTF | DBEF_SENT, clientMsgId, message, emoteOffset);
- }
- else
- {
- ptrA messageType(mir_t2a(ptrT(json_as_string(json_get(node, "messagetype")))));
-
- MCONTACT hContact = AddContact(skypename, true);
+ MEVENT dbevent = GetMessageFromDb(hContact, skypeEditedId);
+ if (isEdited && dbevent != NULL)
+ {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ CMStringA msg;
+ dbei.cbBlob = db_event_getBlobSize(dbevent);
+ mir_ptr<BYTE> blob((PBYTE)mir_alloc(dbei.cbBlob));
+ dbei.pBlob = blob;
- if (!mir_strcmpi(messageType, "Control/Typing"))
- CallService(MS_PROTO_CONTACTISTYPING, hContact, PROTOTYPE_CONTACTTYPING_INFINITE);
+ db_event_get(dbevent, &dbei);
- else if (!mir_strcmpi(messageType, "Control/ClearTyping"))
- CallService(MS_PROTO_CONTACTISTYPING, hContact, PROTOTYPE_CONTACTTYPING_OFF);
+ time_t dbEventTimestamp = dbei.timestamp;
+ ptrA dbMsgText((char *)mir_alloc(dbei.cbBlob));
+ mir_strcpy(dbMsgText, (char*)dbei.pBlob);
- else if (!mir_strcmpi(messageType, "Text") || !mir_strcmpi(messageType, "RichText"))
- {
- debugLogA(__FUNCTION__" timestamp = %d clientmsgid = %s", timestamp, clientMsgId);
- MEVENT dbevent = GetMessageFromDb(hContact, skypeEditedId);
- if (isEdited && dbevent != NULL)
- {
- DBEVENTINFO dbei = { sizeof(dbei) };
- CMStringA msg;
-
- dbei.cbBlob = db_event_getBlobSize(dbevent);
- mir_ptr<BYTE> blob((PBYTE)mir_alloc(dbei.cbBlob));
- dbei.pBlob = blob;
-
- db_event_get(dbevent, &dbei);
-
- time_t dbEventTimestamp = dbei.timestamp;
- ptrA dbMsgText((char *)mir_alloc(dbei.cbBlob));
- mir_strcpy(dbMsgText, (char*)dbei.pBlob);
-
- msg.AppendFormat("%s\n%s [%s]:\n%s", dbMsgText, Translate("Edited at"), ptrA(mir_t2a(composeTime)), message);
- db_event_delete(hContact, dbevent);
- OnReceiveMessage(clientMsgId, from, dbEventTimestamp, msg.GetBuffer(), emoteOffset);
- }
- else
- OnReceiveMessage(clientMsgId, from, timestamp, message, emoteOffset);
+ msg.AppendFormat("%s\n%s [%s]:\n%s", dbMsgText, Translate("Edited at"), ptrA(mir_t2a(composeTime)), message);
+ db_event_delete(hContact, dbevent);
+ OnReceiveMessage(clientMsgId, conversationLink, dbEventTimestamp, msg.GetBuffer(), emoteOffset);
+ }
+ else
+ OnReceiveMessage(clientMsgId, conversationLink, timestamp, message, emoteOffset);
}
else if (!mir_strcmpi(messageType, "Event/SkypeVideoMessage")){}
- }
+
}