Commit 33dcc425 authored by Emmanuel Lepage Vallee's avatar Emmanuel Lepage Vallee Committed by Tristan Matthews

account: Split user defined and volatile account parameters getters (1/2)

This first commit implements the plumbing necessary to expose more
fields.

Refs #56143

Change-Id: I81ce06b0c2b24be1985b7c8ff331e88d22f5b534
parent 041c246a
......@@ -71,6 +71,25 @@
</arg>
</method>
<method name="getVolatileAccountDetails" tp:name-for-bindings="getVolatileAccountDetails">
<arg type="s" name="accountID" direction="in">
<tp:docstring>
The account ID
</tp:docstring>
</arg>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="MapStringString"/>
<arg type="a{ss}" name="details" tp:type="String_String_Map" direction="out">
<tp:docstring>
Account.registrationCoarseStatus ( Coarse status like, UNREGISTERED or TRYING )
Account.registrationStatus ( Error code, like 200 (OK) or 408 (Timeout) )
Account.registrationStatusDescription ( A technical error message (from PJSIP) )
Account.lastSuccessfulRegister ( Timestamp of the last "REGISTERED" event )
Account.presenceStatus ( Published presence status )
Account.presenceNote ( Published presence note (status string) )
</tp:docstring>
</arg>
</method>
<method name="setAccountDetails" tp:name-for-bindings="setAccountDetails">
<tp:docstring>
Send new account parameters, or account parameters changes, to the core. The hash table is not required to be complete, only the updated parameters may be specified.
......@@ -534,6 +553,7 @@
<tp:docstring>
<p>Account state changed, SFLphone received a notification from registrar.</p>
</tp:docstring>
<annotation name="org.freedesktop.DBus.Deprecated" value="true"/>
<arg type="s" name="accountID" >
<tp:docstring>
The account ID
......@@ -551,6 +571,24 @@
</arg>
</signal>
<signal name="volatileAccountDetailsChanged" tp:name-for-bindings="volatileAccountDetailsChanged">
<arg type="s" name="accountID">
<tp:docstring>
The account ID
</tp:docstring>
</arg>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="MapStringString"/>
<arg type="a{ss}" name="details" tp:type="String_String_Map">
<tp:docstring>
Account.registrationCoarseStatus ( Coarse status like, UNREGISTERED or TRYING )
Account.registrationStatus ( Error code, like 200 (OK) or 408 (Timeout) )
Account.registrationStatusDescription ( A technical error message (from PJSIP) )
Account.lastSuccessfulRegister ( Timestamp of the last "REGISTERED" event )
Account.presenceStatus ( Published presence status )
Account.presenceNote ( Published presence note (status string) )
</tp:docstring>
</arg>
</signal>
<signal name="stunStatusFailure" tp:name-for_bindings="stunStatusFailure">
<arg type="s" name="reason">
......
......@@ -183,6 +183,7 @@ int DBusClient::initLibrary(int sflphFlags)
bind(&DBusConfigurationManager::stunStatusFailure, confM, _1),
bind(&DBusConfigurationManager::registrationStateChanged, confM, _1, _2),
bind(&DBusConfigurationManager::sipRegistrationStateChanged, confM, _1, _2, _3),
bind(&DBusConfigurationManager::volatileAccountDetailsChanged, confM, _1, _2),
bind(&DBusConfigurationManager::errorAlert, confM, _1),
};
......
......@@ -42,6 +42,11 @@ std::map<std::string, std::string> DBusConfigurationManager::getAccountDetails(c
return sflph_config_get_account_details(accountID);
}
std::map<std::string, std::string> DBusConfigurationManager::getVolatileAccountDetails(const std::string& accountID)
{
return sflph_config_get_volatile_account_details(accountID);
}
void DBusConfigurationManager::setAccountDetails(const std::string& accountID, const std::map< std::string, std::string >& details)
{
sflph_config_set_account_details(accountID, details);
......
......@@ -68,6 +68,7 @@ class DBusConfigurationManager :
// Methods
std::map< std::string, std::string > getAccountDetails(const std::string& accountID);
std::map<std::string, std::string> getVolatileAccountDetails(const std::string& accountID);
void setAccountDetails(const std::string& accountID, const std::map< std::string, std::string >& details);
std::map<std::string, std::string> getAccountTemplate();
std::string addAccount(const std::map< std::string, std::string >& details);
......
......@@ -240,6 +240,8 @@ std::map<std::string, std::string> Account::getAccountDetails() const
RegistrationState state(registrationState_);
// This method should only stores user-settable fields
// For legacy reasons, the STATUS will be kept for some time
a[CONFIG_ACCOUNT_REGISTRATION_STATUS] = mapStateNumberToString(state);
a[CONFIG_ACCOUNT_USERAGENT] = hasCustomUserAgent_ ? userAgent_ : DEFAULT_USER_AGENT;
a[CONFIG_ACCOUNT_HAS_CUSTOM_USERAGENT] = hasCustomUserAgent_ ? TRUE_STR : FALSE_STR;
......@@ -250,6 +252,16 @@ std::map<std::string, std::string> Account::getAccountDetails() const
return a;
}
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);
return a;
}
#ifdef SFL_VIDEO
static bool
isPositiveInteger(const string &s)
......
......@@ -88,6 +88,8 @@ class Account : public Serializable {
virtual std::map<std::string, std::string> getAccountDetails() const;
virtual std::map<std::string, std::string> getVolatileAccountDetails() const;
/**
* Load the settings for this account.
*/
......
......@@ -79,6 +79,13 @@ std::map<std::string, std::string> ConfigurationManager::getAccountDetails(
return Manager::instance().getAccountDetails(accountID);
}
std::map<std::string, std::string> ConfigurationManager::getVolatileAccountDetails(
const std::string& accountID)
{
return Manager::instance().getVolatileAccountDetails(accountID);
}
std::map<std::string, std::string>
ConfigurationManager::getTlsSettingsDefault()
{
......@@ -631,6 +638,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::errorAlert(int alert)
{
if (evHandlers_.on_error) {
......
......@@ -52,6 +52,7 @@ class ConfigurationManager
// Methods
public:
std::map< std::string, std::string > getAccountDetails(const std::string& accountID);
std::map<std::string, std::string> getVolatileAccountDetails(const std::string& accountID);
void setAccountDetails(const std::string& accountID, const std::map< std::string, std::string >& details);
std::map<std::string, std::string> getAccountTemplate();
std::string addAccount(const std::map< std::string, std::string >& details);
......@@ -155,6 +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 errorAlert(int alert);
std::vector< int32_t > getHardwareAudioFormat();
......
......@@ -84,6 +84,13 @@ std::map<std::string, std::string> IAXAccount::getAccountDetails() const
return a;
}
std::map<std::string, std::string> IAXAccount::getVolatileAccountDetails() const
{
std::map<std::string, std::string> a = Account::getVolatileAccountDetails();
return a;
}
void IAXAccount::doRegister()
{
try {
......
......@@ -63,6 +63,8 @@ class IAXAccount : public Account {
std::map<std::string, std::string> getAccountDetails() const;
virtual std::map<std::string, std::string> getVolatileAccountDetails() const;
void setNextRefreshStamp(int value) {
nextRefreshStamp_ = value;
}
......
......@@ -2338,6 +2338,20 @@ ManagerImpl::getAccountDetails(const std::string& accountID) const
}
}
std::map<std::string, std::string>
ManagerImpl::getVolatileAccountDetails(const std::string& accountID) const
{
const auto account = getAccount(accountID);
if (account) {
return account->getVolatileAccountDetails();
} else {
ERROR("Could not get volatile account details on a non-existing accountID %s", accountID.c_str());
return {{}};
}
}
// method to reduce the if/else mess.
// Even better, switch to XML !
......
......@@ -428,6 +428,13 @@ class ManagerImpl {
*/
std::map<std::string, std::string> getAccountDetails(const std::string& accountID) const;
/**
* Retrieve volatile details such as recent registration errors
* @param accountID The account identifier
* @return std::map< std::string, std::string > The account volatile details
*/
std::map<std::string, std::string> getVolatileAccountDetails(const std::string& accountID) const;
/**
* Retrieve details about a given call
* @param callID The account identifier
......
......@@ -62,6 +62,7 @@ struct sflph_config_ev_handlers
std::function<void (const std::string& /*account_id*/)> on_stun_status_fail;
std::function<void (const std::string& /*account_id*/, int /*state*/)> on_registration_state_change;
std::function<void (const std::string& /*account_id*/, const std::string& /*state*/, int /*code*/)> on_sip_registration_state_change;
std::function<void (const std::string& /*account_id*/, std::map<std::string, std::string> /* details */)> on_volatile_details_change;
std::function<void (int /*alert*/)> on_error;
};
......@@ -198,6 +199,7 @@ void sflph_call_send_text_message(const std::string& call_id, const std::string&
/* configuration API */
std::map<std::string, std::string> sflph_config_get_account_details(const std::string& account_id);
std::map<std::string, std::string> sflph_config_get_volatile_account_details(const std::string& account_id);
void sflph_config_set_account_details(const std::string& account_id, const std::map<std::string, std::string>& details);
std::map<std::string, std::string> sflph_config_get_account_template(void);
std::string sflph_config_add_account(const std::map<std::string, std::string>& details);
......
......@@ -348,6 +348,11 @@ std::map<std::string, std::string> sflph_config_get_account_details(const std::s
return getConfigurationManager()->getAccountDetails(account_id);
}
std::map<std::string, std::string> sflph_config_get_volatile_account_details(const std::string& account_id)
{
return getConfigurationManager()->getVolatileAccountDetails(account_id);
}
void sflph_config_set_account_details(const std::string& account_id, const std::map<std::string, std::string>& details)
{
getConfigurationManager()->setAccountDetails(account_id, details);
......
......@@ -655,6 +655,13 @@ std::map<std::string, std::string> SIPAccount::getAccountDetails() const
return a;
}
std::map<std::string, std::string> SIPAccount::getVolatileAccountDetails() const
{
std::map<std::string, std::string> a = SIPAccountBase::getVolatileAccountDetails();
return a;
}
void SIPAccount::doRegister()
{
if (not isEnabled()) {
......
......@@ -122,6 +122,12 @@ class SIPAccount : public SIPAccountBase {
*/
virtual std::map<std::string, std::string> getAccountDetails() const;
/**
* Retrieve volatile details such as recent registration errors
* @return std::map< std::string, std::string > The account volatile details
*/
virtual std::map<std::string, std::string> getVolatileAccountDetails() const;
/**
* Return the information for the default IP to IP account
*/
......
......@@ -251,6 +251,15 @@ SIPAccountBase::onTransportStateChanged(pjsip_transport_state state, const pjsip
}
}
std::map<std::string, std::string>
SIPAccountBase::getVolatileAccountDetails() const
{
std::map<std::string, std::string> a = Account::getVolatileAccountDetails();
a[CONFIG_ACCOUNT_REGISTRATION_STATUS] = isIP2IP() ? "READY" : mapStateNumberToString(registrationState_);
return a;
}
void
SIPAccountBase::setTransport(const std::shared_ptr<SipTransport>& t)
{
......
......@@ -293,6 +293,12 @@ protected:
virtual std::map<std::string, std::string> getAccountDetails() const;
/**
* Retrieve volatile details such as recent registration errors
* @return std::map< std::string, std::string > The account volatile details
*/
virtual std::map<std::string, std::string> getVolatileAccountDetails() const;
/**
* Callback called by the transport layer when the registration
* transport state changes.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment