From 827437d554190e0a226ba390543bb53699f0bb4d Mon Sep 17 00:00:00 2001
From: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
Date: Thu, 11 May 2017 10:31:44 -0400
Subject: [PATCH] call: send vCard only after the call starts
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Instead of sending the vCard during an incoming or ringing call,
we wait to send the vCard only once the call has started. This
is to prevent connectivity failures during the call initialization
due to dropped vCard packets.

Change-Id: I08e63bf35724ed543c36d88cd43f872aa246b73c
Reviewed-by: Nicolas Jäger <nicolas.jager@savoirfairelinux.com>
---
 src/call.cpp | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/call.cpp b/src/call.cpp
index 49d34903..c6f0720f 100644
--- a/src/call.cpp
+++ b/src/call.cpp
@@ -158,7 +158,7 @@ const TypedStateMachine< TypedStateMachine< function , CallPrivate::DaemonState
 {{
 //                      RINGING          CONNECTING      CURRENT            BUSY               HOLD               HUNGUP         FAILURE          OVER        INACTIVE     /**/
 /*NEW            */  {{CP::nothing    , CP::nothing   , CP::nothing   , CP::nothing      , CP::nothing      , CP::nothing    , CP::nothing  , CP::nothing , CP::nothing}}, /**/
-/*INCOMING       */  {{CP::sendProfile, CP::nothing   , CP::start     , CP::startWeird   , CP::startWeird   , CP::startStop  , CP::failure  , CP::nothing , CP::nothing}}, /**/
+/*INCOMING       */  {{CP::nothing    , CP::nothing   , CP::start     , CP::startWeird   , CP::startWeird   , CP::startStop  , CP::failure  , CP::nothing , CP::nothing}}, /**/
 /*RINGING        */  {{CP::nothing    , CP::nothing   , CP::start     , CP::failure      , CP::start        , CP::startStop  , CP::failure  , CP::nothing , CP::nothing}}, /**/
 /*CURRENT        */  {{CP::nothing    , CP::nothing   , CP::nothing   , CP::warning      , CP::nothing      , CP::stop       , CP::nothing  , CP::stop    , CP::nothing}}, /**/
 /*DIALING        */  {{CP::nothing    , CP::nothing   , CP::warning   , CP::warning      , CP::warning      , CP::stop       , CP::warning  , CP::stop    , CP::nothing}}, /**/
@@ -171,9 +171,9 @@ const TypedStateMachine< TypedStateMachine< function , CallPrivate::DaemonState
 /*ERROR          */  {{CP::error      , CP::error     , CP::error     , CP::error        , CP::error        , CP::stop       , CP::error    , CP::error   , CP::nothing}}, /**/
 /*CONF           */  {{CP::nothing    , CP::nothing   , CP::nothing   , CP::warning      , CP::nothing      , CP::stop       , CP::nothing  , CP::stop    , CP::nothing}}, /**/
 /*CONF_HOLD      */  {{CP::nothing    , CP::nothing   , CP::nothing   , CP::warning      , CP::nothing      , CP::stop       , CP::nothing  , CP::stop    , CP::nothing}}, /**/
-/*INIT           */  {{CP::sendProfile, CP::nothing   , CP::warning   , CP::warning      , CP::warning      , CP::stop       , CP::warning  , CP::stop    , CP::nothing}}, /**/
+/*INIT           */  {{CP::nothing    , CP::nothing   , CP::warning   , CP::warning      , CP::warning      , CP::stop       , CP::warning  , CP::stop    , CP::nothing}}, /**/
 /*ABORTED        */  {{CP::error      , CP::error     , CP::error     , CP::error        , CP::error        , CP::error      , CP::error    , CP::error   , CP::nothing}}, /**/
-/*CONNECTED      */  {{CP::sendProfile, CP::nothing   , CP::warning   , CP::warning      , CP::warning      , CP::stop       , CP::warning  , CP::stop    , CP::nothing}}, /**/
+/*CONNECTED      */  {{CP::nothing    , CP::nothing   , CP::warning   , CP::warning      , CP::warning      , CP::stop       , CP::warning  , CP::stop    , CP::nothing}}, /**/
 }};//                                                                                                                                                                        */
 
 //There is no point to have a 2D matrix, only one transition per state is possible
@@ -1919,6 +1919,9 @@ void CallPrivate::start()
    }
    setStartTimeStamp();
    initTimer();
+
+   /* we want to exchange vCards once the call starts so both peers have updated profiles */
+   sendProfile();
 }
 
 ///Toggle the timer
@@ -1945,6 +1948,9 @@ void CallPrivate::startWeird()
    qDebug() << "Starting call. callId : " << q_ptr  << "ConfId:" << q_ptr;
    setStartTimeStamp();
    qDebug() << "Warning : call " << q_ptr << " had an unexpected transition of state at its start.";
+
+   /* we want to exchange vCards once the call starts so both peers have updated profiles */
+   sendProfile();
 }
 
 ///Print a warning
-- 
GitLab