diff --git a/src/gui/macOS/fileprovidersocketcontroller.cpp b/src/gui/macOS/fileprovidersocketcontroller.cpp index 8463de50e..57671c371 100644 --- a/src/gui/macOS/fileprovidersocketcontroller.cpp +++ b/src/gui/macOS/fileprovidersocketcontroller.cpp @@ -135,11 +135,44 @@ void FileProviderSocketController::requestFileProviderDomainInfo() const sendMessage(requestMessage); } +void FileProviderSocketController::slotAccountStateChanged(const AccountState::State state) +{ + switch(state) { + case AccountState::Disconnected: + case AccountState::ConfigurationError: + case AccountState::NetworkError: + case AccountState::ServiceUnavailable: + case AccountState::MaintenanceMode: + // Do nothing, File Provider will by itself figure out connection issue + break; + case AccountState::SignedOut: + case AccountState::AskingCredentials: + // Notify File Provider that it should show the not authenticated message + break; + case AccountState::Connected: + // Provide credentials + sendAccountDetails(); + break; + } +} + void FileProviderSocketController::sendAccountDetails() const { Q_ASSERT(_accountState); const auto account = _accountState->account(); Q_ASSERT(account); + + qCDebug(lcFileProviderSocketController) << "About to send account details to file provider extension" + << account->displayName(); + + connect(_accountState.data(), &AccountState::stateChanged, this, &FileProviderSocketController::slotAccountStateChanged); + + if (!_accountState->isConnected()) { + qCDebug(lcFileProviderSocketController) << "Not sending account details yet as account is not connected" + << account->displayName(); + return; + } + const auto credentials = account->credentials(); Q_ASSERT(credentials); const auto accountUser = credentials->user(); diff --git a/src/gui/macOS/fileprovidersocketcontroller.h b/src/gui/macOS/fileprovidersocketcontroller.h index ad40300be..4826dc95e 100644 --- a/src/gui/macOS/fileprovidersocketcontroller.h +++ b/src/gui/macOS/fileprovidersocketcontroller.h @@ -43,6 +43,8 @@ private slots: void slotSocketDestroyed(const QObject * const object); void slotReadyRead(); + void slotAccountStateChanged(const AccountState::State state); + void parseReceivedLine(const QString &receivedLine); void requestFileProviderDomainInfo() const; void sendAccountDetails() const;