diff options
author | Tobias Markmann <tm@ayena.de> | 2016-03-31 14:57:35 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2016-03-31 14:57:35 (GMT) |
commit | cfbdb43d2cadd40aa87338d41548e4bf89e146e6 (patch) | |
tree | 18d94153a302445196fc0c18586abf44a1ce4a38 /Swift/Controllers/FileTransfer | |
parent | 1d545a4a7fb877f021508094b88c1f17b30d8b4e (diff) | |
download | swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.zip swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.tar.bz2 |
Convert tabs to 4 spaces for all source files
Removed trailing spaces and whitespace on empty lines
in the process.
Changed CheckTabs.py tool to disallow hard tabs in source
files.
Test-Information:
Manually checked 30 random files that the conversion worked
as expected.
Change-Id: I874f99d617bd3d2bb55f02d58f22f58f9b094480
Diffstat (limited to 'Swift/Controllers/FileTransfer')
6 files changed, 191 insertions, 191 deletions
diff --git a/Swift/Controllers/FileTransfer/FileTransferController.cpp b/Swift/Controllers/FileTransfer/FileTransferController.cpp index 89e9a91..fd13d99 100644 --- a/Swift/Controllers/FileTransfer/FileTransferController.cpp +++ b/Swift/Controllers/FileTransfer/FileTransferController.cpp @@ -28,135 +28,135 @@ namespace Swift { FileTransferController::FileTransferController(const JID& receipient, const std::string& filename, FileTransferManager* fileTransferManager) : - sending(true), otherParty(receipient), filename(filename), ftManager(fileTransferManager), ftProgressInfo(0), chatWindow(0), currentState(FileTransfer::State::WaitingForStart) { - + sending(true), otherParty(receipient), filename(filename), ftManager(fileTransferManager), ftProgressInfo(0), chatWindow(0), currentState(FileTransfer::State::WaitingForStart) { + } FileTransferController::FileTransferController(IncomingFileTransfer::ref transfer) : - sending(false), otherParty(transfer->getSender()), filename(transfer->getFileName()), transfer(transfer), ftManager(0), ftProgressInfo(0), chatWindow(0), currentState(FileTransfer::State::WaitingForStart) { - transfer->onStateChanged.connect(boost::bind(&FileTransferController::handleFileTransferStateChange, this, _1)); + sending(false), otherParty(transfer->getSender()), filename(transfer->getFileName()), transfer(transfer), ftManager(0), ftProgressInfo(0), chatWindow(0), currentState(FileTransfer::State::WaitingForStart) { + transfer->onStateChanged.connect(boost::bind(&FileTransferController::handleFileTransferStateChange, this, _1)); } FileTransferController::~FileTransferController() { - delete ftProgressInfo; - transfer->onStateChanged.disconnect(boost::bind(&FileTransferController::handleFileTransferStateChange, this, _1)); + delete ftProgressInfo; + transfer->onStateChanged.disconnect(boost::bind(&FileTransferController::handleFileTransferStateChange, this, _1)); } const JID &FileTransferController::getOtherParty() const { - return otherParty; + return otherParty; } std::string FileTransferController::setChatWindow(ChatWindow* wnd, std::string nickname) { - chatWindow = wnd; - if (sending) { - 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->getFileSizeInBytes(), transfer->getDescription()); - } - return uiID; + chatWindow = wnd; + if (sending) { + 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->getFileSizeInBytes(), transfer->getDescription()); + } + return uiID; } void FileTransferController::setReceipient(const JID& receipient) { - this->otherParty = receipient; + this->otherParty = receipient; } bool FileTransferController::isIncoming() const { - return !sending; + return !sending; } FileTransfer::State FileTransferController::getState() const { - return currentState; + return currentState; } int FileTransferController::getProgress() const { - return ftProgressInfo ? ftProgressInfo->getPercentage() : 0; + return ftProgressInfo ? ftProgressInfo->getPercentage() : 0; } boost::uintmax_t FileTransferController::getSize() const { - if (transfer) { - return transfer->getFileSizeInBytes(); - } else { - return 0; - } + if (transfer) { + return transfer->getFileSizeInBytes(); + } else { + return 0; + } } void FileTransferController::start(std::string& description) { - SWIFT_LOG(debug) << "FileTransferController::start" << std::endl; - fileReadStream = boost::make_shared<FileReadBytestream>(boost::filesystem::path(filename)); - OutgoingFileTransfer::ref outgoingTransfer = ftManager->createOutgoingFileTransfer(otherParty, boost::filesystem::path(filename), description, fileReadStream); - if (outgoingTransfer) { - ftProgressInfo = new FileTransferProgressInfo(outgoingTransfer->getFileSizeInBytes()); - ftProgressInfo->onProgressPercentage.connect(boost::bind(&FileTransferController::handleProgressPercentageChange, this, _1)); - outgoingTransfer->onStateChanged.connect(boost::bind(&FileTransferController::handleFileTransferStateChange, this, _1)); - outgoingTransfer->onProcessedBytes.connect(boost::bind(&FileTransferProgressInfo::setBytesProcessed, ftProgressInfo, _1)); - outgoingTransfer->start(); - transfer = outgoingTransfer; - } else { - std::cerr << "File transfer not supported!" << std::endl; - } + SWIFT_LOG(debug) << "FileTransferController::start" << std::endl; + fileReadStream = boost::make_shared<FileReadBytestream>(boost::filesystem::path(filename)); + OutgoingFileTransfer::ref outgoingTransfer = ftManager->createOutgoingFileTransfer(otherParty, boost::filesystem::path(filename), description, fileReadStream); + if (outgoingTransfer) { + ftProgressInfo = new FileTransferProgressInfo(outgoingTransfer->getFileSizeInBytes()); + ftProgressInfo->onProgressPercentage.connect(boost::bind(&FileTransferController::handleProgressPercentageChange, this, _1)); + outgoingTransfer->onStateChanged.connect(boost::bind(&FileTransferController::handleFileTransferStateChange, this, _1)); + outgoingTransfer->onProcessedBytes.connect(boost::bind(&FileTransferProgressInfo::setBytesProcessed, ftProgressInfo, _1)); + outgoingTransfer->start(); + transfer = outgoingTransfer; + } else { + std::cerr << "File transfer not supported!" << std::endl; + } } 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)); + 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; - } + 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; + } } void FileTransferController::cancel() { - if (transfer) { - transfer->cancel(); - } else { - chatWindow->setFileTransferStatus(uiID, ChatWindow::Canceled); - } + if (transfer) { + transfer->cancel(); + } else { + chatWindow->setFileTransferStatus(uiID, ChatWindow::Canceled); + } } void FileTransferController::handleFileTransferStateChange(FileTransfer::State state) { - currentState = state; - onStateChanged(); - switch(state.type) { - case FileTransfer::State::Initial: - assert(false); - return; - case FileTransfer::State::Negotiating: - chatWindow->setFileTransferStatus(uiID, ChatWindow::Negotiating); - return; - case FileTransfer::State::Transferring: - chatWindow->setFileTransferStatus(uiID, ChatWindow::Transferring); - return; - case FileTransfer::State::Canceled: - chatWindow->setFileTransferStatus(uiID, ChatWindow::Canceled); - return; - case FileTransfer::State::Finished: - chatWindow->setFileTransferStatus(uiID, ChatWindow::Finished); - if (fileWriteStream) { - fileWriteStream->close(); - } - return; - case FileTransfer::State::Failed: - chatWindow->setFileTransferStatus(uiID, ChatWindow::FTFailed); - return; - case FileTransfer::State::WaitingForAccept: - chatWindow->setFileTransferStatus(uiID, ChatWindow::WaitingForAccept); - return; - case FileTransfer::State::WaitingForStart: - chatWindow->setFileTransferStatus(uiID, ChatWindow::Initialisation); - return; - } - assert(false); + currentState = state; + onStateChanged(); + switch(state.type) { + case FileTransfer::State::Initial: + assert(false); + return; + case FileTransfer::State::Negotiating: + chatWindow->setFileTransferStatus(uiID, ChatWindow::Negotiating); + return; + case FileTransfer::State::Transferring: + chatWindow->setFileTransferStatus(uiID, ChatWindow::Transferring); + return; + case FileTransfer::State::Canceled: + chatWindow->setFileTransferStatus(uiID, ChatWindow::Canceled); + return; + case FileTransfer::State::Finished: + chatWindow->setFileTransferStatus(uiID, ChatWindow::Finished); + if (fileWriteStream) { + fileWriteStream->close(); + } + return; + case FileTransfer::State::Failed: + chatWindow->setFileTransferStatus(uiID, ChatWindow::FTFailed); + return; + case FileTransfer::State::WaitingForAccept: + chatWindow->setFileTransferStatus(uiID, ChatWindow::WaitingForAccept); + return; + case FileTransfer::State::WaitingForStart: + chatWindow->setFileTransferStatus(uiID, ChatWindow::Initialisation); + return; + } + assert(false); } void FileTransferController::handleProgressPercentageChange(int percentage) { - onProgressChange(); - chatWindow->setFileTransferProgress(uiID, percentage); + onProgressChange(); + chatWindow->setFileTransferProgress(uiID, percentage); } } diff --git a/Swift/Controllers/FileTransfer/FileTransferController.h b/Swift/Controllers/FileTransfer/FileTransferController.h index 490773d..a25abee 100644 --- a/Swift/Controllers/FileTransfer/FileTransferController.h +++ b/Swift/Controllers/FileTransfer/FileTransferController.h @@ -32,49 +32,49 @@ class ChatWindow; class FileTransferController { public: - /** - * For outgoing file transfers. It'll create a file transfer via FileTransferManager as soon as the descriptive information is available. - */ - FileTransferController(const JID&, const std::string&, FileTransferManager*); + /** + * For outgoing file transfers. It'll create a file transfer via FileTransferManager as soon as the descriptive information is available. + */ + FileTransferController(const JID&, const std::string&, FileTransferManager*); - /** - * For incoming file transfers. - */ - FileTransferController(IncomingFileTransfer::ref transfer); - ~FileTransferController(); + /** + * For incoming file transfers. + */ + FileTransferController(IncomingFileTransfer::ref transfer); + ~FileTransferController(); - std::string setChatWindow(ChatWindow*, std::string nickname); - void setReceipient(const JID& otherParty); + std::string setChatWindow(ChatWindow*, std::string nickname); + void setReceipient(const JID& otherParty); - void start(std::string& description); - void accept(std::string& file); - void cancel(); + void start(std::string& description); + void accept(std::string& file); + void cancel(); - const JID &getOtherParty() const; - bool isIncoming() const; - FileTransfer::State getState() const; - int getProgress() const; - boost::uintmax_t getSize() const; + const JID &getOtherParty() const; + bool isIncoming() const; + FileTransfer::State getState() const; + int getProgress() const; + boost::uintmax_t getSize() const; - boost::signal<void ()> onStateChanged; - boost::signal<void ()> onProgressChange; + boost::signal<void ()> onStateChanged; + boost::signal<void ()> onProgressChange; private: - void handleFileTransferStateChange(FileTransfer::State); - void handleProgressPercentageChange(int percentage); + void handleFileTransferStateChange(FileTransfer::State); + void handleProgressPercentageChange(int percentage); private: - bool sending; - JID otherParty; - std::string filename; - FileTransfer::ref transfer; - boost::shared_ptr<FileReadBytestream> fileReadStream; - boost::shared_ptr<FileWriteBytestream> fileWriteStream; - FileTransferManager* ftManager; - FileTransferProgressInfo* ftProgressInfo; - ChatWindow* chatWindow; - std::string uiID; - FileTransfer::State currentState; + bool sending; + JID otherParty; + std::string filename; + FileTransfer::ref transfer; + boost::shared_ptr<FileReadBytestream> fileReadStream; + boost::shared_ptr<FileWriteBytestream> fileWriteStream; + FileTransferManager* ftManager; + FileTransferProgressInfo* ftProgressInfo; + ChatWindow* chatWindow; + std::string uiID; + FileTransfer::State currentState; }; } diff --git a/Swift/Controllers/FileTransfer/FileTransferOverview.cpp b/Swift/Controllers/FileTransfer/FileTransferOverview.cpp index 8616c1e..a53b000 100644 --- a/Swift/Controllers/FileTransfer/FileTransferOverview.cpp +++ b/Swift/Controllers/FileTransfer/FileTransferOverview.cpp @@ -23,70 +23,70 @@ namespace Swift { FileTransferOverview::FileTransferOverview(FileTransferManager* ftm) : fileTransferManager(ftm) { - fileTransferManager->onIncomingFileTransfer.connect(boost::bind(&FileTransferOverview::handleIncomingFileTransfer, this, _1)); - onNewFileTransferController.connect(boost::bind(&FileTransferOverview::handleNewFileTransferController, this, _1)); + fileTransferManager->onIncomingFileTransfer.connect(boost::bind(&FileTransferOverview::handleIncomingFileTransfer, this, _1)); + onNewFileTransferController.connect(boost::bind(&FileTransferOverview::handleNewFileTransferController, this, _1)); } FileTransferOverview::~FileTransferOverview() { - onNewFileTransferController.disconnect(boost::bind(&FileTransferOverview::handleNewFileTransferController, this, _1)); - fileTransferManager->onIncomingFileTransfer.disconnect(boost::bind(&FileTransferOverview::handleIncomingFileTransfer, this, _1)); - foreach(FileTransferController* controller, fileTransfers) { - controller->onStateChanged.disconnect(boost::bind(&FileTransferOverview::handleFileTransferStateChanged, this)); - } + onNewFileTransferController.disconnect(boost::bind(&FileTransferOverview::handleNewFileTransferController, this, _1)); + fileTransferManager->onIncomingFileTransfer.disconnect(boost::bind(&FileTransferOverview::handleIncomingFileTransfer, this, _1)); + foreach(FileTransferController* controller, fileTransfers) { + controller->onStateChanged.disconnect(boost::bind(&FileTransferOverview::handleFileTransferStateChanged, this)); + } } - + void FileTransferOverview::sendFile(const JID& jid, const std::string& filename) { - if (boost::filesystem::exists(filename) && boost::filesystem::file_size(filename) > 0) { - FileTransferController* controller = new FileTransferController(jid, filename, fileTransferManager); - onNewFileTransferController(controller); - } + if (boost::filesystem::exists(filename) && boost::filesystem::file_size(filename) > 0) { + FileTransferController* controller = new FileTransferController(jid, filename, fileTransferManager); + onNewFileTransferController(controller); + } } void FileTransferOverview::handleIncomingFileTransfer(IncomingFileTransfer::ref transfer) { - FileTransferController* controller = new FileTransferController(transfer); - onNewFileTransferController(controller); + FileTransferController* controller = new FileTransferController(transfer); + onNewFileTransferController(controller); } void FileTransferOverview::handleNewFileTransferController(FileTransferController* controller) { - fileTransfers.push_back(controller); - controller->onStateChanged.connect(boost::bind(&FileTransferOverview::handleFileTransferStateChanged, this)); + fileTransfers.push_back(controller); + controller->onStateChanged.connect(boost::bind(&FileTransferOverview::handleFileTransferStateChanged, this)); } void FileTransferOverview::handleFileTransferStateChanged() { - onFileTransferListChanged(); + onFileTransferListChanged(); } const std::vector<FileTransferController*>& FileTransferOverview::getFileTransfers() const { - return fileTransfers; + return fileTransfers; } void FileTransferOverview::clearFinished() { - for (std::vector<FileTransferController*>::iterator it = fileTransfers.begin(); it != fileTransfers.end(); ) { - if((*it)->getState().type == FileTransfer::State::Finished - || (*it)->getState().type == FileTransfer::State::Failed - || (*it)->getState().type == FileTransfer::State::Canceled) { - FileTransferController* controller = *it; - it = fileTransfers.erase(it); - controller->onStateChanged.disconnect(boost::bind(&FileTransferOverview::handleFileTransferStateChanged, this)); - delete controller; - } else { - ++it; - } - } - onFileTransferListChanged(); + for (std::vector<FileTransferController*>::iterator it = fileTransfers.begin(); it != fileTransfers.end(); ) { + if((*it)->getState().type == FileTransfer::State::Finished + || (*it)->getState().type == FileTransfer::State::Failed + || (*it)->getState().type == FileTransfer::State::Canceled) { + FileTransferController* controller = *it; + it = fileTransfers.erase(it); + controller->onStateChanged.disconnect(boost::bind(&FileTransferOverview::handleFileTransferStateChanged, this)); + delete controller; + } else { + ++it; + } + } + onFileTransferListChanged(); } bool FileTransferOverview::isClearable() const { - bool isClearable = false; - foreach (FileTransferController* controller, fileTransfers) { - if(controller->getState().type == FileTransfer::State::Finished - || controller->getState().type == FileTransfer::State::Failed - || controller->getState().type == FileTransfer::State::Canceled) { - isClearable = true; - break; - } - } - return isClearable; + bool isClearable = false; + foreach (FileTransferController* controller, fileTransfers) { + if(controller->getState().type == FileTransfer::State::Finished + || controller->getState().type == FileTransfer::State::Failed + || controller->getState().type == FileTransfer::State::Canceled) { + isClearable = true; + break; + } + } + return isClearable; } } diff --git a/Swift/Controllers/FileTransfer/FileTransferOverview.h b/Swift/Controllers/FileTransfer/FileTransferOverview.h index e3cbf81..a55727c 100644 --- a/Swift/Controllers/FileTransfer/FileTransferOverview.h +++ b/Swift/Controllers/FileTransfer/FileTransferOverview.h @@ -25,25 +25,25 @@ class FileTransferManager; class FileTransferOverview { public: - FileTransferOverview(FileTransferManager*); - ~FileTransferOverview(); - - void sendFile(const JID&, const std::string&); - const std::vector<FileTransferController*>& getFileTransfers() const; - void clearFinished(); - bool isClearable() const; + FileTransferOverview(FileTransferManager*); + ~FileTransferOverview(); - boost::signal<void (FileTransferController*)> onNewFileTransferController; - boost::signal<void ()> onFileTransferListChanged; + void sendFile(const JID&, const std::string&); + const std::vector<FileTransferController*>& getFileTransfers() const; + void clearFinished(); + bool isClearable() const; + + boost::signal<void (FileTransferController*)> onNewFileTransferController; + boost::signal<void ()> onFileTransferListChanged; private: - void handleIncomingFileTransfer(IncomingFileTransfer::ref transfer); - void handleNewFileTransferController(FileTransferController* controller); - void handleFileTransferStateChanged(); + void handleIncomingFileTransfer(IncomingFileTransfer::ref transfer); + void handleNewFileTransferController(FileTransferController* controller); + void handleFileTransferStateChanged(); private: - std::vector<FileTransferController*> fileTransfers; - FileTransferManager *fileTransferManager; + std::vector<FileTransferController*> fileTransfers; + FileTransferManager *fileTransferManager; }; } diff --git a/Swift/Controllers/FileTransfer/FileTransferProgressInfo.cpp b/Swift/Controllers/FileTransfer/FileTransferProgressInfo.cpp index a2fff03..b073017 100644 --- a/Swift/Controllers/FileTransfer/FileTransferProgressInfo.cpp +++ b/Swift/Controllers/FileTransfer/FileTransferProgressInfo.cpp @@ -19,21 +19,21 @@ namespace Swift { FileTransferProgressInfo::FileTransferProgressInfo(boost::uintmax_t completeBytes) : completeBytes(completeBytes), completedBytes(0), percentage(0) { - onProgressPercentage(0); + onProgressPercentage(0); } void FileTransferProgressInfo::setBytesProcessed(int processedBytes) { - int oldPercentage = int(double(completedBytes) / double(completeBytes) * 100.0); - completedBytes += boost::numeric_cast<boost::uintmax_t>(processedBytes); - int newPercentage = int(double(completedBytes) / double(completeBytes) * 100.0); - if (oldPercentage != newPercentage) { - onProgressPercentage(newPercentage); - } - percentage = newPercentage; + int oldPercentage = int(double(completedBytes) / double(completeBytes) * 100.0); + completedBytes += boost::numeric_cast<boost::uintmax_t>(processedBytes); + int newPercentage = int(double(completedBytes) / double(completeBytes) * 100.0); + if (oldPercentage != newPercentage) { + onProgressPercentage(newPercentage); + } + percentage = newPercentage; } int FileTransferProgressInfo::getPercentage() const { - return percentage; + return percentage; } } diff --git a/Swift/Controllers/FileTransfer/FileTransferProgressInfo.h b/Swift/Controllers/FileTransfer/FileTransferProgressInfo.h index ea88657..783874a 100644 --- a/Swift/Controllers/FileTransfer/FileTransferProgressInfo.h +++ b/Swift/Controllers/FileTransfer/FileTransferProgressInfo.h @@ -20,18 +20,18 @@ namespace Swift { class FileTransferProgressInfo { public: - FileTransferProgressInfo(boost::uintmax_t completeBytes); + FileTransferProgressInfo(boost::uintmax_t completeBytes); public: - void setBytesProcessed(int processedBytes); + void setBytesProcessed(int processedBytes); - int getPercentage() const; - boost::signal<void (int)> onProgressPercentage; + int getPercentage() const; + boost::signal<void (int)> onProgressPercentage; private: - boost::uintmax_t completeBytes; - boost::uintmax_t completedBytes; - int percentage; + boost::uintmax_t completeBytes; + boost::uintmax_t completedBytes; + int percentage; }; } |