Skip to content
Snippets Groups Projects
Commit 69543fdf authored by Sébastien Blin's avatar Sébastien Blin Committed by Andreas Traczyk
Browse files

migration: take into account ERROR_MIGRATION_NEEDED for clients


Change-Id: I604adb07292e4251ba2483a7ca6211355a7ec583
Gitlab: #837
Reviewed-by: default avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
parent 7a41445a
No related branches found
No related tags found
No related merge requests found
...@@ -55,6 +55,7 @@ enum class Type { ...@@ -55,6 +55,7 @@ enum class Type {
enum class Status { enum class Status {
INVALID, INVALID,
ERROR_NEED_MIGRATION,
INITIALIZING, INITIALIZING,
UNREGISTERED, UNREGISTERED,
TRYING, TRYING,
...@@ -72,6 +73,8 @@ to_status(const std::string& type) ...@@ -72,6 +73,8 @@ to_status(const std::string& type)
return account::Status::TRYING; return account::Status::TRYING;
else if (type == "REGISTERED") else if (type == "REGISTERED")
return account::Status::REGISTERED; return account::Status::REGISTERED;
else if (type == "ERROR_NEED_MIGRATION")
return account::Status::ERROR_NEED_MIGRATION;
else else
return account::Status::INVALID; return account::Status::INVALID;
} }
......
...@@ -219,6 +219,13 @@ Q_SIGNALS: ...@@ -219,6 +219,13 @@ Q_SIGNALS:
*/ */
void registeredNameFound(const std::string& accountId, account::LookupStatus status, const std::string& address, const std::string& name); 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: private:
std::unique_ptr<NewAccountModelPimpl> pimpl_; std::unique_ptr<NewAccountModelPimpl> pimpl_;
}; };
......
...@@ -143,6 +143,11 @@ CallbacksHandler::CallbacksHandler(const Lrc& parent) ...@@ -143,6 +143,11 @@ CallbacksHandler::CallbacksHandler(const Lrc& parent)
&ConfigurationManagerInterface::registeredNameFound, &ConfigurationManagerInterface::registeredNameFound,
this, this,
&CallbacksHandler::slotRegisteredNameFound); &CallbacksHandler::slotRegisteredNameFound);
connect(&ConfigurationManager::instance(),
&ConfigurationManagerInterface::migrationEnded,
this,
&CallbacksHandler::slotMigrationEnded);
} }
CallbacksHandler::~CallbacksHandler() CallbacksHandler::~CallbacksHandler()
...@@ -386,5 +391,10 @@ CallbacksHandler::slotRegisteredNameFound(const QString& accountId, int status, ...@@ -386,5 +391,10 @@ CallbacksHandler::slotRegisteredNameFound(const QString& accountId, int status,
emit registeredNameFound(accountId.toStdString(), status, address.toStdString(), name.toStdString()); 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 } // namespace lrc
...@@ -215,6 +215,13 @@ Q_SIGNALS: ...@@ -215,6 +215,13 @@ Q_SIGNALS:
*/ */
void registeredNameFound(const std::string& accountId, int status, const std::string& address, const std::string& name); 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: private Q_SLOTS:
/** /**
* Emit newAccountMessage * Emit newAccountMessage
...@@ -373,6 +380,13 @@ private Q_SLOTS: ...@@ -373,6 +380,13 @@ private Q_SLOTS:
*/ */
void slotRegisteredNameFound(const QString& accountId, int status, const QString& address, const QString& name); 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: private:
const api::Lrc& parent; const api::Lrc& parent;
}; };
......
...@@ -121,6 +121,13 @@ public Q_SLOTS: ...@@ -121,6 +121,13 @@ public Q_SLOTS:
* @param name * @param name
*/ */
void slotRegisteredNameFound(const std::string& accountId, int status, const std::string& address, const std::string& 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, NewAccountModel::NewAccountModel(Lrc& lrc,
...@@ -307,6 +314,7 @@ NewAccountModelPimpl::NewAccountModelPimpl(NewAccountModel& linked, ...@@ -307,6 +314,7 @@ NewAccountModelPimpl::NewAccountModelPimpl(NewAccountModel& linked,
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);
connect(&callbacksHandler, &CallbacksHandler::migrationEnded, this, &NewAccountModelPimpl::slotMigrationEnded);
// NOTE: because we still use the legacy LRC for configuration, we are still using old signals // NOTE: because we still use the legacy LRC for configuration, we are still using old signals
connect(&AccountModel::instance(), &AccountModel::accountRemoved, this, &NewAccountModelPimpl::slotAccountRemoved); connect(&AccountModel::instance(), &AccountModel::accountRemoved, this, &NewAccountModelPimpl::slotAccountRemoved);
...@@ -418,6 +426,15 @@ NewAccountModelPimpl::slotRegisteredNameFound(const std::string& accountId, int ...@@ -418,6 +426,15 @@ NewAccountModelPimpl::slotRegisteredNameFound(const std::string& accountId, int
emit linked.registeredNameFound(accountId, convertedStatus, address, name); 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 void
NewAccountModelPimpl::addToAccounts(const std::string& accountId) NewAccountModelPimpl::addToAccounts(const std::string& accountId)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment