From 8b2f4af3cd10b70cfaa7f13f4a141c47a554c829 Mon Sep 17 00:00:00 2001
From: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
Date: Mon, 9 Jan 2012 18:12:31 -0500
Subject: [PATCH] * #7264: don't duplicate display name for incoming calls

---
 daemon/src/history/history.cpp     |  4 +---
 daemon/src/history/historyitem.cpp |  8 ++++----
 daemon/src/managerimpl.cpp         | 12 ++++--------
 daemon/src/sip/sipvoiplink.cpp     |  1 -
 gnome/src/contacts/calltree.c      |  1 -
 5 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/daemon/src/history/history.cpp b/daemon/src/history/history.cpp
index a84b2128c0..caa95b663e 100644
--- a/daemon/src/history/history.cpp
+++ b/daemon/src/history/history.cpp
@@ -89,10 +89,8 @@ bool History::save()
 
 void History::addEntry(const HistoryItem &item, int oldest)
 {
-    if (item.hasPeerNumber() and item.youngerThan(oldest)) {
-        DEBUG("Adding history item");
+    if (item.hasPeerNumber() and item.youngerThan(oldest))
         items_.push_back(item);
-    }
 }
 
 void History::ensurePath()
diff --git a/daemon/src/history/historyitem.cpp b/daemon/src/history/historyitem.cpp
index cfcc1c461a..57799b276a 100644
--- a/daemon/src/history/historyitem.cpp
+++ b/daemon/src/history/historyitem.cpp
@@ -57,14 +57,14 @@ HistoryItem::HistoryItem(const map<string, string> &args) : entryMap_(args),
 
 HistoryItem::HistoryItem(std::istream &entry) : entryMap_(), timestampStart_(0)
 {
-    std::string tmp;
+    string tmp;
     while (std::getline(entry, tmp, '\n')) {
         size_t pos = tmp.find('=');
-        if (pos == std::string::npos)
+        if (pos == string::npos)
             break;
         else if (pos < tmp.length() - 1) {
-            std::string key(tmp.substr(0, pos));
-            std::string val(tmp.substr(pos + 1, tmp.length() - pos - 1));
+            string key(tmp.substr(0, pos));
+            string val(tmp.substr(pos + 1, tmp.length() - pos - 1));
             entryMap_[key] = val;
         }
     }
diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp
index aa6d23e2f4..5175812413 100644
--- a/daemon/src/managerimpl.cpp
+++ b/daemon/src/managerimpl.cpp
@@ -1384,10 +1384,11 @@ void ManagerImpl::incomingCall(Call* call, const std::string& accountId)
         // when placing new call from history (if call is IAX, do nothing)
         std::string peerNumber(call->getPeerNumber());
 
-        size_t startIndex = peerNumber.find("sip:");
+        const char SIP_PREFIX[] = "sip:";
+        size_t startIndex = peerNumber.find(SIP_PREFIX);
 
         if (startIndex != std::string::npos)
-            call->setPeerNumber(peerNumber.substr(startIndex + 4));
+            call->setPeerNumber(peerNumber.substr(startIndex + sizeof(SIP_PREFIX) - 1));
     }
 
     if (not hasCurrentCall()) {
@@ -1397,14 +1398,9 @@ void ManagerImpl::incomingCall(Call* call, const std::string& accountId)
 
     addWaitingCall(call->getCallId());
 
-    std::string from(call->getDisplayName());
     std::string number(call->getPeerNumber());
 
-    if (not from.empty() and not number.empty())
-        from += " ";
-
-    from += "<" + number + ">";
-
+    std::string from("<" + number + ">");
     dbus_.getCallManager()->incomingCall(accountId, call->getCallId(), call->getDisplayName() + " " + from);
 }
 
diff --git a/daemon/src/sip/sipvoiplink.cpp b/daemon/src/sip/sipvoiplink.cpp
index 5f556403f3..6d370dc8cb 100644
--- a/daemon/src/sip/sipvoiplink.cpp
+++ b/daemon/src/sip/sipvoiplink.cpp
@@ -1263,7 +1263,6 @@ void SIPVoIPLink::findLocalAddressFromUri(const std::string& uri, pjsip_transpor
 namespace {
 std::string parseDisplayName(const char * buffer)
 {
-    // Parse the display name from "From" header
     const char* from_header = strstr(buffer, "From: ");
 
     if (!from_header)
diff --git a/gnome/src/contacts/calltree.c b/gnome/src/contacts/calltree.c
index 341a16c10b..33f76cacbd 100644
--- a/gnome/src/contacts/calltree.c
+++ b/gnome/src/contacts/calltree.c
@@ -33,7 +33,6 @@
 #include "calllist.h"
 #include "calltree.h"
 #include <stdlib.h>
-#include <glib/gprintf.h>
 
 #include "eel-gconf-extensions.h"
 #include "unused.h"
-- 
GitLab