Skip to content
Snippets Groups Projects
Commit 77b9268c authored by Sébastien Blin's avatar Sébastien Blin
Browse files

newaccountmodel: add the ability to create new accounts


Change-Id: I55f2f3090bb414d46105cb18b2150044c736d881
Reviewed-by: default avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
parent ca18da3a
No related branches found
No related tags found
No related merge requests found
...@@ -143,11 +143,32 @@ public: ...@@ -143,11 +143,32 @@ public:
* @param accountId * @param accountId
* @param password * @param password
* @param username * @param username
* @return string like bootstrap1:port1;bootstrap2:port2;... * @return if operation started
*/ */
bool registerName(const std::string& accountId, const std::string& password, const std::string& username); bool registerName(const std::string& accountId, const std::string& password, const std::string& username);
/**
* Create a new Ring or SIP account
* @param type determine if the new account will be a Ring account or a SIP one
* @param displayName
* @param username
* @param archivePath
* @param password of the archive (unused for SIP)
* @param pin of the archive (unused for SIP)
* @return the created account
*/
static std::string createNewAccount(profile::Type type,
const std::string& displayName = "",
const std::string& archivePath = "",
const std::string& password = "",
const std::string& pin = "");
Q_SIGNALS: Q_SIGNALS:
/**
* Connect this signal to know when an invalid account is here
* @param accountID
*/
void invalidAccountDetected(const std::string& accountID);
/** /**
* Connect this signal to know when the status of an account has changed. * Connect this signal to know when the status of an account has changed.
* @param accountID * @param accountID
......
...@@ -169,7 +169,11 @@ NewAccountModel::setAccountConfig(const std::string& accountId, ...@@ -169,7 +169,11 @@ NewAccountModel::setAccountConfig(const std::string& accountId,
details[ConfProperties::ALIAS] = toQString(accountInfo.profileInfo.alias); details[ConfProperties::ALIAS] = toQString(accountInfo.profileInfo.alias);
details[ConfProperties::DISPLAYNAME] = toQString(accountInfo.profileInfo.alias); details[ConfProperties::DISPLAYNAME] = toQString(accountInfo.profileInfo.alias);
details[ConfProperties::TYPE] = (accountInfo.profileInfo.type == profile::Type::RING) ? QString(ProtocolNames::RING) : QString(ProtocolNames::SIP); details[ConfProperties::TYPE] = (accountInfo.profileInfo.type == profile::Type::RING) ? QString(ProtocolNames::RING) : QString(ProtocolNames::SIP);
if (accountInfo.profileInfo.type == profile::Type::RING) {
details[ConfProperties::USERNAME] = toQString(accountInfo.profileInfo.uri).prepend((accountInfo.profileInfo.type == profile::Type::RING) ? "ring:" : ""); details[ConfProperties::USERNAME] = toQString(accountInfo.profileInfo.uri).prepend((accountInfo.profileInfo.type == profile::Type::RING) ? "ring:" : "");
} else {
details[ConfProperties::USERNAME] = toQString(confProperties.username);
}
configurationManager.setAccountDetails(QString::fromStdString(accountId), details); configurationManager.setAccountDetails(QString::fromStdString(accountId), details);
} }
...@@ -495,6 +499,7 @@ account::Info::fromDetails(const MapStringString& details) ...@@ -495,6 +499,7 @@ account::Info::fromDetails(const MapStringString& details)
confProperties.activeCallLimit = toInt(details[ConfProperties::ACTIVE_CALL_LIMIT]); confProperties.activeCallLimit = toInt(details[ConfProperties::ACTIVE_CALL_LIMIT]);
confProperties.hostname = toStdString(details[ConfProperties::HOSTNAME]); confProperties.hostname = toStdString(details[ConfProperties::HOSTNAME]);
profileInfo.uri = (profileInfo.type == profile::Type::RING and details[ConfProperties::USERNAME].contains("ring:")) ? details[ConfProperties::USERNAME].toStdString().substr(std::string("ring:").size()) : details[ConfProperties::USERNAME].toStdString(); profileInfo.uri = (profileInfo.type == profile::Type::RING and details[ConfProperties::USERNAME].contains("ring:")) ? details[ConfProperties::USERNAME].toStdString().substr(std::string("ring:").size()) : details[ConfProperties::USERNAME].toStdString();
confProperties.username = toStdString(details[ConfProperties::USERNAME]);
confProperties.routeset = toStdString(details[ConfProperties::ROUTE]); confProperties.routeset = toStdString(details[ConfProperties::ROUTE]);
confProperties.password = toStdString(details[ConfProperties::PASSWORD]); confProperties.password = toStdString(details[ConfProperties::PASSWORD]);
confProperties.realm = toStdString(details[ConfProperties::REALM]); confProperties.realm = toStdString(details[ConfProperties::REALM]);
...@@ -684,6 +689,29 @@ account::ConfProperties_t::toDetails() const ...@@ -684,6 +689,29 @@ account::ConfProperties_t::toDetails() const
return details; return details;
} }
std::string
NewAccountModel::createNewAccount(profile::Type type,
const std::string& displayName,
const std::string& archivePath,
const std::string& password,
const std::string& pin)
{
MapStringString details = type == profile::Type::SIP?
ConfigurationManager::instance().getAccountTemplate("SIP") :
ConfigurationManager::instance().getAccountTemplate("RING");
using namespace DRing::Account;
details[ConfProperties::TYPE] = type == profile::Type::SIP? "SIP" : "RING";
details[ConfProperties::DISPLAYNAME] = displayName.c_str();
details[ConfProperties::ALIAS] = displayName.c_str();
details[ConfProperties::UPNP_ENABLED] = "true";
details[ConfProperties::ARCHIVE_PASSWORD] = password.c_str();
details[ConfProperties::ARCHIVE_PIN] = pin.c_str();
details[ConfProperties::ARCHIVE_PATH] = archivePath.c_str();
QString accountId = ConfigurationManager::instance().addAccount(details);
return accountId.toStdString();
}
} // namespace lrc } // namespace lrc
#include "api/moc_newaccountmodel.cpp" #include "api/moc_newaccountmodel.cpp"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment