From 034fbb8245a7bb24e2c45025e685a9587f35ec78 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 17 Jul 2024 17:30:01 +0800 Subject: [PATCH] Add file provider socket state provider method in socket server Signed-off-by: Claudio Cambra --- src/gui/macOS/fileprovidersocketserver.cpp | 18 ++++++++++++++++++ src/gui/macOS/fileprovidersocketserver.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/src/gui/macOS/fileprovidersocketserver.cpp b/src/gui/macOS/fileprovidersocketserver.cpp index 8e73d2d89c..d2abaa8065 100644 --- a/src/gui/macOS/fileprovidersocketserver.cpp +++ b/src/gui/macOS/fileprovidersocketserver.cpp @@ -17,6 +17,8 @@ #include #include +#include "libsync/account.h" + #include "fileprovidersocketcontroller.h" namespace OCC { @@ -81,6 +83,22 @@ void FileProviderSocketServer::slotSocketDestroyed(const QLocalSocket * const so } } +FileProviderSocketState FileProviderSocketServer::socketStateForAccount(const QString &userIdAtHost) const +{ + auto connected = false; + auto latestStatus = SyncResult::Undefined; + + for (const auto &controller : _socketControllers) { + if (controller->accountState()->account()->userIdAtHostWithPort() == userIdAtHost) { + connected = true; + latestStatus = controller->latestStatus(); + break; + } + } + + return { .connected = connected, .latestStatus = latestStatus }; +} + } // namespace Mac } // namespace OCC diff --git a/src/gui/macOS/fileprovidersocketserver.h b/src/gui/macOS/fileprovidersocketserver.h index eee0317342..0aecddc89d 100644 --- a/src/gui/macOS/fileprovidersocketserver.h +++ b/src/gui/macOS/fileprovidersocketserver.h @@ -54,6 +54,8 @@ class FileProviderSocketServer : public QObject public: explicit FileProviderSocketServer(QObject *parent = nullptr); + [[nodiscard]] FileProviderSocketState socketStateForAccount(const QString &userIdAtHost) const; + signals: void syncStateChanged(const AccountPtr &account, SyncResult::Status state) const;