diff --git a/src/api/account.h b/src/api/account.h index 9711b7ed8eec5b8e2f89d8507054ae51f708efa4..8a5e1ef17192e35be3e8be83bd0646e99ae8a164 100644 --- a/src/api/account.h +++ b/src/api/account.h @@ -95,103 +95,104 @@ enum class TlsMethod { }; struct ConfProperties_t { - std::string mailbox; - std::string dtmfType; - bool autoAnswer; - int activeCallLimit; - std::string hostname; - std::string username; - std::string routeset; - std::string password; - std::string realm; - std::string localInterface; - std::string deviceId; - std::string deviceName; - std::string managerUri; - std::string managerUsername; - bool publishedSameAsLocal; - int localPort; - int publishedPort; - std::string publishedAddress; - std::string userAgent; - bool upnpEnabled; - bool hasCustomUserAgent; - bool allowIncoming; - std::string archivePassword; - bool archiveHasPassword; - std::string archivePath; - std::string archivePin; - bool proxyEnabled; - std::string proxyServer; - std::string proxyPushToken; - bool peerDiscovery; - bool accountDiscovery; - bool accountPublish; - int registrationExpire; + std::string mailbox; + std::string dtmfType; + bool autoAnswer; + int activeCallLimit; + std::string hostname; + std::string username; + std::string routeset; + std::string password; + std::string realm; + std::string localInterface; + std::string deviceId; + std::string deviceName; + std::string managerUri; + std::string managerUsername; + bool publishedSameAsLocal; + int localPort; + int publishedPort; + std::string publishedAddress; + std::string userAgent; + bool upnpEnabled; + bool hasCustomUserAgent; + bool allowIncoming; + std::string archivePassword; + bool archiveHasPassword; + std::string archivePath; + std::string archivePin; + bool proxyEnabled; + std::string proxyServer; + std::string proxyPushToken; + bool peerDiscovery; + bool accountDiscovery; + bool accountPublish; + int registrationExpire; + std::vector<std::map<std::string, std::string>> credentials; struct Audio_t { - int audioPortMax; - int audioPortMin; + int audioPortMax; + int audioPortMin; } Audio; struct Video_t { - bool videoEnabled; - int videoPortMax; - int videoPortMin; + bool videoEnabled; + int videoPortMax; + int videoPortMin; } Video; struct STUN_t { - std::string server; - bool enable; + std::string server; + bool enable; } STUN; struct TURN_t { - std::string server; - bool enable; - std::string username; - std::string password; - std::string realm; + std::string server; + bool enable; + std::string username; + std::string password; + std::string realm; } TURN; struct Presence_t { - bool presencePublishSupported; - bool presenceSubscribeSupported; - bool presenceEnabled; + bool presencePublishSupported; + bool presenceSubscribeSupported; + bool presenceEnabled; } Presence; struct Ringtone_t { - std::string ringtonePath; - bool ringtoneEnabled; + std::string ringtonePath; + bool ringtoneEnabled; } Ringtone; struct SRTP_t { - KeyExchangeProtocol keyExchange; - bool enable; - bool rtpFallback; + KeyExchangeProtocol keyExchange; + bool enable; + bool rtpFallback; } SRTP; struct TLS_t { - int listenerPort; - bool enable; - int port; - std::string certificateListFile; - std::string certificateFile; - std::string privateKeyFile; - std::string password; - TlsMethod method; - std::string ciphers; - std::string serverName; - bool verifyServer; - bool verifyClient; - bool requireClientCertificate; - int negotiationTimeoutSec; + int listenerPort; + bool enable; + int port; + std::string certificateListFile; + std::string certificateFile; + std::string privateKeyFile; + std::string password; + TlsMethod method; + std::string ciphers; + std::string serverName; + bool verifyServer; + bool verifyClient; + bool requireClientCertificate; + int negotiationTimeoutSec; } TLS; struct DHT_t { - int port; - bool PublicInCalls; - bool AllowFromTrusted; + int port; + bool PublicInCalls; + bool AllowFromTrusted; } DHT; struct RingNS_t { - std::string uri; - std::string account; + std::string uri; + std::string account; } RingNS; struct Registration_t { - int expire; + int expire; } Registration; - MapStringString toDetails() const; + MapStringString toDetails() const; }; // Possible account export status diff --git a/src/api/newaccountmodel.h b/src/api/newaccountmodel.h index e741b569a3af7af29a61b4535d39927cca207605..8b24fc6f847407c3f0f94f0bd3822d035db7be94 100644 --- a/src/api/newaccountmodel.h +++ b/src/api/newaccountmodel.h @@ -65,12 +65,14 @@ public: * @return a std::vector<std::string>. */ std::vector<std::string> getAccountList() const; + /** * get account informations associated to an accountId. * @param accountId. * @return a const account::Info& structure. */ const account::Info& getAccountInfo(const std::string& accountId) const; + /** * flag account corresponding to passed id as freeable. */ diff --git a/src/newaccountmodel.cpp b/src/newaccountmodel.cpp index 412bdfc3ef99dfdb7d9539a33cae73e61480ebee..f248e4be2660313cba847197117ee0298f2730ee 100644 --- a/src/newaccountmodel.cpp +++ b/src/newaccountmodel.cpp @@ -222,14 +222,26 @@ NewAccountModel::setAccountConfig(const std::string& accountId, if (accountInfo.profileInfo.type == profile::Type::RING) { details[ConfProperties::USERNAME] = toQString(accountInfo.profileInfo.uri).prepend((accountInfo.profileInfo.type == profile::Type::RING) ? "ring:" : ""); } else if (accountInfo.profileInfo.type == profile::Type::SIP) { - MapStringString credentials; - credentials[ConfProperties::USERNAME] = toQString(confProperties.username); - credentials[ConfProperties::PASSWORD] = toQString(confProperties.password); - credentials[ConfProperties::REALM] = confProperties.realm.empty()? QString("*") : toQString(confProperties.realm); - QVector<MapStringString> credentialsVec; - credentialsVec.append(credentials); - ConfigurationManager::instance().setCredentials(accountId.c_str(), credentialsVec); + VectorMapStringString finalCred; + + std::map<std::string, std::string> credentials; + credentials[ConfProperties::USERNAME] = confProperties.username; + credentials[ConfProperties::PASSWORD] = confProperties.password; + credentials[ConfProperties::REALM] = confProperties.realm.empty() ? "*" : confProperties.realm; + + auto credentialsVec = confProperties.credentials; + credentialsVec[0] = credentials; + for (auto const &i : credentialsVec) { + QMap<QString, QString> credMap; + for (auto const &j : i) { + credMap[j.first.c_str()] = j.second.c_str(); + } + finalCred.append(credMap); + } + + ConfigurationManager::instance().setCredentials(accountId.c_str(), finalCred); details[ConfProperties::USERNAME] = toQString(confProperties.username); + accountInfo.confProperties.credentials.swap(credentialsVec); } configurationManager.setAccountDetails(QString::fromStdString(accountId), details); } @@ -621,6 +633,19 @@ NewAccountModelPimpl::addToAccounts(const std::string& accountId, MapStringString details = ConfigurationManager::instance().getAccountDetails(accountId.c_str()); newAccInfo.fromDetails(details); + // Fill account::Info::confProperties credentials + VectorMapStringString credGet = ConfigurationManager::instance().getCredentials(accountId.c_str()); + std::vector<std::map<std::string, std::string>> credToStore; + for (auto const &i : credGet.toStdVector()) { + std::map<std::string, std::string> credMap; + for (auto const &j : i.toStdMap()) { + credMap[j.first.toStdString()] = j.second.toStdString(); + } + credToStore.emplace_back(credMap); + } + + newAccInfo.confProperties.credentials.swap(credToStore); + // Init models for this account newAccInfo.accountModel = &linked; newAccInfo.callModel = std::make_unique<NewCallModel>(newAccInfo, callbacksHandler);