Commit 578d1406 authored by Adrien Béraud's avatar Adrien Béraud Committed by Guillaume Roguez

sipaccount: use emplace, to_string where possible

Refs #67228

Change-Id: Ib1e55e2490e04ab0669275d6e17f036263e20c0e
Signed-off-by: Guillaume Roguez's avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
parent 27d9dfac
......@@ -87,6 +87,9 @@ const char * const Account::HAS_CUSTOM_USER_AGENT_KEY = "hasCustomUserAgent";
const char * const Account::PRESENCE_MODULE_ENABLED_KEY = "presenceModuleEnabled";
const char * const Account::UPNP_ENABLED_KEY = "upnpEnabled";
constexpr const char* Account::TRUE_STR;
constexpr const char* Account::FALSE_STR;
Account::Account(const std::string &accountID)
: accountID_(accountID)
, username_()
......
......@@ -86,8 +86,8 @@ class VoipLinkException : public std::runtime_error
class Account : public Serializable, public std::enable_shared_from_this<Account>
{
public:
constexpr static const char *TRUE_STR = "true";
constexpr static const char *FALSE_STR = "false";
constexpr static const char* TRUE_STR = "true";
constexpr static const char* FALSE_STR = "false";
Account(const std::string& accountID);
......
......@@ -532,7 +532,7 @@ void RingAccount::setAccountDetails(const std::map<std::string, std::string> &de
std::map<std::string, std::string> RingAccount::getAccountDetails() const
{
std::map<std::string, std::string> a = SIPAccountBase::getAccountDetails();
a[Conf::CONFIG_DHT_PORT] = ring::to_string(dhtPort_);
a.emplace(Conf::CONFIG_DHT_PORT, ring::to_string(dhtPort_));
return a;
}
......
This diff is collapsed.
......@@ -167,7 +167,6 @@ void SIPAccountBase::unserialize(const YAML::Node &node)
unserializeRange(node, Conf::VIDEO_PORT_MIN_KEY, Conf::VIDEO_PORT_MAX_KEY, videoPortRange_);
}
void SIPAccountBase::setAccountDetails(const std::map<std::string, std::string> &details)
{
Account::setAccountDetails(details);
......@@ -205,11 +204,11 @@ void SIPAccountBase::setAccountDetails(const std::map<std::string, std::string>
std::map<std::string, std::string>
SIPAccountBase::getAccountDetails() const
{
std::map<std::string, std::string> a = Account::getAccountDetails();
auto a = Account::getAccountDetails();
// note: The IP2IP profile will always have IP2IP as an alias
a[Conf::CONFIG_VIDEO_ENABLED] = videoEnabled_ ? TRUE_STR : FALSE_STR;
a[Conf::CONFIG_ACCOUNT_REGISTRATION_STATUS] = isIP2IP() ? "READY" : mapStateNumberToString(registrationState_);
a.emplace(Conf::CONFIG_VIDEO_ENABLED, videoEnabled_ ? TRUE_STR : FALSE_STR);
a.emplace(Conf::CONFIG_ACCOUNT_REGISTRATION_STATUS, isIP2IP() ? "READY" : mapStateNumberToString(registrationState_));
// Add sip specific details
......@@ -218,29 +217,26 @@ SIPAccountBase::getAccountDetails() const
addRangeToDetails(a, Conf::CONFIG_ACCOUNT_VIDEO_PORT_MIN, Conf::CONFIG_ACCOUNT_VIDEO_PORT_MAX, videoPortRange_);
#endif
a[Conf::CONFIG_ACCOUNT_DTMF_TYPE] = dtmfType_;
a[Conf::CONFIG_LOCAL_INTERFACE] = interface_;
a[Conf::CONFIG_PUBLISHED_PORT] = ring::to_string(publishedPort_);
a[Conf::CONFIG_PUBLISHED_SAMEAS_LOCAL] = publishedSameasLocal_ ? TRUE_STR : FALSE_STR;
a[Conf::CONFIG_PUBLISHED_ADDRESS] = publishedIpAddress_;
a.emplace(Conf::CONFIG_ACCOUNT_DTMF_TYPE, dtmfType_);
a.emplace(Conf::CONFIG_LOCAL_INTERFACE, interface_);
a.emplace(Conf::CONFIG_PUBLISHED_PORT, ring::to_string(publishedPort_));
a.emplace(Conf::CONFIG_PUBLISHED_SAMEAS_LOCAL, publishedSameasLocal_ ? TRUE_STR : FALSE_STR);
a.emplace(Conf::CONFIG_PUBLISHED_ADDRESS, publishedIpAddress_);
a[Conf::CONFIG_TLS_CA_LIST_FILE] = tlsCaListFile_;
a[Conf::CONFIG_TLS_CERTIFICATE_FILE] = tlsCertificateFile_;
a[Conf::CONFIG_TLS_PRIVATE_KEY_FILE] = tlsPrivateKeyFile_;
a[Conf::CONFIG_TLS_PASSWORD] = tlsPassword_;
a.emplace(Conf::CONFIG_TLS_CA_LIST_FILE, tlsCaListFile_);
a.emplace(Conf::CONFIG_TLS_CERTIFICATE_FILE, tlsCertificateFile_);
a.emplace(Conf::CONFIG_TLS_PRIVATE_KEY_FILE, tlsPrivateKeyFile_);
a.emplace(Conf::CONFIG_TLS_PASSWORD, tlsPassword_);
return a;
}
std::map<std::string, std::string>
SIPAccountBase::getVolatileAccountDetails() const
{
std::map<std::string, std::string> a = Account::getVolatileAccountDetails();
a[Conf::CONFIG_ACCOUNT_REGISTRATION_STATUS] = isIP2IP() ? "READY" : mapStateNumberToString(registrationState_);
std::stringstream codestream;
codestream << transportStatus_;
a[Conf::CONFIG_TRANSPORT_STATE_CODE] = codestream.str();
a[Conf::CONFIG_TRANSPORT_STATE_DESC] = transportError_ ;
auto a = Account::getVolatileAccountDetails();
a.emplace(Conf::CONFIG_ACCOUNT_REGISTRATION_STATUS, isIP2IP() ? "READY" : mapStateNumberToString(registrationState_));
a.emplace(Conf::CONFIG_TRANSPORT_STATE_CODE, ring::to_string(transportStatus_));
a.emplace(Conf::CONFIG_TRANSPORT_STATE_DESC, transportError_);
return a;
}
......
......@@ -36,11 +36,11 @@
#include "config.h"
#endif
#include "sip_utils.h"
#include "account.h"
#include "noncopyable.h"
#include "sip_utils.h"
#include "ip_utils.h"
#include "noncopyable.h"
#include <pjsip/sip_types.h>
......
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