From 2329fc3d875b0f3c430ed3b4c53e18abf63ca6dc Mon Sep 17 00:00:00 2001
From: Emmanuel Lepage <emmanuel.lepage@savoirfairelinux.com>
Date: Mon, 7 May 2012 16:00:37 -0400
Subject: [PATCH] [ #10222 ] Test configuration dialog, fix it, implement basic
 messaging

---
 src/Call.cpp      | 5 +++++
 src/Call.h        | 1 +
 src/CallModel.cpp | 2 +-
 src/CallModel.h   | 6 +++---
 src/CallModel.hpp | 7 ++++---
 5 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/Call.cpp b/src/Call.cpp
index e09f029a..d700174d 100644
--- a/src/Call.cpp
+++ b/src/Call.cpp
@@ -535,6 +535,11 @@ void Call::changeCurrentState(call_state newState)
       emit isOver(this);
 }
 
+void Call::sendTextMessage(QString message)
+{
+   CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance();
+   callManager.sendTextMessage(m_CallId,message);
+}
 
 /*****************************************************************************
  *                                                                           *
diff --git a/src/Call.h b/src/Call.h
index 47252d9f..4d763bf4 100644
--- a/src/Call.h
+++ b/src/Call.h
@@ -168,6 +168,7 @@ public:
    void appendText(const QString& str);
    void backspaceItemText();
    void changeCurrentState(call_state newState);
+   void sendTextMessage(QString message);
    
 private:
 
diff --git a/src/CallModel.cpp b/src/CallModel.cpp
index 79acc3b3..f172b83a 100644
--- a/src/CallModel.cpp
+++ b/src/CallModel.cpp
@@ -96,7 +96,7 @@ void CallModelBase::on1_changingConference(const QString &confID, const QString
 {
    Call* conf = getCall(confID);
    qDebug() << "Changing conference state" << conf << confID;
-   if (conf) {
+   if (conf && dynamic_cast<Call*>(conf)) { //Prevent a race condition between call and conference
       changeConference(confID, state);
       emit conferenceChanged(conf);
    }
diff --git a/src/CallModel.h b/src/CallModel.h
index adf17e1a..3346f93d 100644
--- a/src/CallModel.h
+++ b/src/CallModel.h
@@ -40,9 +40,9 @@ class ContactBackend;
 typedef QMap<QString, Call*>  CallMap;
 typedef QList<Call*>          CallList;
 
-///@class CallModelBase Base class for the central model/frontend
-///This class need to exist because template classes can't have signals ans
-///slots because Qt MOC generator can't guess the type at precompilation
+///@class CallModelBase Base class for the central model/frontend          
+///This class need to exist because template classes can't have signals and
+///slots because Qt MOC generator can't guess the type at precompilation   
 class LIB_EXPORT CallModelBase : public QObject
 {
    Q_OBJECT
diff --git a/src/CallModel.hpp b/src/CallModel.hpp
index dc2973ec..5a1719c4 100644
--- a/src/CallModel.hpp
+++ b/src/CallModel.hpp
@@ -736,25 +736,26 @@ template<typename CallWidget, typename Index> CallWidget CallModel<CallWidget,In
 ///Common set of instruction shared by all gui updater
 template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::updateCommon(Call* call)
 {
-   if (!m_sPrivateCallList_call[call]) {
+   if (!m_sPrivateCallList_call[call] && dynamic_cast<Call*>(call)) {
       m_sPrivateCallList_call   [ call              ]             = new InternalStruct            ;
       m_sPrivateCallList_call   [ call              ]->call_real  = call                          ;
       m_sPrivateCallList_call   [ call              ]->conference = false                         ;
       m_sPrivateCallList_callId [ call->getCallId() ]             = m_sPrivateCallList_call[call] ;
    }
+   else
+      return false;
    return true;
 }
 
 ///Update the widget associated with this call                     
 template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::updateWidget     (Call* call, CallWidget value )
 {
-   updateCommon(call);
+   if (!updateCommon(call)) return false;
    m_sPrivateCallList_call[call]->call = value                         ;
    m_sPrivateCallList_widget[value]    = m_sPrivateCallList_call[call] ;
    return true;
 }
 
-
 ///Update the index associated with this call
 template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::updateIndex      (Call* call, Index value      )
 {
-- 
GitLab