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-29 14:21:56 +03:00
|
|
|
class EditLocallyJob;
|
|
|
|
using EditLocallyJobPtr = QSharedPointer<EditLocallyJob>;
|
2022-10-28 20:40:06 +03:00
|
|
|
|
|
|
|
class Folder;
|
|
|
|
class SyncResult;
|
|
|
|
|
2022-10-29 14:21:56 +03:00
|
|
|
class EditLocallyJob : public QObject
|
2022-10-26 21:13:38 +03:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2022-10-29 14:21:56 +03:00
|
|
|
explicit EditLocallyJob(const QString &userId,
|
|
|
|
const QString &relPath,
|
|
|
|
const QString &token,
|
|
|
|
QObject *parent = nullptr);
|
2022-10-26 21:13:38 +03:00
|
|
|
|
|
|
|
[[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;
|
2022-10-29 01:19:04 +03:00
|
|
|
std::unique_ptr<SimpleApiJob> _checkTokenJob;
|
2022-10-26 21:13:38 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|