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;