summaryrefslogtreecommitdiffstats
path: root/Swift
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
parent8fe56244a23cd13ba9bafc439b1e502dfd3f82df (diff)
downloadswift-contrib-1fe7e5991c8d1601874f47d9d7038eafb568f6f2.zip
swift-contrib-1fe7e5991c8d1601874f47d9d7038eafb568f6f2.tar.bz2
added controllers for the History Window
Diffstat (limited to 'Swift')
-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
-rw-r--r--Swift/QtUI/QtUIFactory.cpp6
-rw-r--r--Swift/QtUI/QtUIFactory.h2
-rw-r--r--Swift/QtUI/QtViewHistoryWindow.cpp31
-rw-r--r--Swift/QtUI/QtViewHistoryWindow.h28
-rw-r--r--Swift/QtUI/Roster/QtTreeWidget.cpp3
-rw-r--r--Swift/QtUI/SConscript1
15 files changed, 215 insertions, 1 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;
+
+ };
+}
diff --git a/Swift/QtUI/QtUIFactory.cpp b/Swift/QtUI/QtUIFactory.cpp
index 40ce95e..f5772bf 100644
--- a/Swift/QtUI/QtUIFactory.cpp
+++ b/Swift/QtUI/QtUIFactory.cpp
@@ -7,6 +7,7 @@
#include "QtUIFactory.h"
#include <QSplitter>
+#include <QtDebug>
#include "QtXMLConsoleWidget.h"
#include "QtChatTabs.h"
@@ -23,6 +24,7 @@
#include "UserSearch/QtUserSearchWindow.h"
#include "QtProfileWindow.h"
#include "QtContactEditWindow.h"
+#include "QtViewHistoryWindow.h"
#include "QtAdHocCommandWindow.h"
#define CHATWINDOW_FONT_SIZE "chatWindowFontSize"
@@ -124,6 +126,10 @@ ContactEditWindow* QtUIFactory::createContactEditWindow() {
return new QtContactEditWindow();
}
+ViewHistoryWindow* QtUIFactory::createViewHistoryWindow() {
+ return new QtViewHistoryWindow();
+}
+
void QtUIFactory::createAdHocCommandWindow(boost::shared_ptr<OutgoingAdHocCommandSession> command) {
new QtAdHocCommandWindow(command);
}
diff --git a/Swift/QtUI/QtUIFactory.h b/Swift/QtUI/QtUIFactory.h
index a576ded..895440a 100644
--- a/Swift/QtUI/QtUIFactory.h
+++ b/Swift/QtUI/QtUIFactory.h
@@ -39,6 +39,7 @@ namespace Swift {
virtual JoinMUCWindow* createJoinMUCWindow();
virtual ProfileWindow* createProfileWindow();
virtual ContactEditWindow* createContactEditWindow();
+ virtual ViewHistoryWindow* createViewHistoryWindow();
virtual void createAdHocCommandWindow(boost::shared_ptr<OutgoingAdHocCommandSession> command);
private slots:
@@ -51,6 +52,7 @@ namespace Swift {
QSplitter* netbookSplitter;
QtSystemTray* systemTray;
QtChatWindowFactory* chatWindowFactory;
+ QtChatWindowFactory* viewHistoryFactory;
QtMainWindow* lastMainWindow;
QtLoginWindow* loginWindow;
std::vector<QPointer<QtChatWindow> > chatWindows;
diff --git a/Swift/QtUI/QtViewHistoryWindow.cpp b/Swift/QtUI/QtViewHistoryWindow.cpp
new file mode 100644
index 0000000..2f3bd9e
--- /dev/null
+++ b/Swift/QtUI/QtViewHistoryWindow.cpp
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2011 Vlad Voicu
+ * Licensed under the Simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include "QtViewHistoryWindow.h"
+#include <QWidget>
+#include "QtDebug"
+#include <QBoxLayout>
+
+namespace Swift {
+
+QtViewHistoryWindow::QtViewHistoryWindow() {
+ qDebug() << "I am here";
+}
+
+void QtViewHistoryWindow::show() {
+ QWidget::show();
+ QWidget::activateWindow();
+}
+
+void QtViewHistoryWindow::hide() {
+ QWidget::hide();
+}
+
+void QtViewHistoryWindow::setEnabled(bool b) {
+ QWidget::setEnabled(b);
+}
+
+}
diff --git a/Swift/QtUI/QtViewHistoryWindow.h b/Swift/QtUI/QtViewHistoryWindow.h
new file mode 100644
index 0000000..3fcd7e4
--- /dev/null
+++ b/Swift/QtUI/QtViewHistoryWindow.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2011 Vlad Voicu
+ * Licensed under the Simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#pragma once
+
+#include <QWidget>
+
+#include <Swift/Controllers/UIInterfaces/ViewHistoryWindow.h>
+
+#include <Swiften/JID/JID.h>
+
+namespace Swift {
+ class QtViewHistoryWindow : public QWidget, public ViewHistoryWindow {
+ Q_OBJECT
+ public:
+ QtViewHistoryWindow();
+ void show();
+ void hide();
+ void setEnabled(bool b);
+
+ private:
+ JID jid_;
+ };
+}
+
diff --git a/Swift/QtUI/Roster/QtTreeWidget.cpp b/Swift/QtUI/Roster/QtTreeWidget.cpp
index dcf5bfc..aeaca1a 100644
--- a/Swift/QtUI/Roster/QtTreeWidget.cpp
+++ b/Swift/QtUI/Roster/QtTreeWidget.cpp
@@ -17,6 +17,7 @@
#include "Swift/Controllers/UIEvents/UIEventStream.h"
#include "Swift/Controllers/UIEvents/RequestChatUIEvent.h"
#include "Swift/Controllers/UIEvents/RequestContactEditorUIEvent.h"
+#include "Swift/Controllers/UIEvents/RequestViewHistoryUIEvent.h"
#include "Swift/Controllers/UIEvents/RemoveRosterItemUIEvent.h"
#include "Swift/Controllers/UIEvents/RenameGroupUIEvent.h"
#include "QtSwiftUtil.h"
@@ -154,7 +155,7 @@ void QtTreeWidget::contextMenuEvent(QContextMenuEvent* event) {
}
}
else if (result == viewHistory) {
- //TODO Handle history request
+ eventStream_->send(boost::make_shared<RequestViewHistoryUIEvent>(contact->getJID()));
}
}
else if (GroupRosterItem* group = dynamic_cast<GroupRosterItem*>(item)) {
diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript
index 6157cab..e475388 100644
--- a/Swift/QtUI/SConscript
+++ b/Swift/QtUI/SConscript
@@ -90,6 +90,7 @@ sources = [
"QtAddBookmarkWindow.cpp",
"QtEditBookmarkWindow.cpp",
"QtContactEditWindow.cpp",
+ "QtViewHistoryWindow.cpp",
"QtContactEditWidget.cpp",
"ChatSnippet.cpp",
"MessageSnippet.cpp",