summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-05-26 18:30:52 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-05-26 18:30:52 (GMT)
commit103e5d04240fa6c9decf54802bca083c2cd65744 (patch)
treeb7549d9109099407ae0c64a3f37218cd5838a31b /Swiften
parente497af7cd28d2cf58d81ed8fd351b5d5ccfa56a4 (diff)
downloadswift-contrib-103e5d04240fa6c9decf54802bca083c2cd65744.zip
swift-contrib-103e5d04240fa6c9decf54802bca083c2cd65744.tar.bz2
Do JID Map lookups for MUC rosters.
In the same way as was already done for user rosters. Resolves: #395
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Roster/Roster.cpp15
-rw-r--r--Swiften/Roster/Roster.h3
-rw-r--r--Swiften/Roster/SetPresence.h2
3 files changed, 11 insertions, 9 deletions
diff --git a/Swiften/Roster/Roster.cpp b/Swiften/Roster/Roster.cpp
index a83ea89..9291421 100644
--- a/Swiften/Roster/Roster.cpp
+++ b/Swiften/Roster/Roster.cpp
@@ -21,7 +21,8 @@
namespace Swift {
-Roster::Roster() {
+Roster::Roster(bool fullJIDMapping) {
+ fullJIDMapping_ = fullJIDMapping;
root_ = new GroupRosterItem("Dummy-Root", NULL);
root_->onChildrenChanged.connect(boost::bind(&Roster::handleChildrenChanged, this, root_));
}
@@ -70,7 +71,7 @@ void Roster::addContact(const JID& jid, const String& name, const String& groupN
GroupRosterItem* group(getGroup(groupName));
ContactRosterItem *item = new ContactRosterItem(jid, name, group);
group->addChild(item);
- itemMap_[jid.toBare()].push_back(item);
+ itemMap_[fullJIDMapping_ ? jid : jid.toBare()].push_back(item);
item->onDataChanged.connect(boost::bind(&Roster::handleDataChanged, this, item));
filterContact(item, group);
}
@@ -82,10 +83,10 @@ struct JIDEqualsTo {
};
void Roster::removeContact(const JID& jid) {
- std::vector<ContactRosterItem*>* items = &itemMap_[jid.toBare()];
+ std::vector<ContactRosterItem*>* items = &itemMap_[fullJIDMapping_ ? jid : jid.toBare()];
items->erase(std::remove_if(items->begin(), items->end(), JIDEqualsTo(jid)), items->end());
if (items->size() == 0) {
- itemMap_.erase(jid.toBare());
+ itemMap_.erase(fullJIDMapping_ ? jid : jid.toBare());
}
//Causes the delete
root_->removeChild(jid);
@@ -98,7 +99,7 @@ void Roster::removeContactFromGroup(const JID& jid, const String& groupName) {
GroupRosterItem* group = dynamic_cast<GroupRosterItem*>(*it);
if (group && group->getDisplayName() == groupName) {
ContactRosterItem* deleted = group->removeChild(jid);
- std::vector<ContactRosterItem*>* items = &itemMap_[jid.toBare()];
+ std::vector<ContactRosterItem*>* items = &itemMap_[fullJIDMapping_ ? jid : jid.toBare()];
items->erase(std::remove(items->begin(), items->end(), deleted), items->end());
}
it++;
@@ -115,8 +116,8 @@ void Roster::applyOnItems(const RosterItemOperation& operation) {
}
void Roster::applyOnItem(const RosterItemOperation& operation, const JID& jid) {
- foreach (ContactRosterItem* item, itemMap_[jid.toBare()]) {
- //std::cout << "Applying on item " << item << " : " << item->getDisplayName() << std::endl;
+
+ foreach (ContactRosterItem* item, itemMap_[fullJIDMapping_ ? jid : jid.toBare()]) {
operation(item);
filterContact(item, item->getParent());
}
diff --git a/Swiften/Roster/Roster.h b/Swiften/Roster/Roster.h
index 3af89d7..fcc075a 100644
--- a/Swiften/Roster/Roster.h
+++ b/Swiften/Roster/Roster.h
@@ -25,7 +25,7 @@ class ContactRosterItem;
class Roster {
public:
- Roster();
+ Roster(bool fullJIDMapping = false);
~Roster();
void addContact(const JID& jid, const String& name, const String& group);
@@ -51,6 +51,7 @@ class Roster {
GroupRosterItem* root_;
std::vector<RosterFilter*> filters_;
std::map<JID, std::vector<ContactRosterItem*> > itemMap_;
+ bool fullJIDMapping_;
};
}
diff --git a/Swiften/Roster/SetPresence.h b/Swiften/Roster/SetPresence.h
index 134a63d..9bbf326 100644
--- a/Swiften/Roster/SetPresence.h
+++ b/Swiften/Roster/SetPresence.h
@@ -17,7 +17,7 @@ class RosterItem;
class SetPresence : public RosterItemOperation {
public:
- SetPresence(boost::shared_ptr<Presence> presence, JID::CompareType compareType = JID::WithoutResource) : RosterItemOperation(true, presence->getFrom().toBare()), presence_(presence), compareType_(compareType) {
+ SetPresence(boost::shared_ptr<Presence> presence, JID::CompareType compareType = JID::WithoutResource) : RosterItemOperation(true, compareType == JID::WithoutResource ? presence->getFrom().toBare() : presence->getFrom()), presence_(presence), compareType_(compareType) {
}
virtual void operator() (RosterItem* item) const {