Add support for FILE_PROVIDER_DOMAIN_SYNC_STATE_CHANGE socket messages in client file provider socket controller

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2024-07-16 18:57:52 +08:00
Родитель d70a388511
Коммит 744ac540db
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: C839200C384636B0
2 изменённых файлов: 28 добавлений и 3 удалений

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

@ -89,6 +89,9 @@ void FileProviderSocketController::parseReceivedLine(const QString &receivedLine
_accountState = FileProviderDomainManager::accountStateFromFileProviderDomainIdentifier(argument);
sendAccountDetails();
return;
} else if (command == "FILE_PROVIDER_DOMAIN_SYNC_STATE_CHANGE") {
reportSyncState(argument);
return;
}
qCWarning(lcFileProviderSocketController) << "Unknown command or reply:" << receivedLine;
@ -216,6 +219,24 @@ void FileProviderSocketController::sendAccountDetails() const
sendMessage(message);
}
void FileProviderSocketController::reportSyncState(const QString &receivedState) const
{
auto syncState = SyncResult::Status::Undefined;
if (receivedState == QStringLiteral("SYNC_STARTED")) {
syncState = SyncResult::Status::SyncRunning;
} else if (receivedState == QStringLiteral("SYNC_FINISHED")) {
syncState = SyncResult::Status::Success;
} else if (receivedState == QStringLiteral("SYNC_FAILED")) {
syncState = SyncResult::Status::Problem;
} else if (receivedState == QStringLiteral("SYNC_PAUSED")) {
syncState = SyncResult::Status::Paused;
} else {
qCWarning(lcFileProviderSocketController) << "Unknown sync state received:" << receivedState;
}
emit syncStateChanged(_accountState->account(), syncState);
}
}
} // namespace Mac
} // namespace OCC

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

@ -16,7 +16,8 @@
#include <QPointer>
#include "accountstate.h"
#include "gui/accountstate.h"
#include "libsync/syncresult.h"
class QLocalSocket;
@ -32,7 +33,8 @@ public:
explicit FileProviderSocketController(QLocalSocket * const socket, QObject * const parent = nullptr);
signals:
void socketDestroyed(const QLocalSocket * const socket);
void socketDestroyed(const QLocalSocket * const socket);signals:
void syncStateChanged(const AccountPtr &account, SyncResult::Status state) const;
public slots:
void sendMessage(const QString &message) const;
@ -50,6 +52,8 @@ private slots:
void sendAccountDetails() const;
void sendNotAuthenticated() const;
void reportSyncState(const QString &receivedState) const;
private:
QPointer<QLocalSocket> _socket;
AccountStatePtr _accountState;