diff options
Diffstat (limited to 'Swift/Controllers/BlockListController.cpp')
| -rw-r--r-- | Swift/Controllers/BlockListController.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Swift/Controllers/BlockListController.cpp b/Swift/Controllers/BlockListController.cpp index 6bdb513..d778883 100644 --- a/Swift/Controllers/BlockListController.cpp +++ b/Swift/Controllers/BlockListController.cpp @@ -1,65 +1,66 @@ /* * Copyright (c) 2013 Tobias Markmann * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ #include <Swift/Controllers/BlockListController.h> #include <boost/bind.hpp> #include <Swiften/Client/ClientBlockListManager.h> #include <Swiften/Base/foreach.h> #include <Swiften/Base/format.h> #include <Swift/Controllers/Intl.h> #include <Swift/Controllers/UIEvents/RequestChangeBlockStateUIEvent.h> #include <Swift/Controllers/UIEvents/RequestBlockListDialogUIEvent.h> #include <Swift/Controllers/XMPPEvents/ErrorEvent.h> #include <Swift/Controllers/UIInterfaces/BlockListEditorWidget.h> #include <Swift/Controllers/XMPPEvents/EventController.h> namespace Swift { -BlockListController::BlockListController(ClientBlockListManager* blockListManager, UIEventStream* uiEventStream, BlockListEditorWidgetFactory* blockListEditorWidgetFactory, EventController* eventController) : blockListManager_(blockListManager), blockListEditorWidgetFactory_(blockListEditorWidgetFactory), blockListEditorWidget_(0), eventController_(eventController), remainingRequests_(0) { +BlockListController::BlockListController(ClientBlockListManager* blockListManager, UIEventStream* uiEventStream, BlockListEditorWidgetFactory* blockListEditorWidgetFactory, EventController* eventController) : blockListManager_(blockListManager), blockListEditorWidgetFactory_(blockListEditorWidgetFactory), blockListEditorWidget_(0), eventController_(eventController), remainingRequests_(0), uiEventStream_(uiEventStream) { uiEventStream->onUIEvent.connect(boost::bind(&BlockListController::handleUIEvent, this, _1)); blockListManager_->getBlockList()->onItemAdded.connect(boost::bind(&BlockListController::handleBlockListChanged, this)); blockListManager_->getBlockList()->onItemRemoved.connect(boost::bind(&BlockListController::handleBlockListChanged, this)); } BlockListController::~BlockListController() { + uiEventStream_->onUIEvent.disconnect(boost::bind(&BlockListController::handleUIEvent, this, _1)); blockListManager_->getBlockList()->onItemAdded.disconnect(boost::bind(&BlockListController::handleBlockListChanged, this)); blockListManager_->getBlockList()->onItemRemoved.disconnect(boost::bind(&BlockListController::handleBlockListChanged, this)); } void BlockListController::blockListDifferences(const std::vector<JID> &newBlockList, std::vector<JID> &jidsToUnblock, std::vector<JID> &jidsToBlock) const { foreach (const JID& jid, blockListBeforeEdit) { if (std::find(newBlockList.begin(), newBlockList.end(), jid) == newBlockList.end()) { jidsToUnblock.push_back(jid); } } foreach (const JID& jid, newBlockList) { if (std::find(blockListBeforeEdit.begin(), blockListBeforeEdit.end(), jid) == blockListBeforeEdit.end()) { jidsToBlock.push_back(jid); } } } void BlockListController::handleUIEvent(boost::shared_ptr<UIEvent> rawEvent) { // handle UI dialog boost::shared_ptr<RequestBlockListDialogUIEvent> requestDialogEvent = boost::dynamic_pointer_cast<RequestBlockListDialogUIEvent>(rawEvent); if (requestDialogEvent != NULL) { if (blockListEditorWidget_ == NULL) { blockListEditorWidget_ = blockListEditorWidgetFactory_->createBlockListEditorWidget(); blockListEditorWidget_->onSetNewBlockList.connect(boost::bind(&BlockListController::handleSetNewBlockList, this, _1)); } blockListBeforeEdit = blockListManager_->getBlockList()->getItems(); blockListEditorWidget_->setCurrentBlockList(blockListBeforeEdit); blockListEditorWidget_->show(); return; } // handle block state change boost::shared_ptr<RequestChangeBlockStateUIEvent> changeStateEvent = boost::dynamic_pointer_cast<RequestChangeBlockStateUIEvent>(rawEvent); if (changeStateEvent != NULL) { |
Swift