diff options
-rw-r--r-- | Swift/Controllers/MainController.cpp | 3 | ||||
-rw-r--r-- | Swift/Controllers/RosterController.cpp | 5 | ||||
-rw-r--r-- | Swift/Controllers/RosterController.h | 1 | ||||
-rw-r--r-- | Swift/Controllers/XMPPRosterController.cpp | 1 | ||||
-rw-r--r-- | Swiften/Roster/XMPPRoster.cpp | 5 | ||||
-rw-r--r-- | Swiften/Roster/XMPPRoster.h | 2 |
6 files changed, 16 insertions, 1 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index 7cd4304..b94022e 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -247,7 +247,6 @@ void MainController::handleConnected() { avatarManager_->setMUCRegistry(chatsManager_); xmppRosterController_ = new XMPPRosterController(client_, xmppRoster_); - xmppRosterController_->requestRoster(); eventWindowController_ = new EventWindowController(eventController_, eventWindowFactory_); @@ -267,6 +266,8 @@ void MainController::handleConnected() { mucSearchController_ = new MUCSearchController(jid_, uiEventStream_, mucSearchWindowFactory_, client_); } + xmppRosterController_->requestRoster(); + boost::shared_ptr<GetDiscoInfoRequest> discoInfoRequest(new GetDiscoInfoRequest(JID(), client_)); discoInfoRequest->onResponse.connect(boost::bind(&MainController::handleServerDiscoInfoResponse, this, _1, _2)); discoInfoRequest->send(); diff --git a/Swift/Controllers/RosterController.cpp b/Swift/Controllers/RosterController.cpp index 5ba00e4..87b0b74 100644 --- a/Swift/Controllers/RosterController.cpp +++ b/Swift/Controllers/RosterController.cpp @@ -49,6 +49,7 @@ RosterController::RosterController(const JID& jid, boost::shared_ptr<XMPPRoster> xmppRoster_->onJIDAdded.connect(boost::bind(&RosterController::handleOnJIDAdded, this, _1)); xmppRoster_->onJIDUpdated.connect(boost::bind(&RosterController::handleOnJIDUpdated, this, _1, _2, _3)); xmppRoster_->onJIDRemoved.connect(boost::bind(&RosterController::handleOnJIDRemoved, this, _1)); + xmppRoster_->onRosterCleared.connect(boost::bind(&RosterController::handleRosterCleared, this)); presenceOracle_->onPresenceSubscriptionRequest.connect(boost::bind(&RosterController::handleSubscriptionRequest, this, _1, _2)); presenceOracle_->onPresenceChange.connect(boost::bind(&RosterController::handleIncomingPresence, this, _1, _2)); uiEventConnection_ = uiEventStream->onUIEvent.connect(boost::bind(&RosterController::handleUIEvent, this, _1)); @@ -117,6 +118,10 @@ void RosterController::handleOnJIDAdded(const JID& jid) { } } +void RosterController::handleRosterCleared() { + roster_->removeAll(); +} + void RosterController::handleOnJIDRemoved(const JID& jid) { roster_->removeContact(jid); } diff --git a/Swift/Controllers/RosterController.h b/Swift/Controllers/RosterController.h index 18f6c92..7e2b3da 100644 --- a/Swift/Controllers/RosterController.h +++ b/Swift/Controllers/RosterController.h @@ -45,6 +45,7 @@ namespace Swift { void setEnabled(bool enabled); private: void handleOnJIDAdded(const JID &jid); + void handleRosterCleared(); void handleOnJIDRemoved(const JID &jid); void handleOnJIDUpdated(const JID &jid, const String& oldName, const std::vector<String> oldGroups); void handleStartChatRequest(const JID& contact); diff --git a/Swift/Controllers/XMPPRosterController.cpp b/Swift/Controllers/XMPPRosterController.cpp index de5ff8c..c107315 100644 --- a/Swift/Controllers/XMPPRosterController.cpp +++ b/Swift/Controllers/XMPPRosterController.cpp @@ -28,6 +28,7 @@ XMPPRosterController::XMPPRosterController(IQRouter* iqRouter, boost::shared_ptr } void XMPPRosterController::requestRoster() { + xmppRoster_->clear(); boost::shared_ptr<GetRosterRequest> rosterRequest(new GetRosterRequest(iqRouter_)); rosterRequest->onResponse.connect(boost::bind(&XMPPRosterController::handleRosterReceived, this, _1)); rosterRequest->send(); diff --git a/Swiften/Roster/XMPPRoster.cpp b/Swiften/Roster/XMPPRoster.cpp index 4478f86..28b04c6 100644 --- a/Swiften/Roster/XMPPRoster.cpp +++ b/Swiften/Roster/XMPPRoster.cpp @@ -34,6 +34,11 @@ void XMPPRoster::removeContact(const JID& jid) { onJIDRemoved(jid); } +void XMPPRoster::clear() { + entries_.clear(); + onRosterCleared(); +} + bool XMPPRoster::containsJID(const JID& jid) { return entries_.find(JID(jid.toBare())) != entries_.end(); } diff --git a/Swiften/Roster/XMPPRoster.h b/Swiften/Roster/XMPPRoster.h index 97477bc..e449d28 100644 --- a/Swiften/Roster/XMPPRoster.h +++ b/Swiften/Roster/XMPPRoster.h @@ -32,6 +32,7 @@ class XMPPRoster { void addContact(const JID& jid, const String& name, const std::vector<String>& groups, const RosterItemPayload::Subscription subscription); bool containsJID(const JID& jid); void removeContact(const JID& jid); + void clear(); RosterItemPayload::Subscription getSubscriptionStateForJID(const JID& jid); const String& getNameForJID(const JID& jid); const std::vector<String>& getGroupsForJID(const JID& jid); @@ -39,6 +40,7 @@ class XMPPRoster { boost::signal<void (const JID&)> onJIDAdded; boost::signal<void (const JID&)> onJIDRemoved; boost::signal<void (const JID&, const String&, const std::vector<String>&)> onJIDUpdated; + boost::signal<void ()> onRosterCleared; private: //std::map<JID, std::pair<String, std::vector<String> > > entries_; |