summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/Controllers')
-rw-r--r--Swift/Controllers/IdleDetector.h16
-rw-r--r--Swift/Controllers/MainController.cpp17
-rw-r--r--Swift/Controllers/MainController.h7
3 files changed, 37 insertions, 3 deletions
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 <boost/signals.hpp>
+#include <boost/shared_ptr.hpp>
+
+namespace Swift {
+class IdleDetector {
+ public:
+ virtual ~IdleDetector() {};
+ virtual void forceNotIdle() = 0;
+ boost::signal<void ()> onInputIdle;
+ boost::signal<void ()> 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<JID, ChatController*> JIDChatControllerPair;
typedef std::pair<JID, MUCController*> 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<GetVCardRequest> 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<Presence> initialPresence;
@@ -208,6 +213,14 @@ void MainController::sendPresence(boost::shared_ptr<Presence> presence) {
}
}
+void MainController::handleInputIdle() {
+
+}
+
+void MainController::handleInputNotIdle() {
+
+}
+
void MainController::handleIncomingPresence(boost::shared_ptr<Presence> 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> vCard, const boost::optional<Error>& error);
ChatController* getChatController(const JID &contact);
void sendPresence(boost::shared_ptr<Presence> 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> capsInfo_;
std::map<JID, MUCController*> mucControllers_;
std::map<JID, ChatController*> chatControllers_;