Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Network
KAccounts Providers
Commits
82a5d4b4
Commit
82a5d4b4
authored
Sep 22, 2020
by
Nicolas Fella
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[nextcloud] Add webengine profile and url intercepter
parent
e280db03
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
1 deletion
+30
-1
CMakeLists.txt
CMakeLists.txt
+1
-1
plugins/nextcloud-ui/CMakeLists.txt
plugins/nextcloud-ui/CMakeLists.txt
+1
-0
plugins/nextcloud-ui/nextcloudcontroller.cpp
plugins/nextcloud-ui/nextcloudcontroller.cpp
+15
-0
plugins/nextcloud-ui/nextcloudcontroller.h
plugins/nextcloud-ui/nextcloudcontroller.h
+13
-0
No files found.
CMakeLists.txt
View file @
82a5d4b4
...
@@ -16,7 +16,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ${ECM_MODULE_P
...
@@ -16,7 +16,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ${ECM_MODULE_P
find_package
(
Intltool REQUIRED
)
find_package
(
Intltool REQUIRED
)
find_package
(
KAccounts 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
)
find_package
(
KF5
${
KF5_MIN_VERSION
}
REQUIRED KIO I18n Declarative Package
)
include
(
KDEInstallDirs
)
include
(
KDEInstallDirs
)
...
...
plugins/nextcloud-ui/CMakeLists.txt
View file @
82a5d4b4
...
@@ -10,6 +10,7 @@ add_library(nextcloud_plugin_kaccounts MODULE
...
@@ -10,6 +10,7 @@ add_library(nextcloud_plugin_kaccounts MODULE
target_link_libraries
(
nextcloud_plugin_kaccounts
target_link_libraries
(
nextcloud_plugin_kaccounts
Qt5::Core
Qt5::Core
Qt5::WebEngineWidgets
Qt5::WebEngineWidgets
Qt5::WebEngine
KF5::KIOCore
KF5::KIOCore
KF5::I18n
KF5::I18n
KF5::Declarative
KF5::Declarative
...
...
plugins/nextcloud-ui/nextcloudcontroller.cpp
View file @
82a5d4b4
...
@@ -22,9 +22,21 @@
...
@@ -22,9 +22,21 @@
#include <QFileSystemWatcher>
#include <QFileSystemWatcher>
#include <QDesktopServices>
#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
)
NextcloudController
::
NextcloudController
(
QObject
*
parent
)
:
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
()
NextcloudController
::~
NextcloudController
()
...
@@ -88,6 +100,9 @@ void NextcloudController::fileChecked(KJob* job)
...
@@ -88,6 +100,9 @@ void NextcloudController::fileChecked(KJob* job)
QUrl
url
=
KIO
::
upUrl
(
kJob
->
url
());
QUrl
url
=
KIO
::
upUrl
(
kJob
->
url
());
m_server
=
url
.
toString
();
m_server
=
url
.
toString
();
m_loginUrl
=
m_server
+
QStringLiteral
(
"/index.php/login/flow"
);
Q_EMIT
loginUrlChanged
();
m_state
=
WebLogin
;
m_state
=
WebLogin
;
Q_EMIT
stateChanged
();
Q_EMIT
stateChanged
();
// Call webview for login
// Call webview for login
...
...
plugins/nextcloud-ui/nextcloudcontroller.h
View file @
82a5d4b4
...
@@ -14,6 +14,8 @@
...
@@ -14,6 +14,8 @@
#include <QWebEngineView>
#include <QWebEngineView>
#include <QWebEnginePage>
#include <QWebEnginePage>
#include <QWebEngineHttpRequest>
#include <QWebEngineHttpRequest>
#include <QWebEngineUrlRequestInterceptor>
#include <QQuickWebEngineProfile>
namespace
KIO
namespace
KIO
{
{
...
@@ -22,6 +24,11 @@ namespace KIO
...
@@ -22,6 +24,11 @@ namespace KIO
class
KJob
;
class
KJob
;
class
NextcloudUrlIntercepter
:
public
QWebEngineUrlRequestInterceptor
{
void
interceptRequest
(
QWebEngineUrlRequestInfo
&
info
)
override
;
};
class
NextcloudController
:
public
QObject
class
NextcloudController
:
public
QObject
{
{
Q_OBJECT
Q_OBJECT
...
@@ -29,6 +36,8 @@ class NextcloudController : public QObject
...
@@ -29,6 +36,8 @@ class NextcloudController : public QObject
Q_PROPERTY
(
bool
isLoginComplete
READ
isLoginComplete
NOTIFY
isLoginCompleteChanged
)
Q_PROPERTY
(
bool
isLoginComplete
READ
isLoginComplete
NOTIFY
isLoginCompleteChanged
)
Q_PROPERTY
(
QString
errorMessage
READ
errorMessage
NOTIFY
errorMessageChanged
)
Q_PROPERTY
(
QString
errorMessage
READ
errorMessage
NOTIFY
errorMessageChanged
)
Q_PROPERTY
(
State
state
MEMBER
m_state
NOTIFY
stateChanged
)
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:
public:
...
@@ -54,6 +63,7 @@ Q_SIGNALS:
...
@@ -54,6 +63,7 @@ Q_SIGNALS:
void
isLoginCompleteChanged
();
void
isLoginCompleteChanged
();
void
wizardFinished
(
const
QString
&
username
,
const
QString
&
password
,
const
QVariantMap
&
data
);
void
wizardFinished
(
const
QString
&
username
,
const
QString
&
password
,
const
QVariantMap
&
data
);
void
stateChanged
();
void
stateChanged
();
void
loginUrlChanged
();
private
Q_SLOTS
:
private
Q_SLOTS
:
void
fileChecked
(
KJob
*
job
);
void
fileChecked
(
KJob
*
job
);
...
@@ -80,6 +90,9 @@ private:
...
@@ -80,6 +90,9 @@ private:
bool
m_isWorking
=
false
;
bool
m_isWorking
=
false
;
bool
m_isLoginComplete
=
false
;
bool
m_isLoginComplete
=
false
;
State
m_state
=
ServerUrl
;
State
m_state
=
ServerUrl
;
QQuickWebEngineProfile
*
m_webengineProfile
;
NextcloudUrlIntercepter
m_urlIntercepter
;
QString
m_loginUrl
;
};
};
...
...
Write
Preview
Markdown
is supported
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