Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for compiling without QtWebEngine (webflow / flow2 support) -- rebased #2204

Closed
wants to merge 2 commits into from
Closed
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
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ if(NO_SHIBBOLETH)
add_definitions(-DNO_SHIBBOLETH=1)
endif()

# Disable webengine-based components
option(NO_WEBENGINE "Build without webflow / flow2 support so QtWebEngine isn't required" OFF)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion this should be called something like WITH_WEBFLOW, because this is the feature to be enabled/disabled, with ON as default. The consequence of being enabled is that webengine is pulled in. Thinking as a Gentoo user the use-flag of the nextcloud-client would be something like webflow. A feature like webengine would suggest that there is an alternative, like qtwebkit.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just saw that there is also a NO_SHIBBOLETH and hence the negative-form NO_WEBFLOW should be preserved for consistency.

if(NO_WEBENGINE)
message("Compiling without webengine")
add_definitions(-DNO_WEBENGINE=1)
endif()

if(APPLE)
set( SOCKETAPI_TEAM_IDENTIFIER_PREFIX "" CACHE STRING "SocketApi prefix (including a following dot) that must match the codesign key's TeamIdentifier/Organizational Unit" )
endif()
Expand Down
6 changes: 5 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ endif()

set(synclib_NAME ${APPLICATION_EXECUTABLE}sync)

find_package(Qt5 5.12 COMPONENTS Core Network Xml Concurrent WebEngineWidgets WebEngine REQUIRED)
find_package(Qt5 5.12 COMPONENTS Core Network Xml Concurrent REQUIRED)

if(NOT NO_WEBENGINE)
find_package(Qt5 5.12 COMPONENTS WebEngineWidgets WebEngine REQUIRED)
endif()

if(NOT TOKEN_AUTH_ONLY)
find_package(Qt5Keychain REQUIRED)
Expand Down
18 changes: 13 additions & 5 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ set(client_SRCS
creds/httpcredentialsgui.cpp
creds/oauth.cpp
creds/flow2auth.cpp
creds/webflowcredentials.cpp
creds/webflowcredentialsdialog.cpp
wizard/postfixlineedit.cpp
wizard/abstractcredswizardpage.cpp
wizard/owncloudadvancedsetuppage.cpp
Expand All @@ -126,8 +124,6 @@ set(client_SRCS
wizard/owncloudwizardcommon.cpp
wizard/owncloudwizard.cpp
wizard/owncloudwizardresultpage.cpp
wizard/webviewpage.cpp
wizard/webview.cpp
wizard/slideshow.cpp
)

Expand All @@ -148,6 +144,15 @@ IF(BUILD_UPDATER)
)
endif()

IF(NOT NO_WEBENGINE)
list(APPEND client_SRCS
creds/webflowcredentials.cpp
creds/webflowcredentialsdialog.cpp
wizard/webviewpage.cpp
wizard/webview.cpp
)
endif()

IF( APPLE )
list(APPEND client_SRCS cocoainitializer_mac.mm)
list(APPEND client_SRCS socketapisocket_mac.mm)
Expand Down Expand Up @@ -314,8 +319,11 @@ set_target_properties( ${APPLICATION_EXECUTABLE} PROPERTIES
set_target_properties( ${APPLICATION_EXECUTABLE} PROPERTIES
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/${APPLICATION_EXECUTABLE};${CMAKE_INSTALL_RPATH}" )

target_link_libraries( ${APPLICATION_EXECUTABLE} Qt5::Widgets Qt5::Svg Qt5::Network Qt5::Xml Qt5::Qml Qt5::Quick Qt5::QuickControls2 Qt5::WebEngineWidgets)
target_link_libraries( ${APPLICATION_EXECUTABLE} Qt5::Widgets Qt5::Svg Qt5::Network Qt5::Xml Qt5::Qml Qt5::Quick Qt5::QuickControls2)
target_link_libraries( ${APPLICATION_EXECUTABLE} ${synclib_NAME} )
IF(NOT NO_WEBENGINE)
target_link_libraries( ${APPLICATION_EXECUTABLE} Qt5::WebEngineWidgets )
endif()
IF(BUILD_UPDATER)
target_link_libraries( ${APPLICATION_EXECUTABLE} updater )
endif()
Expand Down
2 changes: 2 additions & 0 deletions src/gui/accountmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ AccountPtr AccountManager::loadAccountHelper(QSettings &settings)
acc->setUrl(urlConfig.toUrl());
}

#ifndef NO_WEBENGINE
// Migrate to webflow
if (authType == QLatin1String("http")) {
authType = "webflow";
Expand All @@ -266,6 +267,7 @@ AccountPtr AccountManager::loadAccountHelper(QSettings &settings)
settings.remove(key);
}
}
#endif

qCInfo(lcAccountManager) << "Account for" << acc->url() << "using auth type" << authType;

Expand Down
4 changes: 4 additions & 0 deletions src/gui/creds/credentialsfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
#ifndef NO_SHIBBOLETH
#include "creds/shibbolethcredentials.h"
#endif
#ifndef NO_WEBENGINE
#include "creds/webflowcredentials.h"
#endif

namespace OCC {

Expand All @@ -40,8 +42,10 @@ namespace CredentialsFactory {
} else if (type == "shibboleth") {
return new ShibbolethCredentials;
#endif
#ifndef NO_WEBENGINE
} else if (type == "webflow") {
return new WebFlowCredentials;
#endif
} else {
qCWarning(lcGuiCredentials, "Unknown credentials type: %s", qPrintable(type));
return new DummyCredentials;
Expand Down
4 changes: 4 additions & 0 deletions src/gui/wizard/owncloudsetuppage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,11 @@ void OwncloudSetupPage::slotLogin()
void OwncloudSetupPage::slotGotoProviderList()
{
_ocWizard->setRegistration(true);
#ifndef NO_WEBENGINE
_ocWizard->setAuthType(DetermineAuthTypeJob::AuthType::WebViewFlow);
#else
_ocWizard->setAuthType(DetermineAuthTypeJob::AuthType::Basic);
#endif
_authTypeKnown = true;
_checking = false;
emit completeChanged();
Expand Down
17 changes: 16 additions & 1 deletion src/gui/wizard/owncloudwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
#endif
#include "wizard/owncloudadvancedsetuppage.h"
#include "wizard/owncloudwizardresultpage.h"
#ifndef NO_WEBENGINE
#include "wizard/webviewpage.h"
#endif
#include "wizard/flow2authcredspage.h"

#include "QProgressIndicator.h"
Expand All @@ -53,7 +55,9 @@ OwncloudWizard::OwncloudWizard(QWidget *parent)
, _flow2CredsPage(new Flow2AuthCredsPage)
, _advancedSetupPage(new OwncloudAdvancedSetupPage)
, _resultPage(new OwncloudWizardResultPage)
#ifndef NO_WEBENGINE
, _webViewPage(new WebViewPage(this))
#endif
{
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setPage(WizardCommon::Page_ServerSetup, _setupPage);
Expand All @@ -65,7 +69,9 @@ OwncloudWizard::OwncloudWizard(QWidget *parent)
#endif
setPage(WizardCommon::Page_AdvancedSetup, _advancedSetupPage);
setPage(WizardCommon::Page_Result, _resultPage);
#ifndef NO_WEBENGINE
setPage(WizardCommon::Page_WebView, _webViewPage);
#endif

connect(this, &QDialog::finished, this, &OwncloudWizard::basicSetupFinished);

Expand All @@ -81,7 +87,9 @@ OwncloudWizard::OwncloudWizard(QWidget *parent)
#ifndef NO_SHIBBOLETH
connect(_shibbolethCredsPage, &OwncloudShibbolethCredsPage::connectToOCUrl, this, &OwncloudWizard::connectToOCUrl);
#endif
#ifndef NO_WEBENGINE
connect(_webViewPage, &WebViewPage::connectToOCUrl, this, &OwncloudWizard::connectToOCUrl);
#endif
connect(_advancedSetupPage, &OwncloudAdvancedSetupPage::createLocalAndRemoteFolders,
this, &OwncloudWizard::createLocalAndRemoteFolders);
connect(this, &QWizard::customButtonClicked, this, &OwncloudWizard::skipFolderConfiguration);
Expand Down Expand Up @@ -187,9 +195,11 @@ void OwncloudWizard::successfulStep()
break;
#endif

#ifndef NO_WEBENGINE
case WizardCommon::Page_WebView:
_webViewPage->setConnected();
break;
#endif

case WizardCommon::Page_AdvancedSetup:
_advancedSetupPage->directoriesCreated();
Expand All @@ -216,8 +226,10 @@ void OwncloudWizard::setAuthType(DetermineAuthTypeJob::AuthType type)
_credentialsPage = _browserCredsPage;
} else if (type == DetermineAuthTypeJob::LoginFlowV2) {
_credentialsPage = _flow2CredsPage;
#ifndef NO_WEBENGINE
} else if (type == DetermineAuthTypeJob::WebViewFlow) {
_credentialsPage = _webViewPage;
#endif
} else { // try Basic auth even for "Unknown"
_credentialsPage = _httpCredsPage;
}
Expand All @@ -242,7 +254,10 @@ void OwncloudWizard::slotCurrentPageChanged(int id)
}

setOption(QWizard::HaveCustomButton1, id == WizardCommon::Page_AdvancedSetup);
if (id == WizardCommon::Page_AdvancedSetup && (_credentialsPage == _browserCredsPage || _credentialsPage == _flow2CredsPage)) {
if (id == WizardCommon::Page_AdvancedSetup
&& (_credentialsPage == _browserCredsPage
|| _credentialsPage == _flow2CredsPage
)) {
// For OAuth, disable the back button in the Page_AdvancedSetup because we don't want
// to re-open the browser.
button(QWizard::BackButton)->setEnabled(false);
Expand Down
4 changes: 4 additions & 0 deletions src/gui/wizard/owncloudwizard.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ class OwncloudAdvancedSetupPage;
class OwncloudWizardResultPage;
class AbstractCredentials;
class AbstractCredentialsWizardPage;
#ifndef NO_WEBENGINE
class WebViewPage;
#endif
class Flow2AuthCredsPage;

/**
Expand Down Expand Up @@ -118,7 +120,9 @@ public slots:
OwncloudAdvancedSetupPage *_advancedSetupPage;
OwncloudWizardResultPage *_resultPage;
AbstractCredentialsWizardPage *_credentialsPage = nullptr;
#ifndef NO_WEBENGINE
WebViewPage *_webViewPage;
#endif

QStringList _setupLog;

Expand Down
8 changes: 8 additions & 0 deletions src/libsync/networkjobs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -966,12 +966,20 @@ void DetermineAuthTypeJob::checkAllDone()

// WebViewFlow > OAuth > Shib > Basic
if (_account->serverVersionInt() >= Account::makeServerVersion(12, 0, 0)) {
#ifndef NO_WEBENGINE
result = WebViewFlow;
#else
result = Basic;
#endif
}

// LoginFlowV2 > WebViewFlow > OAuth > Shib > Basic
if (_account->serverVersionInt() >= Account::makeServerVersion(16, 0, 0)) {
#ifndef NO_WEBENGINE
result = LoginFlowV2;
#else
result = Basic;
#endif
}

// If we determined that we need the webview flow (GS for example) then we switch to that
Expand Down