summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVlad Voicu <vladvoic@gmail.com>2011-05-23 14:53:15 (GMT)
committerVlad Voicu <vladvoic@gmail.com>2011-05-23 20:01:27 (GMT)
commit1fe7e5991c8d1601874f47d9d7038eafb568f6f2 (patch)
treea126ee0f493efdf18c258e29c9f4a97189831cf8 /Swift/Controllers
parent8fe56244a23cd13ba9bafc439b1e502dfd3f82df (diff)
downloadswift-contrib-1fe7e5991c8d1601874f47d9d7038eafb568f6f2.zip
swift-contrib-1fe7e5991c8d1601874f47d9d7038eafb568f6f2.tar.bz2
added controllers for the History Window
Diffstat (limited to 'Swift/Controllers')
-rw-r--r--Swift/Controllers/MainController.cpp9
-rw-r--r--Swift/Controllers/MainController.h2
-rw-r--r--Swift/Controllers/SConscript1
-rw-r--r--Swift/Controllers/UIEvents/RequestViewHistoryUIEvent.h25
-rw-r--r--Swift/Controllers/UIInterfaces/UIFactory.h2
-rw-r--r--Swift/Controllers/UIInterfaces/ViewHistoryWindow.h19
-rw-r--r--Swift/Controllers/UIInterfaces/ViewHistoryWindowFactory.h17
-rw-r--r--Swift/Controllers/ViewHistoryController.cpp40
-rw-r--r--Swift/Controllers/ViewHistoryController.h30
9 files changed, 145 insertions, 0 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index 1e388d5..ce3847c 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -65,6 +65,7 @@
#include "Swiften/Network/NetworkFactories.h"
#include <Swift/Controllers/ProfileController.h>
#include <Swift/Controllers/ContactEditController.h>
+#include <Swift/Controllers/ViewHistoryController.h>
#include <Swift/Controllers/XMPPURIController.h>
#include "Swift/Controllers/AdHocManager.h"
@@ -110,6 +111,7 @@ MainController::MainController(
eventWindowController_ = NULL;
profileController_ = NULL;
contactEditController_ = NULL;
+ viewHistoryController_ = NULL;
userSearchControllerChat_ = NULL;
userSearchControllerAdd_ = NULL;
quitRequested_ = false;
@@ -201,6 +203,8 @@ void MainController::resetClient() {
vCardPhotoHash_.clear();
delete contactEditController_;
contactEditController_ = NULL;
+ delete viewHistoryController_;
+ viewHistoryController_ = NULL;
delete profileController_;
profileController_ = NULL;
delete eventWindowController_;
@@ -270,6 +274,7 @@ void MainController::handleConnected() {
rosterController_->onSignOutRequest.connect(boost::bind(&MainController::signOut, this));
contactEditController_ = new ContactEditController(rosterController_, uiFactory_, uiEventStream_);
+ viewHistoryController_ = new ViewHistoryController(rosterController_, uiFactory_, uiEventStream_);
chatsManager_ = new ChatsManager(jid_, client_->getStanzaChannel(), client_->getIQRouter(), eventController_, uiFactory_, uiFactory_, client_->getNickResolver(), client_->getPresenceOracle(), client_->getPresenceSender(), uiEventStream_, uiFactory_, useDelayForLatency_, networkFactories_->getTimerFactory(), client_->getMUCRegistry(), client_->getEntityCapsProvider(), client_->getMUCManager(), uiFactory_, profileSettings_);
client_->onMessageReceived.connect(boost::bind(&ChatsManager::handleIncomingMessage, chatsManager_, _1));
@@ -302,6 +307,7 @@ void MainController::handleConnected() {
rosterController_->setEnabled(true);
profileController_->setAvailable(true);
contactEditController_->setAvailable(true);
+ viewHistoryController_->setAvailable(true);
/* Send presence later to catch all the incoming presences. */
sendPresence(statusTracker_->getNextPresence());
/* Enable chats last of all, so rejoining MUCs has the right sent presence */
@@ -603,6 +609,9 @@ void MainController::setManagersOffline() {
if (contactEditController_) {
contactEditController_->setAvailable(false);
}
+ if (viewHistoryController_) {
+ viewHistoryController_->setAvailable(false);
+ }
}
void MainController::handleServerDiscoInfoResponse(boost::shared_ptr<DiscoInfo> info, ErrorPayload::ref error) {
diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h
index 21460ec..5d01fb7 100644
--- a/Swift/Controllers/MainController.h
+++ b/Swift/Controllers/MainController.h
@@ -44,6 +44,7 @@ namespace Swift {
class Notifier;
class ProfileController;
class ContactEditController;
+ class ViewHistoryController;
class TogglableNotifier;
class PresenceNotifier;
class EventNotifier;
@@ -144,6 +145,7 @@ namespace Swift {
ChatsManager* chatsManager_;
ProfileController* profileController_;
ContactEditController* contactEditController_;
+ ViewHistoryController* viewHistoryController_;
JID jid_;
JID boundJID_;
SystemTrayController* systemTrayController_;
diff --git a/Swift/Controllers/SConscript b/Swift/Controllers/SConscript
index a7df3a9..3bb4759 100644
--- a/Swift/Controllers/SConscript
+++ b/Swift/Controllers/SConscript
@@ -31,6 +31,7 @@ if env["SCONS_STAGE"] == "build" :
"MainController.cpp",
"ProfileController.cpp",
"ContactEditController.cpp",
+ "ViewHistoryController.cpp",
"Roster/RosterController.cpp",
"Roster/RosterGroupExpandinessPersister.cpp",
"Roster/ContactRosterItem.cpp",
diff --git a/Swift/Controllers/UIEvents/RequestViewHistoryUIEvent.h b/Swift/Controllers/UIEvents/RequestViewHistoryUIEvent.h
new file mode 100644
index 0000000..22ad2d8
--- /dev/null
+++ b/Swift/Controllers/UIEvents/RequestViewHistoryUIEvent.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2011 Vlad Voicu
+ * Licensed under the Simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#pragma once
+
+#include <Swiften/JID/JID.h>
+#include <Swift/Controllers/UIEvents/UIEvent.h>
+
+namespace Swift {
+ class RequestViewHistoryUIEvent : public UIEvent {
+ public:
+ typedef boost::shared_ptr <RequestViewHistoryUIEvent> ref;
+ RequestViewHistoryUIEvent(const JID& jid = NULL) : jid(jid) {
+ }
+
+ const JID& getJID() const {
+ return jid;
+ }
+ private:
+ JID jid;
+ };
+}
diff --git a/Swift/Controllers/UIInterfaces/UIFactory.h b/Swift/Controllers/UIInterfaces/UIFactory.h
index 57f55d0..2c321f5 100644
--- a/Swift/Controllers/UIInterfaces/UIFactory.h
+++ b/Swift/Controllers/UIInterfaces/UIFactory.h
@@ -17,6 +17,7 @@
#include <Swift/Controllers/UIInterfaces/XMLConsoleWidgetFactory.h>
#include <Swift/Controllers/UIInterfaces/ProfileWindowFactory.h>
#include <Swift/Controllers/UIInterfaces/ContactEditWindowFactory.h>
+#include <Swift/Controllers/UIInterfaces/ViewHistoryWindowFactory.h>
#include <Swift/Controllers/UIInterfaces/AdHocCommandWindowFactory.h>
namespace Swift {
@@ -32,6 +33,7 @@ namespace Swift {
public JoinMUCWindowFactory,
public ProfileWindowFactory,
public ContactEditWindowFactory,
+ public ViewHistoryWindowFactory,
public AdHocCommandWindowFactory {
public:
virtual ~UIFactory() {}
diff --git a/Swift/Controllers/UIInterfaces/ViewHistoryWindow.h b/Swift/Controllers/UIInterfaces/ViewHistoryWindow.h
new file mode 100644
index 0000000..18ac86e
--- /dev/null
+++ b/Swift/Controllers/UIInterfaces/ViewHistoryWindow.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2011 Vlad Voicu
+ * Licensed under the Simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/boost_bsignals.h>
+
+namespace Swift {
+ class ViewHistoryWindow {
+ public:
+ virtual ~ViewHistoryWindow() {};
+ virtual void setEnabled(bool b) = 0;
+ virtual void show() = 0;
+ virtual void hide() = 0;
+ };
+}
diff --git a/Swift/Controllers/UIInterfaces/ViewHistoryWindowFactory.h b/Swift/Controllers/UIInterfaces/ViewHistoryWindowFactory.h
new file mode 100644
index 0000000..a91e149
--- /dev/null
+++ b/Swift/Controllers/UIInterfaces/ViewHistoryWindowFactory.h
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2011 Vlad Voicu
+ * Licensed under the Simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#pragma once
+
+#include <Swift/Controllers/UIInterfaces/ViewHistoryWindow.h>
+
+namespace Swift {
+ class ViewHistoryWindowFactory {
+ public:
+ virtual ~ViewHistoryWindowFactory() {};
+ virtual ViewHistoryWindow* createViewHistoryWindow() = 0;
+ };
+}
diff --git a/Swift/Controllers/ViewHistoryController.cpp b/Swift/Controllers/ViewHistoryController.cpp
new file mode 100644
index 0000000..0aaacdf
--- /dev/null
+++ b/Swift/Controllers/ViewHistoryController.cpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011 Vlad Voicu
+ * Licensed under the Simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <Swift/Controllers/ViewHistoryController.h>
+
+#include <boost/bind.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swift/Controllers/UIEvents/RequestViewHistoryUIEvent.h>
+#include <Swift/Controllers/UIEvents/UIEventStream.h>
+#include <Swift/Controllers/UIInterfaces/ViewHistoryWindowFactory.h>
+#include <Swift/Controllers/Roster/RosterController.h>
+
+namespace Swift {
+
+ViewHistoryController::ViewHistoryController(RosterController* rosterController, ViewHistoryWindowFactory* viewHistoryWindowFactory, UIEventStream* uiEventStream): rosterController(rosterController), viewHistoryWindowFactory(viewHistoryWindowFactory), uiEventStream(uiEventStream), viewHistoryWindow(NULL) {
+ uiEventStream->onUIEvent.connect(boost::bind(&ViewHistoryController::handleUIEvent, this, _1));
+}
+
+ViewHistoryController::~ViewHistoryController() {
+
+}
+
+void ViewHistoryController::handleUIEvent(UIEvent::ref event) {
+ RequestViewHistoryUIEvent::ref viewHistoryEvent = boost::dynamic_pointer_cast<RequestViewHistoryUIEvent>(event);
+ if (!viewHistoryWindow) {
+ viewHistoryWindow = viewHistoryWindowFactory->createViewHistoryWindow();
+ }
+}
+
+void ViewHistoryController::setAvailable(bool b) {
+ if (viewHistoryWindow) {
+ viewHistoryWindow->setEnabled(b);
+ }
+}
+
+}
diff --git a/Swift/Controllers/ViewHistoryController.h b/Swift/Controllers/ViewHistoryController.h
new file mode 100644
index 0000000..f306d19
--- /dev/null
+++ b/Swift/Controllers/ViewHistoryController.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2011 Vlad Voicu
+ * Licensed under the Simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#pragma once
+
+#include <Swift/Controllers/UIEvents/UIEvent.h>
+
+namespace Swift {
+ class UIEventStream;
+ class ViewHistoryWindowFactory;
+ class ViewHistoryWindow;
+ class RosterController;
+ class ViewHistoryController {
+ public:
+ ViewHistoryController(RosterController* rosterController, ViewHistoryWindowFactory* viewHistoryWindowFactory, UIEventStream* uiEventStream);
+ ~ViewHistoryController();
+ void setAvailable(bool b);
+
+ private:
+ void handleUIEvent(UIEvent::ref event);
+ RosterController* rosterController;
+ ViewHistoryWindowFactory* viewHistoryWindowFactory;
+ UIEventStream* uiEventStream;
+ ViewHistoryWindow* viewHistoryWindow;
+
+ };
+}