summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-04-12 13:47:07 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-04-12 13:47:07 (GMT)
commita65372d1a0a85d04329cd91bcf6bdff2de492c80 (patch)
treee9ac9af516f402aa4ee62027894a28da5cab98ec /Swift
parented38ddf609f1190ecb2aebb5e23ead115e6a6a8d (diff)
downloadswift-contrib-a65372d1a0a85d04329cd91bcf6bdff2de492c80.zip
swift-contrib-a65372d1a0a85d04329cd91bcf6bdff2de492c80.tar.bz2
Show ErrorEvent when roster push fails.
Resolves: #293
Diffstat (limited to 'Swift')
-rw-r--r--Swift/Controllers/RosterController.cpp8
-rw-r--r--Swift/QtUI/EventViewer/QtEvent.cpp5
-rw-r--r--Swift/QtUI/EventViewer/QtEventWindow.cpp4
3 files changed, 16 insertions, 1 deletions
diff --git a/Swift/Controllers/RosterController.cpp b/Swift/Controllers/RosterController.cpp
index 6ddabc2..ab1f1fb 100644
--- a/Swift/Controllers/RosterController.cpp
+++ b/Swift/Controllers/RosterController.cpp
@@ -15,6 +15,7 @@
#include "Swiften/Queries/Requests/GetRosterRequest.h"
#include "Swiften/Queries/Requests/SetRosterRequest.h"
#include "Swiften/Events/SubscriptionRequestEvent.h"
+#include "Swiften/Events/ErrorEvent.h"
#include "Swiften/Presence/PresenceOracle.h"
#include "Swift/Controllers/EventController.h"
#include "Swiften/Queries/IQRouter.h"
@@ -180,7 +181,12 @@ void RosterController::handleUIEvent(boost::shared_ptr<UIEvent> event) {
}
void RosterController::handleRosterSetError(boost::optional<ErrorPayload> error, boost::shared_ptr<RosterPayload> rosterPayload) {
- //FIXME: Create error events.
+ String text = "Server " + myJID_.getDomain() + " rejected roster change to item '" + rosterPayload->getItems()[0].getJID() + "'";
+ if (!error->getText().isEmpty()) {
+ text += ": " + error->getText();
+ }
+ boost::shared_ptr<ErrorEvent> errorEvent(new ErrorEvent(JID(myJID_.getDomain()), text));
+ eventController_->handleIncomingEvent(errorEvent);
}
void RosterController::handleIncomingPresence(boost::shared_ptr<Presence> newPresence, boost::shared_ptr<Presence> /*oldPresence*/) {
diff --git a/Swift/QtUI/EventViewer/QtEvent.cpp b/Swift/QtUI/EventViewer/QtEvent.cpp
index 91df26f..76875ae 100644
--- a/Swift/QtUI/EventViewer/QtEvent.cpp
+++ b/Swift/QtUI/EventViewer/QtEvent.cpp
@@ -7,6 +7,7 @@
#include "Swift/QtUI/EventViewer/QtEvent.h"
#include "Swiften/Events/MessageEvent.h"
+#include "Swiften/Events/ErrorEvent.h"
#include "Swiften/Events/SubscriptionRequestEvent.h"
#include "Swift/QtUI/QtSwiftUtil.h"
@@ -41,6 +42,10 @@ QString QtEvent::text() {
String message = subscriptionRequestEvent->getJID().toBare().toString() + " would like to add you to their roster" + (reason.isEmpty() ? "." : ", saying '" + reason + "'.");
return P2QSTRING(message);
}
+ boost::shared_ptr<ErrorEvent> errorEvent = boost::dynamic_pointer_cast<ErrorEvent>(event_);
+ if (errorEvent) {
+ return P2QSTRING(errorEvent->getText());
+ }
return "";
}
diff --git a/Swift/QtUI/EventViewer/QtEventWindow.cpp b/Swift/QtUI/EventViewer/QtEventWindow.cpp
index 84758ae..65b946a 100644
--- a/Swift/QtUI/EventViewer/QtEventWindow.cpp
+++ b/Swift/QtUI/EventViewer/QtEventWindow.cpp
@@ -10,6 +10,7 @@
#include <QtDebug>
#include "Swiften/Events/MessageEvent.h"
+#include "Swiften/Events/ErrorEvent.h"
#include "Swift/QtUI/QtSubscriptionRequestWindow.h"
#include "Swiften/Events/SubscriptionRequestEvent.h"
#include "Swift/Controllers/UIEvents/RequestChatUIEvent.h"
@@ -44,12 +45,15 @@ void QtEventWindow::handleItemActivated(const QModelIndex& item) {
QtEvent* event = model_->getItem(item.row());
boost::shared_ptr<MessageEvent> messageEvent = boost::dynamic_pointer_cast<MessageEvent>(event->getEvent());
boost::shared_ptr<SubscriptionRequestEvent> subscriptionEvent = boost::dynamic_pointer_cast<SubscriptionRequestEvent>(event->getEvent());
+ boost::shared_ptr<ErrorEvent> errorEvent = boost::dynamic_pointer_cast<ErrorEvent>(event->getEvent());
if (messageEvent) {
eventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(messageEvent->getStanza()->getFrom())));
} else if (subscriptionEvent) {
QtSubscriptionRequestWindow* window = QtSubscriptionRequestWindow::getWindow(subscriptionEvent, this);
window->show();
+ } else if (errorEvent) {
+ errorEvent->onConclusion();
} else {
qWarning() << "Trying to activate an unexpected event";
}