diff options
author | Remko Tronçon <git@el-tramo.be> | 2011-07-11 11:37:43 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2011-07-11 11:37:43 (GMT) |
commit | 127355ccda505bbfcfa93d1f1304e6027c55516c (patch) | |
tree | 6236bcc102cdffd7cf88d639ef4daeae618dfd64 | |
parent | 1a88be2c3755de25464e403049a95ddd7fca327c (diff) | |
download | swift-contrib-127355ccda505bbfcfa93d1f1304e6027c55516c.zip swift-contrib-127355ccda505bbfcfa93d1f1304e6027c55516c.tar.bz2 |
Make IdleDetector a parameter of MainController.
-rw-r--r-- | SwifTools/Idle/IdleDetector.h | 1 | ||||
-rw-r--r-- | Swift/Controllers/MainController.cpp | 10 | ||||
-rw-r--r-- | Swift/Controllers/MainController.h | 7 | ||||
-rw-r--r-- | Swift/QtUI/QtSwift.cpp | 3 | ||||
-rw-r--r-- | Swift/QtUI/QtSwift.h | 4 |
5 files changed, 16 insertions, 9 deletions
diff --git a/SwifTools/Idle/IdleDetector.h b/SwifTools/Idle/IdleDetector.h index 4b54801..9e379f7 100644 --- a/SwifTools/Idle/IdleDetector.h +++ b/SwifTools/Idle/IdleDetector.h @@ -23,19 +23,18 @@ namespace Swift { return idleTimeSeconds; } virtual bool isIdle() const { return idle; } boost::signal<void (bool /* isIdle */)> onIdleChanged; - protected: void setIdle(bool b) { if (b != idle) { idle = b; onIdleChanged(b); } } private: bool idle; diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index 58b2dbe..92bec85 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -61,18 +61,19 @@ #include "Swift/Controllers/UIEvents/ToggleNotificationsUIEvent.h" #include "Swift/Controllers/UIEvents/JoinMUCUIEvent.h" #include "Swift/Controllers/Storages/CertificateStorageFactory.h" #include "Swift/Controllers/Storages/CertificateStorageTrustChecker.h" #include "Swiften/Network/NetworkFactories.h" #include <Swift/Controllers/ProfileController.h> #include <Swift/Controllers/ContactEditController.h> #include <Swift/Controllers/XMPPURIController.h> #include "Swift/Controllers/AdHocManager.h" +#include <SwifTools/Idle/IdleDetector.h> namespace Swift { static const std::string CLIENT_NAME = "Swift"; static const std::string CLIENT_NODE = "http://swift.im"; static const std::string SHOW_NOTIFICATIONS = "showNotifications"; MainController::MainController( @@ -81,28 +82,29 @@ MainController::MainController( UIFactory* uiFactories, SettingsProvider *settings, SystemTray* systemTray, SoundPlayer* soundPlayer, StoragesFactory* storagesFactory, CertificateStorageFactory* certificateStorageFactory, Dock* dock, Notifier* notifier, URIHandler* uriHandler, + IdleDetector* idleDetector, bool useDelayForLatency, bool eagleMode) : eventLoop_(eventLoop), networkFactories_(networkFactories), uiFactory_(uiFactories), - idleDetector_(&idleQuerier_, networkFactories_->getTimerFactory(), 1000), storagesFactory_(storagesFactory), certificateStorageFactory_(certificateStorageFactory), settings_(settings), uriHandler_(uriHandler), + idleDetector_(idleDetector), loginWindow_(NULL) , useDelayForLatency_(useDelayForLatency), eagleMode_(eagleMode) { storages_ = NULL; certificateStorage_ = NULL; statusTracker_ = NULL; presenceNotifier_ = NULL; eventNotifier_ = NULL; rosterController_ = NULL; @@ -151,36 +153,38 @@ MainController::MainController( loginWindow_->setRememberingAllowed(false); } loginWindow_->onLoginRequest.connect(boost::bind(&MainController::handleLoginRequest, this, _1, _2, _3, _4, _5)); loginWindow_->onPurgeSavedLoginRequest.connect(boost::bind(&MainController::handlePurgeSavedLoginRequest, this, _1)); loginWindow_->onCancelLoginRequest.connect(boost::bind(&MainController::handleCancelLoginRequest, this)); loginWindow_->onQuitRequest.connect(boost::bind(&MainController::handleQuitRequest, this)); - idleDetector_.setIdleTimeSeconds(600); - idleDetector_.onIdleChanged.connect(boost::bind(&MainController::handleInputIdleChanged, this, _1)); + idleDetector_->setIdleTimeSeconds(600); + idleDetector_->onIdleChanged.connect(boost::bind(&MainController::handleInputIdleChanged, this, _1)); xmlConsoleController_ = new XMLConsoleController(uiEventStream_, uiFactory_); uiEventStream_->onUIEvent.connect(boost::bind(&MainController::handleUIEvent, this, _1)); bool enabled = settings_->getBoolSetting(SHOW_NOTIFICATIONS, true); uiEventStream_->send(boost::shared_ptr<ToggleNotificationsUIEvent>(new ToggleNotificationsUIEvent(enabled))); if (loginAutomatically) { profileSettings_ = new ProfileSettingsProvider(selectedLoginJID, settings_); handleLoginRequest(selectedLoginJID, cachedPassword, cachedCertificate, true, true); } else { profileSettings_ = NULL; } } MainController::~MainController() { + idleDetector_->onIdleChanged.disconnect(boost::bind(&MainController::handleInputIdleChanged, this, _1)); + purgeCachedCredentials(); //setManagersOffline(); eventController_->disconnectAll(); resetClient(); delete xmlConsoleController_; delete xmppURIController_; delete soundEventController_; diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h index 21460ec..7ac6648 100644 --- a/Swift/Controllers/MainController.h +++ b/Swift/Controllers/MainController.h @@ -5,34 +5,33 @@ */ #pragma once #include <Swiften/Base/boost_bsignals.h> #include <boost/shared_ptr.hpp> #include <vector> #include "Swiften/Network/Timer.h" -#include "SwifTools/Idle/PlatformIdleQuerier.h" -#include "SwifTools/Idle/ActualIdleDetector.h" #include <string> #include "Swiften/Client/ClientError.h" #include "Swiften/JID/JID.h" #include "Swiften/Elements/DiscoInfo.h" #include "Swiften/Elements/VCard.h" #include "Swiften/Elements/ErrorPayload.h" #include "Swiften/Elements/Presence.h" #include "Swift/Controllers/Settings/SettingsProvider.h" #include "Swift/Controllers/ProfileSettingsProvider.h" #include "Swiften/Elements/CapsInfo.h" #include "Swift/Controllers/XMPPEvents/ErrorEvent.h" #include "Swift/Controllers/UIEvents/UIEvent.h" namespace Swift { + class IdleDetector; class UIFactory; class EventLoop; class Client; class ChatController; class ChatsManager; class CertificateStorageFactory; class CertificateStorage; class CertificateStorageTrustChecker; class EventController; @@ -75,18 +74,19 @@ namespace Swift { UIFactory* uiFactories, SettingsProvider *settings, SystemTray* systemTray, SoundPlayer* soundPlayer, StoragesFactory* storagesFactory, CertificateStorageFactory* certificateStorageFactory, Dock* dock, Notifier* notifier, URIHandler* uriHandler, + IdleDetector* idleDetector, bool useDelayForLatency, bool eagleMode); ~MainController(); private: void resetClient(); void handleConnected(); void handleLoginRequest(const std::string& username, const std::string& password, const std::string& certificateFile, bool remember, bool loginAutomatically); @@ -112,31 +112,30 @@ namespace Swift { void setManagersOffline(); void handleNotificationClicked(const JID& jid); void handleForceQuit(); void purgeCachedCredentials(); private: EventLoop* eventLoop_; NetworkFactories* networkFactories_; UIFactory* uiFactory_; - PlatformIdleQuerier idleQuerier_; - ActualIdleDetector idleDetector_; StoragesFactory* storagesFactory_; Storages* storages_; CertificateStorageFactory* certificateStorageFactory_; CertificateStorage* certificateStorage_; CertificateStorageTrustChecker* certificateTrustChecker_; bool clientInitialized_; boost::shared_ptr<Client> client_; SettingsProvider *settings_; ProfileSettingsProvider* profileSettings_; Dock* dock_; URIHandler* uriHandler_; + IdleDetector* idleDetector_; TogglableNotifier* notifier_; PresenceNotifier* presenceNotifier_; EventNotifier* eventNotifier_; RosterController* rosterController_; EventController* eventController_; EventWindowController* eventWindowController_; AdHocManager* adHocManager_; LoginWindow* loginWindow_; UIEventStream* uiEventStream_; diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp index 1d820b1..398150e 100644 --- a/Swift/QtUI/QtSwift.cpp +++ b/Swift/QtUI/QtSwift.cpp @@ -74,19 +74,19 @@ po::options_description QtSwift::getOptionsDescription() { ("latency-debug", "Use latency debugging (unsupported)") ("multi-account", po::value<int>()->default_value(1), "Number of accounts to open windows for (unsupported)") ("start-minimized", "Don't show the login/roster window at startup") ("eagle-mode", "Settings more suitable for military/secure deployments") ; return result; } -QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMainThreadCaller_), autoUpdater_(NULL) { +QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMainThreadCaller_), autoUpdater_(NULL), idleDetector_(&idleQuerier_, networkFactories_->getTimerFactory(), 1000) { if (options.count("netbook-mode")) { splitter_ = new QSplitter(); } else { splitter_ = NULL; } QCoreApplication::setApplicationName(SWIFT_APPLICATION_NAME); QCoreApplication::setOrganizationName(SWIFT_ORGANIZATION_NAME); QCoreApplication::setOrganizationDomain(SWIFT_ORGANIZATION_DOMAIN); QCoreApplication::setApplicationVersion(buildVersion); @@ -159,18 +159,19 @@ QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMa uiFactory, settings_, systemTrays_[i], soundPlayer_, storagesFactory_, certificateStorageFactory_, dock_, notifier_, uriHandler_, + &idleDetector_, options.count("latency-debug") > 0, eagleMode); mainControllers_.push_back(mainController); } // PlatformAutoUpdaterFactory autoUpdaterFactory; // if (autoUpdaterFactory.isSupported()) { // autoUpdater_ = autoUpdaterFactory.createAutoUpdater(SWIFT_APPCAST_URL); diff --git a/Swift/QtUI/QtSwift.h b/Swift/QtUI/QtSwift.h index 4bf5c97..7f33475 100644 --- a/Swift/QtUI/QtSwift.h +++ b/Swift/QtUI/QtSwift.h @@ -15,18 +15,20 @@ #include "Swiften/Base/Platform.h" #include "Swiften/EventLoop/Qt/QtEventLoop.h" #include "QtSettingsProvider.h" #if defined(SWIFTEN_PLATFORM_MACOSX) #include "SwifTools/Application/CocoaApplication.h" #endif #if defined(SWIFTEN_PLATFORM_WINDOWS) #include "WindowsNotifier.h" #endif +#include "SwifTools/Idle/PlatformIdleQuerier.h" +#include "SwifTools/Idle/ActualIdleDetector.h" namespace po = boost::program_options; class QSplitter; namespace Swift { class QtUIFactory; class CertificateStorageFactory; class Dock; @@ -65,14 +67,16 @@ namespace Swift { QtSoundPlayer* soundPlayer_; Dock* dock_; URIHandler* uriHandler_; QtChatTabs* tabs_; ApplicationPathProvider* applicationPathProvider_; StoragesFactory* storagesFactory_; CertificateStorageFactory* certificateStorageFactory_; AutoUpdater* autoUpdater_; Notifier* notifier_; + PlatformIdleQuerier idleQuerier_; + ActualIdleDetector idleDetector_; #if defined(SWIFTEN_PLATFORM_MACOSX) CocoaApplication cocoaApplication_; #endif }; } |