summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCatalin Badea <catalin.badea392@gmail.com>2012-06-26 07:56:42 (GMT)
committerCatalin Badea <catalin.badea392@gmail.com>2012-06-26 07:56:42 (GMT)
commit88ef15d265a9ff9ab40ac5d90d14af08b0f8c4dd (patch)
treefd349b0adb02c8b0c956154efa7ebf915b1ebe4f /Swift/Controllers/HistoryViewController.cpp
parentcba5a2aa6db557102998028977e4d84d25181304 (diff)
downloadswift-contrib-88ef15d265a9ff9ab40ac5d90d14af08b0f8c4dd.zip
swift-contrib-88ef15d265a9ff9ab40ac5d90d14af08b0f8c4dd.tar.bz2
Use seperate controllers for viewing/handling history
Diffstat (limited to 'Swift/Controllers/HistoryViewController.cpp')
-rw-r--r--Swift/Controllers/HistoryViewController.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/Swift/Controllers/HistoryViewController.cpp b/Swift/Controllers/HistoryViewController.cpp
new file mode 100644
index 0000000..cbfa687
--- /dev/null
+++ b/Swift/Controllers/HistoryViewController.cpp
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2012 Catalin Badea
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <Swift/Controllers/HistoryViewController.h>
+
+#include <Swift/Controllers/UIInterfaces/HistoryWindowFactory.h>
+#include <Swift/Controllers/UIEvents/RequestHistoryUIEvent.h>
+
+namespace Swift {
+
+HistoryViewController::HistoryViewController(UIEventStream* uiEventStream, HistoryWindowFactory* historyWindowFactory) : uiEventStream_(uiEventStream), historyWindowFactory_(historyWindowFactory), historyWindow_(NULL) {
+ uiEventStream_->onUIEvent.connect(boost::bind(&HistoryViewController::handleUIEvent, this, _1));
+}
+
+HistoryViewController::~HistoryViewController() {
+ uiEventStream_->onUIEvent.disconnect(boost::bind(&HistoryViewController::handleUIEvent, this, _1));
+ delete historyWindow_;
+ delete roster_;
+}
+
+void HistoryViewController::handleUIEvent(boost::shared_ptr<UIEvent> rawEvent) {
+ boost::shared_ptr<RequestHistoryUIEvent> event = boost::dynamic_pointer_cast<RequestHistoryUIEvent>(rawEvent);
+ if (event != NULL) {
+ if (historyWindow_ == NULL) {
+ historyWindow_ = historyWindowFactory_->createHistoryWindow(uiEventStream_);
+ roster_ = new Roster(false, true);
+ historyWindow_->setRosterModel(roster_);
+
+ JID putin("vputin@karla.com");
+ JID medvedev("dmedvedev@karla.com");
+ JID kev("kevin@doomsong.co.uk");
+ const std::set<ContactRosterItem::Feature> none;
+ roster_->addContact(putin, putin, "Vladimir Putin", "Recent", "");
+ roster_->addContact(medvedev, medvedev, "Dmitri Medvedev", "Recent", "");
+ roster_->addContact(kev, kev, "Kev", "Recent", "");
+ }
+ historyWindow_->activate();
+ }
+}
+
+}