summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-04-11 18:17:06 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-04-11 18:17:54 (GMT)
commit77d4eb7588e113beaa03f3347523b26adefdeb06 (patch)
tree439d9ac1d8c44871a97a1216ebd49856349a5b6e /Swift/Controllers
parentd9a29f93cd4ff505e264974febd0566ae29880ca (diff)
downloadswift-77d4eb7588e113beaa03f3347523b26adefdeb06.zip
swift-77d4eb7588e113beaa03f3347523b26adefdeb06.tar.bz2
Don't duplicate roster items for roster pushes.
Resolves: #218
Diffstat (limited to 'Swift/Controllers')
-rw-r--r--Swift/Controllers/RosterController.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/Swift/Controllers/RosterController.cpp b/Swift/Controllers/RosterController.cpp
index ea7c7bb..9364e93 100644
--- a/Swift/Controllers/RosterController.cpp
+++ b/Swift/Controllers/RosterController.cpp
@@ -131,19 +131,25 @@ void RosterController::handleOnJIDRemoved(const JID& jid) {
roster_->removeContact(jid);
}
-void RosterController::handleOnJIDUpdated(const JID& jid, const String& oldName, const std::vector<String> oldGroups) {
+void RosterController::handleOnJIDUpdated(const JID& jid, const String& oldName, const std::vector<String> passedOldGroups) {
if (oldName != xmppRoster_->getNameForJID(jid)) {
+ handleOnJIDRemoved(jid);
handleOnJIDAdded(jid);
+ //FIXME: use a roster visitor to avoid losing presence.
return;
}
std::vector<String> groups = xmppRoster_->getGroupsForJID(jid);
+ std::vector<String> oldGroups = passedOldGroups;
String name = xmppRoster_->getNameForJID(jid);
String contactsGroup = "Contacts";
+ if (oldGroups.empty()) {
+ oldGroups.push_back(contactsGroup);
+ }
if (groups.empty()) {
groups.push_back(contactsGroup);
}
foreach(const String& group, groups) {
- if (std::find(oldGroups.begin(), oldGroups.end(), jid) == oldGroups.end()) {
+ if (std::find(oldGroups.begin(), oldGroups.end(), group) == oldGroups.end()) {
roster_->addContact(jid, xmppRoster_->getNameForJID(jid), group);
}
}