From 0f09e23b2d77e50649ab23216947b728e8b41138 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> Date: Thu, 2 Oct 2014 17:04:29 +0200 Subject: [PATCH] account: Split user defined and volatile account parameters getters (2/2) Use the new volatileAccountDetailsChanged as a replacement for sipRegistrationStateChanged. What this commit does *NOT* do: * Clean outdated SIP error messages * Forward TLS error messages * Forward other transport errors * Compute downtime timestamp Those features will be part of future commits. Refs #56143 Change-Id: I336cc6826b468a96e14ef08748c6718823bd647b --- daemon/src/account.cpp | 5 ++--- daemon/src/account_schema.h | 10 +++++++--- daemon/src/client/configurationmanager.cpp | 7 +++++-- daemon/src/client/configurationmanager.h | 2 +- daemon/src/sip/sipaccount.cpp | 16 ++++++++++++++++ 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/daemon/src/account.cpp b/daemon/src/account.cpp index 4c15ad5ac5..0e5c29a804 100644 --- a/daemon/src/account.cpp +++ b/daemon/src/account.cpp @@ -138,6 +138,7 @@ void Account::setRegistrationState(RegistrationState state) // Notify the client ConfigurationManager *c(Manager::instance().getClient()->getConfigurationManager()); c->registrationStateChanged(accountID_, static_cast<int32_t>(registrationState_)); + c->volatileAccountDetailsChanged(getAccountID()); } } @@ -256,9 +257,7 @@ std::map<std::string, std::string> Account::getVolatileAccountDetails() const { std::map<std::string, std::string> a; - RegistrationState state(registrationState_); - - a[CONFIG_ACCOUNT_REGISTRATION_STATUS] = mapStateNumberToString(state); + a[CONFIG_ACCOUNT_REGISTRATION_STATUS] = mapStateNumberToString(registrationState_); return a; } diff --git a/daemon/src/account_schema.h b/daemon/src/account_schema.h index 7a61a87a15..f6fddc671f 100644 --- a/daemon/src/account_schema.h +++ b/daemon/src/account_schema.h @@ -44,9 +44,6 @@ static const char *const CONFIG_ACCOUNT_MAILBOX = "Account.mailb static const char *const CONFIG_ACCOUNT_ENABLE = "Account.enable"; static const char *const CONFIG_ACCOUNT_AUTOANSWER = "Account.autoAnswer"; static const char *const CONFIG_ACCOUNT_REGISTRATION_EXPIRE = "Account.registrationExpire"; -static const char *const CONFIG_ACCOUNT_REGISTRATION_STATUS = "Account.registrationStatus"; -static const char *const CONFIG_ACCOUNT_REGISTRATION_STATE_CODE = "Account.registrationCode"; -static const char *const CONFIG_ACCOUNT_REGISTRATION_STATE_DESC = "Account.registrationDescription"; static const char *const CONFIG_ACCOUNT_DTMF_TYPE = "Account.dtmfType"; static const char *const CONFIG_RINGTONE_PATH = "Account.ringtonePath"; static const char *const CONFIG_RINGTONE_ENABLED = "Account.ringtoneEnabled"; @@ -103,4 +100,11 @@ static const char *const CONFIG_TLS_VERIFY_CLIENT = "TLS.verifyCli static const char *const CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE = "TLS.requireClientCertificate"; static const char *const CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC = "TLS.negotiationTimeoutSec"; +// Volatile parameters +static const char *const CONFIG_ACCOUNT_REGISTRATION_STATUS = "Account.registrationStatus"; +static const char *const CONFIG_ACCOUNT_REGISTRATION_STATE_CODE = "Account.registrationCode"; +static const char *const CONFIG_ACCOUNT_REGISTRATION_STATE_DESC = "Account.registrationDescription"; +static const char *const CONFIG_TLS_TRANSPORT_STATE_CODE = "TLS.transportStatusCode"; +static const char *const CONFIG_TLS_TRANSPORT_STATE_DESC = "TLS.transportStatusDescription"; + #endif // ACCOUNT_SCHEMA_H_ diff --git a/daemon/src/client/configurationmanager.cpp b/daemon/src/client/configurationmanager.cpp index f19a1220e7..92e9929c8f 100644 --- a/daemon/src/client/configurationmanager.cpp +++ b/daemon/src/client/configurationmanager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2013 Savoir-Faire Linux Inc. + * Copyright (C) 2004-2014 Savoir-Faire Linux Inc. * Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com> * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> * Author: Guillaume Carmel-Archambault <guillaume.carmel-archambault@savoirfairelinux.com> @@ -639,8 +639,11 @@ void ConfigurationManager::sipRegistrationStateChanged(const std::string& accoun } -void ConfigurationManager::volatileAccountDetailsChanged(const std::string& accountID, const std::map< std::string, std::string >& details) +void ConfigurationManager::volatileAccountDetailsChanged(const std::string& accountID) { + if (evHandlers_.on_volatile_details_change) { + evHandlers_.on_volatile_details_change(accountID, Manager::instance().getVolatileAccountDetails(accountID)); + } } void ConfigurationManager::errorAlert(int alert) diff --git a/daemon/src/client/configurationmanager.h b/daemon/src/client/configurationmanager.h index 171dad4c04..30774f8a8c 100644 --- a/daemon/src/client/configurationmanager.h +++ b/daemon/src/client/configurationmanager.h @@ -156,7 +156,7 @@ class ConfigurationManager void registrationStateChanged(const std::string& accoundID, int state); void sipRegistrationStateChanged(const std::string&, const std::string&, int32_t state); - void volatileAccountDetailsChanged(const std::string& accountID, const std::map< std::string, std::string >& details); + void volatileAccountDetailsChanged(const std::string& accountID); void errorAlert(int alert); std::vector< int32_t > getHardwareAudioFormat(); diff --git a/daemon/src/sip/sipaccount.cpp b/daemon/src/sip/sipaccount.cpp index 13c80c083f..f19d7e533e 100644 --- a/daemon/src/sip/sipaccount.cpp +++ b/daemon/src/sip/sipaccount.cpp @@ -658,6 +658,21 @@ std::map<std::string, std::string> SIPAccount::getAccountDetails() const std::map<std::string, std::string> SIPAccount::getVolatileAccountDetails() const { std::map<std::string, std::string> a = SIPAccountBase::getVolatileAccountDetails(); + std::stringstream codestream; + codestream << registrationStateDetailed_.first; + a[ CONFIG_ACCOUNT_REGISTRATION_STATE_CODE ] = codestream.str(); + a[ CONFIG_ACCOUNT_REGISTRATION_STATE_DESC ] = registrationStateDetailed_.second; + +#ifdef SFL_PRESENCE + if (presence_) { + a[CONFIG_PRESENCE_STATUS] = presence_ and presence_->isOnline()? TRUE_STR : FALSE_STR; + a[CONFIG_PRESENCE_NOTE] = presence_ ? presence_->getNote() : " "; + } +#endif + +#if HAVE_TLS + //TODO +#endif return a; } @@ -1004,6 +1019,7 @@ SIPAccount::onRegister(pjsip_regc_cbparam *param) std::string state(description->ptr, description->slen); Manager::instance().getClient()->getConfigurationManager()->sipRegistrationStateChanged(getAccountID(), state, param->code); + Manager::instance().getClient()->getConfigurationManager()->volatileAccountDetailsChanged(getAccountID()); std::pair<int, std::string> details(param->code, state); // TODO: there id a race condition for this ressource when closing the application setRegistrationStateDetailed(details); -- GitLab