diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2013-05-10 17:11:05 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2013-05-10 17:11:05 +0000 |
commit | 9403f94a71782e106d29f1ca2df5aa682ea3f746 (patch) | |
tree | 8a7ee36aa1f57295209f50f9044c679a248a9fab /protocols/Skype | |
parent | b94dc989d9eba4bcbf255421b84d1803cbfd0bc1 (diff) |
- added skype emote support (/me chat command)
git-svn-id: http://svn.miranda-ng.org/main/trunk@4623 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Skype')
-rw-r--r-- | protocols/Skype/src/skype_chat.cpp | 41 | ||||
-rw-r--r-- | protocols/Skype/src/skype_database.cpp | 4 | ||||
-rw-r--r-- | protocols/Skype/src/skype_events.cpp | 61 | ||||
-rw-r--r-- | protocols/Skype/src/skype_messages.cpp | 21 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.cpp | 8 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.h | 2 |
6 files changed, 89 insertions, 48 deletions
diff --git a/protocols/Skype/src/skype_chat.cpp b/protocols/Skype/src/skype_chat.cpp index 1a240d7089..48269d71c8 100644 --- a/protocols/Skype/src/skype_chat.cpp +++ b/protocols/Skype/src/skype_chat.cpp @@ -692,45 +692,4 @@ void CSkypeProto::UpdateChatUserStatus(CContact::Ref contact) 0,
CSkypeProto::SkypeToMirandaStatus(availability));
}
-}
-
-void CSkypeProto::OnChatMessageReceived(CConversation::Ref &conversation, CMessage::Ref &message)
-{
- SEString data;
-
- uint timestamp;
- message->GetPropTimestamp(timestamp);
-
- message->GetPropBodyXml(data);
- char *text = CSkypeProto::RemoveHtml(data);
-
- message->GetPropAuthor(data);
- mir_ptr<wchar_t> sid( ::mir_utf8decodeW(data));
-
- conversation->GetPropIdentity(data);
- mir_ptr<wchar_t> cid( ::mir_utf8decodeW(data));
-
- //this->SendChatMessage(cid, sid, mir_ptr<wchar_t>(::mir_utf8decodeW(text)));
- this->RaiseChatEvent(cid, sid, GC_EVENT_MESSAGE, GCEF_ADDTOLOG, 0, NULL, mir_ptr<wchar_t>(::mir_utf8decodeW(text)));
-}
-
-void CSkypeProto::OnChatMessageSent(CConversation::Ref &conversation, CMessage::Ref &message)
-{
- SEString data;
-
- uint timestamp;
- message->GetPropTimestamp(timestamp);
-
- message->GetPropBodyXml(data);
- char *text = CSkypeProto::RemoveHtml(data);
-
- conversation->GetPropIdentity(data);
- mir_ptr<wchar_t> cid( ::mir_utf8decodeW(data));
-
- mir_ptr<wchar_t> nick( ::db_get_wsa(NULL, this->m_szModuleName, "Nick"));
- if (::wcsicmp(nick, L"") == 0)
- nick = ::db_get_wsa(NULL, this->m_szModuleName, SKYPE_SETTINGS_LOGIN);
-
- //this->SendChatMessage(cid, nick, mir_ptr<wchar_t>(::mir_utf8decodeW(text)));
- this->RaiseChatEvent(cid, nick, GC_EVENT_MESSAGE, GCEF_ADDTOLOG, 0, NULL, mir_ptr<wchar_t>(::mir_utf8decodeW(text)));
}
\ No newline at end of file diff --git a/protocols/Skype/src/skype_database.cpp b/protocols/Skype/src/skype_database.cpp index d7e010d125..67853c73b3 100644 --- a/protocols/Skype/src/skype_database.cpp +++ b/protocols/Skype/src/skype_database.cpp @@ -17,7 +17,7 @@ bool CSkypeProto::IsMessageInDB(HANDLE hContact, DWORD timestamp, SEBinary &guid break;
int sendFlag = dbei.flags & DBEF_SENT;
- if (dbei.eventType == EVENTTYPE_MESSAGE && sendFlag == flag)
+ if ((dbei.eventType == EVENTTYPE_MESSAGE || dbei.eventType == SKYPE_DB_EVENT_TYPE_EMOTE) && sendFlag == flag)
if (::memcmp(&dbei.pBlob[dbei.cbBlob - guid.size()], guid.data(), guid.size()) == 0)
return true;
}
@@ -118,7 +118,7 @@ void CSkypeProto::RaiseMessageSentEvent(HANDLE hContact, DWORD timestamp, SEBina this->AddDBEvent(
hContact,
- EVENTTYPE_MESSAGE,
+ EVENTTYPE_MESSAGE,
timestamp,
flags,
msgLen + guidLen,
diff --git a/protocols/Skype/src/skype_events.cpp b/protocols/Skype/src/skype_events.cpp index d0af5aea8c..a89729a46f 100644 --- a/protocols/Skype/src/skype_events.cpp +++ b/protocols/Skype/src/skype_events.cpp @@ -201,6 +201,67 @@ int __cdecl CSkypeProto::OnTabSRMMButtonPressed(WPARAM wParam, LPARAM lParam) return 1;
}
+void CSkypeProto::OnChatMessageReceived(CConversation::Ref &conversation, CMessage::Ref &message)
+{
+ SEString data;
+
+ uint timestamp;
+ message->GetPropTimestamp(timestamp);
+
+ message->GetPropBodyXml(data);
+ char *text = CSkypeProto::RemoveHtml(data);
+
+ message->GetPropAuthor(data);
+ mir_ptr<wchar_t> sid( ::mir_utf8decodeW(data));
+
+ conversation->GetPropIdentity(data);
+ mir_ptr<wchar_t> cid( ::mir_utf8decodeW(data));
+
+ CMessage::TYPE messageType;
+ message->GetPropType(messageType);
+
+ //this->SendChatMessage(cid, sid, mir_ptr<wchar_t>(::mir_utf8decodeW(text)));
+ this->RaiseChatEvent(
+ cid,
+ sid,
+ messageType == CMessage::POSTED_TEXT ? /*GC_EVENT_MESSAGE */ 0x0040 : /*GC_EVENT_ACTION */ 0x0200,
+ /*GCEF_ADDTOLOG*/ 0x0001,
+ 0,
+ NULL,
+ mir_ptr<wchar_t>(::mir_utf8decodeW(text)));
+}
+
+void CSkypeProto::OnChatMessageSent(CConversation::Ref &conversation, CMessage::Ref &message)
+{
+ SEString data;
+
+ uint timestamp;
+ message->GetPropTimestamp(timestamp);
+
+ message->GetPropBodyXml(data);
+ char *text = CSkypeProto::RemoveHtml(data);
+
+ conversation->GetPropIdentity(data);
+ mir_ptr<wchar_t> cid( ::mir_utf8decodeW(data));
+
+ mir_ptr<wchar_t> nick( ::db_get_wsa(NULL, this->m_szModuleName, "Nick"));
+ if (::wcsicmp(nick, L"") == 0)
+ nick = ::db_get_wsa(NULL, this->m_szModuleName, SKYPE_SETTINGS_LOGIN);
+
+ CMessage::TYPE messageType;
+ message->GetPropType(messageType);
+
+ //this->SendChatMessage(cid, nick, mir_ptr<wchar_t>(::mir_utf8decodeW(text)));
+ this->RaiseChatEvent(
+ cid,
+ nick,
+ messageType == CMessage::POSTED_TEXT ? /*GC_EVENT_MESSAGE */ 0x0040 : /*GC_EVENT_ACTION */ 0x0200,
+ /*GCEF_ADDTOLOG*/ 0x0001,
+ 0,
+ NULL,
+ mir_ptr<wchar_t>(::mir_utf8decodeW(text)));
+}
+
void CSkypeProto::OnChatEvent(CConversation::Ref &conversation, CMessage::Ref &message)
{
CMessage::TYPE messageType;
diff --git a/protocols/Skype/src/skype_messages.cpp b/protocols/Skype/src/skype_messages.cpp index 31b1b4d03d..64b29939e1 100644 --- a/protocols/Skype/src/skype_messages.cpp +++ b/protocols/Skype/src/skype_messages.cpp @@ -10,9 +10,24 @@ int CSkypeProto::OnMessagePreCreate(WPARAM, LPARAM lParam) SEBinary guid;
if (message->GetPropGuid(guid))
{
- 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 += (DWORD)guid.size();
+ CMessage::TYPE messageType;
+ message->GetPropType(messageType);
+
+ if (messageType == CMessage::POSTED_TEXT)
+ {
+ 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 += (DWORD)guid.size();
+ }
+ else if (messageType == CMessage::POSTED_EMOTE)
+ {
+ evt->dbei->pBlob = (PBYTE)::mir_realloc(evt->dbei->pBlob, evt->dbei->cbBlob + guid.size() - 4);
+ ::memcpy((char *)&evt->dbei->pBlob[0], (char *)&evt->dbei->pBlob[4], evt->dbei->cbBlob - 4);
+ ::memcpy((char *)&evt->dbei->pBlob[evt->dbei->cbBlob - 4], guid.data(), guid.size());
+ evt->dbei->cbBlob += (DWORD)guid.size() - 4;
+
+ evt->dbei->eventType = SKYPE_DB_EVENT_TYPE_EMOTE;
+ }
}
return 1;
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp index 1dfa99c3c5..9cca6581d6 100644 --- a/protocols/Skype/src/skype_proto.cpp +++ b/protocols/Skype/src/skype_proto.cpp @@ -293,9 +293,15 @@ int __cdecl CSkypeProto::RecvMsg(HANDLE hContact, PROTORECVEVENT* pre) message = (char *)::mir_realloc(message, msgLen + guid->size());
::memcpy((char *)&message[msgLen], guid->data(), guid->size());
+ CMessage::Ref skype_message;
+ g_skype->GetMessageByGuid(*guid, skype_message);
+
+ CMessage::TYPE messageType;
+ skype_message->GetPropType(messageType);
+
return (INT_PTR)this->AddDBEvent(
hContact,
- EVENTTYPE_MESSAGE,
+ messageType == CMessage::POSTED_TEXT ? EVENTTYPE_MESSAGE : SKYPE_DB_EVENT_TYPE_EMOTE,
pre->timestamp,
DBEF_UTF | ((pre->flags & PREF_CREATEREAD) ? DBEF_READ : 0),
DWORD(msgLen + guid->size()),
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index ee2cc4da46..9487e6b35e 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -419,7 +419,7 @@ protected: HANDLE hContact,
DWORD timestamp,
SEBinary &guid,
- const char *message,
+ const char *message,
bool isUnreaded = true);
void RaiseAuthRequestEvent(
DWORD timestamp,
|