diff --git a/sflphone-common/src/managerimpl.h b/sflphone-common/src/managerimpl.h index a3a521e7544a31665c81c876bbe584329dc44245..608f369524edc465936abf18ab1d084a30a9c4cf 100755 --- a/sflphone-common/src/managerimpl.h +++ b/sflphone-common/src/managerimpl.h @@ -113,6 +113,7 @@ class ManagerImpl { ManagerImpl (void); ~ManagerImpl (void); + Preferences preferences; short buildConfiguration(); @@ -1347,8 +1348,6 @@ private: Conf::YamlParser *parser; - Preferences preferences; - #ifdef TEST bool testCallAccountMap(); bool testAccountMap(); diff --git a/sflphone-common/src/sip/sipaccount.cpp b/sflphone-common/src/sip/sipaccount.cpp index 42ae1e306fb35fd6ee7d2eb95d2cdb5c70b24393..10b33c10e333041e09bd15d43014455f3be27a20 100755 --- a/sflphone-common/src/sip/sipaccount.cpp +++ b/sflphone-common/src/sip/sipaccount.cpp @@ -36,6 +36,28 @@ #include <pwd.h> +Credentials::Credentials() : credentialCount(0) {} + +Credentials::~Credentials() {} + +void Credentials::serialize(Engine *engine) +{ + +} + +void Credentials::unserialize(Conf::MappingNode *map) +{ + + Conf::ScalarNode *val = NULL; + + _debug("SipAccount: Unserialize"); + + val = (Conf::ScalarNode *)(map->getValue(credentialCountKey)); + if(val) { credentialCount = atoi(val->getValue().data()); val = NULL; } +} + + + SIPAccount::SIPAccount (const AccountID& accountID) : Account (accountID, "sip") , _routeSet("") @@ -122,6 +144,7 @@ void SIPAccount::unserialize(Conf::MappingNode *map) Conf::MappingNode *srtpMap; Conf::MappingNode *tlsMap; Conf::MappingNode *zrtpMap; + Conf::MappingNode *credMap; _debug("SipAccount: Unserialize"); @@ -167,6 +190,8 @@ void SIPAccount::unserialize(Conf::MappingNode *map) // _dtmfType = atoi(val->getValue(); // stun enabled + credMap = (Conf::MappingNode *)(map->getValue(credKey)); + credentials.unserialize(credMap); // get srtp submap srtpMap = (Conf::MappingNode *)(map->getValue(srtpKey)); @@ -242,12 +267,12 @@ void SIPAccount::setVoIPLink() { int SIPAccount::initCredential (void) { int credentialCount = 0; - credentialCount = Manager::instance().getConfigInt (_accountID, CONFIG_CREDENTIAL_NUMBER); + credentialCount = credentials.getCredentialCount();// Manager::instance().getConfigInt (_accountID, CONFIG_CREDENTIAL_NUMBER); credentialCount += 1; bool md5HashingEnabled = false; int dataType = 0; - md5HashingEnabled = Manager::instance().getConfigBool (PREFERENCES, CONFIG_MD5HASH); + md5HashingEnabled = Manager::instance().preferences.getMd5Hash(); // Manager::instance().getConfigBool (PREFERENCES, CONFIG_MD5HASH); std::string digest; // Create the credential array diff --git a/sflphone-common/src/sip/sipaccount.h b/sflphone-common/src/sip/sipaccount.h index 0b16480e9d52c695fa0ffa74a4a37f9e396a5ddd..1db6cebfa905f77849b8bf202e5c790373bd8395 100755 --- a/sflphone-common/src/sip/sipaccount.h +++ b/sflphone-common/src/sip/sipaccount.h @@ -43,6 +43,7 @@ #include "pjsip/sip_types.h" #include "config/serializable.h" #include <exception> +#include <map> enum DtmfType { OVERRTP, SIPINFO}; @@ -89,6 +90,9 @@ const Conf::Key serverKey("server"); const Conf::Key verifyClientKey("verifyClient"); const Conf::Key verifyServerKey("verifyServer"); +const Conf::Key credKey("credential"); +const Conf::Key credentialCountKey("count"); + class SIPVoIPLink; /** @@ -115,6 +119,32 @@ class SipAccountException : public std::exception }; +class Credentials : public Serializable +{ + public: + + typedef std::map<std::string, std::string> CredentialMap; + + Credentials(); + + ~Credentials(); + + virtual void serialize(Engine *engine); + + virtual void unserialize(Conf::MappingNode *map); + + int getCredentialCount(void) { return credentialCount; } + void setCredentialCount(int count) { credentialCount = count; } + + private: + + int credentialCount; + + CredentialMap credentialMap; + +}; + + class SIPAccount : public Account { public: @@ -546,6 +576,7 @@ class SIPAccount : public Account pjsip_cred_info *_cred; std::string _realm; std::string _authenticationUsername; + Credentials credentials; // The TLS settings, if tls is chosen as // a sip transport.