diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-04-12 15:26:21 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-04-12 15:26:21 (GMT) |
commit | e34961aa9b20a745af6934c161ab956867602de2 (patch) | |
tree | f580042afa262362a8c5758f92201082dba8283b /Swift/Controllers | |
parent | fa47c498947e818438ec9c6318924d11c2ae6c84 (diff) | |
download | swift-contrib-e34961aa9b20a745af6934c161ab956867602de2.zip swift-contrib-e34961aa9b20a745af6934c161ab956867602de2.tar.bz2 |
Allow roster items to be deleted.
Resolves: #296
Diffstat (limited to 'Swift/Controllers')
-rw-r--r-- | Swift/Controllers/RosterController.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
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<UserRosterAction> action) { boost::shared_ptr<OpenChatRosterAction> chatAction = boost::dynamic_pointer_cast<OpenChatRosterAction>(action); - if (chatAction.get() != NULL) { + if (chatAction) { ContactRosterItem *contactItem = dynamic_cast<ContactRosterItem*>(chatAction->getRosterItem()); assert(contactItem); onStartChatRequest(contactItem->getJID().toBare()); @@ -111,10 +111,17 @@ void RosterController::handleUserAction(boost::shared_ptr<UserRosterAction> acti } boost::shared_ptr<RemoveItemRosterAction> removeAction = boost::dynamic_pointer_cast<RemoveItemRosterAction>(action); - if (removeAction.get() != NULL) { - ContactRosterItem *contactItem = dynamic_cast<ContactRosterItem*>(chatAction->getRosterItem()); + if (removeAction) { + ContactRosterItem *contactItem = dynamic_cast<ContactRosterItem*>(removeAction->getRosterItem()); assert(contactItem); - //FIXME: remove it + + RosterItemPayload item(contactItem->getJID(), "", RosterItemPayload::Remove); + boost::shared_ptr<RosterPayload> roster(new RosterPayload()); + roster->addItem(item); + boost::shared_ptr<SetRosterRequest> 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<UIEvent> event) { } void RosterController::handleRosterSetError(boost::optional<ErrorPayload> error, boost::shared_ptr<RosterPayload> 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(); |