diff options
Diffstat (limited to 'Swift/Controllers')
-rw-r--r-- | Swift/Controllers/FileTransfer/FileTransferController.cpp | 2 | ||||
-rw-r--r-- | Swift/Controllers/FileTransfer/FileTransferController.h | 19 | ||||
-rw-r--r-- | Swift/Controllers/FileTransfer/FileTransferOverview.cpp | 58 | ||||
-rw-r--r-- | Swift/Controllers/FileTransfer/FileTransferOverview.h | 15 | ||||
-rw-r--r-- | Swift/Controllers/MainController.cpp | 107 |
5 files changed, 134 insertions, 67 deletions
diff --git a/Swift/Controllers/FileTransfer/FileTransferController.cpp b/Swift/Controllers/FileTransfer/FileTransferController.cpp index f7ce8e6..c21c364 100644 --- a/Swift/Controllers/FileTransfer/FileTransferController.cpp +++ b/Swift/Controllers/FileTransfer/FileTransferController.cpp @@ -121,7 +121,7 @@ void FileTransferController::cancel() { void FileTransferController::handleFileTransferStateChange(FileTransfer::State state) { currentState = state; - onStateChage(); + onStateChanged(); switch(state.type) { case FileTransfer::State::Initial: assert(false); diff --git a/Swift/Controllers/FileTransfer/FileTransferController.h b/Swift/Controllers/FileTransfer/FileTransferController.h index 3d6f7d5..490773d 100644 --- a/Swift/Controllers/FileTransfer/FileTransferController.h +++ b/Swift/Controllers/FileTransfer/FileTransferController.h @@ -4,18 +4,25 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ +/* + * Copyright (c) 2015 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + #pragma once #include <string> -#include <boost/shared_ptr.hpp> #include <boost/cstdint.hpp> +#include <boost/shared_ptr.hpp> -#include <Swiften/JID/JID.h> -#include <Swiften/FileTransfer/FileTransfer.h> -#include <Swiften/FileTransfer/IncomingFileTransfer.h> #include <Swiften/FileTransfer/FileReadBytestream.h> +#include <Swiften/FileTransfer/FileTransfer.h> #include <Swiften/FileTransfer/FileWriteBytestream.h> +#include <Swiften/FileTransfer/IncomingFileTransfer.h> +#include <Swiften/JID/JID.h> + #include <Swift/Controllers/FileTransfer/FileTransferProgressInfo.h> namespace Swift { @@ -49,14 +56,14 @@ public: int getProgress() const; boost::uintmax_t getSize() const; - boost::signal<void ()> onStateChage; + boost::signal<void ()> onStateChanged; boost::signal<void ()> onProgressChange; private: void handleFileTransferStateChange(FileTransfer::State); void handleProgressPercentageChange(int percentage); -private: +private: bool sending; JID otherParty; std::string filename; diff --git a/Swift/Controllers/FileTransfer/FileTransferOverview.cpp b/Swift/Controllers/FileTransfer/FileTransferOverview.cpp index 2a8c319..b2afea9 100644 --- a/Swift/Controllers/FileTransfer/FileTransferOverview.cpp +++ b/Swift/Controllers/FileTransfer/FileTransferOverview.cpp @@ -4,41 +4,89 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ +/* + * Copyright (c) 2015 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + #include "FileTransferOverview.h" #include <boost/bind.hpp> #include <boost/filesystem.hpp> -#include <Swiften/Base/boost_bsignals.h> +#include <Swiften/Base/Log.h> +#include <Swiften/Base/boost_bsignals.h> +#include <Swiften/Base/foreach.h> #include <Swiften/FileTransfer/FileTransferManager.h> 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)); } 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)); + } } 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); - fileTransfers.push_back(controller); - onNewFileTransferController(controller); } } void FileTransferOverview::handleIncomingFileTransfer(IncomingFileTransfer::ref transfer) { FileTransferController* controller = new FileTransferController(transfer); - fileTransfers.push_back(controller); onNewFileTransferController(controller); } +void FileTransferOverview::handleNewFileTransferController(FileTransferController* controller) { + fileTransfers.push_back(controller); + controller->onStateChanged.connect(boost::bind(&FileTransferOverview::handleFileTransferStateChanged, this)); +} + +void FileTransferOverview::handleFileTransferStateChanged() { + onFileTransferListChanged(); +} + const std::vector<FileTransferController*>& FileTransferOverview::getFileTransfers() const { 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(); +} + +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; +} + } diff --git a/Swift/Controllers/FileTransfer/FileTransferOverview.h b/Swift/Controllers/FileTransfer/FileTransferOverview.h index 716666a..e3cbf81 100644 --- a/Swift/Controllers/FileTransfer/FileTransferOverview.h +++ b/Swift/Controllers/FileTransfer/FileTransferOverview.h @@ -4,14 +4,20 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ +/* + * Copyright (c) 2015 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + #pragma once #include <vector> -#include "Swift/Controllers/FileTransfer/FileTransferController.h" - #include <Swiften/Base/boost_bsignals.h> +#include <Swift/Controllers/FileTransfer/FileTransferController.h> + namespace Swift { class ChatsManager; @@ -24,11 +30,16 @@ public: 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(); private: std::vector<FileTransferController*> fileTransfers; diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index a65a18a..cdaa207 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -13,84 +13,84 @@ #include <boost/shared_ptr.hpp> #include <boost/smart_ptr/make_shared.hpp> -#include <Swiften/Base/format.h> #include <Swiften/Base/Algorithm.h> #include <Swiften/Base/String.h> -#include <Swiften/StringCodecs/Base64.h> -#include <Swiften/Network/TimerFactory.h> -#include <Swiften/Client/Storages.h> -#include <Swiften/VCards/VCardManager.h> -#include <Swiften/Client/NickResolver.h> #include <Swiften/Base/foreach.h> +#include <Swiften/Base/format.h> #include <Swiften/Client/Client.h> -#include <Swiften/Presence/PresenceSender.h> +#include <Swiften/Client/ClientBlockListManager.h> +#include <Swiften/Client/ClientXMLTracer.h> +#include <Swiften/Client/NickResolver.h> +#include <Swiften/Client/StanzaChannel.h> +#include <Swiften/Client/Storages.h> +#include <Swiften/Crypto/CryptoProvider.h> +#include <Swiften/Disco/CapsInfoGenerator.h> +#include <Swiften/Disco/ClientDiscoManager.h> +#include <Swiften/Disco/GetDiscoInfoRequest.h> #include <Swiften/Elements/ChatState.h> +#include <Swiften/Elements/DiscoInfo.h> #include <Swiften/Elements/Presence.h> #include <Swiften/Elements/VCardUpdate.h> -#include <Swiften/Elements/DiscoInfo.h> -#include <Swiften/Disco/CapsInfoGenerator.h> -#include <Swiften/Disco/GetDiscoInfoRequest.h> -#include <Swiften/Disco/ClientDiscoManager.h> -#include <Swiften/VCards/GetVCardRequest.h> -#include <Swiften/StringCodecs/Hexify.h> -#include <Swiften/Network/NetworkFactories.h> #include <Swiften/FileTransfer/FileTransferManager.h> -#include <Swiften/Client/ClientXMLTracer.h> -#include <Swiften/Client/StanzaChannel.h> -#include <Swiften/Client/ClientBlockListManager.h> -#include <Swiften/Crypto/CryptoProvider.h> +#include <Swiften/Network/NetworkFactories.h> +#include <Swiften/Network/TimerFactory.h> +#include <Swiften/Presence/PresenceSender.h> +#include <Swiften/StringCodecs/Base64.h> +#include <Swiften/StringCodecs/Hexify.h> +#include <Swiften/VCards/GetVCardRequest.h> +#include <Swiften/VCards/VCardManager.h> #ifdef SWIFTEN_PLATFORM_WIN32 #include <Swiften/SASL/WindowsAuthentication.h> #endif -#include <SwifTools/Dock/Dock.h> -#include <SwifTools/Notifier/TogglableNotifier.h> -#include <SwifTools/Idle/IdleDetector.h> - -#include <Swift/Controllers/Intl.h> -#include <Swift/Controllers/UIInterfaces/UIFactory.h> +#include <Swift/Controllers/AdHocManager.h> +#include <Swift/Controllers/BlockListController.h> #include <Swift/Controllers/BuildVersion.h> -#include <Swift/Controllers/Chat/UserSearchController.h> #include <Swift/Controllers/Chat/ChatsManager.h> -#include <Swift/Controllers/XMPPEvents/EventController.h> -#include <Swift/Controllers/EventWindowController.h> -#include <Swift/Controllers/UIInterfaces/LoginWindow.h> -#include <Swift/Controllers/UIInterfaces/LoginWindowFactory.h> -#include <Swift/Controllers/UIInterfaces/MainWindow.h> #include <Swift/Controllers/Chat/MUCController.h> +#include <Swift/Controllers/Chat/UserSearchController.h> +#include <Swift/Controllers/ContactEditController.h> +#include <Swift/Controllers/ContactSuggester.h> +#include <Swift/Controllers/ContactsFromXMPPRoster.h> +#include <Swift/Controllers/EventNotifier.h> +#include <Swift/Controllers/EventWindowController.h> +#include <Swift/Controllers/FileTransfer/FileTransferOverview.h> +#include <Swift/Controllers/FileTransferListController.h> +#include <Swift/Controllers/HighlightEditorController.h> +#include <Swift/Controllers/HighlightManager.h> +#include <Swift/Controllers/HistoryController.h> +#include <Swift/Controllers/HistoryViewController.h> +#include <Swift/Controllers/Intl.h> +#include <Swift/Controllers/PresenceNotifier.h> +#include <Swift/Controllers/ProfileController.h> #include <Swift/Controllers/Roster/RosterController.h> +#include <Swift/Controllers/SettingConstants.h> +#include <Swift/Controllers/Settings/SettingsProvider.h> +#include <Swift/Controllers/ShowProfileController.h> #include <Swift/Controllers/SoundEventController.h> #include <Swift/Controllers/SoundPlayer.h> #include <Swift/Controllers/StatusTracker.h> +#include <Swift/Controllers/Storages/CertificateStorageFactory.h> +#include <Swift/Controllers/Storages/CertificateStorageTrustChecker.h> +#include <Swift/Controllers/Storages/StoragesFactory.h> #include <Swift/Controllers/SystemTray.h> #include <Swift/Controllers/SystemTrayController.h> -#include <Swift/Controllers/XMLConsoleController.h> -#include <Swift/Controllers/HistoryController.h> -#include <Swift/Controllers/HistoryViewController.h> -#include <Swift/Controllers/FileTransferListController.h> +#include <Swift/Controllers/UIEvents/JoinMUCUIEvent.h> +#include <Swift/Controllers/UIEvents/RequestChatUIEvent.h> #include <Swift/Controllers/UIEvents/UIEventStream.h> -#include <Swift/Controllers/PresenceNotifier.h> -#include <Swift/Controllers/EventNotifier.h> -#include <Swift/Controllers/Storages/StoragesFactory.h> +#include <Swift/Controllers/UIInterfaces/LoginWindow.h> +#include <Swift/Controllers/UIInterfaces/LoginWindowFactory.h> +#include <Swift/Controllers/UIInterfaces/MainWindow.h> +#include <Swift/Controllers/UIInterfaces/UIFactory.h> #include <Swift/Controllers/WhiteboardManager.h> -#include <Swift/Controllers/Settings/SettingsProvider.h> -#include <Swift/Controllers/UIEvents/RequestChatUIEvent.h> -#include <Swift/Controllers/UIEvents/JoinMUCUIEvent.h> -#include <Swift/Controllers/Storages/CertificateStorageFactory.h> -#include <Swift/Controllers/Storages/CertificateStorageTrustChecker.h> -#include <Swift/Controllers/ProfileController.h> -#include <Swift/Controllers/ShowProfileController.h> -#include <Swift/Controllers/ContactEditController.h> +#include <Swift/Controllers/XMLConsoleController.h> +#include <Swift/Controllers/XMPPEvents/EventController.h> #include <Swift/Controllers/XMPPURIController.h> -#include <Swift/Controllers/AdHocManager.h> -#include <Swift/Controllers/FileTransfer/FileTransferOverview.h> -#include <Swift/Controllers/SettingConstants.h> -#include <Swift/Controllers/HighlightManager.h> -#include <Swift/Controllers/HighlightEditorController.h> -#include <Swift/Controllers/BlockListController.h> -#include <Swift/Controllers/ContactSuggester.h> -#include <Swift/Controllers/ContactsFromXMPPRoster.h> + +#include <SwifTools/Dock/Dock.h> +#include <SwifTools/Idle/IdleDetector.h> +#include <SwifTools/Notifier/TogglableNotifier.h> namespace Swift { @@ -270,6 +270,7 @@ void MainController::resetClient() { delete historyController_; historyController_ = NULL; #endif + fileTransferListController_->setFileTransferOverview(NULL); delete ftOverview_; ftOverview_ = NULL; delete blockListController_; |