summaryrefslogtreecommitdiffstats
blob: 1c51cb7e1ec34cba7b25afc7ead7a0b2a88c29d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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;
}

}