Add file provider socket state provider method in socket server

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2024-07-17 17:30:01 +08:00
parent fd7f1ce0fc
commit 034fbb8245
No known key found for this signature in database
GPG Key ID: C839200C384636B0
2 changed files with 20 additions and 0 deletions

View File

@ -17,6 +17,8 @@
#include <QLocalSocket>
#include <QLoggingCategory>
#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

View File

@ -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;