From 170e408e18579ceac6520a404ad945fcda404248 Mon Sep 17 00:00:00 2001 From: Richard Maudsley Date: Mon, 14 Jul 2014 15:53:35 +0100 Subject: Fix renaming contact group makes blocked user appear to be unblocked. Test-Information: Block a user and rename the group then verify that the user still appears as blocked in the roster. Try renaming a group with several users in various states of blocked and unblocked and verify that the states are preserved after renaming. Change-Id: I93ff721b053f299d5f1c3f62dd8687f021701fe1 diff --git a/Swift/Controllers/Roster/RosterController.cpp b/Swift/Controllers/Roster/RosterController.cpp index ecca9fe..e823a1c 100644 --- a/Swift/Controllers/Roster/RosterController.cpp +++ b/Swift/Controllers/Roster/RosterController.cpp @@ -282,7 +282,7 @@ void RosterController::updateItem(const XMPPRosterItem& item) { roster->addItem(itemPayload); SetRosterRequest::ref request = SetRosterRequest::create(roster, iqRouter_); - request->onResponse.connect(boost::bind(&RosterController::handleRosterSetError, this, _1, roster)); + request->onResponse.connect(boost::bind(&RosterController::handleRosterItemUpdated, this, _1, roster)); request->send(); } @@ -300,6 +300,20 @@ void RosterController::initBlockingCommand() { } } +void RosterController::handleRosterItemUpdated(ErrorPayload::ref error, boost::shared_ptr rosterPayload) { + if (!!error) { + handleRosterSetError(error, rosterPayload); + } + boost::shared_ptr blockList = clientBlockListManager_->getBlockList(); + std::vector items = rosterPayload->getItems(); + if (blockList->getState() == BlockList::Available && items.size() > 0) { + std::vector jids = blockList->getItems(); + if (std::find(jids.begin(), jids.end(), items[0].getJID()) != jids.end()) { + roster_->applyOnItems(SetBlockingState(items[0].getJID(), ContactRosterItem::IsBlocked)); + } + } +} + void RosterController::handleRosterSetError(ErrorPayload::ref error, boost::shared_ptr rosterPayload) { if (!error) { return; diff --git a/Swift/Controllers/Roster/RosterController.h b/Swift/Controllers/Roster/RosterController.h index d0c7024..3338d7f 100644 --- a/Swift/Controllers/Roster/RosterController.h +++ b/Swift/Controllers/Roster/RosterController.h @@ -80,6 +80,7 @@ namespace Swift { void handleSubscriptionRequestAccepted(SubscriptionRequestEvent* event); void handleSubscriptionRequestDeclined(SubscriptionRequestEvent* event); void handleUIEvent(boost::shared_ptr event); + void handleRosterItemUpdated(ErrorPayload::ref error, boost::shared_ptr rosterPayload); void handleRosterSetError(ErrorPayload::ref error, boost::shared_ptr rosterPayload); void applyAllPresenceTo(const JID& jid); void handleEditProfileRequest(); -- cgit v0.10.2-6-g49f6