diff options
Diffstat (limited to 'protocols/Skype/src/skype_events.cpp')
-rw-r--r-- | protocols/Skype/src/skype_events.cpp | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/protocols/Skype/src/skype_events.cpp b/protocols/Skype/src/skype_events.cpp index fcacb7117f..ac29ab59e9 100644 --- a/protocols/Skype/src/skype_events.cpp +++ b/protocols/Skype/src/skype_events.cpp @@ -148,6 +148,146 @@ void CSkypeProto::OnMessageReceived(CConversation::Ref conversation, CMessage::R HXML hXml = xi.parseString(xml, &bytesProcessed, NULL);*/
}
+void CSkypeProto::OnTransferChanged(int prop, CTransfer::Ref transfer)
+{
+ if (prop == Transfer::P_STATUS)
+ {
+ Transfer::STATUS status;
+ transfer->GetPropStatus(status);
+
+ /*CConversation::Ref conversation;
+ transfer->GetPropConvoId(conversation);
+
+ SEBinary guid;
+ transfer->GetPropChatmsgGuid(guid);
+ auto ft = this->FindTransfer(guid);*/
+ auto ft = this->FindFileTransfer(transfer);
+
+ SEString sid;
+ transfer->GetPropPartnerHandle(sid);
+ //CParticipant::Refs participants;
+ //conversation->GetParticipants(participants, CConversation::OTHER_CONSUMERS);
+ ////for (uint i = 0; i < participants.size(); i++)
+ //participants[0]->GetPropIdentity(sid);
+
+ HANDLE hContact = this->GetContactBySid(sid);
+
+ switch(status)
+ {
+ /*case CTransfer::NEW:
+ break;*/
+ /*case CTransfer::WAITING_FOR_ACCEPT:
+ break;*/
+ case CTransfer::CONNECTING:
+ this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, (HANDLE)ft, 0);
+ break;
+ case CTransfer::TRANSFERRING:
+ case CTransfer::TRANSFERRING_OVER_RELAY:
+ this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_CONNECTED, (HANDLE)ft, 0);
+ break;
+ case CTransfer::FAILED:
+ this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (HANDLE)ft, 0);
+ break;
+ case CTransfer::COMPLETED:
+ this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, (HANDLE)ft, 0);
+ break;
+ case CTransfer::CANCELLED:
+ case CTransfer::CANCELLED_BY_REMOTE:
+ this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_DENIED, (HANDLE)ft, 0);
+ break;
+ }
+ }
+ if (prop == Transfer::P_BYTESTRANSFERRED)
+ {
+ //PROTOFILETRANSFERSTATUS
+ //this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (HANDLE)ccid, 0);
+ //SEString transferProgressStr;
+ //transfer->GetPropBytestransferred(transferProgressStr);
+ //uint transferProgress = transferProgressStr.toUInt();
+
+ //SEString fileSizeStr;
+ //transfer->GetPropFilesize(fileSizeStr);
+
+ //// fileSize is float here, to avoid trouble with
+ //// files lessthan 100 bytes in size.
+ //float fileSize = (float)fileSizeStr.toUInt();
+ //float progress = (100 * transferProgress) / fileSize;
+
+ //uint transferRate;
+ //transfer->GetPropBytespersecond(transferRate);
+ //float transferRateInKb = (float)transferRate / 1024;
+
+ //PROTOFILETRANSFERSTATUS pfts = {0};
+ //pfts.cbSize = sizeof(pfts);
+ ////pfts.szCurrentFile
+ //pfts.currentFileProgress = progress;
+ //pfts.
+
+ //this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_DATA, (HANDLE)ccid, 0);
+ // printf("Progress: %3.0f%% (%1.0f KB/s)\n", progress, transferRateInKb);
+ }
+}
+
+void CSkypeProto::OnFileReceived(CConversation::Ref conversation, CMessage::Ref message)
+{
+ CTransfer::Refs transferList;
+ message->GetTransfers(transferList);
+ Sid::fetch(transferList);
+
+ Transfer::TYPE transferType;
+ Transfer::STATUS transferStatus;
+
+ for (uint i = 0; i < transferList.size(); i++)
+ {
+ auto transfer = transferList[i];
+ transfer.fetch();
+ transfer->SetOnTransferCallback(
+ (CTransfer::OnTransfer)&CSkypeProto::OnTransferChanged,
+ this);
+ //this->transferList.append(transfer);
+
+ // 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->GetPropType(transferType);
+ transfer->GetPropStatus(transferStatus);
+ if ((transferType == Transfer::INCOMING) && (transferStatus == Transfer::NEW))
+ {
+ //transferList[i]->AutoAccept();
+ SEString name;
+ transfer->GetPropFilename(name);
+
+ wchar_t *path = ::mir_utf8decodeW(name);
+
+ SEString sid;
+ transfer->GetPropPartnerHandle(sid);
+ HANDLE hContact = this->GetContactBySid(sid);
+
+ auto ft = new FileTransfer(this);
+ ft->transfers.append(transfer);
+ transfer->GetPropChatmsgGuid(ft->guid);
+ this->fileTransferList.insert(ft);
+
+ PROTORECVFILET pre = {0};
+ pre.flags = PREF_TCHAR;
+ pre.fileCount = 1;
+ pre.timestamp = time(NULL);
+ pre.tszDescription = L" ";
+ pre.ptszFiles = &path;
+ pre.lParam = (LPARAM)ft;
+ ::ProtoChainRecvFile(hContact, &pre);
+
+ ::mir_free(path);
+ }
+ }
+
+ //SEString bodyXml;
+ //message->GetPropBodyXml(bodyXml);
+ //printf("File transfer msg BodyXML:\n%s\n", (const char*)bodyXml);
+}
+
void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref message)
{
CMessage::TYPE messageType;
@@ -156,6 +296,12 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa CMessage::SENDING_STATUS sendingStatus;
message->GetPropSendingStatus(sendingStatus);
+ if (messageType == CMessage::POSTED_FILES)
+ {
+ this->OnFileReceived(conversation, message);
+ return;
+ }
+
CMessage::CONSUMPTION_STATUS status;
message->GetPropConsumptionStatus(status);
@@ -179,6 +325,9 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa }
break;
+ case CMessage::POSTED_FILES:
+ break;
+
case CMessage::ADDED_CONSUMERS:
{
SEString data;
|