From a04c157e156061a08bb6dec573eb05f1b6e15b9e Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Wed, 15 Dec 2010 19:39:17 +0000
Subject: Emit nickname change signal when adding to the roster.

So open chat windows should change their title if you're talking
to a contact not in your roster, and then add them.

Resolves: #704

diff --git a/Swiften/Client/NickResolver.cpp b/Swiften/Client/NickResolver.cpp
index 9bfe269..3e1ae8e 100644
--- a/Swiften/Client/NickResolver.cpp
+++ b/Swiften/Client/NickResolver.cpp
@@ -28,12 +28,18 @@ NickResolver::NickResolver(const JID& ownJID, XMPPRoster* xmppRoster, VCardManag
 	}
 	mucRegistry_ = mucRegistry;
 	xmppRoster_->onJIDUpdated.connect(boost::bind(&NickResolver::handleJIDUpdated, this, _1, _2, _3));
+	xmppRoster_->onJIDAdded.connect(boost::bind(&NickResolver::handleJIDAdded, this, _1));
 }
 
 void NickResolver::handleJIDUpdated(const JID& jid, const String& previousNick, const std::vector<String>& /*groups*/) {
 	onNickChanged(jid, previousNick);
 }
 
+void NickResolver::handleJIDAdded(const JID& jid) {
+	String oldNick(jidToNick(jid));
+	onNickChanged(jid, oldNick);
+}
+
 String NickResolver::jidToNick(const JID& jid) {
 	if (jid.toBare() == ownJID_) {
 		if (!ownNick_.isEmpty()) {
diff --git a/Swiften/Client/NickResolver.h b/Swiften/Client/NickResolver.h
index de7d64a..697409f 100644
--- a/Swiften/Client/NickResolver.h
+++ b/Swiften/Client/NickResolver.h
@@ -27,6 +27,7 @@ namespace Swift {
 		private:
 			void handleVCardReceived(const JID& jid, VCard::ref vCard);
 			void handleJIDUpdated(const JID& jid, const String& previousNick, const std::vector<String>& groups);
+			void handleJIDAdded(const JID& jid);
 
 		private:
 			JID ownJID_;
-- 
cgit v0.10.2-6-g49f6