diff options
author | Kevin Smith <git@kismith.co.uk> | 2009-09-15 21:33:52 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2009-09-15 21:33:52 (GMT) |
commit | 416e20360efab8b12bfaa223c287b6d49dc2a3b8 (patch) | |
tree | dd6aaf35b2310bb4124d432051709ac10075f655 /Swift/Controllers | |
parent | ed5963e48eeb141c3eed51d6c4729be7e61bfa19 (diff) | |
download | swift-416e20360efab8b12bfaa223c287b6d49dc2a3b8.zip swift-416e20360efab8b12bfaa223c287b6d49dc2a3b8.tar.bz2 |
Collapse an enable and disable method into setEnabled(bool).
Diffstat (limited to 'Swift/Controllers')
-rw-r--r-- | Swift/Controllers/ChatControllerBase.cpp | 1 | ||||
-rw-r--r-- | Swift/Controllers/MainController.cpp | 24 | ||||
-rw-r--r-- | Swift/Controllers/MainController.h | 3 |
3 files changed, 9 insertions, 19 deletions
diff --git a/Swift/Controllers/ChatControllerBase.cpp b/Swift/Controllers/ChatControllerBase.cpp index 7d11401..baa715b 100644 --- a/Swift/Controllers/ChatControllerBase.cpp +++ b/Swift/Controllers/ChatControllerBase.cpp @@ -16,6 +16,7 @@ ChatControllerBase::ChatControllerBase(const JID& self, StanzaChannel* stanzaCha chatWindow_ = chatWindowFactory_->createChatWindow(toJID); chatWindow_->onAllMessagesRead.connect(boost::bind(&ChatControllerBase::handleAllMessagesRead, this)); chatWindow_->onSendMessageRequest.connect(boost::bind(&ChatControllerBase::handleSendMessageRequest, this, _1)); + setEnabled(stanzaChannel->isAvailable() && iqRouter->isAvailable()); } ChatControllerBase::~ChatControllerBase() { diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index a8fec70..63c854f 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -168,7 +168,7 @@ void MainController::handleConnected() { initialPresence = boost::shared_ptr<Presence>(new Presence()); } initialPresence->addPayload(capsInfo_); - enableManagers(); + setManagersEnabled(true); sendPresence(initialPresence); } @@ -278,30 +278,20 @@ void MainController::signout() { } void MainController::logout() { - disableManagers(); + setManagersEnabled(false); } -void MainController::disableManagers() { +void MainController::setManagersEnabled(bool enabled) { foreach (JIDChatControllerPair controllerPair, chatControllers_) { - controllerPair.second->setEnabled(false); + //printf("Setting enabled on %d to %d\n", controllerPair.second, enabled); + controllerPair.second->setEnabled(enabled); } foreach (JIDMUCControllerPair controllerPair, mucControllers_) { - controllerPair.second->setEnabled(false); + controllerPair.second->setEnabled(enabled); } - rosterController_->setEnabled(false); + rosterController_->setEnabled(enabled); } -void MainController::enableManagers() { - foreach (JIDChatControllerPair controllerPair, chatControllers_) { - controllerPair.second->setEnabled(true); - } - foreach (JIDMUCControllerPair controllerPair, mucControllers_) { - controllerPair.second->setEnabled(true); - } - rosterController_->setEnabled(true); -} - - void MainController::handleChatRequest(const String &contact) { ChatController* controller = getChatController(JID(contact)); controller->showChatWindow(); diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h index 3fbe9b4..a52ebba 100644 --- a/Swift/Controllers/MainController.h +++ b/Swift/Controllers/MainController.h @@ -74,8 +74,7 @@ namespace Swift { private: void performLoginFromCachedCredentials(); - void enableManagers(); - void disableManagers(); + void setManagersEnabled(bool enabled); Client* client_; ChatWindowFactory* chatWindowFactory_; MainWindowFactory* mainWindowFactory_; |