mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 13:35:58 +03:00
Fix review comments from Claudio III.
Signed-off-by: alex-z <blackslayer4@gmail.com>
This commit is contained in:
parent
07be556eca
commit
cecd24b6c5
3 changed files with 52 additions and 26 deletions
|
@ -19,6 +19,29 @@ namespace OCC
|
||||||
{
|
{
|
||||||
Q_LOGGING_CATEGORY(lcAccountSetupCommandLineManager, "nextcloud.gui.accountsetupcommandlinemanager", QtInfoMsg)
|
Q_LOGGING_CATEGORY(lcAccountSetupCommandLineManager, "nextcloud.gui.accountsetupcommandlinemanager", QtInfoMsg)
|
||||||
|
|
||||||
|
AccountSetupCommandLineManager *AccountSetupCommandLineManager::_instance = nullptr;
|
||||||
|
|
||||||
|
AccountSetupCommandLineManager::AccountSetupCommandLineManager(QObject *parent)
|
||||||
|
: QObject{parent}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
AccountSetupCommandLineManager *AccountSetupCommandLineManager::instance()
|
||||||
|
{
|
||||||
|
if (!_instance) {
|
||||||
|
_instance = new AccountSetupCommandLineManager();
|
||||||
|
}
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AccountSetupCommandLineManager::destroy()
|
||||||
|
{
|
||||||
|
if (_instance) {
|
||||||
|
_instance->deleteLater();
|
||||||
|
_instance = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool AccountSetupCommandLineManager::parseCommandlineOption(const QString &option, QStringListIterator &optionsIterator, QString &errorMessage)
|
bool AccountSetupCommandLineManager::parseCommandlineOption(const QString &option, QStringListIterator &optionsIterator, QString &errorMessage)
|
||||||
{
|
{
|
||||||
if (option == QStringLiteral("--apppassword")) {
|
if (option == QStringLiteral("--apppassword")) {
|
||||||
|
@ -67,16 +90,16 @@ bool AccountSetupCommandLineManager::parseCommandlineOption(const QString &optio
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AccountSetupCommandLineManager::isCommandLineParsed()
|
bool AccountSetupCommandLineManager::isCommandLineParsed() const
|
||||||
{
|
{
|
||||||
return !_appPassword.isEmpty() && !_userId.isEmpty() && _serverUrl.isValid();
|
return !_appPassword.isEmpty() && !_userId.isEmpty() && _serverUrl.isValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountSetupCommandLineManager::setupAccountFromCommandLine(QObject *parent)
|
void AccountSetupCommandLineManager::setupAccountFromCommandLine()
|
||||||
{
|
{
|
||||||
if (isCommandLineParsed()) {
|
if (isCommandLineParsed()) {
|
||||||
qCInfo(lcAccountSetupCommandLineManager) << QStringLiteral("Command line has been parsed and account setup parameters have been found. Attempting setup a new account %1...").arg(_userId);
|
qCInfo(lcAccountSetupCommandLineManager) << QStringLiteral("Command line has been parsed and account setup parameters have been found. Attempting setup a new account %1...").arg(_userId);
|
||||||
const auto accountSetupJob = new AccountSetupFromCommandLineJob(_appPassword, _userId, _serverUrl, _localDirPath, _isVfsEnabled, _remoteDirPath, parent);
|
const auto accountSetupJob = new AccountSetupFromCommandLineJob(_appPassword, _userId, _serverUrl, _localDirPath, _isVfsEnabled, _remoteDirPath, parent());
|
||||||
accountSetupJob->handleAccountSetupFromCommandLine();
|
accountSetupJob->handleAccountSetupFromCommandLine();
|
||||||
} else {
|
} else {
|
||||||
qCInfo(lcAccountSetupCommandLineManager) << QStringLiteral("No account setup parameters have been found, or they are invalid. Proceed with normal startup...");
|
qCInfo(lcAccountSetupCommandLineManager) << QStringLiteral("No account setup parameters have been found, or they are invalid. Proceed with normal startup...");
|
||||||
|
@ -88,11 +111,4 @@ void AccountSetupCommandLineManager::setupAccountFromCommandLine(QObject *parent
|
||||||
_localDirPath.clear();
|
_localDirPath.clear();
|
||||||
_isVfsEnabled = true;
|
_isVfsEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AccountSetupCommandLineManager::_appPassword;
|
|
||||||
QString AccountSetupCommandLineManager::_userId;
|
|
||||||
QUrl AccountSetupCommandLineManager::_serverUrl;
|
|
||||||
QString AccountSetupCommandLineManager::_remoteDirPath;
|
|
||||||
QString AccountSetupCommandLineManager::_localDirPath;
|
|
||||||
bool AccountSetupCommandLineManager::_isVfsEnabled = true;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,24 +20,32 @@
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
namespace OCC {
|
namespace OCC {
|
||||||
class AccountSetupCommandLineManager
|
class AccountSetupCommandLineManager : public QObject
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] static bool parseCommandlineOption(const QString &option, QStringListIterator &optionsIterator, QString &errorMessage);
|
[[nodiscard]] static AccountSetupCommandLineManager *instance();
|
||||||
|
static void destroy();
|
||||||
|
|
||||||
[[nodiscard]] static bool isCommandLineParsed();
|
[[nodiscard]] bool parseCommandlineOption(const QString &option, QStringListIterator &optionsIterator, QString &errorMessage);
|
||||||
|
|
||||||
static void setupAccountFromCommandLine(QObject *parent = nullptr);
|
[[nodiscard]] bool isCommandLineParsed() const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setupAccountFromCommandLine();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit AccountSetupCommandLineManager() = delete;
|
explicit AccountSetupCommandLineManager(QObject *parent = nullptr);
|
||||||
|
|
||||||
static QString _appPassword;
|
static AccountSetupCommandLineManager *_instance;
|
||||||
static QString _userId;
|
|
||||||
static QUrl _serverUrl;
|
QString _appPassword;
|
||||||
static QString _remoteDirPath;
|
QString _userId;
|
||||||
static QString _localDirPath;
|
QUrl _serverUrl;
|
||||||
static bool _isVfsEnabled;
|
QString _remoteDirPath;
|
||||||
|
QString _localDirPath;
|
||||||
|
bool _isVfsEnabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -419,9 +419,10 @@ Application::Application(int &argc, char **argv)
|
||||||
|
|
||||||
handleEditLocallyFromOptions();
|
handleEditLocallyFromOptions();
|
||||||
|
|
||||||
if (AccountSetupCommandLineManager::isCommandLineParsed()) {
|
if (AccountSetupCommandLineManager::instance()->isCommandLineParsed()) {
|
||||||
AccountSetupCommandLineManager::setupAccountFromCommandLine(this);
|
AccountSetupCommandLineManager::instance()->setupAccountFromCommandLine();
|
||||||
}
|
}
|
||||||
|
AccountSetupCommandLineManager::destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::~Application()
|
Application::~Application()
|
||||||
|
@ -590,9 +591,10 @@ void Application::slotParseMessage(const QString &msg, QObject *)
|
||||||
|
|
||||||
handleEditLocallyFromOptions();
|
handleEditLocallyFromOptions();
|
||||||
|
|
||||||
if (AccountSetupCommandLineManager::isCommandLineParsed()) {
|
if (AccountSetupCommandLineManager::instance()->isCommandLineParsed()) {
|
||||||
AccountSetupCommandLineManager::setupAccountFromCommandLine(this);
|
AccountSetupCommandLineManager::instance()->setupAccountFromCommandLine();
|
||||||
}
|
}
|
||||||
|
AccountSetupCommandLineManager::destroy();
|
||||||
|
|
||||||
} else if (msg.startsWith(QLatin1String("MSG_SHOWMAINDIALOG"))) {
|
} else if (msg.startsWith(QLatin1String("MSG_SHOWMAINDIALOG"))) {
|
||||||
qCInfo(lcApplication) << "Running for" << _startedAt.elapsed() / 1000.0 << "sec";
|
qCInfo(lcApplication) << "Running for" << _startedAt.elapsed() / 1000.0 << "sec";
|
||||||
|
@ -681,7 +683,7 @@ void Application::parseOptions(const QStringList &options)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
if (!AccountSetupCommandLineManager::parseCommandlineOption(option, it, errorMessage)) {
|
if (!AccountSetupCommandLineManager::instance()->parseCommandlineOption(option, it, errorMessage)) {
|
||||||
if (!errorMessage.isEmpty()) {
|
if (!errorMessage.isEmpty()) {
|
||||||
showHint(errorMessage.toStdString());
|
showHint(errorMessage.toStdString());
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue