summaryrefslogtreecommitdiff
path: root/protocols/Skype/src/skype_database.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Skype/src/skype_database.cpp')
-rw-r--r--protocols/Skype/src/skype_database.cpp107
1 files changed, 51 insertions, 56 deletions
diff --git a/protocols/Skype/src/skype_database.cpp b/protocols/Skype/src/skype_database.cpp
index 6ce36fbaa8..c6d2778aa9 100644
--- a/protocols/Skype/src/skype_database.cpp
+++ b/protocols/Skype/src/skype_database.cpp
@@ -1,12 +1,48 @@
#include "skype_proto.h"
+bool CSkypeProto::IsMessageInDB(HANDLE hContact, DWORD timestamp, const char* guid, int flag)
+{
+ bool result = false;
+
+ HANDLE hDbEvent = ::db_event_last(hContact);
+ while (hDbEvent)
+ {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.cbBlob = ::db_event_getBlobSize(hDbEvent);
+ dbei.pBlob = (PBYTE)::mir_alloc(dbei.cbBlob);
+ ::db_event_get(hDbEvent, &dbei);
+
+ if (dbei.timestamp < timestamp)
+ {
+ ::mir_free(dbei.pBlob);
+ break;
+ }
+
+ int sendFlag = dbei.flags & DBEF_SENT;
+ if (dbei.eventType == EVENTTYPE_MESSAGE && sendFlag == flag)
+ {
+ if (::memcmp(&dbei.pBlob[dbei.cbBlob - 32], guid, 32) == 0)
+ {
+ ::mir_free(dbei.pBlob);
+ result = true;
+ break;
+ }
+ }
+
+ ::mir_free(dbei.pBlob);
+ hDbEvent = ::db_event_prev(hDbEvent);
+ }
+
+ return result;
+}
+
HANDLE CSkypeProto::AddDataBaseEvent(HANDLE hContact, WORD type, DWORD timestamp, DWORD flags, DWORD cbBlob, PBYTE pBlob)
{
DBEVENTINFO dbei = { 0 };
dbei.cbSize = sizeof(dbei);
dbei.szModule = this->m_szModuleName;
dbei.timestamp = timestamp;
- dbei.eventType = EVENTTYPE_MESSAGE;
+ dbei.eventType = type;
dbei.cbBlob = cbBlob;
dbei.pBlob = pBlob;
dbei.flags = flags;
@@ -18,28 +54,23 @@ void CSkypeProto::RaiseAuthRequestEvent(
DWORD timestamp,
CContact::Ref contact)
{
- char *sid = ::mir_utf8decodeA(contact->GetSid());
- char *nick = ::mir_utf8decodeA(contact->GetNick());
+ char *sid = ::mir_strdup(contact->GetSid());
+ char *nick = ::mir_strdup(contact->GetNick());
SEString data;
contact->GetPropReceivedAuthrequest(data);
- char* reason = ::mir_utf8decodeA(data);
+ char* reason = ::mir_strdup(data);
SEString last;
contact->GetFullname(data, last);
- char* firstName = ::mir_utf8decodeA(data);
- char* lastName = ::mir_utf8decodeA(last);
-
- PROTORECVEVENT pre = {0};
-
- CCSDATA ccs = {0};
- ccs.szProtoService = PSR_AUTH;
- ccs.hContact = this->AddContact(contact);
- ccs.wParam = 0;
- ccs.lParam = (LPARAM)&pre;
- pre.timestamp = timestamp;
- pre.lParam = (DWORD)
+ char* firstName = ::mir_strdup(data);
+ char* lastName = ::mir_strdup(last);
+
+ HANDLE hContact = this->AddContact(contact);
+
+ /*blob is: 0(DWORD), hContact(DWORD), nick(ASCIIZ), firstName(ASCIIZ), lastName(ASCIIZ), sid(ASCIIZ), reason(ASCIIZ)*/
+ DWORD cbBlob = (DWORD)
(sizeof(DWORD) * 2) +
::strlen(nick) +
::strlen(firstName) +
@@ -48,54 +79,18 @@ void CSkypeProto::RaiseAuthRequestEvent(
::strlen(reason) +
5;
- /*blob is: 0(DWORD), hContact(DWORD), nick(ASCIIZ), firstName(ASCIIZ), lastName(ASCIIZ), sid(ASCIIZ), reason(ASCIIZ)*/
- char *pCurBlob = pre.szMessage = (char*)::mir_alloc(pre.lParam);
+ PBYTE pBlob, pCurBlob;
+ pCurBlob = pBlob = (PBYTE)::mir_alloc(cbBlob);
*((PDWORD)pCurBlob) = 0; pCurBlob += sizeof(DWORD);
- *((PDWORD)pCurBlob) = (DWORD)ccs.hContact; pCurBlob += sizeof(DWORD);
+ *((PDWORD)pCurBlob) = (DWORD)hContact; pCurBlob += sizeof(DWORD);
::strcpy((char*)pCurBlob, nick); pCurBlob += ::strlen(nick) + 1;
::strcpy((char*)pCurBlob, firstName); pCurBlob += ::strlen(firstName) + 1;
::strcpy((char*)pCurBlob, lastName); pCurBlob += ::strlen(lastName) + 1;
::strcpy((char*)pCurBlob, sid); pCurBlob += ::strlen(sid) + 1;
::strcpy((char*)pCurBlob, reason);
- ::CallService(MS_PROTO_CHAINRECV, 0, (LPARAM)&ccs);
-}
-
-bool CSkypeProto::IsMessageInDB(HANDLE hContact, DWORD timestamp, const char* guid, int flag)
-{
- bool result = false;
-
- HANDLE hDbEvent = ::db_event_last(hContact);
- while (hDbEvent)
- {
- DBEVENTINFO dbei = { sizeof(dbei) };
- dbei.cbBlob = ::db_event_getBlobSize(hDbEvent);
- dbei.pBlob = (PBYTE)::mir_alloc(dbei.cbBlob);
- ::db_event_get(hDbEvent, &dbei);
-
- if (dbei.timestamp < timestamp)
- {
- ::mir_free(dbei.pBlob);
- break;
- }
-
- int sendFlag = dbei.flags & DBEF_SENT;
- if (dbei.eventType == EVENTTYPE_MESSAGE && sendFlag == flag)
- {
- if (::memcmp(&dbei.pBlob[dbei.cbBlob - 32], guid, 32) == 0)
- {
- ::mir_free(dbei.pBlob);
- result = true;
- break;
- }
- }
-
- ::mir_free(dbei.pBlob);
- hDbEvent = ::db_event_prev(hDbEvent);
- }
-
- return result;
+ this->AddDataBaseEvent(hContact, EVENTTYPE_AUTHREQUEST, time(NULL), PREF_UTF, cbBlob, pBlob);
}
void CSkypeProto::RaiseMessageReceivedEvent(