summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-06-01 08:48:42 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-06-01 09:24:28 (GMT)
commit2812bddd81f8a1b804c7460f4e14cd0aa393d129 (patch)
treed46294f35150c4f0f43deaf2d31fceaf945ae715 /Swiften/Controllers/NickResolver.cpp
downloadswift-contrib-2812bddd81f8a1b804c7460f4e14cd0aa393d129.zip
swift-contrib-2812bddd81f8a1b804c7460f4e14cd0aa393d129.tar.bz2
Import.
Diffstat (limited to 'Swiften/Controllers/NickResolver.cpp')
-rw-r--r--Swiften/Controllers/NickResolver.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/Swiften/Controllers/NickResolver.cpp b/Swiften/Controllers/NickResolver.cpp
new file mode 100644
index 0000000..1c51cb7
--- /dev/null
+++ b/Swiften/Controllers/NickResolver.cpp
@@ -0,0 +1,22 @@
+#include "Swiften/Controllers/NickResolver.h"
+
+#include <boost/shared_ptr.hpp>
+
+#include "Swiften/Roster/XMPPRoster.h"
+
+namespace Swift {
+
+NickResolver::NickResolver(boost::shared_ptr<XMPPRoster> xmppRoster) {
+ xmppRoster_ = xmppRoster;
+}
+
+String NickResolver::jidToNick(const JID& jid) {
+ if (xmppRoster_->containsJID(jid)) {
+ return xmppRoster_->getNameForJID(jid);
+ }
+ std::map<JID, String>::iterator it = map_.find(jid);
+ return (it == map_.end()) ? jid.toBare() : it->second;
+}
+
+}
+