diff options
Diffstat (limited to 'Swift/Controllers/FileTransfer')
-rw-r--r-- | Swift/Controllers/FileTransfer/FileTransferController.cpp | 22 | ||||
-rw-r--r-- | Swift/Controllers/FileTransfer/FileTransferProgressInfo.cpp | 4 |
2 files changed, 16 insertions, 10 deletions
diff --git a/Swift/Controllers/FileTransfer/FileTransferController.cpp b/Swift/Controllers/FileTransfer/FileTransferController.cpp index 3feaf49..0160a7a 100644 --- a/Swift/Controllers/FileTransfer/FileTransferController.cpp +++ b/Swift/Controllers/FileTransfer/FileTransferController.cpp @@ -11,4 +11,5 @@ #include <Swiften/Base/boost_bsignals.h> #include <boost/bind.hpp> +#include <boost/filesystem.hpp> #include "Swift/Controllers/UIInterfaces/ChatWindow.h" #include <Swiften/Base/Log.h> @@ -25,5 +26,5 @@ FileTransferController::FileTransferController(const JID& receipient, const std: FileTransferController::FileTransferController(IncomingFileTransfer::ref transfer) : - sending(false), otherParty(transfer->getSender()), filename(transfer->filename), transfer(transfer), ftManager(0), ftProgressInfo(0), chatWindow(0), currentState(FileTransfer::State::WaitingForStart) { + sending(false), otherParty(transfer->getSender()), filename(transfer->getFileName()), transfer(transfer), ftManager(0), ftProgressInfo(0), chatWindow(0), currentState(FileTransfer::State::WaitingForStart) { } @@ -42,5 +43,5 @@ std::string FileTransferController::setChatWindow(ChatWindow* wnd, std::string n uiID = wnd->addFileTransfer(QT_TRANSLATE_NOOP("", "me"), true, filename, boost::filesystem::file_size(boost::filesystem::path(filename))); } else { - uiID = wnd->addFileTransfer(nickname, false, filename, transfer->fileSizeInBytes); + uiID = wnd->addFileTransfer(nickname, false, filename, transfer->getFileSizeInBytes()); } return uiID; @@ -65,5 +66,5 @@ int FileTransferController::getProgress() const { boost::uintmax_t FileTransferController::getSize() const { if (transfer) { - return transfer->fileSizeInBytes; + return transfer->getFileSizeInBytes(); } else { return 0; @@ -76,7 +77,7 @@ void FileTransferController::start(std::string& description) { OutgoingFileTransfer::ref outgoingTransfer = ftManager->createOutgoingFileTransfer(otherParty, boost::filesystem::path(filename), description, fileReadStream); if (outgoingTransfer) { - ftProgressInfo = new FileTransferProgressInfo(outgoingTransfer->fileSizeInBytes); + ftProgressInfo = new FileTransferProgressInfo(outgoingTransfer->getFileSizeInBytes()); ftProgressInfo->onProgressPercentage.connect(boost::bind(&FileTransferController::handleProgressPercentageChange, this, _1)); - outgoingTransfer->onStateChange.connect(boost::bind(&FileTransferController::handleFileTransferStateChange, this, _1)); + outgoingTransfer->onStateChanged.connect(boost::bind(&FileTransferController::handleFileTransferStateChange, this, _1)); outgoingTransfer->onProcessedBytes.connect(boost::bind(&FileTransferProgressInfo::setBytesProcessed, ftProgressInfo, _1)); outgoingTransfer->start(); @@ -93,7 +94,7 @@ void FileTransferController::accept(std::string& file) { fileWriteStream = boost::make_shared<FileWriteBytestream>(boost::filesystem::path(file)); - ftProgressInfo = new FileTransferProgressInfo(transfer->fileSizeInBytes); + ftProgressInfo = new FileTransferProgressInfo(transfer->getFileSizeInBytes()); ftProgressInfo->onProgressPercentage.connect(boost::bind(&FileTransferController::handleProgressPercentageChange, this, _1)); - transfer->onStateChange.connect(boost::bind(&FileTransferController::handleFileTransferStateChange, this, _1)); + transfer->onStateChanged.connect(boost::bind(&FileTransferController::handleFileTransferStateChange, this, _1)); transfer->onProcessedBytes.connect(boost::bind(&FileTransferProgressInfo::setBytesProcessed, ftProgressInfo, _1)); incomingTransfer->accept(fileWriteStream); @@ -114,5 +115,8 @@ void FileTransferController::handleFileTransferStateChange(FileTransfer::State s currentState = state; onStateChage(); - switch(state.state) { + switch(state.type) { + case FileTransfer::State::Initial: + assert(false); + return; case FileTransfer::State::Negotiating: chatWindow->setFileTransferStatus(uiID, ChatWindow::Negotiating); @@ -139,5 +143,5 @@ void FileTransferController::handleFileTransferStateChange(FileTransfer::State s return; } - std::cerr << "Unhandled FileTransfer::State!" << std::endl; + assert(false); } diff --git a/Swift/Controllers/FileTransfer/FileTransferProgressInfo.cpp b/Swift/Controllers/FileTransfer/FileTransferProgressInfo.cpp index 6d19fa1..3081f71 100644 --- a/Swift/Controllers/FileTransfer/FileTransferProgressInfo.cpp +++ b/Swift/Controllers/FileTransfer/FileTransferProgressInfo.cpp @@ -7,4 +7,6 @@ #include "FileTransferProgressInfo.h" +#include <boost/numeric/conversion/cast.hpp> + #include <Swiften/Base/Log.h> @@ -17,5 +19,5 @@ FileTransferProgressInfo::FileTransferProgressInfo(boost::uintmax_t completeByte void FileTransferProgressInfo::setBytesProcessed(int processedBytes) { int oldPercentage = int(double(completedBytes) / double(completeBytes) * 100.0); - completedBytes += processedBytes; + completedBytes += boost::numeric_cast<boost::uintmax_t>(processedBytes); int newPercentage = int(double(completedBytes) / double(completeBytes) * 100.0); if (oldPercentage != newPercentage) { |