Commit 475d0885 authored by Sébastien Blin's avatar Sébastien Blin
Browse files

callbackshandler: connect to volatileAccountDetailsChanged

Change-Id: I4d658afc5adb4b81ca12b3bcfe484eb3315eae7b
parent feed316a
...@@ -98,6 +98,12 @@ CallbacksHandler::CallbacksHandler(const Lrc& parent) ...@@ -98,6 +98,12 @@ CallbacksHandler::CallbacksHandler(const Lrc& parent)
&CallbacksHandler::slotAccountDetailsChanged, &CallbacksHandler::slotAccountDetailsChanged,
Qt::QueuedConnection); Qt::QueuedConnection);
connect(&ConfigurationManager::instance(),
&ConfigurationManagerInterface::volatileAccountDetailsChanged,
this,
&CallbacksHandler::slotVolatileAccountDetailsChanged,
Qt::QueuedConnection);
connect(&ConfigurationManager::instance(), connect(&ConfigurationManager::instance(),
&ConfigurationManagerInterface::accountsChanged, &ConfigurationManagerInterface::accountsChanged,
this, this,
...@@ -343,6 +349,13 @@ CallbacksHandler::slotAccountDetailsChanged(const QString& accountId, ...@@ -343,6 +349,13 @@ CallbacksHandler::slotAccountDetailsChanged(const QString& accountId,
emit accountDetailsChanged(accountId.toStdString(), convertMap(details)); emit accountDetailsChanged(accountId.toStdString(), convertMap(details));
} }
void
CallbacksHandler::slotVolatileAccountDetailsChanged(const QString& accountId,
const MapStringString& details)
{
emit volatileAccountDetailsChanged(accountId.toStdString(), convertMap(details));
}
void void
CallbacksHandler::slotAccountsChanged() CallbacksHandler::slotAccountsChanged()
{ {
......
...@@ -121,6 +121,13 @@ Q_SIGNALS: ...@@ -121,6 +121,13 @@ Q_SIGNALS:
*/ */
void accountDetailsChanged(const std::string& accountId, void accountDetailsChanged(const std::string& accountId,
const std::map<std::string,std::string>& details); const std::map<std::string,std::string>& details);
/**
* Connect this signal to know when the volatile account details have changed
* @param accountId the one who changes
* @param details the new details
*/
void volatileAccountDetailsChanged(const std::string& accountId,
const std::map<std::string,std::string>& details);
/** /**
* Connect this signal to know when the accounts list changed * Connect this signal to know when the accounts list changed
*/ */
...@@ -335,6 +342,13 @@ private Q_SLOTS: ...@@ -335,6 +342,13 @@ private Q_SLOTS:
*/ */
void slotAccountDetailsChanged(const QString& accountId, void slotAccountDetailsChanged(const QString& accountId,
const MapStringString& details); const MapStringString& details);
/**
* Emit volatileAccountDetailsChanged
* @param accountId
* @param details
*/
void slotVolatileAccountDetailsChanged(const QString& accountId,
const MapStringString& details);
/** /**
* Emit accountsChanged * Emit accountsChanged
*/ */
......
...@@ -126,6 +126,12 @@ public Q_SLOTS: ...@@ -126,6 +126,12 @@ public Q_SLOTS:
*/ */
void slotAccountDetailsChanged(const std::string& accountID, const std::map<std::string, std::string>& details); void slotAccountDetailsChanged(const std::string& accountID, const std::map<std::string, std::string>& details);
/**
* @param accountId
* @param details
*/
void slotVolatileAccountDetailsChanged(const std::string& accountID, const std::map<std::string, std::string>& details);
/** /**
* Emit nameRegistrationEnded * Emit nameRegistrationEnded
* @param accountId * @param accountId
...@@ -357,6 +363,7 @@ NewAccountModelPimpl::NewAccountModelPimpl(NewAccountModel& linked, ...@@ -357,6 +363,7 @@ NewAccountModelPimpl::NewAccountModelPimpl(NewAccountModel& linked,
connect(&callbacksHandler, &CallbacksHandler::accountsChanged, this, &NewAccountModelPimpl::updateAccounts); connect(&callbacksHandler, &CallbacksHandler::accountsChanged, this, &NewAccountModelPimpl::updateAccounts);
connect(&callbacksHandler, &CallbacksHandler::accountStatusChanged, this, &NewAccountModelPimpl::slotAccountStatusChanged); connect(&callbacksHandler, &CallbacksHandler::accountStatusChanged, this, &NewAccountModelPimpl::slotAccountStatusChanged);
connect(&callbacksHandler, &CallbacksHandler::accountDetailsChanged, this, &NewAccountModelPimpl::slotAccountDetailsChanged); connect(&callbacksHandler, &CallbacksHandler::accountDetailsChanged, this, &NewAccountModelPimpl::slotAccountDetailsChanged);
connect(&callbacksHandler, &CallbacksHandler::volatileAccountDetailsChanged, this, &NewAccountModelPimpl::slotVolatileAccountDetailsChanged);
connect(&callbacksHandler, &CallbacksHandler::exportOnRingEnded, this, &NewAccountModelPimpl::slotExportOnRingEnded); connect(&callbacksHandler, &CallbacksHandler::exportOnRingEnded, this, &NewAccountModelPimpl::slotExportOnRingEnded);
connect(&callbacksHandler, &CallbacksHandler::nameRegistrationEnded, this, &NewAccountModelPimpl::slotNameRegistrationEnded); connect(&callbacksHandler, &CallbacksHandler::nameRegistrationEnded, this, &NewAccountModelPimpl::slotNameRegistrationEnded);
connect(&callbacksHandler, &CallbacksHandler::registeredNameFound, this, &NewAccountModelPimpl::slotRegisteredNameFound); connect(&callbacksHandler, &CallbacksHandler::registeredNameFound, this, &NewAccountModelPimpl::slotRegisteredNameFound);
...@@ -463,6 +470,22 @@ NewAccountModelPimpl::slotAccountDetailsChanged(const std::string& accountId, co ...@@ -463,6 +470,22 @@ NewAccountModelPimpl::slotAccountDetailsChanged(const std::string& accountId, co
emit linked.accountStatusChanged(accountId); emit linked.accountStatusChanged(accountId);
} }
void
NewAccountModelPimpl::slotVolatileAccountDetailsChanged(const std::string& accountId, const std::map<std::string, std::string>& details)
{
auto account = accounts.find(accountId);
if (account == accounts.end()) {
throw std::out_of_range("NewAccountModelPimpl::slotVolatileAccountDetailsChanged, can't find " + accountId);
}
auto& accountInfo = account->second.first;
auto new_usernameIt = details.find(DRing::Account::VolatileProperties::REGISTERED_NAME);
if (new_usernameIt == details.end())
return;
accountInfo.registeredName = new_usernameIt->second;
emit linked.profileUpdated(accountId);
}
void void
NewAccountModelPimpl::slotExportOnRingEnded(const std::string& accountID, int status, const std::string& pin) NewAccountModelPimpl::slotExportOnRingEnded(const std::string& accountID, int status, const std::string& pin)
{ {
......
Supports Markdown
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