From 192f844de90d87caa43be679b7719490e943dd12 Mon Sep 17 00:00:00 2001
From: yanmorin <yanmorin>
Date: Fri, 4 Nov 2005 15:18:15 +0000
Subject: [PATCH] Bash script fixe for sflphone-qt and sflphone-cli Fixe for no
 username bugs

---
 sflphone.spec.in         |  2 +-
 sflphoned-fedora.spec.in |  5 +++--
 src/managerimpl.cpp      |  3 +++
 src/sflphone.in          | 43 ++++++++++++++++++++++++----------------
 src/sipcall.cpp          |  4 ++--
 src/sipvoiplink.cpp      |  4 +---
 6 files changed, 36 insertions(+), 25 deletions(-)

diff --git a/sflphone.spec.in b/sflphone.spec.in
index ecdd21b047..acd9ce12be 100644
--- a/sflphone.spec.in
+++ b/sflphone.spec.in
@@ -1,5 +1,5 @@
 %define name sflphoned
-%define version 0.5
+%define version 0.6
 %define release 1
 %define prefix /usr
 Autoreq: 0
diff --git a/sflphoned-fedora.spec.in b/sflphoned-fedora.spec.in
index 451a6f7726..954b3bad43 100644
--- a/sflphoned-fedora.spec.in
+++ b/sflphoned-fedora.spec.in
@@ -1,5 +1,5 @@
 %define name sflphoned
-%define version 0.5
+%define version 0.6
 %define release 1
 %define prefix /usr
 Autoreq: 0
@@ -37,6 +37,7 @@ rm -rf %{buildroot}
 
 %files
 %defattr(-, root, root)
-%{_bindir}/sflphoned
+%{_bindir}/sflphone
+%{_libexecdir}/sflphoned
 %{_datadir}/sflphone/ringtones/*
 
diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp
index 4aaa0ac2ed..52e9839ef0 100644
--- a/src/managerimpl.cpp
+++ b/src/managerimpl.cpp
@@ -287,6 +287,9 @@ ManagerImpl::hangupCall (CALLID id)
 {
   _debug("%10d: Hangup Call\n", id);
   ost::MutexLock m(_mutex);
+  if (id == _currentCallId || _currentCallId == 0) {
+    stopTone(); // stop tone, like a 700 error: number not found Not Found
+  }
   Call* call = getCall(id);
   if (call == NULL) {
     return -1;
diff --git a/src/sflphone.in b/src/sflphone.in
index 4e01b1308e..06b93dd4d0 100755
--- a/src/sflphone.in
+++ b/src/sflphone.in
@@ -10,28 +10,37 @@ export LD_LIBRARY_PATH
 
 message="Warning, you probably did not extract the archive in the / directory,
 you must edit this script ($0) and change SFLPHONE_DIR to the correct location.
-%libexecdir% must contain the provided libraries."
-if [ ! -d ${SFLPHONE_DIR} ]
-then
-	echo $message
-	exit 1
+@libexecdir@ must contain the provided libraries."
+if [ ! -d ${SFLPHONE_DIR} ]; then
+  echo $message
+  exit 1
 else
-		if [ ! -d @libexecdir@ ]
-		then
-			echo $message
-			exit 1
-		fi
+  if [ ! -d @libexecdir@ ]; then
+    echo $message
+    exit 1
+  fi
 fi
 
 # Let's try to go..
 PATH=@libexecdir@:${PATH}
-binary=@libexecdir@/sflphone-qt.bin
-if [ -x ${binary} ]
-then
-	exec $binary
-else
-	echo "Could not find the sflphone-qt.bin executable in %libexecdir% !"
-	exit 1
+binaryqtname=sflphone-qt
+binaryqt=@libexecdir@/${binaryqtname}
+binarycliname=sflphone-cli
+binarycli=@libexecdir@/${binarycliname}
+if [ "$1" != "--text" ]; then
+  if [ -x ${binaryqt} ]; then
+    exec $binaryqt
+  else
+    echo "Could not find the ${binaryqtname} executable in @libexecdir@ !"
+    exit 1
+  fi
+else 
+  if [ -x ${binarycli} ]; then
+    SFLPHONE_CORE_DIR=@libexecdir@ exec $binarycli
+  else
+    echo "Could not find the ${binarycliname} executable in @libexecdir@ !"
+    exit 1
+  fi
 fi
 
 # EOF
diff --git a/src/sipcall.cpp b/src/sipcall.cpp
index fca71b522e..c4c8aea721 100644
--- a/src/sipcall.cpp
+++ b/src/sipcall.cpp
@@ -186,7 +186,7 @@ SipCall::newIncomingCall (eXosip_event_t *event) {
         _name = name;
       }
       osip_uri_t* url = osip_from_get_url(from); 
-      if ( url != NULL ) {
+      if ( url != NULL && url->username != NULL) {
         _number = url->username;
       }
       osip_from_free(from);
@@ -346,7 +346,7 @@ SipCall::newReinviteCall (eXosip_event_t *event) {
         _name = name;
       }
       osip_uri_t* url = osip_from_get_url(from); 
-      if ( url != NULL ) {
+      if ( url != NULL && url->username != NULL ) {
         _number = url->username;
       }
       osip_from_free(from);
diff --git a/src/sipvoiplink.cpp b/src/sipvoiplink.cpp
index aa1643ed3c..ea3b8a647c 100644
--- a/src/sipvoiplink.cpp
+++ b/src/sipvoiplink.cpp
@@ -1529,10 +1529,8 @@ SipVoIPLink::startCall (CALLID id, const std::string& from, const std::string& t
   }
   
   // this is the cid (call id from exosip)
-  _debug("< INVITE (%d)", id);
+  _debug("< INVITE (%d)\n", id);
   int cid = eXosip_call_send_initial_invite (invite);
-
-  _debug("> Start a new Call: Send INVITE\n");
   _debug("  Local IP:port: %s:%d\n", getLocalIpAddress().c_str(), getLocalPort());
   _debug("  Payload:       %s\n", media_audio);
 
-- 
GitLab