From bfdf408bed69a279eb710de915e932764ceaed76 Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Sun, 25 Oct 2009 15:47:40 +0000 Subject: Some groundwork ready for autoaway diff --git a/Swift/Controllers/IdleDetector.h b/Swift/Controllers/IdleDetector.h new file mode 100644 index 0000000..72fe07c --- /dev/null +++ b/Swift/Controllers/IdleDetector.h @@ -0,0 +1,16 @@ +#pragma once + +#include +#include + +namespace Swift { +class IdleDetector { + public: + virtual ~IdleDetector() {}; + virtual void forceNotIdle() = 0; + boost::signal onInputIdle; + boost::signal onInputNotIdle; +}; +} + + diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index 6c862ec..5495ec0 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -10,6 +10,7 @@ #include "Swift/Controllers/ChatController.h" #include "Swift/Controllers/ChatWindowFactory.h" #include "Swift/Controllers/EventController.h" +#include "Swift/Controllers/IdleDetector.h" #include "Swift/Controllers/LoginWindow.h" #include "Swift/Controllers/LoginWindowFactory.h" #include "Swift/Controllers/MainWindow.h" @@ -59,9 +60,10 @@ static const String CLIENT_NODE = "http://swift.im"; typedef std::pair JIDChatControllerPair; typedef std::pair JIDMUCControllerPair; -MainController::MainController(ChatWindowFactory* chatWindowFactory, MainWindowFactory *mainWindowFactory, LoginWindowFactory *loginWindowFactory, TreeWidgetFactory *treeWidgetFactory, SettingsProvider *settings, Application* application, SystemTray* systemTray, SoundPlayer* soundPlayer) +MainController::MainController(ChatWindowFactory* chatWindowFactory, MainWindowFactory *mainWindowFactory, LoginWindowFactory *loginWindowFactory, TreeWidgetFactory *treeWidgetFactory, SettingsProvider *settings, Application* application, SystemTray* systemTray, SoundPlayer* soundPlayer, IdleDetector* idleDetector) : client_(NULL), chatWindowFactory_(chatWindowFactory), mainWindowFactory_(mainWindowFactory), loginWindowFactory_(loginWindowFactory), treeWidgetFactory_(treeWidgetFactory), settings_(settings), xmppRosterController_(NULL), rosterController_(NULL), loginWindow_(NULL), clientVersionResponder_(NULL), nickResolver_(NULL), discoResponder_(NULL) { + idleDetector_ = idleDetector; application_ = application; presenceOracle_ = NULL; avatarManager_ = NULL; @@ -161,6 +163,9 @@ void MainController::handleConnected() { boost::shared_ptr vCardRequest(new GetVCardRequest(JID(), client_)); vCardRequest->onResponse.connect(boost::bind(&MainController::handleOwnVCardReceived, this, _1, _2)); vCardRequest->send(); + + idleDetector_->onInputIdle.connect(boost::bind(&MainController::handleInputIdle, this)); + idleDetector_->onInputNotIdle.connect(boost::bind(&MainController::handleInputNotIdle, this)); //Send presence last to catch all the incoming presences. boost::shared_ptr initialPresence; @@ -208,6 +213,14 @@ void MainController::sendPresence(boost::shared_ptr presence) { } } +void MainController::handleInputIdle() { + +} + +void MainController::handleInputNotIdle() { + +} + void MainController::handleIncomingPresence(boost::shared_ptr presence) { //FIXME: subscribe, subscribed rosterController_->handleIncomingPresence(presence); @@ -273,6 +286,8 @@ void MainController::handleCancelLoginRequest() { void MainController::signOut() { logout(); + idleDetector_->onInputIdle.connect(boost::bind(&MainController::handleInputIdle, this)); + idleDetector_->onInputNotIdle.connect(boost::bind(&MainController::handleInputNotIdle, this)); loginWindow_->loggedOut(); foreach (JIDChatControllerPair controllerPair, chatControllers_) { delete controllerPair.second; diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h index 2971493..5cdd9fa 100644 --- a/Swift/Controllers/MainController.h +++ b/Swift/Controllers/MainController.h @@ -25,6 +25,7 @@ namespace Swift { class ChatWindowFactory; class ChatController; class EventController; + class IdleDetector; class MainWindowFactory; class MainWindow; class NickResolver; @@ -46,7 +47,7 @@ namespace Swift { class MainController : public MUCRegistry { public: - MainController(ChatWindowFactory* chatWindowFactory, MainWindowFactory *mainWindowFactory, LoginWindowFactory *loginWindowFactory, TreeWidgetFactory* treeWidgetFactory, SettingsProvider *settings, Application* application, SystemTray* systemTray, SoundPlayer* soundPlayer); + MainController(ChatWindowFactory* chatWindowFactory, MainWindowFactory *mainWindowFactory, LoginWindowFactory *loginWindowFactory, TreeWidgetFactory* treeWidgetFactory, SettingsProvider *settings, Application* application, SystemTray* systemTray, SoundPlayer* soundPlayer, IdleDetector* idleDetector); ~MainController(); @@ -68,12 +69,13 @@ namespace Swift { void handleOwnVCardReceived(boost::shared_ptr vCard, const boost::optional& error); ChatController* getChatController(const JID &contact); void sendPresence(boost::shared_ptr presence); + void handleInputIdle(); + void handleInputNotIdle(); void logout(); void signOut(); virtual bool isMUC(const JID& muc) const; - private: void performLoginFromCachedCredentials(); void setManagersEnabled(bool enabled); Client* client_; @@ -92,6 +94,7 @@ namespace Swift { SoftwareVersionResponder* clientVersionResponder_; NickResolver* nickResolver_; DiscoInfoResponder* discoResponder_; + IdleDetector* idleDetector_; boost::shared_ptr capsInfo_; std::map mucControllers_; std::map chatControllers_; diff --git a/Swift/QtUI/QtIdleDetector.cpp b/Swift/QtUI/QtIdleDetector.cpp new file mode 100644 index 0000000..e947854 --- /dev/null +++ b/Swift/QtUI/QtIdleDetector.cpp @@ -0,0 +1,16 @@ +#include "QtIdleDetector.h" + +namespace Swift { + +QtIdleDetector::QtIdleDetector() { +} + +QtIdleDetector::~QtIdleDetector() { +} + +void QtIdleDetector::forceNotIdle() { + +} + + +} diff --git a/Swift/QtUI/QtIdleDetector.h b/Swift/QtUI/QtIdleDetector.h new file mode 100644 index 0000000..e21e4a8 --- /dev/null +++ b/Swift/QtUI/QtIdleDetector.h @@ -0,0 +1,14 @@ +#pragma once + +#include "Swift/Controllers/IdleDetector.h" + +namespace Swift { +class QtIdleDetector : public IdleDetector { + public: + QtIdleDetector(); + virtual ~QtIdleDetector(); + virtual void forceNotIdle(); + + +}; +} diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp index 656e8ce..0def66f 100644 --- a/Swift/QtUI/QtSwift.cpp +++ b/Swift/QtUI/QtSwift.cpp @@ -8,6 +8,7 @@ #include "Roster/QtTreeWidgetFactory.h" #include "QtSystemTray.h" #include "QtSoundPlayer.h" +#include "QtIdleDetector.h" #include #include @@ -41,10 +42,11 @@ QtSwift::QtSwift(bool netbookMode) { chatWindowFactory_ = new QtChatWindowFactory(treeWidgetFactory_, splitter_, settings_); rosterWindowFactory_ = new QtMainWindowFactory(treeWidgetFactory_); soundPlayer_ = new QtSoundPlayer(); + idleDetector_ = new QtIdleDetector(); if (splitter_) { splitter_->show(); } - mainController_ = new MainController(chatWindowFactory_, rosterWindowFactory_, loginWindowFactory_, treeWidgetFactory_, settings_, application_, systemTray_, soundPlayer_); + mainController_ = new MainController(chatWindowFactory_, rosterWindowFactory_, loginWindowFactory_, treeWidgetFactory_, settings_, application_, systemTray_, soundPlayer_, idleDetector_); } QtSwift::~QtSwift() { @@ -58,6 +60,7 @@ QtSwift::~QtSwift() { delete systemTray_; delete splitter_; delete soundPlayer_; + delete idleDetector_; } } diff --git a/Swift/QtUI/QtSwift.h b/Swift/QtUI/QtSwift.h index 263dc05..60ff5a7 100644 --- a/Swift/QtUI/QtSwift.h +++ b/Swift/QtUI/QtSwift.h @@ -7,6 +7,7 @@ #include "QtMainWindowFactory.h" #include "QtChatWindowFactory.h" #include "QtSettingsProvider.h" +#include "QtIdleDetector.h" class QSplitter; @@ -36,6 +37,7 @@ namespace Swift { QtSystemTray* systemTray_; QSplitter* splitter_; QtSoundPlayer* soundPlayer_; + QtIdleDetector* idleDetector_; Application* application_; }; } diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript index cf0dc47..c70f8a0 100644 --- a/Swift/QtUI/SConscript +++ b/Swift/QtUI/SConscript @@ -51,6 +51,7 @@ sources = [ "QtAddContactDialog.cpp", "QtChatWindow.cpp", "QtChatWindowFactory.cpp", + "QtIdleDetector.cpp", "QtJoinMUCDialog.cpp", "QtLoginWindow.cpp", "QtLoginWindowFactory.cpp", -- cgit v0.10.2-6-g49f6