From 4c9515d2984a0c8c1053dcf63c13f7c969bac136 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Tue, 28 Apr 2015 01:15:50 -0400
Subject: [PATCH] call: add connecting state event

Refs #71781

Change-Id: I05098c994eec4a7eeeed8867c833f9e8a5754f89
---
 bin/dbus/callmanager-introspec.xml |  1 +
 src/dring/call_const.h             | 14 ++++++++++++++
 src/manager.cpp                    |  3 ++-
 src/ringdht/ringaccount.cpp        |  3 +++
 4 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/bin/dbus/callmanager-introspec.xml b/bin/dbus/callmanager-introspec.xml
index 2fb551ce33..66cb318e86 100644
--- a/bin/dbus/callmanager-introspec.xml
+++ b/bin/dbus/callmanager-introspec.xml
@@ -520,6 +520,7 @@
                 The acceptable states are:
                 <ul>
                   <li>INCOMING: Initial state of incoming calls</li>
+                  <li>CONNECTING: Peer found, contacting him</li>
                   <li>RINGING: Initial state of received outgoing call</li>
                   <li>CURRENT: The normal active state of an answered call</li>
                   <li>HUNGUP: Notify that the call has been hungup by peer</li>
diff --git a/src/dring/call_const.h b/src/dring/call_const.h
index 85ac20cf78..64078d525b 100644
--- a/src/dring/call_const.h
+++ b/src/dring/call_const.h
@@ -34,6 +34,20 @@ namespace DRing {
 
 namespace Call {
 
+namespace StateEvent {
+
+constexpr static char INCOMING                 [] = "INCOMING"           ;
+constexpr static char CONNECTING               [] = "CONNECTING"         ;
+constexpr static char RINGING                  [] = "RINGING"            ;
+constexpr static char CURRENT                  [] = "CURRENT"            ;
+constexpr static char HUNGUP                   [] = "HUNGUP"             ;
+constexpr static char BUSY                     [] = "BUSY"               ;
+constexpr static char FAILURE                  [] = "FAILURE"            ;
+constexpr static char HOLD                     [] = "HOLD"               ;
+constexpr static char UNHOLD                   [] = "UNHOLD"             ;
+
+}
+
 namespace Details {
 
 constexpr static char CALL_TYPE                [] = "CALL_TYPE"           ;
diff --git a/src/manager.cpp b/src/manager.cpp
index a430f6bb7d..b1e1e8e32a 100644
--- a/src/manager.cpp
+++ b/src/manager.cpp
@@ -78,6 +78,7 @@
 #include "ice_transport.h"
 
 #include "client/ring_signal.h"
+#include "dring/call_const.h"
 
 #if HAVE_TLS
 #include "gnutls_support.h"
@@ -685,7 +686,7 @@ Manager::offHoldCall(const std::string& callId)
         return false;
     }
 
-    emitSignal<DRing::CallSignal::StateChange>(callId, "UNHOLD", 0);
+    emitSignal<DRing::CallSignal::StateChange>(callId, DRing::Call::StateEvent::UNHOLD, 0);
 
     if (isConferenceParticipant(callId))
         switchCall(getCallFromCallID(call->getConfId()));
diff --git a/src/ringdht/ringaccount.cpp b/src/ringdht/ringaccount.cpp
index c2f8138138..33b24e8c9a 100644
--- a/src/ringdht/ringaccount.cpp
+++ b/src/ringdht/ringaccount.cpp
@@ -45,6 +45,7 @@
 #include "ice_transport.h"
 
 #include "client/ring_signal.h"
+#include "dring/call_const.h"
 
 #include "upnp/upnp_control.h"
 #include "system_codec_container.h"
@@ -230,6 +231,8 @@ RingAccount::newOutgoingCall(const std::string& toUrl)
                     dht::DhtMessage msg {v->data};
                     RING_WARN("ICE request replied from DHT peer %s",
                               toH.toString().c_str());
+                    call->setConnectionState(Call::PROGRESSING);
+                    emitSignal<DRing::CallSignal::StateChange>(call->getCallId(), DRing::Call::StateEvent::CONNECTING, 0);
                     ice->start(msg.getMessage());
                     return false;
                 }
-- 
GitLab