diff options
Diffstat (limited to 'Swift/Controllers/Roster/Roster.cpp')
-rw-r--r-- | Swift/Controllers/Roster/Roster.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Swift/Controllers/Roster/Roster.cpp b/Swift/Controllers/Roster/Roster.cpp index 84561e5..77d6b78 100644 --- a/Swift/Controllers/Roster/Roster.cpp +++ b/Swift/Controllers/Roster/Roster.cpp | |||
@@ -49,10 +49,32 @@ Roster::~Roster() { | |||
49 | 49 | ||
50 | GroupRosterItem* Roster::getRoot() const { | 50 | GroupRosterItem* Roster::getRoot() const { |
51 | return root_; | 51 | return root_; |
52 | } | 52 | } |
53 | 53 | ||
54 | std::set<JID> Roster::getJIDs() const { | ||
55 | std::set<JID> jids; | ||
56 | |||
57 | std::deque<RosterItem*> queue; | ||
58 | queue.push_back(root_); | ||
59 | while (!queue.empty()) { | ||
60 | RosterItem* item = *queue.begin(); | ||
61 | queue.pop_front(); | ||
62 | GroupRosterItem* group = dynamic_cast<GroupRosterItem*>(item); | ||
63 | ContactRosterItem *contact = dynamic_cast<ContactRosterItem*>(item); | ||
64 | if (contact) { | ||
65 | jids.insert(contact->getJID()); | ||
66 | jids.insert(contact->getDisplayJID()); | ||
67 | } | ||
68 | else if (group) { | ||
69 | queue.insert(queue.begin(), group->getChildren().begin(), group->getChildren().end()); | ||
70 | } | ||
71 | } | ||
72 | |||
73 | return jids; | ||
74 | } | ||
75 | |||
54 | GroupRosterItem* Roster::getGroup(const std::string& groupName) { | 76 | GroupRosterItem* Roster::getGroup(const std::string& groupName) { |
55 | foreach (RosterItem *item, root_->getChildren()) { | 77 | foreach (RosterItem *item, root_->getChildren()) { |
56 | GroupRosterItem *group = dynamic_cast<GroupRosterItem*>(item); | 78 | GroupRosterItem *group = dynamic_cast<GroupRosterItem*>(item); |
57 | if (group && group->getDisplayName() == groupName) { | 79 | if (group && group->getDisplayName() == groupName) { |
58 | return group; | 80 | return group; |