From f3b17ffad8d05bd90525c9c267a0a5fb67319b10 Mon Sep 17 00:00:00 2001
From: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
Date: Mon, 31 Mar 2008 11:11:12 -0400
Subject: [PATCH] SIP Bug: The incoming call rings back!

---
 src/sipcall.cpp     |  7 ++++---
 src/sipvoiplink.cpp | 19 +++++++++----------
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/sipcall.cpp b/src/sipcall.cpp
index 8e658628b8..6ca79249b5 100644
--- a/src/sipcall.cpp
+++ b/src/sipcall.cpp
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2004-2007 Savoir-Faire Linux inc.
+ *  Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
  *  Author: Alexandre Bourget <alexandre.bourget@savoirfairelinux.com>
  *  Author: Yan Morin <yan.morin@savoirfairelinux.com>
  *  Author : Laurielle Lea <laurielle.lea@savoirfairelinux.com>
@@ -110,9 +111,9 @@ SIPCall::SIPCallInvite(eXosip_event_t *event)
         sdp_message_free (local_sdp);
       }
       _debug("< Sending answer 183\n");
-      if (0 != eXosip_call_send_answer (event->tid, 183, answer)) {
-        _debug("SipCall::newIncomingCall: cannot send 183 progress?\n");
-      }
+      //if (0 != eXosip_call_send_answer (event->tid, 183, answer)) {
+        //_debug("SipCall::newIncomingCall: cannot send 183 progress?\n");
+      //}
     }
   }
   eXosip_unlock ();
diff --git a/src/sipvoiplink.cpp b/src/sipvoiplink.cpp
index 9d520e097d..6536a1b0b7 100644
--- a/src/sipvoiplink.cpp
+++ b/src/sipvoiplink.cpp
@@ -249,8 +249,8 @@ SIPVoIPLink::getEvent()
 
 	/* INVITE related events within calls */
 	case EXOSIP_CALL_INVITE:          /** 05 < announce a new call                   */
-		SIPCallInvite(event);
 		_debugMid(" !EXOSIP_CALL_INVITE\n");
+		SIPCallInvite(event);
 		break;
 	case EXOSIP_CALL_REINVITE:        /** 06 < announce a new INVITE within call     */
 		SIPCallReinvite(event);
@@ -599,13 +599,6 @@ SIPVoIPLink::answer(const CallID& id)
     return false;
   }
 
-  // Send 180 RINGING
-  _debug("< Send 180 Ringing\n");
-  eXosip_lock ();
-  eXosip_call_send_answer(call->getTid(), SIP_RINGING, NULL);
-  eXosip_unlock ();
-  call->setConnectionState(Call::Ringing);
-
   // Send 200 OK
   osip_message_t *answerMessage = NULL;
   eXosip_lock();
@@ -665,7 +658,6 @@ SIPVoIPLink::answer(const CallID& id)
 bool
 SIPVoIPLink::hangup(const CallID& id)
 {
-  _debug("nvlnljbnzjkdbnjzdfbnjzdflnbjlzdfnbjlzdfbnzdfjlnjlb\n");
   SIPCall* call = getSIPCall(id);
   Manager::instance().peerHungupCall( id );
   if (call==0) { _debug("! SIP Error: Call doesn't exist\n"); return false; }  
@@ -1275,7 +1267,6 @@ void
 SIPVoIPLink::SIPCallInvite(eXosip_event_t *event)
 {
   _debug("> INVITE (receive)\n");
-
   CallID id = Manager::instance().getNewCallID();
 
   SIPCall* call = new SIPCall(id, Call::Incoming);
@@ -1283,6 +1274,7 @@ SIPVoIPLink::SIPCallInvite(eXosip_event_t *event)
     _debug("! SIP Failure: unable to create an incoming call");
     return;
   }
+
   setCallAudioLocal(call);
   call->setCodecMap(Manager::instance().getCodecDescriptorMap());
   call->setConnectionState(Call::Progressing);
@@ -1295,6 +1287,12 @@ SIPVoIPLink::SIPCallInvite(eXosip_event_t *event)
   } else {
     delete call; call = 0;
   }
+  // Send 180 RINGING
+  _debug("< Send 180 Ringing\n");
+  eXosip_lock ();
+  eXosip_call_send_answer(event->tid, 180, NULL);
+  eXosip_unlock ();
+  call->setConnectionState(Call::Ringing);
 }
 
 void
@@ -1324,6 +1322,7 @@ SIPVoIPLink::SIPCallReinvite(eXosip_event_t *event)
 void
 SIPVoIPLink::SIPCallRinging(eXosip_event_t *event)
 {
+  
   SIPCall* call = findSIPCallWithCid(event->cid);
   if (!call) {
     _debug("! SIP Failure: unknown call\n");
-- 
GitLab