From 0bdb45be4aa66dcc478d5f061096b1adbaa3ab2c Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Thu, 27 May 2010 08:59:51 +0100
Subject: Show JIDs for users without nicks in the roster.

Resolves: #344

diff --git a/Swift/Controllers/NickResolver.cpp b/Swift/Controllers/NickResolver.cpp
index c271a31..ed2c8df 100644
--- a/Swift/Controllers/NickResolver.cpp
+++ b/Swift/Controllers/NickResolver.cpp
@@ -29,9 +29,10 @@ String NickResolver::jidToNick(const JID& jid) {
 		return jid.getResource();
 	}
 
-	if (xmppRoster_->containsJID(jid) && xmppRoster_->getNameForJID(jid) != "") {
+	if (xmppRoster_->containsJID(jid) && !xmppRoster_->getNameForJID(jid).isEmpty()) {
 		return xmppRoster_->getNameForJID(jid);
 	}
+
 	std::map<JID, String>::const_iterator it = map_.find(jid);
 	return (it == map_.end()) ? jid.toBare() : it->second;
 }
diff --git a/Swift/Controllers/RosterController.cpp b/Swift/Controllers/RosterController.cpp
index d8897e9..191d5fb 100644
--- a/Swift/Controllers/RosterController.cpp
+++ b/Swift/Controllers/RosterController.cpp
@@ -101,10 +101,7 @@ void RosterController::handleChangeStatusRequest(StatusShow::Type show, const St
 
 void RosterController::handleOnJIDAdded(const JID& jid) {
 	std::vector<String> groups = xmppRoster_->getGroupsForJID(jid);
-	String name = xmppRoster_->getNameForJID(jid);
-	if (name.isEmpty()) {
-		name = jid.toString();
-	}
+	String name = nickResolver_->jidToNick(jid);
 	if (!groups.empty()) {
 		foreach(const String& group, groups) {
 			roster_->addContact(jid, name, group);
@@ -120,15 +117,12 @@ void RosterController::handleOnJIDRemoved(const JID& jid) {
 
 void RosterController::handleOnJIDUpdated(const JID& jid, const String& oldName, const std::vector<String> passedOldGroups) {
 	if (oldName != xmppRoster_->getNameForJID(jid)) {
-		roster_->applyOnItems(SetName(xmppRoster_->getNameForJID(jid), jid));
+		roster_->applyOnItems(SetName(nickResolver_->jidToNick(jid), jid));
 		return;
 	}
 	std::vector<String> groups = xmppRoster_->getGroupsForJID(jid);
 	std::vector<String> oldGroups = passedOldGroups;
-	String name = xmppRoster_->getNameForJID(jid);
-	if (name.isEmpty()) {
-		name = jid.toString();
-	}
+	String name = nickResolver_->jidToNick(jid);
 	String contactsGroup = "Contacts";
 	if (oldGroups.empty()) {
 		oldGroups.push_back(contactsGroup);
-- 
cgit v0.10.2-6-g49f6