summaryrefslogtreecommitdiff
path: root/protocols/Skype/src/skype_events.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2013-05-08 15:08:27 +0000
committerAlexander Lantsev <aunsane@gmail.com>2013-05-08 15:08:27 +0000
commit27cac8c07ca2465c187bb90e7058a854f46b6746 (patch)
treeb561f2aba5067fca7d10613161326ad7e67ce2b9 /protocols/Skype/src/skype_events.cpp
parent57ddd953a88d6633ab06b6ef5ca04414338b566f (diff)
- code restructurization
- started network log filling git-svn-id: http://svn.miranda-ng.org/main/trunk@4598 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Skype/src/skype_events.cpp')
-rw-r--r--protocols/Skype/src/skype_events.cpp383
1 files changed, 62 insertions, 321 deletions
diff --git a/protocols/Skype/src/skype_events.cpp b/protocols/Skype/src/skype_events.cpp
index 6137de071d..ca54a4904d 100644
--- a/protocols/Skype/src/skype_events.cpp
+++ b/protocols/Skype/src/skype_events.cpp
@@ -30,7 +30,7 @@ int CSkypeProto::OnModulesLoaded(WPARAM, LPARAM)
}
g_skype->SetOnMessageCallback(
- (CSkype::OnMessaged)&CSkypeProto::OnMessage,
+ (CSkype::OnMessaged)&CSkypeProto::OnSkypeEvent,
this);
return 0;
@@ -42,6 +42,10 @@ int CSkypeProto::OnPreShutdown(WPARAM, LPARAM)
{
BBButton bbd = { sizeof(bbd) };
bbd.pszModuleName = MODULE;
+
+ bbd.dwButtonID = BBB_ID_CONF_INVITE;
+ ::CallService(MS_BB_REMOVEBUTTON, 0, (LPARAM)&bbd);
+
bbd.dwButtonID = BBB_ID_CONF_SPAWN;
::CallService(MS_BB_REMOVEBUTTON, 0, (LPARAM)&bbd);
}
@@ -151,288 +155,7 @@ int __cdecl CSkypeProto::OnTabSRMMButtonPressed(WPARAM wParam, LPARAM lParam)
return 1;
}
-int CSkypeProto::OnMessagePreCreate(WPARAM, LPARAM lParam)
-{
- MessageWindowEvent *evt = (MessageWindowEvent *)lParam;
-
- MessageRef message(evt->seq);
- 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());
- evt->dbei->cbBlob += (DWORD)guid.size();
- }
-
- return 1;
-}
-
-void CSkypeProto::OnMessageReceived(CConversation::Ref &conversation, CMessage::Ref &message)
-{
- SEString data;
-
- CMessage::TYPE messageType;
- message->GetPropType(messageType);
-
- uint timestamp;
- message->GetPropTimestamp(timestamp);
-
- CMessage::CONSUMPTION_STATUS status;
- message->GetPropConsumptionStatus(status);
-
- message->GetPropBodyXml(data);
- char *text = CSkypeProto::RemoveHtml(data);
-
- CConversation::TYPE type;
- conversation->GetPropType(type);
- if (type == CConversation::DIALOG)
- {
- message->GetPropAuthor(data);
-
- CContact::Ref author;
- g_skype->GetContact(data, author);
-
- HANDLE hContact = this->AddContact(author);
-
- SEBinary guid;
- message->GetPropGuid(guid);
-
- char *cguid = ::mir_strdup(guid.data());
- cguid[guid.size()] = 0;
-
- this->RaiseMessageReceivedEvent(
- hContact,
- timestamp,
- cguid,
- text,
- status == CMessage::UNCONSUMED_NORMAL);
- }
- else
- {
- 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)));
- }
-}
-
-void CSkypeProto::OnMessageSended(CConversation::Ref &conversation, CMessage::Ref &message)
-{
- SEString data;
-
- CMessage::TYPE messageType;
- message->GetPropType(messageType);
-
- uint timestamp;
- message->GetPropTimestamp(timestamp);
-
- CMessage::SENDING_STATUS sstatus;
- message->GetPropSendingStatus(sstatus);
-
- CMessage::CONSUMPTION_STATUS status;
- message->GetPropConsumptionStatus(status);
-
- message->GetPropBodyXml(data);
- char *text = CSkypeProto::RemoveHtml(data);
-
- CConversation::TYPE type;
- conversation->GetPropType(type);
- if (type == CConversation::DIALOG)
- {
- CParticipant::Refs participants;
- conversation->GetParticipants(participants, CConversation::OTHER_CONSUMERS);
- participants[0]->GetPropIdentity(data);
-
- CContact::Ref receiver;
- g_skype->GetContact(data, receiver);
-
- HANDLE hContact = this->AddContact(receiver);
-
- //if (sstatus != CMessage::SENDING)
- {
- this->SendBroadcast(
- hContact,
- ACKTYPE_MESSAGE,
- sstatus == CMessage::FAILED_TO_SEND ? ACKRESULT_FAILED : ACKRESULT_SUCCESS,
- (HANDLE)message->getOID(), 0);
-
- SEBinary guid;
- message->GetPropGuid(guid);
-
- char *cguid = ::mir_strdup(guid.data());
- cguid[guid.size()] = 0;
-
- this->RaiseMessageSendedEvent(
- hContact,
- timestamp,
- cguid,
- text,
- status == CMessage::UNCONSUMED_NORMAL);
- }
- }
- else
- {
- 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)));
- }
-}
-
-
-void CSkypeProto::OnTransferChanged(CTransfer::Ref transfer, int prop)
-{
- switch (prop)
- {
- case Transfer::P_STATUS:
- {
- SEBinary guid;
- transfer->GetPropChatmsgGuid(guid);
-
- CMessage::Ref message;
- g_skype->GetMessageByGuid(guid, message);
-
- uint oid = message->getOID();
-
- SEString data;
- transfer->GetPropPartnerHandle(data);
- HANDLE hContact = this->GetContactBySid(mir_ptr<wchar_t>(::mir_utf8decodeW(data)));
-
- Transfer::STATUS status;
- transfer->GetPropStatus(status);
- switch(status)
- {
- /*case CTransfer::NEW:
- break;*/
- /*case CTransfer::WAITING_FOR_ACCEPT:
- break;*/
- case CTransfer::CONNECTING:
- this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, (HANDLE)oid, 0);
- break;
- case CTransfer::TRANSFERRING:
- case CTransfer::TRANSFERRING_OVER_RELAY:
- this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_CONNECTED, (HANDLE)oid, 0);
- break;
- case CTransfer::FAILED:
- this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (HANDLE)oid, 0);
- this->transferList.remove_val(transfer);
- break;
- case CTransfer::COMPLETED:
- this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, (HANDLE)oid, 0);
- this->transferList.remove_val(transfer);
- break;
- case CTransfer::CANCELLED:
- case CTransfer::CANCELLED_BY_REMOTE:
- this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_DENIED, (HANDLE)oid, 0);
- this->transferList.remove_val(transfer);
- break;
- }
- }
- break;
-
- case Transfer::P_BYTESTRANSFERRED:
- {
- SEString data;
-
- SEBinary guid;
- transfer->GetPropChatmsgGuid(guid);
-
- CMessage::Ref message;
- g_skype->GetMessageByGuid(guid, message);
-
- uint oid = message->getOID();
-
- PROTOFILETRANSFERSTATUS pfts = {0};
- pfts.cbSize = sizeof(pfts);
- pfts.flags = PFTS_UTF | PFTS_RECEIVING;
- pfts.totalFiles = 1;
- pfts.currentFileNumber = 0;
-
- transfer->GetPropPartnerHandle(data);
- HANDLE hContact = this->GetContactBySid(mir_ptr<wchar_t>(::mir_utf8decodeW(data)));
- pfts.hContact = hContact;
-
- transfer->GetPropFilename(data);
- pfts.szCurrentFile = ::mir_strdup(data);
-
- pfts.pszFiles = &pfts.szCurrentFile;
-
- transfer->GetPropFilesize(data);
- pfts.totalBytes = pfts.currentFileSize = data.toUInt64();
-
- transfer->GetPropBytestransferred(data);
- pfts.totalProgress = pfts.currentFileProgress = data.toUInt64();
-
- this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_DATA, (HANDLE)oid, (LPARAM)&pfts);
- }
- break;
- }
-}
-
-void CSkypeProto::OnFile(CConversation::Ref &conversation, CMessage::Ref &message)
-{
- CTransfer::Refs transfers;
- message->GetTransfers(transfers);
- //Sid::fetch(transferList);
-
- Transfer::TYPE transferType;
- Transfer::STATUS transferStatus;
-
- for (uint i = 0; i < transfers.size(); i++)
- {
- auto transfer = transfers[i];
-
- // For incomings, we need to check for transfer status, just to be sure.
- // In some cases, a transfer can appear with STATUS == PLACEHOLDER
- // As such transfers cannot be accepted, we will need to just store
- // the reference to Transfer Object and then check for further
- // status changes in Transfer::OnChange
- transfer->GetPropStatus(transferStatus);
- if (transferStatus == Transfer::NEW)
- {
- transfer->GetPropType(transferType);
- if (transferType == Transfer::INCOMING)
- {
- transfer.fetch();
- transfer->SetOnTransferCallback(
- (CTransfer::OnTransfer)&CSkypeProto::OnTransferChanged,
- this);
- this->transferList.append(transfer);
-
- uint timestamp;
- message->GetPropTimestamp(timestamp);
-
- SEString data;
- transfer->GetPropPartnerHandle(data);
- HANDLE hContact = this->GetContactBySid(mir_ptr<wchar_t>(::mir_utf8decodeW(data)));
-
- transfer->GetPropFilename(data);
- wchar_t *path = ::mir_utf8decodeW(data);
-
- PROTORECVFILET pre = {0};
- pre.flags = PREF_TCHAR;
- pre.fileCount = 1;
- pre.timestamp = timestamp;
- pre.tszDescription = L" ";
- pre.ptszFiles = &path;
- pre.lParam = (LPARAM)message->getOID();
- ::ProtoChainRecvFile(hContact, &pre);
- }
- }
- }
-}
-
-void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref message)
+void CSkypeProto::OnChatEvent(CConversation::Ref &conversation, CMessage::Ref &message)
{
CMessage::TYPE messageType;
message->GetPropType(messageType);
@@ -446,16 +169,12 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa
message->GetPropAuthor(author);
if (::wcsicmp(mir_ptr<wchar_t>(::mir_utf8decodeW(author)), this->login) == 0)
- this->OnMessageSended(conversation, message);
+ this->OnChatMessageSended(conversation, message);
else
- this->OnMessageReceived(conversation, message);
+ this->OnChatMessageReceived(conversation, message);
}
break;
- case CMessage::POSTED_FILES:
- this->OnFile(conversation, message);
- break;
-
case CMessage::ADDED_CONSUMERS:
{
SEString data;
@@ -520,6 +239,7 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa
this->RemoveChatContact(cid, sid);
}
break;
+
case CMessage::RETIRED_OTHERS:
{
SEString data;
@@ -562,58 +282,79 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa
break;
case CMessage::STARTED_LIVESESSION:
- conversation->LeaveLiveSession();
-
- CConversation::TYPE type;
- conversation->GetPropType(type);
- if (type == CConversation::DIALOG)
{
+ conversation->LeaveLiveSession();
- uint timestamp;
- message->GetPropTimestamp(timestamp);
-
- SEString identity;
- message->GetPropAuthor(identity);
-
- CContact::Ref author;
- g_skype->GetContact(identity, author);
-
- HANDLE hContact = this->AddContact(author);
-
- char *message = ::mir_utf8encode(::Translate("Incoming call"));
-
- this->AddDBEvent(
- hContact,
- SKYPE_DB_EVENT_TYPE_CALL,
- timestamp,
- DBEF_UTF,
- (DWORD)::strlen(message) + 1,
- (PBYTE)message);
- }
- else
- {
SEString data;
conversation->GetPropIdentity(data);
mir_ptr<wchar_t> cid( ::mir_utf8decodeW(data));
HANDLE hContact = this->GetChatRoomByCid(cid);
- this->RaiseChatEvent(cid, this->login, /*GC_EVENT_INFORMATION*/ 0x0100, /*GCEF_ADDTOLOG*/ 0x0001, 0, NULL, ::TranslateT("Group call"));
+
+ this->RaiseChatEvent(
+ cid,
+ this->login,
+ /*GC_EVENT_INFORMATION*/ 0x0100,
+ /*GCEF_ADDTOLOG*/ 0x0001,
+ 0,
+ NULL,
+ ::TranslateT("Group call"));
}
break;
case CMessage::ENDED_LIVESESSION:
- conversation->GetPropType(type);
- if (type != CConversation::DIALOG)
{
SEString data;
conversation->GetPropIdentity(data);
mir_ptr<wchar_t> cid( ::mir_utf8decodeW(data));
HANDLE hContact = this->GetChatRoomByCid(cid);
- this->RaiseChatEvent(cid, this->login, /*GC_EVENT_INFORMATION*/ 0x0100, /*GCEF_ADDTOLOG*/ 0x0001, 0, NULL, ::TranslateT("The call is completed"));
+
+ this->RaiseChatEvent(
+ cid,
+ this->login,
+ /*GC_EVENT_INFORMATION*/ 0x0100,
+ /*GCEF_ADDTOLOG*/ 0x0001,
+ 0,
+ NULL,
+ ::TranslateT("The call is completed"));
+ }
+ break;
+ }
+}
+
+void CSkypeProto::OnSkypeEvent(CConversation::Ref conversation, CMessage::Ref message)
+{
+ CMessage::TYPE messageType;
+ message->GetPropType(messageType);
+
+ switch (messageType)
+ {
+ case CMessage::POSTED_EMOTE:
+ case CMessage::POSTED_TEXT:
+ case CMessage::STARTED_LIVESESSION:
+ case CMessage::ENDED_LIVESESSION:
+ {
+ CConversation::TYPE type;
+ conversation->GetPropType(type);
+ if (type == CConversation::DIALOG)
+ this->OnMessageEvent(conversation, message);
+ else
+ this->OnChatEvent(conversation, message);
}
break;
+ case CMessage::ADDED_CONSUMERS:
+ case CMessage::RETIRED:
+ case CMessage::RETIRED_OTHERS:
+ case CMessage::SPAWNED_CONFERENCE:
+ this->OnChatEvent(conversation, message);
+ break;
+
+ case CMessage::POSTED_FILES:
+ this->OnFile(conversation, message);
+ break;
+
//case CMessage::REQUESTED_AUTH:
// break;