From af64eab612166b29df416b3f498a5ec1b7c08870 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sat, 27 Apr 2013 08:31:38 +0000 Subject: fixed message hystory sync 2 git-svn-id: http://svn.miranda-ng.org/main/trunk@4547 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Skype/src/skype_database.cpp | 19 ++++++++----------- protocols/Skype/src/skype_events.cpp | 21 +++++++++++++++------ protocols/Skype/src/skype_proto.cpp | 33 +++++++++++++++------------------ protocols/Skype/src/skype_proto.h | 2 +- 4 files changed, 39 insertions(+), 36 deletions(-) (limited to 'protocols/Skype') diff --git a/protocols/Skype/src/skype_database.cpp b/protocols/Skype/src/skype_database.cpp index 5361ada67d..9ed2a21797 100644 --- a/protocols/Skype/src/skype_database.cpp +++ b/protocols/Skype/src/skype_database.cpp @@ -36,7 +36,7 @@ bool CSkypeProto::IsMessageInDB(HANDLE hContact, DWORD timestamp, const char* gu return result; } -HANDLE CSkypeProto::AddDataBaseEvent(HANDLE hContact, WORD type, DWORD timestamp, DWORD flags, DWORD cbBlob, PBYTE pBlob) +HANDLE CSkypeProto::AddDBEvent(HANDLE hContact, WORD type, DWORD timestamp, DWORD flags, DWORD cbBlob, PBYTE pBlob) { DBEVENTINFO dbei = { 0 }; dbei.cbSize = sizeof(dbei); @@ -88,7 +88,7 @@ void CSkypeProto::RaiseAuthRequestEvent(DWORD timestamp, CContact::Ref contact) ::strcpy((char*)pCurBlob, sid); pCurBlob += ::strlen(sid) + 1; ::strcpy((char*)pCurBlob, reason); - this->AddDataBaseEvent(hContact, EVENTTYPE_AUTHREQUEST, time(NULL), PREF_UTF, cbBlob, pBlob); + this->AddDBEvent(hContact, EVENTTYPE_AUTHREQUEST, time(NULL), PREF_UTF, cbBlob, pBlob); } void CSkypeProto::RaiseMessageReceivedEvent(HANDLE hContact, DWORD timestamp, const char *guid, const wchar_t *message, bool isNeedCheck) @@ -111,16 +111,13 @@ void CSkypeProto::RaiseMessageSendedEvent(HANDLE hContact, DWORD timestamp, cons if (this->IsMessageInDB(hContact, timestamp, guid, DBEF_SENT)) return; + int guidLen = ::strlen(guid); + char *msg = ::mir_utf8encodeW(message); + int msgLen = ::strlen(msg) + 1; - DBEVENTINFO dbei = { 0 }; - dbei.cbSize = sizeof(dbei); - dbei.szModule = this->m_szModuleName; - dbei.timestamp = timestamp; - dbei.eventType = EVENTTYPE_MESSAGE; - dbei.cbBlob = (DWORD)::strlen(msg) + 1; - dbei.pBlob = (PBYTE)msg; - dbei.flags = PREF_UTF | DBEF_SENT; + msg = (char *)::mir_realloc(msg, msgLen + 32); + ::memcpy((char *)&msg[msgLen], guid, 32); - ::db_event_add(hContact, &dbei); + this->AddDBEvent(hContact, EVENTTYPE_MESSAGE, timestamp, PREF_UTF | DBEF_SENT, msgLen + guidLen, (PBYTE)msg); } \ No newline at end of file diff --git a/protocols/Skype/src/skype_events.cpp b/protocols/Skype/src/skype_events.cpp index ebee196ebd..28a003453d 100644 --- a/protocols/Skype/src/skype_events.cpp +++ b/protocols/Skype/src/skype_events.cpp @@ -54,9 +54,12 @@ int CSkypeProto::OnMessagePreCreate(WPARAM, LPARAM lParam) SEBinary guid; if (message->GetPropGuid(guid)) { + char *cguid = ::mir_strdup(guid.data()); + cguid[guid.size()] = 0; + evt->dbei->pBlob = (PBYTE)::mir_realloc(evt->dbei->pBlob, evt->dbei->cbBlob + guid.size()); - ::memcpy((char *)&evt->dbei->pBlob[evt->dbei->cbBlob], guid.data(), guid.size()); - evt->dbei->cbBlob += 32; + ::memcpy((char *)&evt->dbei->pBlob[evt->dbei->cbBlob], cguid, guid.size()); + evt->dbei->cbBlob += guid.size(); } return 1; @@ -102,10 +105,13 @@ void CSkypeProto::OnMessageSended(CConversation::Ref &conversation, CMessage::Re SEBinary guid; message->GetPropGuid(guid); + char *cguid = ::mir_strdup(guid.data()); + cguid[guid.size()] = 0; + this->RaiseMessageSendedEvent( hContact, timestamp, - guid.data(), + cguid, text); } } @@ -117,7 +123,7 @@ void CSkypeProto::OnMessageSended(CConversation::Ref &conversation, CMessage::Re wchar_t *nick = ::db_get_wsa(NULL, this->m_szModuleName, "Nick"); if (::wcsicmp(nick, L"") == 0) { - nick = ::db_get_wsa(NULL, this->m_szModuleName, "sid"); + nick = ::db_get_wsa(NULL, this->m_szModuleName, SKYPE_SETTINGS_LOGIN); } this->SendChatMessage(cid, nick, text); @@ -156,10 +162,13 @@ void CSkypeProto::OnMessageReceived(CConversation::Ref &conversation, CMessage:: SEBinary guid; message->GetPropGuid(guid); + char *cguid = ::mir_strdup(guid.data()); + cguid[guid.size()] = 0; + this->RaiseMessageReceivedEvent( hContact, timestamp, - guid.data(), + cguid, text, status != CMessage::UNCONSUMED_NORMAL); } @@ -459,7 +468,7 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa wchar_t *message = new wchar_t[14]; ::wcscpy(message, L"Incoming call"); - this->AddDataBaseEvent( + this->AddDBEvent( hContact, SKYPE_DB_EVENT_TYPE_CALL, timestamp, diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp index ddf36cedb7..48688727dd 100644 --- a/protocols/Skype/src/skype_proto.cpp +++ b/protocols/Skype/src/skype_proto.cpp @@ -104,7 +104,7 @@ int __cdecl CSkypeProto::AuthRecv(HANDLE hContact, PROTORECVEVENT* pre) if (pre->flags & PREF_UTF) flags |= DBEF_UTF; - this->AddDataBaseEvent( + this->AddDBEvent( hContact, EVENTTYPE_AUTHREQUEST, pre->timestamp, @@ -274,7 +274,7 @@ int __cdecl CSkypeProto::RecvContacts( HANDLE hContact, PROTORECVEVENT* ) { r int __cdecl CSkypeProto::RecvFile( HANDLE hContact, PROTORECVFILET* evt) { ::db_unset(hContact, "CList", "Hidden"); - return Proto_RecvFile(hContact, evt); + return ::Proto_RecvFile(hContact, evt); } int __cdecl CSkypeProto::RecvMsg( HANDLE hContact, PROTORECVEVENT* pre) @@ -282,25 +282,22 @@ int __cdecl CSkypeProto::RecvMsg( HANDLE hContact, PROTORECVEVENT* pre) ::db_unset(hContact, "CList", "Hidden"); this->UserIsTyping(hContact, PROTOTYPE_SELFTYPING_OFF); - DBEVENTINFO dbei = { 0 }; - dbei.cbSize = sizeof(dbei); - dbei.szModule = GetContactProto(hContact); - dbei.timestamp = pre->timestamp; - dbei.eventType = EVENTTYPE_MESSAGE; - dbei.cbBlob = (DWORD)strlen(pre->szMessage) + 1; - dbei.pBlob = (PBYTE) pre->szMessage; - char *guid = (char *)pre->lParam; - dbei.pBlob = (PBYTE)::mir_realloc(dbei.pBlob, dbei.cbBlob + 32); - ::memcpy((char *)&dbei.pBlob[dbei.cbBlob], guid, 32); - dbei.cbBlob += 32; + int guidLen = ::strlen(guid); - if (pre->flags & PREF_CREATEREAD) - dbei.flags |= DBEF_READ; - if (pre->flags & PREF_UTF) - dbei.flags |= DBEF_UTF; + char *message = (char *)pre->szMessage; + int msgLen = ::strlen(message) + 1; - return (INT_PTR)::db_event_add(hContact, &dbei); + message = (char *)::mir_realloc(message, msgLen + guidLen); + ::memcpy((char *)&message[msgLen], guid, guidLen); + + return (INT_PTR)this->AddDBEvent( + hContact, + EVENTTYPE_MESSAGE, + pre->timestamp, + DBEF_UTF | ((pre->flags & PREF_CREATEREAD) ? DBEF_READ : 0), + msgLen + guidLen, + (PBYTE)message); //return ::Proto_RecvMessage(hContact, pre); } diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index ec8967734a..5ad86dfc6b 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -467,7 +467,7 @@ protected: // database bool IsMessageInDB(HANDLE hContact, DWORD timestamp, const char* guid, int flag = 0); - HANDLE AddDataBaseEvent(HANDLE hContact, WORD type, DWORD time, DWORD flags = 0, DWORD cbBlob = 0, PBYTE pBlob = 0); + HANDLE AddDBEvent(HANDLE hContact, WORD type, DWORD time, DWORD flags = 0, DWORD cbBlob = 0, PBYTE pBlob = 0); void RaiseMessageReceivedEvent( HANDLE hContact, DWORD timestamp, -- cgit v1.2.3