diff options
-rw-r--r-- | protocols/Skype/src/skype.cpp | 2 | ||||
-rw-r--r-- | protocols/Skype/src/skype_database.cpp | 19 | ||||
-rw-r--r-- | protocols/Skype/src/skype_messages.cpp | 15 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.h | 6 |
4 files changed, 16 insertions, 26 deletions
diff --git a/protocols/Skype/src/skype.cpp b/protocols/Skype/src/skype.cpp index 24a461da6b..51c189318a 100644 --- a/protocols/Skype/src/skype.cpp +++ b/protocols/Skype/src/skype.cpp @@ -267,7 +267,7 @@ extern "C" int __declspec(dllexport) Load(void) return 1;
}
- g_skype = new CSkype();
+ g_skype = new CSkype(4);
TransportInterface::Status status = g_skype->init(keyPair, "127.0.0.1", port);
if (status != TransportInterface::OK)
{
diff --git a/protocols/Skype/src/skype_database.cpp b/protocols/Skype/src/skype_database.cpp index f087f96412..7a967e7ab2 100644 --- a/protocols/Skype/src/skype_database.cpp +++ b/protocols/Skype/src/skype_database.cpp @@ -1,6 +1,6 @@ #include "skype_proto.h"
-bool CSkypeProto::IsMessageInDB(HANDLE hContact, DWORD timestamp, const char *guid, int flag)
+bool CSkypeProto::IsMessageInDB(HANDLE hContact, DWORD timestamp, SEBinary &guid, int flag)
{
bool result = false;
@@ -9,7 +9,7 @@ bool CSkypeProto::IsMessageInDB(HANDLE hContact, DWORD timestamp, const char *gu {
DBEVENTINFO dbei = { sizeof(dbei) };
dbei.cbBlob = ::db_event_getBlobSize(hDbEvent);
- if (dbei.cbBlob < 32)
+ if (dbei.cbBlob < guid.size())
continue;
mir_ptr<BYTE> blob((PBYTE)::mir_alloc(dbei.cbBlob));
@@ -22,7 +22,7 @@ bool CSkypeProto::IsMessageInDB(HANDLE hContact, DWORD timestamp, const char *gu int sendFlag = dbei.flags & DBEF_SENT;
if (dbei.eventType == EVENTTYPE_MESSAGE && sendFlag == flag)
{
- if (::memcmp(&dbei.pBlob[dbei.cbBlob - 32], guid, 32) == 0)
+ if (::memcmp(&dbei.pBlob[dbei.cbBlob - 32], guid.data(), guid.size()) == 0)
{
result = true;
break;
@@ -96,7 +96,7 @@ void CSkypeProto::RaiseAuthRequestEvent(DWORD timestamp, CContact::Ref contact) this->AddDBEvent(hContact, EVENTTYPE_AUTHREQUEST, time(NULL), PREF_UTF, cbBlob, pBlob);
}
-void CSkypeProto::RaiseMessageReceivedEvent(HANDLE hContact, DWORD timestamp, const char *guid, const char *message, bool isUnreaded)
+void CSkypeProto::RaiseMessageReceivedEvent(HANDLE hContact, DWORD timestamp, SEBinary &guid, const char *message, bool isUnreaded)
{
if ( !isUnreaded)
if (this->IsMessageInDB(hContact, timestamp, guid))
@@ -104,26 +104,25 @@ void CSkypeProto::RaiseMessageReceivedEvent(HANDLE hContact, DWORD timestamp, co PROTORECVEVENT recv;
recv.flags = PREF_UTF;
- recv.lParam = (LPARAM)guid;
+ recv.lParam = (LPARAM)&guid;
recv.timestamp = timestamp;
recv.szMessage = ::mir_strdup(message);
-
::ProtoChainRecvMsg(hContact, &recv);
}
-void CSkypeProto::RaiseMessageSendedEvent(HANDLE hContact, DWORD timestamp, const char *guid, const char *message, bool isUnreaded)
+void CSkypeProto::RaiseMessageSendedEvent(HANDLE hContact, DWORD timestamp, SEBinary &guid, const char *message, bool isUnreaded)
{
if (this->IsMessageInDB(hContact, timestamp, guid, DBEF_SENT))
return;
- int guidLen = (int)::strlen(guid);
+ int guidLen = (int)guid.size();
int msgLen = (int)::strlen(message) + 1;
char *msg = (char *)::mir_alloc(msgLen + guidLen);
::strcpy(msg, message);
msg[msgLen - 1] = 0;
- ::memcpy((char *)&msg[msgLen], guid, guidLen);
+ ::memcpy((char *)&msg[msgLen], guid.data(), guidLen);
DWORD flags = DBEF_UTF | DBEF_SENT;
if ( !isUnreaded)
@@ -136,4 +135,4 @@ void CSkypeProto::RaiseMessageSendedEvent(HANDLE hContact, DWORD timestamp, cons flags,
msgLen + guidLen,
(PBYTE)msg);
-}
\ No newline at end of file +}
diff --git a/protocols/Skype/src/skype_messages.cpp b/protocols/Skype/src/skype_messages.cpp index 31d08c19f9..7d7f3347e6 100644 --- a/protocols/Skype/src/skype_messages.cpp +++ b/protocols/Skype/src/skype_messages.cpp @@ -8,11 +8,8 @@ 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], cguid, guid.size());
+ ::memcpy((char *)&evt->dbei->pBlob[evt->dbei->cbBlob], guid.data(), guid.size());
evt->dbei->cbBlob += (DWORD)guid.size();
}
@@ -45,13 +42,10 @@ 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,
- cguid,
+ guid,
text,
status == CMessage::UNCONSUMED_NORMAL);
}
@@ -93,13 +87,10 @@ 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,
- cguid,
+ guid,
text,
status == CMessage::UNCONSUMED_NORMAL);
}
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index 0015b5422b..a8f9d20acb 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -402,19 +402,19 @@ protected: int OnPrebuildContactMenu(WPARAM wParam, LPARAM);
// database
- bool IsMessageInDB(HANDLE hContact, DWORD timestamp, const char* guid, int flag = 0);
+ bool IsMessageInDB(HANDLE hContact, DWORD timestamp, SEBinary &guid, int flag = 0);
HANDLE AddDBEvent(HANDLE hContact, WORD type, DWORD time, DWORD flags = 0, DWORD cbBlob = 0, PBYTE pBlob = 0);
void RaiseMessageReceivedEvent(
HANDLE hContact,
DWORD timestamp,
- const char* guid,
+ SEBinary &guid,
const char *message,
bool isUnreaded = true);
void RaiseMessageSendedEvent(
HANDLE hContact,
DWORD timestamp,
- const char* guid,
+ SEBinary &guid,
const char *message,
bool isUnreaded = true);
void RaiseAuthRequestEvent(
|