From 0a10514896b30c47e5a9b4fea0342b60f81925c6 Mon Sep 17 00:00:00 2001
From: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
Date: Fri, 29 Jan 2016 18:32:47 -0500
Subject: [PATCH] Call: update ContactMethod when peerName is set

The ContactMethod uses the peerName as an alternative name; however
it was only getting this info via the PhoneDirectoryModel during
slotCallAdded and this info was not always ready at that moment.

Change-Id: Ic00f5c8afbf62f91ac045ce8f2c42ffb9102e6a5
Tuleap: #307
---
 src/call.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/call.cpp b/src/call.cpp
index 1fe3d2b3..13df1f1a 100644
--- a/src/call.cpp
+++ b/src/call.cpp
@@ -1197,6 +1197,10 @@ void CallPrivate::setRecordingPath(const QString& path)
 void Call::setPeerName(const QString& name)
 {
    d_ptr->m_PeerName = name;
+
+   // its possible that this is not set at the begining of a call, so we should update the CM here
+   if (peerContactMethod())
+      peerContactMethod()->incrementAlternativeName(name);
 }
 
 ///Set the account (DIALING only, may be ignored)
@@ -1280,7 +1284,7 @@ Call::State CallPrivate::stateChanged(const QString& newStateName)
 
       if (!details[DRing::Call::Details::DISPLAY_NAME].isEmpty()
           and ( details[DRing::Call::Details::DISPLAY_NAME] != m_PeerName) )
-         m_PeerName = details[DRing::Call::Details::DISPLAY_NAME];
+         q_ptr->setPeerName(details[DRing::Call::Details::DISPLAY_NAME]);
 
       //Load the certificate if it's now available
       if (!q_ptr->certificate() && !details[DRing::TlsTransport::TLS_PEER_CERT].isEmpty()) {
-- 
GitLab