diff options
| -rw-r--r-- | Swift/Controllers/FileTransfer/FileTransferController.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/Swift/Controllers/FileTransfer/FileTransferController.cpp b/Swift/Controllers/FileTransfer/FileTransferController.cpp index 0160a7a..076d3c0 100644 --- a/Swift/Controllers/FileTransfer/FileTransferController.cpp +++ b/Swift/Controllers/FileTransfer/FileTransferController.cpp | |||
| @@ -2,37 +2,46 @@ | |||
| 2 | * Copyright (c) 2011 Tobias Markmann | 2 | * Copyright (c) 2011 Tobias Markmann |
| 3 | * Licensed under the simplified BSD license. | 3 | * Licensed under the simplified BSD license. |
| 4 | * See Documentation/Licenses/BSD-simplified.txt for more information. | 4 | * See Documentation/Licenses/BSD-simplified.txt for more information. |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #include "FileTransferController.h" | 7 | /* |
| 8 | #include "Swiften/FileTransfer/OutgoingJingleFileTransfer.h" | 8 | * Copyright (c) 2015 Isode Limited. |
| 9 | #include "Swiften/FileTransfer/FileTransferManager.h" | 9 | * All rights reserved. |
| 10 | #include <Swiften/FileTransfer/FileReadBytestream.h> | 10 | * See the COPYING file for more information. |
| 11 | #include <Swiften/Base/boost_bsignals.h> | 11 | */ |
| 12 | |||
| 13 | #include <Swift/Controllers/FileTransfer/FileTransferController.h> | ||
| 14 | |||
| 12 | #include <boost/bind.hpp> | 15 | #include <boost/bind.hpp> |
| 13 | #include <boost/filesystem.hpp> | 16 | #include <boost/filesystem.hpp> |
| 14 | #include "Swift/Controllers/UIInterfaces/ChatWindow.h" | 17 | #include <boost/smart_ptr/make_shared.hpp> |
| 18 | |||
| 19 | #include <Swiften/FileTransfer/FileTransferManager.h> | ||
| 20 | #include <Swiften/FileTransfer/OutgoingJingleFileTransfer.h> | ||
| 15 | #include <Swiften/Base/Log.h> | 21 | #include <Swiften/Base/Log.h> |
| 16 | #include <Swift/Controllers/Intl.h> | 22 | #include <Swiften/Base/boost_bsignals.h> |
| 23 | #include <Swiften/FileTransfer/FileReadBytestream.h> | ||
| 17 | 24 | ||
| 18 | #include <boost/smart_ptr/make_shared.hpp> | 25 | #include <Swift/Controllers/UIInterfaces/ChatWindow.h> |
| 26 | #include <Swift/Controllers/Intl.h> | ||
| 19 | 27 | ||
| 20 | namespace Swift { | 28 | namespace Swift { |
| 21 | 29 | ||
| 22 | FileTransferController::FileTransferController(const JID& receipient, const std::string& filename, FileTransferManager* fileTransferManager) : | 30 | FileTransferController::FileTransferController(const JID& receipient, const std::string& filename, FileTransferManager* fileTransferManager) : |
| 23 | sending(true), otherParty(receipient), filename(filename), ftManager(fileTransferManager), ftProgressInfo(0), chatWindow(0), currentState(FileTransfer::State::WaitingForStart) { | 31 | sending(true), otherParty(receipient), filename(filename), ftManager(fileTransferManager), ftProgressInfo(0), chatWindow(0), currentState(FileTransfer::State::WaitingForStart) { |
| 24 | 32 | ||
| 25 | } | 33 | } |
| 26 | 34 | ||
| 27 | FileTransferController::FileTransferController(IncomingFileTransfer::ref transfer) : | 35 | FileTransferController::FileTransferController(IncomingFileTransfer::ref transfer) : |
| 28 | sending(false), otherParty(transfer->getSender()), filename(transfer->getFileName()), transfer(transfer), ftManager(0), ftProgressInfo(0), chatWindow(0), currentState(FileTransfer::State::WaitingForStart) { | 36 | sending(false), otherParty(transfer->getSender()), filename(transfer->getFileName()), transfer(transfer), ftManager(0), ftProgressInfo(0), chatWindow(0), currentState(FileTransfer::State::WaitingForStart) { |
| 29 | 37 | transfer->onStateChanged.connect(boost::bind(&FileTransferController::handleFileTransferStateChange, this, _1)); | |
| 30 | } | 38 | } |
| 31 | 39 | ||
| 32 | FileTransferController::~FileTransferController() { | 40 | FileTransferController::~FileTransferController() { |
| 33 | delete ftProgressInfo; | 41 | delete ftProgressInfo; |
| 42 | transfer->onStateChanged.disconnect(boost::bind(&FileTransferController::handleFileTransferStateChange, this, _1)); | ||
| 34 | } | 43 | } |
| 35 | 44 | ||
| 36 | const JID &FileTransferController::getOtherParty() const { | 45 | const JID &FileTransferController::getOtherParty() const { |
| 37 | return otherParty; | 46 | return otherParty; |
| 38 | } | 47 | } |
| @@ -93,11 +102,10 @@ void FileTransferController::accept(std::string& file) { | |||
| 93 | if (incomingTransfer) { | 102 | if (incomingTransfer) { |
| 94 | fileWriteStream = boost::make_shared<FileWriteBytestream>(boost::filesystem::path(file)); | 103 | fileWriteStream = boost::make_shared<FileWriteBytestream>(boost::filesystem::path(file)); |
| 95 | 104 | ||
| 96 | ftProgressInfo = new FileTransferProgressInfo(transfer->getFileSizeInBytes()); | 105 | ftProgressInfo = new FileTransferProgressInfo(transfer->getFileSizeInBytes()); |
| 97 | ftProgressInfo->onProgressPercentage.connect(boost::bind(&FileTransferController::handleProgressPercentageChange, this, _1)); | 106 | ftProgressInfo->onProgressPercentage.connect(boost::bind(&FileTransferController::handleProgressPercentageChange, this, _1)); |
| 98 | transfer->onStateChanged.connect(boost::bind(&FileTransferController::handleFileTransferStateChange, this, _1)); | ||
| 99 | transfer->onProcessedBytes.connect(boost::bind(&FileTransferProgressInfo::setBytesProcessed, ftProgressInfo, _1)); | 107 | transfer->onProcessedBytes.connect(boost::bind(&FileTransferProgressInfo::setBytesProcessed, ftProgressInfo, _1)); |
| 100 | incomingTransfer->accept(fileWriteStream); | 108 | incomingTransfer->accept(fileWriteStream); |
| 101 | } else { | 109 | } else { |
| 102 | std::cerr << "Expected an incoming transfer in this situation!" << std::endl; | 110 | std::cerr << "Expected an incoming transfer in this situation!" << std::endl; |
| 103 | } | 111 | } |
Swift