Commit 281c50f5 authored by Ming Rui Zhang's avatar Ming Rui Zhang

newaccountmodel: add functions to interact with sip credential informations

Change-Id: Id1540c50cbbf6da7f62bc85de12a7664c4ad10c8
parent 3e6e9038
......@@ -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
......
......@@ -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);
......
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