From ceae4e57634e4ff9efe506e3e937006d16f4787f Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Mon, 13 Jul 2015 17:58:06 +0000 Subject: SkypeWeb: big refactoring git-svn-id: http://svn.miranda-ng.org/main/trunk@14551 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/skype_db.cpp | 48 ++++--------------------------------- 1 file changed, 5 insertions(+), 43 deletions(-) (limited to 'protocols/SkypeWeb/src/skype_db.cpp') diff --git a/protocols/SkypeWeb/src/skype_db.cpp b/protocols/SkypeWeb/src/skype_db.cpp index 87a067b3f1..eead114f49 100644 --- a/protocols/SkypeWeb/src/skype_db.cpp +++ b/protocols/SkypeWeb/src/skype_db.cpp @@ -52,44 +52,18 @@ MEVENT CSkypeProto::GetMessageFromDb(MCONTACT hContact, const char *messageId, L return NULL; } -MEVENT CSkypeProto::AddMessageToDb(MCONTACT hContact, DWORD timestamp, DWORD flags, const char *messageId, char *content, int emoteOffset) +MEVENT CSkypeProto::AddDbEvent(WORD type, MCONTACT hContact, DWORD timestamp, DWORD flags, const char *content, const char *uid) { - if (MEVENT hDbEvent = GetMessageFromDb(hContact, messageId, timestamp)) - return hDbEvent; - size_t messageLength = mir_strlen(&content[emoteOffset]) + 1; - size_t messageIdLength = mir_strlen(messageId); - size_t cbBlob = messageLength + messageIdLength; - PBYTE pBlob = (PBYTE)mir_alloc(cbBlob); - memcpy(pBlob, &content[emoteOffset], messageLength); - memcpy(pBlob + messageLength, messageId, messageIdLength); - - return AddEventToDb(hContact, emoteOffset == 0 ? EVENTTYPE_MESSAGE : SKYPE_DB_EVENT_TYPE_ACTION, timestamp, flags, (DWORD)cbBlob, pBlob); -} - -MEVENT CSkypeProto::AddCallInfoToDb(MCONTACT hContact, DWORD timestamp, DWORD flags, const char *messageId, char *content) -{ - if (MEVENT hDbEvent = GetMessageFromDb(hContact, messageId, timestamp)) + if (MEVENT hDbEvent = GetMessageFromDb(hContact, uid, timestamp)) return hDbEvent; size_t messageLength = mir_strlen(content) + 1; - size_t messageIdLength = mir_strlen(messageId); + size_t messageIdLength = mir_strlen(uid); size_t cbBlob = messageLength + messageIdLength; PBYTE pBlob = (PBYTE)mir_alloc(cbBlob); memcpy(pBlob, content, messageLength); - memcpy(pBlob + messageLength, messageId, messageIdLength); + memcpy(pBlob + messageLength, uid, messageIdLength); - return AddEventToDb(hContact, SKYPE_DB_EVENT_TYPE_CALL_INFO, timestamp, flags, (DWORD)cbBlob, pBlob); -} - -MEVENT CSkypeProto::AddCallToDb(MCONTACT hContact, DWORD timestamp, DWORD flags, const char *callId, const char *gp) -{ - size_t callIdLength = mir_strlen(callId); - size_t messageLength = mir_strlen(gp) + 1; - size_t cbBlob = messageLength + callIdLength; - PBYTE pBlob = (PBYTE)mir_alloc(cbBlob); - memcpy(pBlob, gp, messageLength); - memcpy(pBlob + messageLength, callId, callIdLength); - - return AddEventToDb(hContact, SKYPE_DB_EVENT_TYPE_INCOMING_CALL, timestamp, flags, (DWORD)cbBlob, pBlob); + return AddEventToDb(hContact, type, timestamp, flags, (DWORD)cbBlob, pBlob); } MEVENT CSkypeProto::AddEventToDb(MCONTACT hContact, WORD type, DWORD timestamp, DWORD flags, DWORD cbBlob, PBYTE pBlob) @@ -102,16 +76,4 @@ MEVENT CSkypeProto::AddEventToDb(MCONTACT hContact, WORD type, DWORD timestamp, dbei.pBlob = pBlob; dbei.flags = flags; return db_event_add(hContact, &dbei); -} - -time_t CSkypeProto::GetLastMessageTime(MCONTACT hContact) -{ - MEVENT hDbEvent = db_event_last(hContact); - if (hDbEvent != NULL) - { - DBEVENTINFO dbei = { sizeof(dbei) }; - db_event_get(hDbEvent, &dbei); - return dbei.timestamp; - } - return 0; } \ No newline at end of file -- cgit v1.2.3