Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@
<file>src/gui/ResolveConflictsDialog.qml</file>
<file>src/gui/ConflictDelegate.qml</file>
<file>src/gui/ConflictItemFileInfo.qml</file>
<file>src/gui/wizard/qml/AccountWizardWindow.qml</file>
<file>src/gui/wizard/qml/AdvancedOptionsDialog.qml</file>
<file>src/gui/wizard/qml/BrowserAuthPage.qml</file>
<file>src/gui/wizard/qml/OptionRow.qml</file>
<file>src/gui/wizard/qml/ServerPage.qml</file>
<file>src/gui/wizard/qml/SyncOptionsPage.qml</file>
<file>src/gui/wizard/qml/WizardButton.qml</file>
<file>src/gui/wizard/qml/WizardDialogFrame.qml</file>
<file>src/gui/wizard/qml/WizardTextField.qml</file>
<file>src/gui/macOS/ui/FileProviderSettings.qml</file>
<file>src/gui/macOS/ui/FileProviderFileDelegate.qml</file>
<file>src/gui/integration/FileActionsWindow.qml</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -746,9 +746,13 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = "$(CURRENT_PROJECT_VERSION)";
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 649J6ZGB3X;
ENABLE_TESTING_SEARCH_PATHS = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
Expand Down Expand Up @@ -795,9 +799,13 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = "$(CURRENT_PROJECT_VERSION)";
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 649J6ZGB3X;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_TESTING_SEARCH_PATHS = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
Expand Down Expand Up @@ -839,9 +847,13 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = "$(CURRENT_PROJECT_VERSION)";
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 649J6ZGB3X;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu17;
GCC_DYNAMIC_NO_PIC = NO;
Expand Down Expand Up @@ -900,9 +912,13 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = "$(CURRENT_PROJECT_VERSION)";
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 649J6ZGB3X;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu17;
Expand Down Expand Up @@ -1115,9 +1131,13 @@
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 649J6ZGB3X;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
Expand Down Expand Up @@ -1169,9 +1189,13 @@
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 649J6ZGB3X;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand Down Expand Up @@ -1214,9 +1238,13 @@
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 649J6ZGB3X;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
Expand Down Expand Up @@ -1267,9 +1295,13 @@
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 649J6ZGB3X;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand Down
2 changes: 2 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ set(client_SRCS
creds/webflowcredentialsdialog.cpp
wizard/abstractcredswizardpage.h
wizard/abstractcredswizardpage.cpp
wizard/accountwizardcontroller.h
wizard/accountwizardcontroller.cpp
wizard/owncloudadvancedsetuppage.h
wizard/owncloudadvancedsetuppage.cpp
wizard/owncloudconnectionmethoddialog.h
Expand Down
2 changes: 2 additions & 0 deletions src/gui/owncloudgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "wheelhandler.h"
#include "syncconflictsmodel.h"
#include "syncengine.h"
#include "wizard/accountwizardcontroller.h"
#include "filedetails/datefieldbackend.h"
#include "filedetails/filedetails.h"
#include "filedetails/shareemodel.h"
Expand Down Expand Up @@ -143,6 +144,7 @@
qmlRegisterType<SortedShareModel>("com.nextcloud.desktopclient", 1, 0, "SortedShareModel");
qmlRegisterType<SyncConflictsModel>("com.nextcloud.desktopclient", 1, 0, "SyncConflictsModel");
qmlRegisterType<FileActionsModel>("com.nextcloud.desktopclient", 1, 0, "FileActionsModel");
qmlRegisterType<AccountWizardController>("com.nextcloud.desktopclient", 1, 0, "AccountWizardController");

qmlRegisterUncreatableType<QAbstractItemModel>("com.nextcloud.desktopclient", 1, 0, "QAbstractItemModel", "QAbstractItemModel");
qmlRegisterUncreatableType<Activity>("com.nextcloud.desktopclient", 1, 0, "activity", "Activity");
Expand Down Expand Up @@ -242,7 +244,7 @@
// or SSL error dialog also comes to front.
}

void ownCloudGui::slotSyncStateChange(Folder *folder)

Check warning on line 247 in src/gui/owncloudgui.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ4m_STQj4RHA-zkWkK-&open=AZ4m_STQj4RHA-zkWkK-&pullRequest=10030
{
if (!folder) {
return; // Valid, just a general GUI redraw was needed.
Expand Down Expand Up @@ -388,7 +390,7 @@
QStringList messages;
messages.append(tr("Disconnected from accounts:"));
for (const auto &accountState : std::as_const(problemAccounts)) {
QString message = tr("Account %1: %2").arg(accountState->account()->displayName(), accountState->stateString(accountState->state()));

Check warning on line 393 in src/gui/owncloudgui.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace "->" with "::" for access to "OCC::AccountState::stateString".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ4m_STQj4RHA-zkWkLA&open=AZ4m_STQj4RHA-zkWkLA&pullRequest=10030
if (!accountState->connectionErrors().empty()) {
message += QLatin1String("\n");
message += accountState->connectionErrors().join(QLatin1String("\n"));
Expand Down
87 changes: 86 additions & 1 deletion src/gui/owncloudsetupwizard.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2012 ownCloud GmbH
* SPDX-License-Identifier: GPL-2.0-or-later
*/

#include "accessmanager.h"

Check failure on line 7 in src/gui/owncloudsetupwizard.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/owncloudsetupwizard.cpp:7:10 [clang-diagnostic-error]

'accessmanager.h' file not found
#include "account.h"
#include "accountmanager.h"
#include "clientproxy.h"
Expand All @@ -17,6 +17,8 @@
#include "owncloudsetupwizard.h"
#include "owncloudpropagator_p.h"
#include "sslerrordialog.h"
#include "systray.h"
#include "wizard/accountwizardcontroller.h"
#include "wizard/owncloudwizard.h"
#include "wizard/owncloudwizardcommon.h"
#include "account.h"
Expand All @@ -36,6 +38,11 @@
#include <QMessageBox>
#include <QDesktopServices>
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QQmlComponent>
#include <QQmlContext>
#include <QQuickWindow>
#include <QVariant>

using namespace Qt::StringLiterals;

Expand Down Expand Up @@ -63,6 +70,9 @@

OwncloudSetupWizard::~OwncloudSetupWizard()
{
if (_qmlWizardWindow) {
_qmlWizardWindow->deleteLater();
}
_ocWizard->deleteLater();
}

Expand All @@ -85,9 +95,17 @@

owncloudSetupWizard = new OwncloudSetupWizard(parent);
connect(owncloudSetupWizard, SIGNAL(ownCloudWizardDone(int)), obj, amember);
connect(owncloudSetupWizard->_ocWizard, &OwncloudWizard::wizardClosed, obj, [] { owncloudSetupWizard.clear(); });

FolderMan::instance()->setSyncEnabled(false);
// The widget wizard stays as a fallback until the QML flow owns every setup branch.
if (owncloudSetupWizard->startQmlWizard()) {
connect(owncloudSetupWizard->_qmlController, &AccountWizardController::finished, obj, [] {
owncloudSetupWizard.clear();
});
return;
}

connect(owncloudSetupWizard->_ocWizard, &OwncloudWizard::wizardClosed, obj, [] { owncloudSetupWizard.clear(); });
owncloudSetupWizard->startWizard();
}

Expand All @@ -97,6 +115,13 @@
return false;
}

if (owncloudSetupWizard->_qmlWizardWindow) {
owncloudSetupWizard->_qmlWizardWindow->show();
owncloudSetupWizard->_qmlWizardWindow->raise();
owncloudSetupWizard->_qmlWizardWindow->requestActivate();
return true;
}

ownCloudGui::raiseDialog(owncloudSetupWizard->_ocWizard);
return true;
}
Expand Down Expand Up @@ -148,6 +173,66 @@
_ocWizard->raise();
}

bool OwncloudSetupWizard::startQmlWizard()

Check warning on line 176 in src/gui/owncloudsetupwizard.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/owncloudsetupwizard.cpp:176:27 [modernize-use-trailing-return-type]

use a trailing return type for this function
{
auto *engine = Systray::instance()->trayEngine();

Check warning on line 178 in src/gui/owncloudsetupwizard.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/owncloudsetupwizard.cpp:178:11 [cppcoreguidelines-init-variables]

variable 'engine' is not initialized
if (!engine) {
qCWarning(lcWizard) << "Cannot start QML account wizard without a QML engine.";
return false;
}

_qmlController = new AccountWizardController(this);
QQmlComponent component(engine, QStringLiteral("qrc:/qml/src/gui/wizard/qml/AccountWizardWindow.qml"));

Check warning on line 185 in src/gui/owncloudsetupwizard.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/owncloudsetupwizard.cpp:185:19 [cppcoreguidelines-init-variables]

variable 'component' is not initialized
QVariantMap initialProperties;

Check warning on line 186 in src/gui/owncloudsetupwizard.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/owncloudsetupwizard.cpp:186:17 [cppcoreguidelines-init-variables]

variable 'initialProperties' is not initialized
initialProperties.insert(QStringLiteral("controller"), QVariant::fromValue<QObject *>(_qmlController));
auto *createdObject = component.createWithInitialProperties(initialProperties);

Check warning on line 188 in src/gui/owncloudsetupwizard.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/owncloudsetupwizard.cpp:188:11 [cppcoreguidelines-init-variables]

variable 'createdObject' is not initialized

Check warning on line 188 in src/gui/owncloudsetupwizard.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "createdObject" of type "class QObject *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ4m_SUej4RHA-zkWkLD&open=AZ4m_SUej4RHA-zkWkLD&pullRequest=10030

if (component.isError()) {
qCWarning(lcWizard) << "Failed to load QML account wizard:" << component.errors();
}

_qmlWizardWindow = qobject_cast<QQuickWindow *>(createdObject);
if (!_qmlWizardWindow) {
if (createdObject) {
createdObject->deleteLater();
}
_qmlController->deleteLater();
_qmlController = nullptr;
return false;
}

#if defined(Q_OS_MACOS) && QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)
_qmlWizardWindow->setFlag(Qt::ExpandedClientAreaHint, true);
_qmlWizardWindow->setFlag(Qt::NoTitleBarBackgroundHint, true);
#endif

connect(_qmlController, &AccountWizardController::finished, this, [this](int result) {
emit ownCloudWizardDone(result);

Check warning on line 210 in src/gui/owncloudsetupwizard.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/owncloudsetupwizard.cpp:210:14 [cppcoreguidelines-init-variables]

variable 'ownCloudWizardDone' is not initialized
if (_qmlWizardWindow) {
_qmlWizardWindow->deleteLater();
_qmlWizardWindow.clear();
}
deleteLater();
});

connect(_qmlController, &AccountWizardController::legacyWizardRequested, this, [this] {
if (_qmlWizardWindow) {
_qmlWizardWindow->deleteLater();
_qmlWizardWindow.clear();
}
_qmlController->deleteLater();
_qmlController = nullptr;

connect(_ocWizard, &OwncloudWizard::wizardClosed, this, [] { owncloudSetupWizard.clear(); });
startWizard();
});

_qmlWizardWindow->show();
_qmlWizardWindow->raise();
_qmlWizardWindow->requestActivate();
return true;
}

// also checks if an installation is valid and determines auth type in a second step
void OwncloudSetupWizard::slotCheckServer(const QUrl &serverURL, const OCC::WizardProxySettingsDialog::WizardProxySettings &proxySettings)
{
Expand All @@ -155,7 +240,7 @@
account->setUrl(serverURL);

account->setProxyType(proxySettings._proxyType);
switch (proxySettings._proxyType)

Check failure on line 243 in src/gui/owncloudsetupwizard.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add a "default" case to this switch statement.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ4m_SUej4RHA-zkWkLG&open=AZ4m_SUej4RHA-zkWkLG&pullRequest=10030
{
case QNetworkProxy::HttpCachingProxy:
case QNetworkProxy::FtpCachingProxy:
Expand Down Expand Up @@ -406,11 +491,11 @@
job->setFollowRedirects(false);
job->setProperties(QList<QByteArray>() << "getlastmodified");
connect(job, &PropfindJob::result, _ocWizard, &OwncloudWizard::successfulStep);
connect(job, &PropfindJob::finishedWithError, this, [this] (QNetworkReply *reply) -> void {

Check warning on line 494 in src/gui/owncloudsetupwizard.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the redundant return type of this lambda.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ4m_SUej4RHA-zkWkLH&open=AZ4m_SUej4RHA-zkWkLH&pullRequest=10030
if (reply && reply->error() == QNetworkReply::ContentAccessDenied) {
// A 403 might indicate that the terms of service need to be signed.
// catch this special case here, fall back to the standard error handler if it's not TOS-related
auto davException = OCC::getExceptionFromReply(reply);

Check warning on line 498 in src/gui/owncloudsetupwizard.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this declaration by a structured binding declaration.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ4m_SUej4RHA-zkWkLJ&open=AZ4m_SUej4RHA-zkWkLJ&pullRequest=10030
if (!davException.first.isEmpty() && davException.first == QStringLiteral(R"(OCA\TermsOfService\TermsNotSignedException)")) {
// authentication was successful, but the user hasn't signed the terms of service yet. Prompt for that in the next step
qCInfo(lcWizard) << "Terms of service not accepted yet! Will prompt the user in the next step";
Expand Down
6 changes: 6 additions & 0 deletions src/gui/owncloudsetupwizard.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#ifndef OWNCLOUDSETUPWIZARD_H
#define OWNCLOUDSETUPWIZARD_H

#include <QObject>

Check failure on line 10 in src/gui/owncloudsetupwizard.h

View workflow job for this annotation

GitHub Actions / build

src/gui/owncloudsetupwizard.h:10:10 [clang-diagnostic-error]

'QObject' file not found
#include <QWidget>
#include <QProcess>
#include <QNetworkReply>
Expand All @@ -19,12 +19,15 @@

#include "wizard/wizardproxysettingsdialog.h"

class QQuickWindow;

namespace OCC {

class AccountState;
class TermsOfServiceChecker;

class OwncloudWizard;
class AccountWizardController;

/**
* @brief The OwncloudSetupWizard class
Expand Down Expand Up @@ -67,6 +70,7 @@
explicit OwncloudSetupWizard(QObject *parent = nullptr);
~OwncloudSetupWizard() override;
void startWizard();
bool startQmlWizard();
void testOwnCloudConnect();
void createRemoteFolder();
void finalizeSetup(bool);
Expand All @@ -75,6 +79,8 @@
bool checkDowngradeAdvised(QNetworkReply *reply);

OwncloudWizard *_ocWizard = nullptr;
AccountWizardController *_qmlController = nullptr;
QPointer<QQuickWindow> _qmlWizardWindow;
QString _initLocalFolder;
QString _remoteFolder;
};
Expand Down
Loading
Loading