From e34961aa9b20a745af6934c161ab956867602de2 Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Mon, 12 Apr 2010 15:26:21 +0000 Subject: Allow roster items to be deleted. Resolves: #296 diff --git a/Swift/Controllers/RosterController.cpp b/Swift/Controllers/RosterController.cpp index ab1f1fb..c9ba612 100644 --- a/Swift/Controllers/RosterController.cpp +++ b/Swift/Controllers/RosterController.cpp @@ -103,7 +103,7 @@ void RosterController::handleChangeStatusRequest(StatusShow::Type show, const St void RosterController::handleUserAction(boost::shared_ptr action) { boost::shared_ptr chatAction = boost::dynamic_pointer_cast(action); - if (chatAction.get() != NULL) { + if (chatAction) { ContactRosterItem *contactItem = dynamic_cast(chatAction->getRosterItem()); assert(contactItem); onStartChatRequest(contactItem->getJID().toBare()); @@ -111,10 +111,17 @@ void RosterController::handleUserAction(boost::shared_ptr acti } boost::shared_ptr removeAction = boost::dynamic_pointer_cast(action); - if (removeAction.get() != NULL) { - ContactRosterItem *contactItem = dynamic_cast(chatAction->getRosterItem()); + if (removeAction) { + ContactRosterItem *contactItem = dynamic_cast(removeAction->getRosterItem()); assert(contactItem); - //FIXME: remove it + + RosterItemPayload item(contactItem->getJID(), "", RosterItemPayload::Remove); + boost::shared_ptr roster(new RosterPayload()); + roster->addItem(item); + boost::shared_ptr request(new SetRosterRequest(roster, iqRouter_)); + request->onResponse.connect(boost::bind(&RosterController::handleRosterSetError, this, _1, roster)); + request->send(); + return; } } @@ -181,6 +188,9 @@ void RosterController::handleUIEvent(boost::shared_ptr event) { } void RosterController::handleRosterSetError(boost::optional error, boost::shared_ptr rosterPayload) { + if (!error) { + return; + } String text = "Server " + myJID_.getDomain() + " rejected roster change to item '" + rosterPayload->getItems()[0].getJID() + "'"; if (!error->getText().isEmpty()) { text += ": " + error->getText(); -- cgit v0.10.2-6-g49f6