Ejemplo n.º 1
0
void GaduFileTransferService::fileTransferReceived(Contact peer, QString downloadId, QString fileName)
{
	auto transfer = FileTransfer::create();
	transfer.setPeer(peer);
	transfer.setTransferDirection(FileTransferDirection::Incoming);
	transfer.setTransferType(FileTransferType::Url);
	transfer.setTransferStatus(FileTransferStatus::ReadyToDownload);
	transfer.setRemoteFileName(QUrl::fromPercentEncoding(fileName.toUtf8()));
	transfer.setFileSize(0); // we don't know file size yet
	transfer.addProperty("gg:downloadId", downloadId, CustomProperties::Storable);
	transfer.addProperty("gg:remoteFileName", fileName, CustomProperties::Storable);

	emit incomingFileTransfer(transfer);
}
Ejemplo n.º 2
0
void JabberFileTransferService::fileReceived(QXmppTransferJob *transferJob)
{
    auto jid = Jid::parse(transferJob->jid());
    auto peer = m_contactManager->byId(m_account, jid.bare(), ActionCreateAndAdd);

    auto transfer = m_fileTransferStorage->create();
    transfer.setPeer(peer);
    transfer.setTransferDirection(FileTransferDirection::Incoming);
    transfer.setTransferType(FileTransferType::Stream);
    transfer.setTransferStatus(FileTransferStatus::WaitingForAccept);
    transfer.setRemoteFileName(transferJob->fileName());
    transfer.setFileSize(transferJob->fileSize());

    if (!m_fileTransferHandlerManager->ensureHandler(transfer))
        return;

    auto handler = qobject_cast<JabberStreamIncomingFileTransferHandler *>(transfer.handler());
    if (handler)
        handler->setTransferJob(transferJob);

    emit incomingFileTransfer(transfer);
}