2022-10-26 21:13:38 +03:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Claudio Cambra <claudio.cambra@nextcloud.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
2022-10-28 20:40:06 +03:00
|
|
|
#include "accountstate.h"
|
2022-10-26 21:13:38 +03:00
|
|
|
|
|
|
|
namespace OCC {
|
|
|
|
|
2022-10-28 20:40:06 +03:00
|
|
|
class EditLocallyHandler;
|
|
|
|
using EditLocallyHandlerPtr = QSharedPointer<EditLocallyHandler>;
|
|
|
|
|
|
|
|
class Folder;
|
|
|
|
class SyncResult;
|
|
|
|
|
2022-10-26 21:13:38 +03:00
|
|
|
class EditLocallyHandler : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit EditLocallyHandler(const QString &userId,
|
|
|
|
const QString &relPath,
|
|
|
|
const QString &token,
|
|
|
|
QObject *parent = nullptr);
|
|
|
|
|
|
|
|
[[nodiscard]] static bool isTokenValid(const QString &token);
|
|
|
|
[[nodiscard]] static bool isRelPathValid(const QString &relPath);
|
|
|
|
[[nodiscard]] static bool isRelPathExcluded(const QString &relPath);
|
|
|
|
[[nodiscard]] static QString prefixSlashToPath(const QString &path);
|
|
|
|
|
|
|
|
signals:
|
2022-10-28 17:42:57 +03:00
|
|
|
void setupFinished();
|
|
|
|
void error(const QString &message, const QString &informativeText);
|
|
|
|
void fileOpened();
|
2022-10-26 21:13:38 +03:00
|
|
|
|
|
|
|
public slots:
|
2022-10-28 17:42:57 +03:00
|
|
|
void startSetup();
|
2022-10-26 21:13:38 +03:00
|
|
|
void startEditLocally();
|
|
|
|
|
|
|
|
private slots:
|
2022-10-28 21:22:27 +03:00
|
|
|
void startTokenRemoteCheck();
|
2022-10-28 17:42:57 +03:00
|
|
|
void proceedWithSetup();
|
|
|
|
|
|
|
|
void showError(const QString &message, const QString &informativeText);
|
2022-10-26 21:13:38 +03:00
|
|
|
void showErrorNotification(const QString &message, const QString &informativeText) const;
|
|
|
|
void showErrorMessageBox(const QString &message, const QString &informativeText) const;
|
|
|
|
|
2022-10-28 17:42:57 +03:00
|
|
|
void remoteTokenCheckResultReceived(const int statusCode);
|
2022-10-26 21:13:38 +03:00
|
|
|
void folderSyncFinished(const OCC::SyncResult &result);
|
|
|
|
|
|
|
|
void disconnectSyncFinished() const;
|
|
|
|
void openFile();
|
|
|
|
|
|
|
|
private:
|
2022-10-28 17:42:57 +03:00
|
|
|
bool _tokenVerified = false;
|
2022-10-26 21:13:38 +03:00
|
|
|
|
|
|
|
AccountStatePtr _accountState;
|
2022-10-28 17:42:57 +03:00
|
|
|
QString _userId;
|
2022-10-26 21:13:38 +03:00
|
|
|
QString _relPath;
|
|
|
|
QString _token;
|
|
|
|
|
|
|
|
QString _fileName;
|
|
|
|
QString _localFilePath;
|
|
|
|
Folder *_folderForFile = nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|