diff options
Diffstat (limited to 'Swiften')
-rw-r--r-- | Swiften/Roster/Roster.cpp | 12 | ||||
-rw-r--r-- | Swiften/Roster/Roster.h | 1 | ||||
-rw-r--r-- | Swiften/Roster/XMPPRoster.cpp | 5 | ||||
-rw-r--r-- | Swiften/Roster/XMPPRoster.h | 2 |
4 files changed, 18 insertions, 2 deletions
diff --git a/Swiften/Roster/Roster.cpp b/Swiften/Roster/Roster.cpp index b09964c..28245af 100644 --- a/Swiften/Roster/Roster.cpp +++ b/Swiften/Roster/Roster.cpp @@ -72,6 +72,18 @@ void Roster::removeContact(const JID& jid) { } } +void Roster::removeContactFromGroup(const JID& jid, const String& groupName) { + std::vector<RosterItem*>::iterator it = children_.begin(); + while (it != children_.end()) { + GroupRosterItem* group = dynamic_cast<GroupRosterItem*>(*it); + if (group && group->getName() == groupName) { + group->removeChild(jid); + } + it++; + } +} + + void Roster::applyOnItems(const RosterItemOperation& operation) { std::deque<RosterItem*> queue(children_.begin(), children_.end()); while (!queue.empty()) { diff --git a/Swiften/Roster/Roster.h b/Swiften/Roster/Roster.h index cdd1407..6010832 100644 --- a/Swiften/Roster/Roster.h +++ b/Swiften/Roster/Roster.h @@ -27,6 +27,7 @@ class Roster { GroupRosterItem* getGroup(const String& groupName); void addContact(const JID& jid, const String& name, const String& group); void removeContact(const JID& jid); + void removeContactFromGroup(const JID& jid, const String& group); void applyOnItems(const RosterItemOperation& operation); boost::signal<void (boost::shared_ptr<UserRosterAction>)> onUserAction; void addFilter(RosterFilter *filter) {filters_.push_back(filter);filterAll();} diff --git a/Swiften/Roster/XMPPRoster.cpp b/Swiften/Roster/XMPPRoster.cpp index 9661171..a5cccaf 100644 --- a/Swiften/Roster/XMPPRoster.cpp +++ b/Swiften/Roster/XMPPRoster.cpp @@ -8,9 +8,12 @@ void XMPPRoster::addContact(const JID& jid, const String& name, const std::vecto if (exists) { entries_.erase(bareJID); } + String oldName = getNameForJID(bareJID); + std::vector<String> oldGroups = entries_[bareJID].second; entries_[bareJID] = std::pair<String, std::vector<String> >(name, groups); if (exists) { - onJIDUpdated(bareJID); + + onJIDUpdated(bareJID, oldName, oldGroups); } else { onJIDAdded(bareJID); } diff --git a/Swiften/Roster/XMPPRoster.h b/Swiften/Roster/XMPPRoster.h index f2afbb3..7a72e00 100644 --- a/Swiften/Roster/XMPPRoster.h +++ b/Swiften/Roster/XMPPRoster.h @@ -23,7 +23,7 @@ class XMPPRoster { boost::signal<void (const JID&)> onJIDAdded; boost::signal<void (const JID&)> onJIDRemoved; - boost::signal<void (const JID&)> onJIDUpdated; + boost::signal<void (const JID&, const String&, const std::vector<String>&)> onJIDUpdated; private: std::map<JID, std::pair<String, std::vector<String> > > entries_; |