31c9599b1c4e2c78d8e3ed33ee9a0a88e78822af
[shuber-gentoo-overlay.git] / net-misc / nextcloud-client / files / v3.1.1-nowebengine.patch
1 diff --git a/CMakeLists.txt b/CMakeLists.txt
2 index 5df238838..4a333dbdd 100644
3 --- a/CMakeLists.txt
4 +++ b/CMakeLists.txt
5 @@ -176,6 +176,13 @@ if(NO_SHIBBOLETH)
6 add_definitions(-DNO_SHIBBOLETH=1)
7 endif()
8
9 +# Disable webengine-based components
10 +option(NO_WEBENGINE "Build without webflow / flow2 support so QtWebEngine isn't required" OFF)
11 +if(NO_WEBENGINE)
12 + message("Compiling without webengine")
13 + add_definitions(-DNO_WEBENGINE=1)
14 +endif()
15 +
16 if(APPLE)
17 set( SOCKETAPI_TEAM_IDENTIFIER_PREFIX "" CACHE STRING "SocketApi prefix (including a following dot) that must match the codesign key's TeamIdentifier/Organizational Unit" )
18 endif()
19 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
20 index a79edfcfb..c8ef114a4 100644
21 --- a/src/CMakeLists.txt
22 +++ b/src/CMakeLists.txt
23 @@ -4,7 +4,11 @@ endif()
24
25 set(synclib_NAME ${APPLICATION_EXECUTABLE}sync)
26
27 -find_package(Qt5 5.12 COMPONENTS Core Network Xml Concurrent WebEngineWidgets WebEngine REQUIRED)
28 +find_package(Qt5 5.12 COMPONENTS Core Network Xml Concurrent REQUIRED)
29 +
30 +if(NOT NO_WEBENGINE)
31 + find_package(Qt5 5.12 COMPONENTS WebEngineWidgets WebEngine REQUIRED)
32 +endif()
33
34 if(NOT TOKEN_AUTH_ONLY)
35 find_package(Qt5Keychain REQUIRED)
36 diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt
37 index b6a666924..cd01e020c 100644
38 --- a/src/gui/CMakeLists.txt
39 +++ b/src/gui/CMakeLists.txt
40 @@ -119,23 +119,16 @@ set(client_SRCS
41 creds/credentialsfactory.cpp
42 creds/httpcredentialsgui.cpp
43 creds/oauth.cpp
44 - creds/flow2auth.cpp
45 - creds/webflowcredentials.cpp
46 - creds/webflowcredentialsdialog.cpp
47 wizard/postfixlineedit.cpp
48 wizard/abstractcredswizardpage.cpp
49 wizard/owncloudadvancedsetuppage.cpp
50 wizard/owncloudconnectionmethoddialog.cpp
51 wizard/owncloudhttpcredspage.cpp
52 wizard/owncloudoauthcredspage.cpp
53 - wizard/flow2authcredspage.cpp
54 - wizard/flow2authwidget.cpp
55 wizard/owncloudsetuppage.cpp
56 wizard/owncloudwizardcommon.cpp
57 wizard/owncloudwizard.cpp
58 wizard/owncloudwizardresultpage.cpp
59 - wizard/webviewpage.cpp
60 - wizard/webview.cpp
61 wizard/slideshow.cpp
62 )
63
64 @@ -156,6 +149,18 @@ IF(BUILD_UPDATER)
65 )
66 endif()
67
68 +IF(NOT NO_WEBENGINE)
69 + list(APPEND client_SRCS
70 + creds/flow2auth.cpp
71 + creds/webflowcredentials.cpp
72 + creds/webflowcredentialsdialog.cpp
73 + wizard/flow2authcredspage.cpp
74 + wizard/flow2authwidget.cpp
75 + wizard/webviewpage.cpp
76 + wizard/webview.cpp
77 + )
78 +endif()
79 +
80 IF( APPLE )
81 list(APPEND client_SRCS cocoainitializer_mac.mm)
82 list(APPEND client_SRCS socketapisocket_mac.mm)
83 @@ -328,8 +333,11 @@ set_target_properties( ${APPLICATION_EXECUTABLE} PROPERTIES
84 set_target_properties( ${APPLICATION_EXECUTABLE} PROPERTIES
85 INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/${APPLICATION_EXECUTABLE};${CMAKE_INSTALL_RPATH}" )
86
87 -target_link_libraries( ${APPLICATION_EXECUTABLE} Qt5::Widgets Qt5::GuiPrivate Qt5::Svg Qt5::Network Qt5::Xml Qt5::Qml Qt5::Quick Qt5::QuickControls2 Qt5::WebEngineWidgets)
88 +target_link_libraries( ${APPLICATION_EXECUTABLE} Qt5::Widgets Qt5::GuiPrivate Qt5::Svg Qt5::Network Qt5::Xml Qt5::Qml Qt5::Quick Qt5::QuickControls2)
89 target_link_libraries( ${APPLICATION_EXECUTABLE} ${synclib_NAME} )
90 +IF(NOT NO_WEBENGINE)
91 + target_link_libraries( ${APPLICATION_EXECUTABLE} Qt5::WebEngineWidgets )
92 +endif()
93 IF(BUILD_UPDATER)
94 target_link_libraries( ${APPLICATION_EXECUTABLE} updater )
95 endif()
96 diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp
97 index fa9da6237..83388ea57 100644
98 --- a/src/gui/accountmanager.cpp
99 +++ b/src/gui/accountmanager.cpp
100 @@ -253,6 +253,7 @@ AccountPtr AccountManager::loadAccountHelper(QSettings &settings)
101 acc->setUrl(urlConfig.toUrl());
102 }
103
104 +#ifndef NO_WEBENGINE
105 // Migrate to webflow
106 if (authType == QLatin1String("http")) {
107 authType = "webflow";
108 @@ -266,6 +267,7 @@ AccountPtr AccountManager::loadAccountHelper(QSettings &settings)
109 settings.remove(key);
110 }
111 }
112 +#endif
113
114 qCInfo(lcAccountManager) << "Account for" << acc->url() << "using auth type" << authType;
115
116 diff --git a/src/gui/creds/credentialsfactory.cpp b/src/gui/creds/credentialsfactory.cpp
117 index 6062f70eb..723196d08 100644
118 --- a/src/gui/creds/credentialsfactory.cpp
119 +++ b/src/gui/creds/credentialsfactory.cpp
120 @@ -21,7 +21,9 @@
121 #ifndef NO_SHIBBOLETH
122 #include "creds/shibbolethcredentials.h"
123 #endif
124 +#ifndef NO_WEBENGINE
125 #include "creds/webflowcredentials.h"
126 +#endif
127
128 namespace OCC {
129
130 @@ -40,8 +42,10 @@ namespace CredentialsFactory {
131 } else if (type == "shibboleth") {
132 return new ShibbolethCredentials;
133 #endif
134 +#ifndef NO_WEBENGINE
135 } else if (type == "webflow") {
136 return new WebFlowCredentials;
137 +#endif
138 } else {
139 qCWarning(lcGuiCredentials, "Unknown credentials type: %s", qPrintable(type));
140 return new DummyCredentials;
141 diff --git a/src/gui/wizard/owncloudsetuppage.cpp b/src/gui/wizard/owncloudsetuppage.cpp
142 index 8f03fa124..56bbe8866 100644
143 --- a/src/gui/wizard/owncloudsetuppage.cpp
144 +++ b/src/gui/wizard/owncloudsetuppage.cpp
145 @@ -148,7 +148,11 @@ void OwncloudSetupPage::slotLogin()
146 void OwncloudSetupPage::slotGotoProviderList()
147 {
148 _ocWizard->setRegistration(true);
149 +#ifndef NO_WEBENGINE
150 _ocWizard->setAuthType(DetermineAuthTypeJob::AuthType::WebViewFlow);
151 +#else
152 + _ocWizard->setAuthType(DetermineAuthTypeJob::AuthType::Basic);
153 +#endif
154 _authTypeKnown = true;
155 _checking = false;
156 emit completeChanged();
157 diff --git a/src/gui/wizard/owncloudwizard.cpp b/src/gui/wizard/owncloudwizard.cpp
158 index 912222dca..463c19d48 100644
159 --- a/src/gui/wizard/owncloudwizard.cpp
160 +++ b/src/gui/wizard/owncloudwizard.cpp
161 @@ -27,8 +27,10 @@
162 #endif
163 #include "wizard/owncloudadvancedsetuppage.h"
164 #include "wizard/owncloudwizardresultpage.h"
165 +#ifndef NO_WEBENGINE
166 #include "wizard/webviewpage.h"
167 #include "wizard/flow2authcredspage.h"
168 +#endif
169
170 #include "QProgressIndicator.h"
171
172 @@ -50,22 +52,30 @@ OwncloudWizard::OwncloudWizard(QWidget *parent)
173 #ifndef NO_SHIBBOLETH
174 , _shibbolethCredsPage(new OwncloudShibbolethCredsPage)
175 #endif
176 +#ifndef NO_WEBENGINE
177 , _flow2CredsPage(new Flow2AuthCredsPage)
178 +#endif
179 , _advancedSetupPage(new OwncloudAdvancedSetupPage)
180 , _resultPage(new OwncloudWizardResultPage)
181 +#ifndef NO_WEBENGINE
182 , _webViewPage(new WebViewPage(this))
183 +#endif
184 {
185 setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
186 setPage(WizardCommon::Page_ServerSetup, _setupPage);
187 setPage(WizardCommon::Page_HttpCreds, _httpCredsPage);
188 setPage(WizardCommon::Page_OAuthCreds, _browserCredsPage);
189 +#ifndef NO_WEBENGINE
190 setPage(WizardCommon::Page_Flow2AuthCreds, _flow2CredsPage);
191 +#endif
192 #ifndef NO_SHIBBOLETH
193 setPage(WizardCommon::Page_ShibbolethCreds, _shibbolethCredsPage);
194 #endif
195 setPage(WizardCommon::Page_AdvancedSetup, _advancedSetupPage);
196 setPage(WizardCommon::Page_Result, _resultPage);
197 +#ifndef NO_WEBENGINE
198 setPage(WizardCommon::Page_WebView, _webViewPage);
199 +#endif
200
201 connect(this, &QDialog::finished, this, &OwncloudWizard::basicSetupFinished);
202
203 @@ -77,11 +87,15 @@ OwncloudWizard::OwncloudWizard(QWidget *parent)
204 connect(_setupPage, &OwncloudSetupPage::determineAuthType, this, &OwncloudWizard::determineAuthType);
205 connect(_httpCredsPage, &OwncloudHttpCredsPage::connectToOCUrl, this, &OwncloudWizard::connectToOCUrl);
206 connect(_browserCredsPage, &OwncloudOAuthCredsPage::connectToOCUrl, this, &OwncloudWizard::connectToOCUrl);
207 +#ifndef NO_WEBENGINE
208 connect(_flow2CredsPage, &Flow2AuthCredsPage::connectToOCUrl, this, &OwncloudWizard::connectToOCUrl);
209 +#endif
210 #ifndef NO_SHIBBOLETH
211 connect(_shibbolethCredsPage, &OwncloudShibbolethCredsPage::connectToOCUrl, this, &OwncloudWizard::connectToOCUrl);
212 #endif
213 +#ifndef NO_WEBENGINE
214 connect(_webViewPage, &WebViewPage::connectToOCUrl, this, &OwncloudWizard::connectToOCUrl);
215 +#endif
216 connect(_advancedSetupPage, &OwncloudAdvancedSetupPage::createLocalAndRemoteFolders,
217 this, &OwncloudWizard::createLocalAndRemoteFolders);
218 connect(this, &QWizard::customButtonClicked, this, &OwncloudWizard::skipFolderConfiguration);
219 @@ -103,12 +117,16 @@ OwncloudWizard::OwncloudWizard(QWidget *parent)
220 // Connect styleChanged events to our widgets, so they can adapt (Dark-/Light-Mode switching)
221 connect(this, &OwncloudWizard::styleChanged, _setupPage, &OwncloudSetupPage::slotStyleChanged);
222 connect(this, &OwncloudWizard::styleChanged, _advancedSetupPage, &OwncloudAdvancedSetupPage::slotStyleChanged);
223 +#ifndef NO_WEBENGINE
224 connect(this, &OwncloudWizard::styleChanged, _flow2CredsPage, &Flow2AuthCredsPage::slotStyleChanged);
225 +#endif
226
227 customizeStyle();
228
229 +#ifndef NO_WEBENGINE
230 // allow Flow2 page to poll on window activation
231 connect(this, &OwncloudWizard::onActivate, _flow2CredsPage, &Flow2AuthCredsPage::slotPollNow);
232 +#endif
233 }
234
235 void OwncloudWizard::setAccount(AccountPtr account)
236 @@ -177,9 +195,11 @@ void OwncloudWizard::successfulStep()
237 _browserCredsPage->setConnected();
238 break;
239
240 +#ifndef NO_WEBENGINE
241 case WizardCommon::Page_Flow2AuthCreds:
242 _flow2CredsPage->setConnected();
243 break;
244 +#endif
245
246 #ifndef NO_SHIBBOLETH
247 case WizardCommon::Page_ShibbolethCreds:
248 @@ -187,9 +207,11 @@ void OwncloudWizard::successfulStep()
249 break;
250 #endif
251
252 +#ifndef NO_WEBENGINE
253 case WizardCommon::Page_WebView:
254 _webViewPage->setConnected();
255 break;
256 +#endif
257
258 case WizardCommon::Page_AdvancedSetup:
259 _advancedSetupPage->directoriesCreated();
260 @@ -214,10 +236,12 @@ void OwncloudWizard::setAuthType(DetermineAuthTypeJob::AuthType type)
261 #endif
262 if (type == DetermineAuthTypeJob::OAuth) {
263 _credentialsPage = _browserCredsPage;
264 +#ifndef NO_WEBENGINE
265 } else if (type == DetermineAuthTypeJob::LoginFlowV2) {
266 _credentialsPage = _flow2CredsPage;
267 } else if (type == DetermineAuthTypeJob::WebViewFlow) {
268 _credentialsPage = _webViewPage;
269 +#endif
270 } else { // try Basic auth even for "Unknown"
271 _credentialsPage = _httpCredsPage;
272 }
273 @@ -242,7 +266,12 @@ void OwncloudWizard::slotCurrentPageChanged(int id)
274 }
275
276 setOption(QWizard::HaveCustomButton1, id == WizardCommon::Page_AdvancedSetup);
277 - if (id == WizardCommon::Page_AdvancedSetup && (_credentialsPage == _browserCredsPage || _credentialsPage == _flow2CredsPage)) {
278 + if (id == WizardCommon::Page_AdvancedSetup
279 + && (_credentialsPage == _browserCredsPage
280 +#ifndef NO_WEBENGINE
281 + || _credentialsPage == _flow2CredsPage
282 +#endif
283 + )) {
284 // For OAuth, disable the back button in the Page_AdvancedSetup because we don't want
285 // to re-open the browser.
286 button(QWizard::BackButton)->setEnabled(false);
287 diff --git a/src/gui/wizard/owncloudwizard.h b/src/gui/wizard/owncloudwizard.h
288 index ee6161ca5..c0ee06403 100644
289 --- a/src/gui/wizard/owncloudwizard.h
290 +++ b/src/gui/wizard/owncloudwizard.h
291 @@ -39,8 +39,10 @@ class OwncloudAdvancedSetupPage;
292 class OwncloudWizardResultPage;
293 class AbstractCredentials;
294 class AbstractCredentialsWizardPage;
295 +#ifndef NO_WEBENGINE
296 class WebViewPage;
297 class Flow2AuthCredsPage;
298 +#endif
299
300 /**
301 * @brief The OwncloudWizard class
302 @@ -114,11 +116,15 @@ private:
303 #ifndef NO_SHIBBOLETH
304 OwncloudShibbolethCredsPage *_shibbolethCredsPage;
305 #endif
306 +#ifndef NO_WEBENGINE
307 Flow2AuthCredsPage *_flow2CredsPage;
308 +#endif
309 OwncloudAdvancedSetupPage *_advancedSetupPage;
310 OwncloudWizardResultPage *_resultPage;
311 AbstractCredentialsWizardPage *_credentialsPage = nullptr;
312 +#ifndef NO_WEBENGINE
313 WebViewPage *_webViewPage;
314 +#endif
315
316 QStringList _setupLog;
317
318 diff --git a/src/libsync/networkjobs.cpp b/src/libsync/networkjobs.cpp
319 index fc8464558..dbf625e38 100644
320 --- a/src/libsync/networkjobs.cpp
321 +++ b/src/libsync/networkjobs.cpp
322 @@ -963,12 +963,20 @@ void DetermineAuthTypeJob::checkAllDone()
323
324 // WebViewFlow > OAuth > Shib > Basic
325 if (_account->serverVersionInt() >= Account::makeServerVersion(12, 0, 0)) {
326 +#ifndef NO_WEBENGINE
327 result = WebViewFlow;
328 +#else
329 + result = Basic;
330 +#endif
331 }
332
333 // LoginFlowV2 > WebViewFlow > OAuth > Shib > Basic
334 if (_account->serverVersionInt() >= Account::makeServerVersion(16, 0, 0)) {
335 +#ifndef NO_WEBENGINE
336 result = LoginFlowV2;
337 +#else
338 + result = Basic;
339 +#endif
340 }
341
342 // If we determined that we need the webview flow (GS for example) then we switch to that