summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Roster/XMPPRoster.cpp')
-rw-r--r--Swiften/Roster/XMPPRoster.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/Swiften/Roster/XMPPRoster.cpp b/Swiften/Roster/XMPPRoster.cpp
new file mode 100644
index 0000000..9661171
--- /dev/null
+++ b/Swiften/Roster/XMPPRoster.cpp
@@ -0,0 +1,37 @@
+#include "Swiften/Roster/XMPPRoster.h"
+
+namespace Swift {
+
+void XMPPRoster::addContact(const JID& jid, const String& name, const std::vector<String>& groups) {
+ JID bareJID(jid.toBare());
+ bool exists = containsJID(bareJID);
+ if (exists) {
+ entries_.erase(bareJID);
+ }
+ entries_[bareJID] = std::pair<String, std::vector<String> >(name, groups);
+ if (exists) {
+ onJIDUpdated(bareJID);
+ } else {
+ onJIDAdded(bareJID);
+ }
+}
+
+void XMPPRoster::removeContact(const JID& jid) {
+ entries_.erase(JID(jid.toBare()));
+ onJIDRemoved(jid);
+}
+
+bool XMPPRoster::containsJID(const JID& jid) {
+ return entries_.find(JID(jid.toBare())) != entries_.end();
+}
+
+const String& XMPPRoster::getNameForJID(const JID& jid) {
+ return entries_[JID(jid.toBare())].first;
+}
+
+const std::vector<String>& XMPPRoster::getGroupsForJID(const JID& jid) {
+ return entries_[JID(jid.toBare())].second;
+}
+
+}
+