Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Network
KAccounts Providers
Commits
82a5d4b4
Commit
82a5d4b4
authored
Sep 22, 2020
by
Nicolas Fella
Browse files
[nextcloud] Add webengine profile and url intercepter
parent
e280db03
Changes
4
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
82a5d4b4
...
...
@@ -16,7 +16,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ${ECM_MODULE_P
find_package
(
Intltool REQUIRED
)
find_package
(
KAccounts REQUIRED
)
find_package
(
Qt5
${
QT_REQUIRED_VERSION
}
CONFIG REQUIRED Core Qml WebEngineWidgets
)
find_package
(
Qt5
${
QT_REQUIRED_VERSION
}
CONFIG REQUIRED Core Qml WebEngineWidgets
WebEngine
)
find_package
(
KF5
${
KF5_MIN_VERSION
}
REQUIRED KIO I18n Declarative Package
)
include
(
KDEInstallDirs
)
...
...
plugins/nextcloud-ui/CMakeLists.txt
View file @
82a5d4b4
...
...
@@ -10,6 +10,7 @@ add_library(nextcloud_plugin_kaccounts MODULE
target_link_libraries
(
nextcloud_plugin_kaccounts
Qt5::Core
Qt5::WebEngineWidgets
Qt5::WebEngine
KF5::KIOCore
KF5::I18n
KF5::Declarative
...
...
plugins/nextcloud-ui/nextcloudcontroller.cpp
View file @
82a5d4b4
...
...
@@ -22,9 +22,21 @@
#include <QFileSystemWatcher>
#include <QDesktopServices>
// Document for login flow : https://docs.nextcloud.com/server/stable/developer_manual/client_apis/LoginFlow/index.html
void
NextcloudUrlIntercepter
::
interceptRequest
(
QWebEngineUrlRequestInfo
&
info
)
{
info
.
setHttpHeader
(
"OCS-APIREQUEST"
,
"true"
);
}
NextcloudController
::
NextcloudController
(
QObject
*
parent
)
:
QObject
(
parent
)
,
m_webengineProfile
(
new
QQuickWebEngineProfile
(
this
))
{
m_webengineProfile
->
setUrlRequestInterceptor
(
&
m_urlIntercepter
);
m_webengineProfile
->
setHttpUserAgent
(
QStringLiteral
(
"Mozilla/5.0 nextcloud-ui-plugin"
));
QDesktopServices
::
setUrlHandler
(
"nc"
,
this
,
"finalUrlHandler"
);
}
NextcloudController
::~
NextcloudController
()
...
...
@@ -88,6 +100,9 @@ void NextcloudController::fileChecked(KJob* job)
QUrl
url
=
KIO
::
upUrl
(
kJob
->
url
());
m_server
=
url
.
toString
();
m_loginUrl
=
m_server
+
QStringLiteral
(
"/index.php/login/flow"
);
Q_EMIT
loginUrlChanged
();
m_state
=
WebLogin
;
Q_EMIT
stateChanged
();
// Call webview for login
...
...
plugins/nextcloud-ui/nextcloudcontroller.h
View file @
82a5d4b4
...
...
@@ -14,6 +14,8 @@
#include <QWebEngineView>
#include <QWebEnginePage>
#include <QWebEngineHttpRequest>
#include <QWebEngineUrlRequestInterceptor>
#include <QQuickWebEngineProfile>
namespace
KIO
{
...
...
@@ -22,6 +24,11 @@ namespace KIO
class
KJob
;
class
NextcloudUrlIntercepter
:
public
QWebEngineUrlRequestInterceptor
{
void
interceptRequest
(
QWebEngineUrlRequestInfo
&
info
)
override
;
};
class
NextcloudController
:
public
QObject
{
Q_OBJECT
...
...
@@ -29,6 +36,8 @@ class NextcloudController : public QObject
Q_PROPERTY
(
bool
isLoginComplete
READ
isLoginComplete
NOTIFY
isLoginCompleteChanged
)
Q_PROPERTY
(
QString
errorMessage
READ
errorMessage
NOTIFY
errorMessageChanged
)
Q_PROPERTY
(
State
state
MEMBER
m_state
NOTIFY
stateChanged
)
Q_PROPERTY
(
QQuickWebEngineProfile
*
webengineProfile
MEMBER
m_webengineProfile
CONSTANT
)
Q_PROPERTY
(
QString
loginUrl
MEMBER
m_loginUrl
NOTIFY
loginUrlChanged
)
public:
...
...
@@ -54,6 +63,7 @@ Q_SIGNALS:
void
isLoginCompleteChanged
();
void
wizardFinished
(
const
QString
&
username
,
const
QString
&
password
,
const
QVariantMap
&
data
);
void
stateChanged
();
void
loginUrlChanged
();
private
Q_SLOTS
:
void
fileChecked
(
KJob
*
job
);
...
...
@@ -80,6 +90,9 @@ private:
bool
m_isWorking
=
false
;
bool
m_isLoginComplete
=
false
;
State
m_state
=
ServerUrl
;
QQuickWebEngineProfile
*
m_webengineProfile
;
NextcloudUrlIntercepter
m_urlIntercepter
;
QString
m_loginUrl
;
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment