void FileTransferController::accept(std::string& file) {
	SWIFT_LOG(debug) << "FileTransferController::accept" << std::endl;
	IncomingFileTransfer::ref incomingTransfer = boost::dynamic_pointer_cast<IncomingFileTransfer>(transfer);
	if (incomingTransfer) {
		fileWriteStream = boost::make_shared<FileWriteBytestream>(boost::filesystem::path(file));

		ftProgressInfo = new FileTransferProgressInfo(transfer->getFileSizeInBytes());
		ftProgressInfo->onProgressPercentage.connect(boost::bind(&FileTransferController::handleProgressPercentageChange, this, _1));
		transfer->onProcessedBytes.connect(boost::bind(&FileTransferProgressInfo::setBytesProcessed, ftProgressInfo, _1));
		incomingTransfer->accept(fileWriteStream);
	} else {
		std::cerr << "Expected an incoming transfer in this situation!" << std::endl;
	}
}
Exemplo n.º 2
0
		void handleReceiverIncomingFileTransfer(IncomingFileTransfer::ref transfer) {
			incomingFileTransfers_.push_back(transfer);
			boost::shared_ptr<FileWriteBytestream> out = boost::make_shared<FileWriteBytestream>(receiveFilePath_.native());
			transfer->onFinished.connect(boost::bind(&FileTransferTest::handleReceiverFileTransferFinished, this, _1, out));

			FileTransferOptions options;
			options = options.withInBandAllowed(receiverCandidates_ & InBandBytestream);
			options = options.withDirectAllowed(receiverCandidates_ & S5B_Direct);
			options = options.withAssistedAllowed(receiverCandidates_ & S5B_Assisted);
			options = options.withProxiedAllowed(receiverCandidates_ & S5B_Proxied);

			std::cout << "Incoming transfer options: " << "IBB (" << options.isInBandAllowed() << ")" << ", ";
			std::cout << "S5B Direct (" << options.isDirectAllowed() << ")" << ", ";
			std::cout << "S5B Assisted (" << options.isAssistedAllowed() << ")" << ", ";
			std::cout << "S5B Proxied (" << options.isProxiedAllowed() << ")" << std::endl;

			transfer->accept(out, options);
		}