From fa47c498947e818438ec9c6318924d11c2ae6c84 Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Mon, 12 Apr 2010 15:05:57 +0000 Subject: Allow ErrorEvents into the EventController (display them to the user). diff --git a/Swift/Controllers/EventController.cpp b/Swift/Controllers/EventController.cpp index 70d56c7..bf24ff0 100644 --- a/Swift/Controllers/EventController.cpp +++ b/Swift/Controllers/EventController.cpp @@ -10,6 +10,7 @@ #include #include "Swiften/Events/MessageEvent.h" +#include "Swiften/Events/ErrorEvent.h" #include "Swiften/Events/SubscriptionRequestEvent.h" namespace Swift { @@ -20,7 +21,8 @@ EventController::EventController() { void EventController::handleIncomingEvent(boost::shared_ptr sourceEvent) { boost::shared_ptr messageEvent = boost::dynamic_pointer_cast(sourceEvent); boost::shared_ptr subscriptionEvent = boost::dynamic_pointer_cast(sourceEvent); - if ((messageEvent && messageEvent->isReadable()) || subscriptionEvent) { + boost::shared_ptr errorEvent = boost::dynamic_pointer_cast(sourceEvent); + if ((messageEvent && messageEvent->isReadable()) || subscriptionEvent || errorEvent) { events_.push_back(sourceEvent); sourceEvent->onConclusion.connect(boost::bind(&EventController::handleEventConcluded, this, sourceEvent)); onEventQueueLengthChange(events_.size()); diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index 33928f8..e8c6c94 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -353,9 +353,11 @@ void MainController::handleError(const ClientError& error) { signOut(); loginWindow_->setMessage(message); } else { + std::cout << "Yay, error" << std::endl; if (!lastDisconnectError_) { - message = "Disconnected from " + jid_.getDomain() + ": "; + message = "Disconnected from " + jid_.getDomain() + ": " + message; lastDisconnectError_ = boost::shared_ptr(new ErrorEvent(JID(jid_.getDomain()), message)); + std::cout << message << std::endl; eventController_->handleIncomingEvent(lastDisconnectError_); } } diff --git a/Swift/QtUI/EventViewer/EventView.pri b/Swift/QtUI/EventViewer/EventView.pri index 017f498..3676905 100644 --- a/Swift/QtUI/EventViewer/EventView.pri +++ b/Swift/QtUI/EventViewer/EventView.pri @@ -2,10 +2,12 @@ SOURCES += $$PWD/EventDelegate.cpp \ $$PWD/EventModel.cpp \ $$PWD/EventView.cpp \ $$PWD/QtEventWindow.cpp \ - $$PWD/QtEvent.cpp + $$PWD/QtEvent.cpp \ + $$PWD/../QtSubscriptionRequestWindow.cpp HEADERS += $$PWD/EventDelegate.h \ $$PWD/EventModel.h \ $$PWD/EventView.h \ $$PWD/QtEventWindow.h \ - $$PWD/QtEvent.h + $$PWD/QtEvent.h \ + $$PWD/../QtSubscriptionRequestWindow.h diff --git a/Swift/QtUI/EventViewer/EventView.pro b/Swift/QtUI/EventViewer/EventView.pro index 942f0ba..3addbde 100644 --- a/Swift/QtUI/EventViewer/EventView.pro +++ b/Swift/QtUI/EventViewer/EventView.pro @@ -8,7 +8,7 @@ INCLUDEPATH += ../. ../../.. ../../../3rdParty/Boost/src DEFINES += BOOST_SIGNALS_NAMESPACE=bsignals BOOST_ALL_NO_LIB -#LIBS += ../../Controllers/Controllers.a +LIBS += ../../Controllers/libSwiftControllers.a LIBS += ../../../Swiften/libSwiften.a LIBS += ../../../3rdParty/Boost/libBoost.a LIBS += ../../../3rdParty/LibIDN/libIDN.a diff --git a/Swift/QtUI/EventViewer/main.cpp b/Swift/QtUI/EventViewer/main.cpp index ec96561..afdb442 100644 --- a/Swift/QtUI/EventViewer/main.cpp +++ b/Swift/QtUI/EventViewer/main.cpp @@ -10,18 +10,22 @@ #include "QtEventWindow.h" #include "Swiften/Events/MessageEvent.h" +#include "Swiften/Events/ErrorEvent.h" +#include "Swiften/JID/JID.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); - Swift::QtEventWindow* viewer = new Swift::QtEventWindow(); + Swift::UIEventStream eventStream; + Swift::QtEventWindow* viewer = new Swift::QtEventWindow(&eventStream); viewer->show(); boost::shared_ptr message1(new Swift::Message()); message1->setBody("Oooh, shiny"); boost::shared_ptr event1(new Swift::MessageEvent(message1)); - viewer->addEvent(boost::dynamic_pointer_cast(event1), true); + viewer->addEvent(boost::dynamic_pointer_cast(event1), true); for (int i = 0; i < 100; i++) { - viewer->addEvent(boost::dynamic_pointer_cast(event1), false); + viewer->addEvent(boost::dynamic_pointer_cast(event1), false); } + viewer->addEvent(boost::dynamic_pointer_cast(boost::shared_ptr(new Swift::ErrorEvent(Swift::JID("me@example.com"), "Something bad did happen to you."))), true); return app.exec(); } -- cgit v0.10.2-6-g49f6