diff options
-rw-r--r-- | protocols/Skype/src/skype.h | 2 | ||||
-rw-r--r-- | protocols/Skype/src/skype_contacts.cpp | 4 | ||||
-rw-r--r-- | protocols/Skype/src/skype_database.cpp | 24 | ||||
-rw-r--r-- | protocols/Skype/src/skype_events.cpp | 32 | ||||
-rw-r--r-- | protocols/Skype/src/skype_profile.cpp | 5 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.cpp | 7 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.h | 4 |
7 files changed, 63 insertions, 15 deletions
diff --git a/protocols/Skype/src/skype.h b/protocols/Skype/src/skype.h index 5cf4e84ace..963235e755 100644 --- a/protocols/Skype/src/skype.h +++ b/protocols/Skype/src/skype.h @@ -24,7 +24,7 @@ //#include <m_history.h>
//#include <m_idle.h>
#include <m_langpack.h>
-//#include <m_message.h>
+#include <m_message.h>
#include <m_netlib.h>
#include <m_options.h>
#include <m_popup.h>
diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp index d9ec251ab7..4e9090cbd7 100644 --- a/protocols/Skype/src/skype_contacts.cpp +++ b/protocols/Skype/src/skype_contacts.cpp @@ -168,6 +168,7 @@ HANDLE CSkypeProto::GetContactBySid(const wchar_t *sid) HANDLE CSkypeProto::GetContactFromAuthEvent(HANDLE hEvent)
{
+ // db_event_getContact
DWORD body[3];
DBEVENTINFO dbei = { sizeof(DBEVENTINFO) };
dbei.cbBlob = sizeof(DWORD) * 2;
@@ -242,10 +243,10 @@ void __cdecl CSkypeProto::LoadContactList(void*) this);
this->commonList->GetContacts(this->contactList);
+ fetch(this->contactList);
for (uint i = 0; i < this->contactList.size(); i++)
{
CContact::Ref contact = this->contactList[i];
- SEObject *obj = contact.fetch();
contact->SetOnContactChangedCallback(
(CContact::OnContactChanged)&CSkypeProto::OnContactChanged,
this);
@@ -255,6 +256,7 @@ void __cdecl CSkypeProto::LoadContactList(void*) this->UpdateContactAuthState(hContact, contact);
this->UpdateContactStatus(hContact, contact);
+ SEObject *obj = contact.fetch();
this->UpdateProfile(obj, hContact);
this->UpdateProfileAvatar(obj, hContact);
this->UpdateProfileStatusMessage(obj, hContact);
diff --git a/protocols/Skype/src/skype_database.cpp b/protocols/Skype/src/skype_database.cpp index b607c8e4b7..8b3088b484 100644 --- a/protocols/Skype/src/skype_database.cpp +++ b/protocols/Skype/src/skype_database.cpp @@ -63,12 +63,10 @@ void CSkypeProto::RaiseAuthRequestEvent( ::CallService(MS_PROTO_CHAINRECV, 0, (LPARAM)&ccs);
}
-bool CSkypeProto::IsMessageInDB(HANDLE hContact, DWORD timestamp, const char* message, int flag)
+bool CSkypeProto::IsMessageInDB(HANDLE hContact, DWORD timestamp, const char* guid, int flag)
{
bool result = false;
- int length = ::strlen(message);
-
HANDLE hDbEvent = ::db_event_last(hContact);
while (hDbEvent)
{
@@ -86,8 +84,7 @@ bool CSkypeProto::IsMessageInDB(HANDLE hContact, DWORD timestamp, const char* me int sendFlag = dbei.flags & DBEF_SENT;
if (dbei.eventType == EVENTTYPE_MESSAGE && sendFlag == flag)
{
- char *dbMessage = (char *)dbei.pBlob;
- if (::strncmp(dbMessage, message, length) == 0 && dbei.timestamp == timestamp)
+ if (::memcmp(&dbei.pBlob[dbei.cbBlob - 32], guid, 32) == 0)
{
::mir_free(dbei.pBlob);
result = true;
@@ -105,17 +102,19 @@ bool CSkypeProto::IsMessageInDB(HANDLE hContact, DWORD timestamp, const char* me void CSkypeProto::RaiseMessageReceivedEvent(
HANDLE hContact,
DWORD timestamp,
+ const char *guid,
const wchar_t *message,
bool isNeedCheck)
{
- /*if (isNeedCheck)
- if (this->IsMessageInDB(hContact, timestamp, message))
- return;*/
+ if (isNeedCheck)
+ if (this->IsMessageInDB(hContact, timestamp, guid))
+ return;
PROTORECVEVENT recv;
- recv.flags = PREF_UNICODE;
+ recv.flags = PREF_UTF;
+ recv.lParam = (LPARAM)guid;
recv.timestamp = timestamp;
- recv.tszMessage = ::mir_wstrdup(message);
+ recv.szMessage = ::mir_utf8encodeW(message);
::ProtoChainRecvMsg(hContact, &recv);
}
@@ -123,10 +122,11 @@ void CSkypeProto::RaiseMessageReceivedEvent( void CSkypeProto::RaiseMessageSendedEvent(
HANDLE hContact,
DWORD timestamp,
+ const char *guid,
const wchar_t *message)
{
- /*if (this->IsMessageInDB(hContact, timestamp, message, DBEF_SENT))
- return;*/
+ if (this->IsMessageInDB(hContact, timestamp, guid, DBEF_SENT))
+ return;
char *msg = ::mir_utf8encodeW(message);
diff --git a/protocols/Skype/src/skype_events.cpp b/protocols/Skype/src/skype_events.cpp index 90ab1ff27b..87d491cbb5 100644 --- a/protocols/Skype/src/skype_events.cpp +++ b/protocols/Skype/src/skype_events.cpp @@ -46,6 +46,23 @@ int CSkypeProto::OnContactDeleted(WPARAM wParam, LPARAM lParam) return 0;
}
+int CSkypeProto::OnMessagePreCreate(WPARAM, LPARAM lParam)
+{
+ MessageWindowEvent *evt = (MessageWindowEvent *)lParam;
+
+ MessageRef message(evt->seq);
+
+ SEBinary guid;
+ if (message->GetPropGuid(guid))
+ {
+ evt->dbei->pBlob = (PBYTE)::mir_realloc(evt->dbei->pBlob, (evt->dbei->cbBlob + 32));
+ ::memcpy(&evt->dbei->pBlob[evt->dbei->cbBlob], guid.data(), 32);
+ evt->dbei->cbBlob += 32;
+ }
+
+ return 1;
+}
+
void CSkypeProto::OnMessageSended(CConversation::Ref conversation, CMessage::Ref message, CContact::Ref receiver)
{
SEString data;
@@ -70,15 +87,25 @@ void CSkypeProto::OnMessageSended(CConversation::Ref conversation, CMessage::Ref if (sstatus != CMessage::SENDING)
{
+ // todo: shit shit shit
this->SendBroadcast(
hContact,
ACKTYPE_MESSAGE,
sstatus == CMessage::FAILED_TO_SEND ? ACKRESULT_FAILED : ACKRESULT_SUCCESS,
(HANDLE)message->getOID(), 0);
+ this->SendBroadcast(
+ hContact,
+ ACKTYPE_MESSAGE,
+ sstatus == CMessage::FAILED_TO_SEND ? ACKRESULT_FAILED : ACKRESULT_SUCCESS,
+ (HANDLE)message->getOID(), 0);
+
+ SEBinary guid;
+ message->GetPropGuid(guid);
this->RaiseMessageSendedEvent(
hContact,
timestamp,
+ guid.data(),
text);
}
}
@@ -129,10 +156,13 @@ void CSkypeProto::OnMessageReceived(CConversation::Ref conversation, CMessage::R {
HANDLE hContact = this->AddContact(author);
- // fixme
+ SEBinary guid;
+ message->GetPropGuid(guid);
+
this->RaiseMessageReceivedEvent(
hContact,
timestamp,
+ guid.data(),
text,
status != CMessage::UNCONSUMED_NORMAL);
}
diff --git a/protocols/Skype/src/skype_profile.cpp b/protocols/Skype/src/skype_profile.cpp index 37d9dff106..44ddea1d42 100644 --- a/protocols/Skype/src/skype_profile.cpp +++ b/protocols/Skype/src/skype_profile.cpp @@ -370,5 +370,10 @@ void CSkypeProto::UpdateProfile(SEObject *obj, HANDLE hContact) void __cdecl CSkypeProto::LoadOwnInfo(void*)
{
+ wchar_t *nick = ::db_get_wsa(NULL, this->m_szModuleName, "Nick");
+ if (!nick || !::wcslen(nick))
+ {
+ ::db_set_ws(NULL, this->m_szModuleName, "Nick", this->login);
+ }
this->UpdateProfile(this->account.fetch());
}
\ No newline at end of file diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp index 0dfb3b1bd8..95fbf1d96a 100644 --- a/protocols/Skype/src/skype_proto.cpp +++ b/protocols/Skype/src/skype_proto.cpp @@ -13,6 +13,8 @@ CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName) : fileTra this->signin_lock = CreateMutex(0, false, 0);
this->SetAllContactStatus(ID_STATUS_OFFLINE);
+ this->HookEvent(ME_MSG_PRECREATEEVENT, &CSkypeProto::OnMessagePreCreate);
+
this->CreateServiceObj(PS_CREATEACCMGRUI, &CSkypeProto::OnAccountManagerInit);
// Chat API
this->CreateServiceObj(PS_JOINCHAT, &CSkypeProto::OnJoinChat);
@@ -264,6 +266,11 @@ int __cdecl CSkypeProto::RecvFile( HANDLE hContact, PROTORECVFILET* evt) int __cdecl CSkypeProto::RecvMsg( HANDLE hContact, PROTORECVEVENT* pre)
{
this->UserIsTyping(hContact, PROTOTYPE_SELFTYPING_OFF);
+
+ int length = ::strlen(pre->szMessage) + 1;
+ pre->szMessage = (char *)::mir_realloc(pre->szMessage, length + 32);
+ ::memcpy(&pre->szMessage[length], (char *)pre->lParam, 32);
+
return ::Proto_RecvMessage(hContact, pre);
}
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index 4a31a66d21..5cf18527b5 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -239,6 +239,8 @@ public: int __cdecl OnUserInfoInit(WPARAM, LPARAM);
INT_PTR __cdecl OnAccountManagerInit(WPARAM wParam, LPARAM lParam);
+ int __cdecl OnMessagePreCreate(WPARAM, LPARAM);
+
// instances
static CSkypeProto* InitSkypeProto(const char* protoName, const wchar_t* userName);
static int UninitSkypeProto(CSkypeProto* ppro);
@@ -473,11 +475,13 @@ protected: void RaiseMessageReceivedEvent(
HANDLE hContact,
DWORD timestamp,
+ const char* guid,
const wchar_t *message,
bool isNeedCheck = true);
void RaiseMessageSendedEvent(
HANDLE hContact,
DWORD timestamp,
+ const char* guid,
const wchar_t *message);
/*void RaiseFileReceivedEvent(
DWORD timestamp,
|