From a44454daf8bf08035fceb5714de0407f238dd627 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 23 Jan 2024 22:24:36 +0800 Subject: [PATCH] Simplify and clarify utility of socket system for file provider Signed-off-by: Claudio Cambra --- src/gui/macOS/fileprovidersocketcontroller.cpp | 13 +++++++++++-- src/gui/macOS/fileprovidersocketserver.h | 13 +++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/gui/macOS/fileprovidersocketcontroller.cpp b/src/gui/macOS/fileprovidersocketcontroller.cpp index 4790123e35..68de963706 100644 --- a/src/gui/macOS/fileprovidersocketcontroller.cpp +++ b/src/gui/macOS/fileprovidersocketcontroller.cpp @@ -112,7 +112,6 @@ void FileProviderSocketController::sendMessage(const QString &message) const } } - void FileProviderSocketController::start() { Q_ASSERT(_socket); @@ -121,6 +120,12 @@ void FileProviderSocketController::start() return; } + /* + * We have a new file provider extension connection. When this happens, we: + * 1. Request the file provider domain identifier + * 2. Receive the file provider domain identifier from the extension + * 3. Send the account details to the extension according to the domain identifier + */ requestFileProviderDomainInfo(); } @@ -181,7 +186,11 @@ 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, Qt::UniqueConnection); + // Even though we have XPC send over the account details and related calls when the account state changes, in the + // brief window where we start the file provider extension on app startup and the account state changes, we need to + // be able to send over the details when the account is done getting configured. + 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" diff --git a/src/gui/macOS/fileprovidersocketserver.h b/src/gui/macOS/fileprovidersocketserver.h index 893de666e5..e650e0ca2b 100644 --- a/src/gui/macOS/fileprovidersocketserver.h +++ b/src/gui/macOS/fileprovidersocketserver.h @@ -26,6 +26,19 @@ using FileProviderSocketControllerPtr = QPointer; QString fileProviderSocketPath(); +/* + * Establishes communication between the app and the file provider extension. + * This is done via a local socket server. + * Note that this should be used for extension->client communication. + * + * We can communicate bidirectionally, but the File Provider XPC API is a better interface for this as we cannot account + * for the lifetime of a file provider extension when using sockets, and cannot control this on the client side. + * Use FileProviderXPC for client->extension communication when possible. + * + * This socket system is critical for the file provider extensions to be able to request authentication details. + * + * TODO: This should rewritten to use XPC instead of sockets + */ class FileProviderSocketServer : public QObject { Q_OBJECT