From 30a7dd4592e6d108bbc7c780e0945a35b0dbee13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Wed, 3 Oct 2018 22:27:56 -0400 Subject: [PATCH] newaccountmodel: improve some signals emission + Fix SIP account creation + Update status when necessary Note: SIP status signals are not perfect. See #393 Change-Id: Idde847af4bceaec55fd59145c9f68712b3e46edc --- src/newaccountmodel.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/newaccountmodel.cpp b/src/newaccountmodel.cpp index 8875c2ec..5c2d3432 100644 --- a/src/newaccountmodel.cpp +++ b/src/newaccountmodel.cpp @@ -373,6 +373,12 @@ NewAccountModelPimpl::updateAccounts() if (accountInfo == accounts.end()) { qDebug("detected new account %s", id.toStdString().c_str()); addToAccounts(id.toStdString()); + if (accountInfo->second.profileInfo.type == profile::Type::SIP) { + // NOTE: At this point, a SIP account is ready, but not a Ring + // account. Indeed, the keys are not generated at this point. + // See slotAccountStatusChanged for more details. + emit linked.accountAdded(id.toStdString()); + } } } } @@ -389,10 +395,19 @@ NewAccountModelPimpl::slotAccountStatusChanged(const std::string& accountID, con auto& accountInfo = it->second; - if (status == api::account::Status::REGISTERED && accountInfo.profileInfo.uri.empty()) { - accounts.erase(accountID); - addToAccounts(accountID); - emit linked.accountAdded(accountID); + if (accountInfo.profileInfo.type != profile::Type::SIP) { + if (status != api::account::Status::INITIALIZING + && accountInfo.status == api::account::Status::INITIALIZING) { + // Detect when a new account is generated (keys are ready). During + // the generation, a Ring account got the "INITIALIZING" status. + // When keys are generated, the status will change. + accounts.erase(accountID); + addToAccounts(accountID); + emit linked.accountAdded(accountID); + } else if (!accountInfo.profileInfo.uri.empty()) { + accountInfo.status = status; + emit linked.accountStatusChanged(accountID); + } } else { accountInfo.status = status; emit linked.accountStatusChanged(accountID); -- GitLab