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

}