summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/Controllers/Roster')
-rw-r--r--Swift/Controllers/Roster/RosterController.cpp16
-rw-r--r--Swift/Controllers/Roster/RosterController.h1
2 files changed, 16 insertions, 1 deletions
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
@@ -276,36 +276,50 @@ void RosterController::setContactGroups(const JID& jid, const std::vector<std::s
void RosterController::updateItem(const XMPPRosterItem& item) {
RosterItemPayload itemPayload(item.getJID(), item.getName(), item.getSubscription());
itemPayload.setGroups(item.getGroups());
RosterPayload::ref roster = boost::make_shared<RosterPayload>();
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();
}
void RosterController::initBlockingCommand() {
boost::shared_ptr<BlockList> blockList = clientBlockListManager_->getBlockList();
blockingOnStateChangedConnection_ = blockList->onStateChanged.connect(boost::bind(&RosterController::handleBlockingStateChanged, this));
blockingOnItemAddedConnection_ = blockList->onItemAdded.connect(boost::bind(&RosterController::handleBlockingItemAdded, this, _1));
blockingOnItemRemovedConnection_ = blockList->onItemRemoved.connect(boost::bind(&RosterController::handleBlockingItemRemoved, this, _1));
roster_->setBlockingSupported(true);
if (blockList->getState() == BlockList::Available) {
foreach(const JID& jid, blockList->getItems()) {
roster_->applyOnItems(SetBlockingState(jid, ContactRosterItem::IsBlocked));
}
}
}
+void RosterController::handleRosterItemUpdated(ErrorPayload::ref error, boost::shared_ptr<RosterPayload> rosterPayload) {
+ if (!!error) {
+ handleRosterSetError(error, rosterPayload);
+ }
+ boost::shared_ptr<BlockList> blockList = clientBlockListManager_->getBlockList();
+ std::vector<RosterItemPayload> items = rosterPayload->getItems();
+ if (blockList->getState() == BlockList::Available && items.size() > 0) {
+ std::vector<JID> 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> rosterPayload) {
if (!error) {
return;
}
std::string text = str(format(QT_TRANSLATE_NOOP("", "Server %1% rejected contact list change to item '%2%'")) % myJID_.getDomain() % rosterPayload->getItems()[0].getJID().toString());
if (!error->getText().empty()) {
text += ": " + error->getText();
}
boost::shared_ptr<ErrorEvent> errorEvent(new ErrorEvent(JID(myJID_.getDomain()), text));
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
@@ -74,18 +74,19 @@ namespace Swift {
void handleOnJIDUpdated(const JID &jid, const std::string& oldName, const std::vector<std::string>& oldGroups);
void handleStartChatRequest(const JID& contact);
void handleChangeStatusRequest(StatusShow::Type show, const std::string &statusText);
void handleShowOfflineToggled(bool state);
void handleIncomingPresence(boost::shared_ptr<Presence> newPresence);
void handleSubscriptionRequest(const JID& jid, const std::string& message);
void handleSubscriptionRequestAccepted(SubscriptionRequestEvent* event);
void handleSubscriptionRequestDeclined(SubscriptionRequestEvent* event);
void handleUIEvent(boost::shared_ptr<UIEvent> event);
+ void handleRosterItemUpdated(ErrorPayload::ref error, boost::shared_ptr<RosterPayload> rosterPayload);
void handleRosterSetError(ErrorPayload::ref error, boost::shared_ptr<RosterPayload> rosterPayload);
void applyAllPresenceTo(const JID& jid);
void handleEditProfileRequest();
void handleOnCapsChanged(const JID& jid);
void handleSettingChanged(const std::string& settingPath);
void handleBlockingStateChanged();
void handleBlockingItemAdded(const JID& jid);
void handleBlockingItemRemoved(const JID& jid);