Unauthenticate the file provider extension when account is logged out

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-03-11 15:55:46 +01:00
Родитель 6d1fe0b4f7
Коммит 287a4e4c0b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: C839200C384636B0
4 изменённых файлов: 23 добавлений и 2 удалений

Просмотреть файл

@ -628,4 +628,8 @@ class FileProviderExtension: NSObject, NSFileProviderReplicatedExtension, NKComm
signalEnumeratorAfterAccountSetup()
}
func removeAccountConfig() {
ncAccount = nil
}
}

Просмотреть файл

@ -18,7 +18,7 @@ import NCDesktopClientSocketKit
class FileProviderSocketLineProcessor: NSObject, LineProcessor {
var delegate: FileProviderExtension
init(delegate: FileProviderExtension) {
required init(delegate: FileProviderExtension) {
self.delegate = delegate
}
@ -35,6 +35,8 @@ class FileProviderSocketLineProcessor: NSObject, LineProcessor {
NSLog("Received command: %@", command)
if (command == "SEND_FILE_PROVIDER_DOMAIN_IDENTIFIER") {
delegate.sendFileProviderDomainIdentifier()
} else if (command == "ACCOUNT_NOT_AUTHENTICATED") {
delegate.removeAccountConfig()
} else if (command == "ACCOUNT_DETAILS") {
guard let accountDetailsSubsequence = splitLine.last else { return }
let splitAccountDetails = accountDetailsSubsequence.split(separator: "~", maxSplits: 2)

Просмотреть файл

@ -148,6 +148,7 @@ void FileProviderSocketController::slotAccountStateChanged(const AccountState::S
case AccountState::SignedOut:
case AccountState::AskingCredentials:
// Notify File Provider that it should show the not authenticated message
sendNotAuthenticated();
break;
case AccountState::Connected:
// Provide credentials
@ -156,6 +157,19 @@ void FileProviderSocketController::slotAccountStateChanged(const AccountState::S
}
}
void FileProviderSocketController::sendNotAuthenticated() const
{
Q_ASSERT(_accountState);
const auto account = _accountState->account();
Q_ASSERT(account);
qCDebug(lcFileProviderSocketController) << "About to send not authenticated message to file provider extension"
<< account->displayName();
const auto message = QString(QStringLiteral("ACCOUNT_NOT_AUTHENTICATED"));
sendMessage(message);
}
void FileProviderSocketController::sendAccountDetails() const
{
Q_ASSERT(_accountState);
@ -165,7 +179,7 @@ void FileProviderSocketController::sendAccountDetails() const
qCDebug(lcFileProviderSocketController) << "About to send account details to file provider extension"
<< account->displayName();
connect(_accountState.data(), &AccountState::stateChanged, this, &FileProviderSocketController::slotAccountStateChanged);
connect(_accountState.data(), &AccountState::stateChanged, this, &FileProviderSocketController::slotAccountStateChanged, Qt::UniqueConnection);
if (!_accountState->isConnected()) {
qCDebug(lcFileProviderSocketController) << "Not sending account details yet as account is not connected"

Просмотреть файл

@ -48,6 +48,7 @@ private slots:
void parseReceivedLine(const QString &receivedLine);
void requestFileProviderDomainInfo() const;
void sendAccountDetails() const;
void sendNotAuthenticated() const;
private:
static AccountStatePtr accountStateFromFileProviderDomainIdentifier(const QString &domainIdentifier);