From cc7c849e98666eed731074175603535b0b3d26de Mon Sep 17 00:00:00 2001
From: Emmanuel Lepage <emmanuel.lepage@savoirfairelinux.com>
Date: Wed, 2 May 2012 10:31:55 -0400
Subject: [PATCH] [ #10222 ] Fix minor itches and bugs

---
 src/Account.cpp      |  6 +++---
 src/AccountList.cpp  |  8 ++++----
 src/CallModel.cpp    |  7 ++++++-
 src/CallModel.h      | 21 ++++++++++++---------
 src/CallModel.hpp    | 10 +++++++++-
 src/sflphone_const.h | 20 ++++++++++----------
 6 files changed, 44 insertions(+), 28 deletions(-)

diff --git a/src/Account.cpp b/src/Account.cpp
index 6e4f05e0..e3b349d9 100644
--- a/src/Account.cpp
+++ b/src/Account.cpp
@@ -183,7 +183,7 @@ bool Account::isEnabled() const
 ///Is this account registered
 bool Account::isRegistered() const
 {
-   return (getAccountDetail(REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED);
+   return (getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED);
 }
 
 
@@ -232,8 +232,8 @@ void Account::updateState()
    if(! isNew()) {
       ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
       MapStringString details = configurationManager.getAccountDetails(getAccountId()).value();
-      QString status = details[REGISTRATION_STATUS];
-      setAccountDetail(REGISTRATION_STATUS, status); //Update -internal- object state
+      QString status = details[ACCOUNT_REGISTRATION_STATUS];
+      setAccountDetail(ACCOUNT_REGISTRATION_STATUS, status); //Update -internal- object state
    }
 }
 
diff --git a/src/AccountList.cpp b/src/AccountList.cpp
index 30c440de..9b462220 100644
--- a/src/AccountList.cpp
+++ b/src/AccountList.cpp
@@ -143,7 +143,7 @@ QVector<Account*> AccountList::getAccountsByState(const QString& state)
 {
    QVector<Account *> v;
    for (int i = 0; i < m_pAccounts->size(); ++i) {
-      if ((*m_pAccounts)[i]->getAccountDetail(REGISTRATION_STATUS) == state)
+      if ((*m_pAccounts)[i]->getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == state)
          v += (*m_pAccounts)[i];
    }
    return v;
@@ -157,7 +157,7 @@ QVector<Account*> AccountList::registeredAccounts() const
    Account* current;
    for (int i = 0; i < m_pAccounts->count(); ++i) {
       current = (*m_pAccounts)[i];
-      if(current->getAccountDetail(REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED) {
+      if(current->getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED) {
          qDebug() << current->getAlias() << " : " << current;
          registeredAccounts.append(current);
       }
@@ -171,11 +171,11 @@ Account* AccountList::firstRegisteredAccount() const
    Account* current;
    for (int i = 0; i < m_pAccounts->count(); ++i) {
       current = (*m_pAccounts)[i];
-      if(current && current->getAccountDetail(REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED) {
+      if(current && current->getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED) {
          return current;
       }
       else {
-         qDebug() << "Account " << ((current)?current->getAccountId():"") << " is not registered (" << ((current)?current->getAccountDetail(REGISTRATION_STATUS):"") << ") State:" << ((current)?current->getAccountDetail(REGISTRATION_STATUS):"");
+         qDebug() << "Account " << ((current)?current->getAccountId():"") << " is not registered (" << ((current)?current->getAccountDetail(ACCOUNT_REGISTRATION_STATUS):"") << ") State:" << ((current)?current->getAccountDetail(ACCOUNT_REGISTRATION_STATUS):"");
       }
    }
    return NULL;
diff --git a/src/CallModel.cpp b/src/CallModel.cpp
index 66c37d1f..79acc3b3 100644
--- a/src/CallModel.cpp
+++ b/src/CallModel.cpp
@@ -60,7 +60,12 @@ void CallModelBase::on1_callStateChanged(const QString &callID, const QString &s
       qDebug() << "Call found" << call;
       call->stateChanged(state);
    }
-   //updateWindowCallState(); //NEED_PORT
+
+   if (call->getCurrentState() == CALL_STATE_OVER) {
+      addToHistory(call);
+      emit historyChanged();
+   }
+   
    emit callStateChanged(call);
    
 }
diff --git a/src/CallModel.h b/src/CallModel.h
index 76441382..924264d8 100644
--- a/src/CallModel.h
+++ b/src/CallModel.h
@@ -54,6 +54,7 @@ public:
    virtual Call* findCallByCallId ( const QString& callId                       ) = 0;
    virtual Call* addRingingCall   ( const QString& callId                       ) = 0;
    virtual Call* addIncomingCall  ( const QString& callId                       ) = 0;
+   virtual void  addToHistory     ( Call* call                                  ) = 0;
    virtual Call* addCall          ( Call* call           , Call* parent =0      );
    virtual Call* getCall          ( const QString& callId                       ) const = 0;
 public slots:
@@ -67,15 +68,16 @@ public slots:
 private:
    static bool dbusInit;
 signals:
-   void callStateChanged        (Call* call                              );
-   void incomingCall            (Call* call                              );
-   void conferenceCreated       (Call* conf                              );
-   void conferenceChanged       (Call* conf                              );
-   void conferenceRemoved       (const QString& confId                   );
-   void aboutToRemoveConference (Call* conf                              );
-   void voiceMailNotify         (const QString& accountID , int    count );
-   void volumeChanged           (const QString& device    , double value );
-   void callAdded               (Call* call               , Call* parent );
+   void callStateChanged        ( Call* call                              );
+   void incomingCall            ( Call* call                              );
+   void conferenceCreated       ( Call* conf                              );
+   void conferenceChanged       ( Call* conf                              );
+   void conferenceRemoved       ( const QString& confId                   );
+   void aboutToRemoveConference ( Call* conf                              );
+   void voiceMailNotify         ( const QString& accountID , int    count );
+   void volumeChanged           ( const QString& device    , double value );
+   void callAdded               ( Call* call               , Call* parent );
+   void historyChanged          (                                         );
 };
 
 /**
@@ -109,6 +111,7 @@ class LIB_EXPORT CallModel : public CallModelBase {
       void           removeCall       ( Call* call                                     );
       void           attendedTransfer ( Call* toTransfer           , Call* target      );
       void           transfer         ( Call* toTransfer           , QString target    );
+      void           addToHistory     ( Call* call                                     );
       
       virtual bool selectItem(Call* item) { Q_UNUSED(item); return false;}
 
diff --git a/src/CallModel.hpp b/src/CallModel.hpp
index 8fb295df..2145ac8c 100644
--- a/src/CallModel.hpp
+++ b/src/CallModel.hpp
@@ -419,6 +419,14 @@ template<typename CallWidget, typename Index> const CallHash& CallModel<CallWidg
    return m_sHistoryCalls;
 }
 
+///Add to history
+template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>::addToHistory(Call* call)
+{
+   if (call) {
+      m_sHistoryCalls[call->getStartTimeStamp()] = call;
+   }
+}
+
 /*****************************************************************************
  *                                                                           *
  *                           Account related code                            *
@@ -442,7 +450,7 @@ template<typename CallWidget, typename Index> QString CallModel<CallWidget,Index
 template<typename CallWidget, typename Index> Account* CallModel<CallWidget,Index>::getCurrentAccount()
 {
    Account* priorAccount = getAccountList()->getAccountById(m_sPriorAccountId);
-   if(priorAccount && priorAccount->getAccountDetail(REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED ) {
+   if(priorAccount && priorAccount->getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED ) {
       return priorAccount;
    }
    else {
diff --git a/src/sflphone_const.h b/src/sflphone_const.h
index 500cca98..14d75422 100644
--- a/src/sflphone_const.h
+++ b/src/sflphone_const.h
@@ -173,6 +173,10 @@
 #define ACCOUNT_MAILBOX                    "Account.mailbox"
 #define ACCOUNT_USERAGENT                  "Account.useragent"
 #define ACCOUNT_REGISTRATION_EXPIRE        "Account.registrationExpire"
+#define ACCOUNT_REGISTRATION_STATUS        "Account.registrationStatus"
+#define ACCOUNT_REGISTRATION_STATE_CODE    "Account.registrationCode"
+#define ACCOUNT_REGISTRATION_STATE_DESC    "Account.registrationDescription"
+
 #define ACCOUNT_SIP_STUN_SERVER            "STUN.server"
 #define ACCOUNT_SIP_STUN_ENABLED           "STUN.enable"
 #define ACCOUNT_DTMF_TYPE                  "Account.dtmfType"
@@ -211,16 +215,6 @@
 #define TLS_NEGOTIATION_TIMEOUT_SEC        "TLS.negotiationTimeoutSec"
 #define TLS_NEGOTIATION_TIMEOUT_MSEC       "TLS.negotiationTimemoutMsec"
 
-#define LOCAL_INTERFACE                    "Account.localInterface"
-#define PUBLISHED_SAMEAS_LOCAL             "Account.publishedSameAsLocal"
-#define LOCAL_PORT                         "Account.localPort"
-#define PUBLISHED_PORT                     "Account.publishedPort"
-#define PUBLISHED_ADDRESS                  "Account.publishedAddress"
-
-#define REGISTRATION_STATUS                "Registration.Status"
-#define REGISTRATION_STATE_CODE            "Registration.code"
-#define REGISTRATION_STATE_DESCRIPTION     "Registration.description"
-
 #define SHORTCUT_PICKUP                    "pickUp"
 #define SHORTCUT_HANGUP                    "hangUp"
 #define SHORTCUT_POPUP                     "popupWindow"
@@ -236,6 +230,12 @@
 #define CONFIG_ACCOUNT_DEFAULT_REALM        "*"
 #define CONFIG_ACCOUNT_USERAGENT            "Account.useragent"
 
+#define LOCAL_INTERFACE                    "Account.localInterface"
+#define PUBLISHED_SAMEAS_LOCAL             "Account.publishedSameAsLocal"
+#define LOCAL_PORT                         "Account.localPort"
+#define PUBLISHED_PORT                     "Account.publishedPort"
+#define PUBLISHED_ADDRESS                  "Account.publishedAddress"
+
 
 /** Maybe to remove **/
 // #define ACCOUNT_EXPIRE                   "Account.expire"
-- 
GitLab