Commit 69543fdf authored by Sébastien Blin's avatar Sébastien Blin Committed by Andreas Traczyk

migration: take into account ERROR_MIGRATION_NEEDED for clients

Change-Id: I604adb07292e4251ba2483a7ca6211355a7ec583
Gitlab: #837
Reviewed-by: Andreas Traczyk's avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
parent 7a41445a
......@@ -55,6 +55,7 @@ enum class Type {
enum class Status {
INVALID,
ERROR_NEED_MIGRATION,
INITIALIZING,
UNREGISTERED,
TRYING,
......@@ -72,6 +73,8 @@ to_status(const std::string& type)
return account::Status::TRYING;
else if (type == "REGISTERED")
return account::Status::REGISTERED;
else if (type == "ERROR_NEED_MIGRATION")
return account::Status::ERROR_NEED_MIGRATION;
else
return account::Status::INVALID;
}
......
......@@ -219,6 +219,13 @@ Q_SIGNALS:
*/
void registeredNameFound(const std::string& accountId, account::LookupStatus status, const std::string& address, const std::string& name);
/**
* Migration has finished
* @param accountId
* @param ok
*/
void migrationEnded(const std::string& accountId, bool ok);
private:
std::unique_ptr<NewAccountModelPimpl> pimpl_;
};
......
......@@ -143,6 +143,11 @@ CallbacksHandler::CallbacksHandler(const Lrc& parent)
&ConfigurationManagerInterface::registeredNameFound,
this,
&CallbacksHandler::slotRegisteredNameFound);
connect(&ConfigurationManager::instance(),
&ConfigurationManagerInterface::migrationEnded,
this,
&CallbacksHandler::slotMigrationEnded);
}
CallbacksHandler::~CallbacksHandler()
......@@ -386,5 +391,10 @@ CallbacksHandler::slotRegisteredNameFound(const QString& accountId, int status,
emit registeredNameFound(accountId.toStdString(), status, address.toStdString(), name.toStdString());
}
void
CallbacksHandler::slotMigrationEnded(const QString& accountId, const QString& status)
{
emit migrationEnded(accountId.toStdString(), status == "SUCCESS");
}
} // namespace lrc
......@@ -215,6 +215,13 @@ Q_SIGNALS:
*/
void registeredNameFound(const std::string& accountId, int status, const std::string& address, const std::string& name);
/**
* Migration ended
* @param accountId
* @param ok if migration succeed
*/
void migrationEnded(const std::string& accountId, bool ok);
private Q_SLOTS:
/**
* Emit newAccountMessage
......@@ -373,6 +380,13 @@ private Q_SLOTS:
*/
void slotRegisteredNameFound(const QString& accountId, int status, const QString& address, const QString& name);
/**
* emit migrationEnded
* @param accountId
* @param status
*/
void slotMigrationEnded(const QString& accountId, const QString& status);
private:
const api::Lrc& parent;
};
......
......@@ -121,6 +121,13 @@ public Q_SLOTS:
* @param name
*/
void slotRegisteredNameFound(const std::string& accountId, int status, const std::string& address, const std::string& name);
/**
* Emit migrationEnded
* @param accountId
* @param ok
*/
void slotMigrationEnded(const std::string& accountId, bool ok);
};
NewAccountModel::NewAccountModel(Lrc& lrc,
......@@ -307,6 +314,7 @@ NewAccountModelPimpl::NewAccountModelPimpl(NewAccountModel& linked,
connect(&callbacksHandler, &CallbacksHandler::exportOnRingEnded, this, &NewAccountModelPimpl::slotExportOnRingEnded);
connect(&callbacksHandler, &CallbacksHandler::nameRegistrationEnded, this, &NewAccountModelPimpl::slotNameRegistrationEnded);
connect(&callbacksHandler, &CallbacksHandler::registeredNameFound, this, &NewAccountModelPimpl::slotRegisteredNameFound);
connect(&callbacksHandler, &CallbacksHandler::migrationEnded, this, &NewAccountModelPimpl::slotMigrationEnded);
// NOTE: because we still use the legacy LRC for configuration, we are still using old signals
connect(&AccountModel::instance(), &AccountModel::accountRemoved, this, &NewAccountModelPimpl::slotAccountRemoved);
......@@ -418,6 +426,15 @@ NewAccountModelPimpl::slotRegisteredNameFound(const std::string& accountId, int
emit linked.registeredNameFound(accountId, convertedStatus, address, name);
}
void
NewAccountModelPimpl::slotMigrationEnded(const std::string& accountId, bool ok)
{
if (ok) {
addToAccounts(accountId);
}
emit linked.migrationEnded(accountId, ok);
}
void
NewAccountModelPimpl::addToAccounts(const std::string& accountId)
{
......
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