summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-04-21 12:35:17 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-04-21 12:35:17 +0000
commita66c0e42361082de91f26357d877b67bb798eeb9 (patch)
tree8f25583dc182e4159677afdb53568acb16ad923c /protocols
parent0bc1bd3f2a77e48286c436518292c58e2e788282 (diff)
fix for searching message duplicates
git-svn-id: http://svn.miranda-ng.org/main/trunk@13006 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/SkypeWeb/src/skype_messages.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp
index 54349181ec..59e23a1b4b 100644
--- a/protocols/SkypeWeb/src/skype_messages.cpp
+++ b/protocols/SkypeWeb/src/skype_messages.cpp
@@ -21,9 +21,11 @@ MEVENT CSkypeProto::GetMessageFromDb(MCONTACT hContact, const char *messageId, L
{
if(messageId == NULL)
return NULL;
- mir_cslock lock(messageSyncLock);
+ timestamp -= 600; // we check events written 10 minutes ago
size_t messageIdLength = mir_strlen(messageId);
+
+ mir_cslock lock(messageSyncLock);
for (MEVENT hDbEvent = db_event_last(hContact); hDbEvent; hDbEvent = db_event_prev(hContact, hDbEvent))
{
DBEVENTINFO dbei = { sizeof(dbei) };
@@ -36,14 +38,15 @@ MEVENT CSkypeProto::GetMessageFromDb(MCONTACT hContact, const char *messageId, L
dbei.pBlob = blob;
db_event_get(hDbEvent, &dbei);
- if (dbei.timestamp < timestamp)
- break;
-
if (dbei.eventType != EVENTTYPE_MESSAGE && dbei.eventType != SKYPE_DB_EVENT_TYPE_ACTION)
continue;
- if (memcmp(&dbei.pBlob[dbei.cbBlob - messageIdLength], messageId, messageIdLength) == 0)
+ size_t cbLen = strlen((char*)dbei.pBlob);
+ if (memcmp(&dbei.pBlob[cbLen+1], messageId, messageIdLength) == 0)
return hDbEvent;
+
+ if (dbei.timestamp < timestamp)
+ break;
}
return NULL;
@@ -60,7 +63,7 @@ MEVENT CSkypeProto::AddMessageToDb(MCONTACT hContact, DWORD timestamp, DWORD fla
memcpy(pBlob, &content[emoteOffset], messageLength);
memcpy(pBlob + messageLength, messageId, messageIdLength);
- return AddEventToDb(hContact, emoteOffset == 0 ? EVENTTYPE_MESSAGE : SKYPE_DB_EVENT_TYPE_ACTION, timestamp, flags, cbBlob, pBlob);
+ return AddEventToDb(hContact, emoteOffset == 0 ? EVENTTYPE_MESSAGE : SKYPE_DB_EVENT_TYPE_ACTION, timestamp, flags, (DWORD)cbBlob, pBlob);
}
/* MESSAGE RECEIVING */
@@ -81,7 +84,7 @@ int CSkypeProto::OnReceiveMessage(const char *messageId, const char *url, time_t
recv.szMessage = content;
recv.lParam = emoteOffset;
recv.pCustomData = (void*)messageId;
- recv.cbCustomDataSize = mir_strlen(messageId);
+ recv.cbCustomDataSize = (DWORD)mir_strlen(messageId);
if (isRead)
recv.flags |= PREF_CREATEREAD;