Skip to content
Snippets Groups Projects
Commit 281c50f5 authored by Ming Rui Zhang's avatar Ming Rui Zhang
Browse files

newaccountmodel: add functions to interact with sip credential informations

Change-Id: Id1540c50cbbf6da7f62bc85de12a7664c4ad10c8
parent 3e6e9038
Branches
No related tags found
No related merge requests found
......@@ -128,6 +128,7 @@ struct ConfProperties_t {
bool accountDiscovery;
bool accountPublish;
int registrationExpire;
std::vector<std::map<std::string, std::string>> credentials;
struct Audio_t {
int audioPortMax;
int audioPortMin;
......
......@@ -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.
*/
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment