digiKam
wsauthenticationpage.h
Go to the documentation of this file.
1
/* ============================================================
2
*
3
* This file is a part of digiKam project
4
* https://www.digikam.org
5
*
6
* Date : 2018-07-02
7
* Description : embedded web browser for web service authentication
8
*
9
* Copyright (C) 2018 by Thanh Trung Dinh <dinhthanhtrung1996 at gmail dot com>
10
*
11
* This program is free software; you can redistribute it
12
* and/or modify it under the terms of the GNU General
13
* Public License as published by the Free Software Foundation;
14
* either version 2, or (at your option)
15
* any later version.
16
*
17
* This program is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
* GNU General Public License for more details.
21
*
22
* ============================================================ */
23
24
#ifndef DIGIKAM_WS_AUTHENTICATION_PAGE_H
25
#define DIGIKAM_WS_AUTHENTICATION_PAGE_H
26
27
#include "digikam_config.h"
28
29
// Qt includes
30
31
#include <QByteArray>
32
#include <QString>
33
#include <QUrl>
34
#include <QMap>
35
36
#ifdef HAVE_QWEBENGINE
37
# include <QWebEngineView>
38
# include <QWebEnginePage>
39
# include <QWebEngineProfile>
40
# include <QWebEngineCookieStore>
41
#else
42
# include <qwebview.h>
43
# include <qwebpage.h>
44
# include <qwebframe.h>
45
# include <QNetworkRequest>
46
#endif
47
48
// Local includes
49
50
#include "
dwizardpage.h
"
51
#include "
dinfointerface.h
"
52
#include "
wsauthentication.h
"
53
54
using namespace
Digikam
;
55
56
namespace
DigikamGenericUnifiedPlugin
57
{
58
59
#ifdef HAVE_QWEBENGINE
60
61
class
WSAuthenticationPage :
public
QWebEnginePage
62
63
#else
64
65
class
WSAuthenticationPage
:
public
QWebPage
66
67
#endif
// #ifdef HAVE_QWEBENGINE
68
69
{
70
Q_OBJECT
71
72
public
:
73
74
#ifdef HAVE_QWEBENGINE
75
76
explicit
WSAuthenticationPage
(QObject*
const
parent, QWebEngineProfile* profile,
const
QString& callbackUrl);
77
78
#else
79
80
explicit
WSAuthenticationPage
(QObject*
const
parent,
const
QString& callbackUrl);
81
82
#endif
// #ifdef HAVE_QWEBENGINE
83
84
virtual
~
WSAuthenticationPage
();
85
86
void
setCallbackUrl(
const
QString& url);
87
88
#ifdef HAVE_QWEBENGINE
89
90
bool
acceptNavigationRequest(
const
QUrl& url, QWebEnginePage::NavigationType type,
bool
isMainFrame);
91
92
#else
93
94
private
Q_SLOTS:
95
96
bool
slotUrlChanged(
const
QUrl& url);
97
98
#endif
// #ifdef HAVE_QWEBENGINE
99
100
Q_SIGNALS:
101
102
void
callbackCatched
(
const
QString&);
103
104
private
:
105
106
QString m_callbackUrl;
107
};
108
109
// -------------------------------------------------------------------
110
111
#ifdef HAVE_QWEBENGINE
112
113
class
WSAuthenticationPageView
:
public
QWebEngineView
114
115
#else
116
117
class
WSAuthenticationPageView
:
public
QWebView
118
119
#endif
120
{
121
Q_OBJECT
122
123
public
:
124
125
explicit
WSAuthenticationPageView
(QWidget*
const
parent,
126
WSAuthentication
*
const
wsAuth,
127
const
QString& callbackUrl);
128
~
WSAuthenticationPageView
();
129
130
bool
authenticationComplete()
const
;
131
132
private
:
133
134
/*
135
* Parse url into a hash map with key and value for each parameter
136
*/
137
QMap<QString, QString> parseUrlFragment(
const
QString& urlFragment);
138
139
Q_SIGNALS:
140
141
void
signalAuthenticationComplete
(
bool
);
142
143
private
Q_SLOTS:
144
145
void
slotCallbackCatched(
const
QString& callbackUrl);
146
void
slotOpenBrowser(
const
QUrl& url);
147
void
slotCloseBrowser();
148
149
private
:
150
151
WSAuthentication
* m_WSAuthentication;
152
};
153
154
// -------------------------------------------------------------------
155
156
class
WSAuthenticationWizard
:
public
DWizardPage
157
{
158
Q_OBJECT
159
160
public
:
161
162
explicit
WSAuthenticationWizard
(QWizard*
const
dialog,
const
QString& title,
163
const
QString& callback = QLatin1String(
"http://127.1.1.0:8000/"
));
// krazy:exclude=insecurenet
164
~
WSAuthenticationWizard
();
165
166
bool
isComplete()
const
;
167
168
void
initializePage();
169
bool
validatePage();
170
void
cleanupPage();
171
172
public
Q_SLOTS:
173
174
void
slotAuthenticationComplete(
bool
isLinked);
175
176
private
:
177
178
class
Private;
179
Private*
const
d;
180
};
181
182
}
// namespace DigikamGenericUnifiedPlugin
183
184
#endif
// DIGIKAM_WS_AUTHENTICATION_PAGE_H
DigikamGenericUnifiedPlugin::WSAuthenticationPageView
Definition:
wsauthenticationpage.h:120
DigikamGenericUnifiedPlugin::WSAuthenticationPageView::signalAuthenticationComplete
void signalAuthenticationComplete(bool)
DigikamGenericUnifiedPlugin::WSAuthenticationPage
Definition:
wsauthenticationpage.h:69
DigikamGenericUnifiedPlugin::WSAuthenticationPage::callbackCatched
void callbackCatched(const QString &)
DigikamGenericUnifiedPlugin::WSAuthenticationWizard
Definition:
wsauthenticationpage.h:157
DigikamGenericUnifiedPlugin::WSAuthentication
Definition:
wsauthentication.h:49
Digikam::DWizardPage
Definition:
dwizardpage.h:42
dinfointerface.h
dwizardpage.h
DigikamGenericUnifiedPlugin
Definition:
wsauthentication.cpp:56
Digikam
Definition:
datefolderview.cpp:43
wsauthentication.h
core
dplugins
generic
webservices
unified
wizard
wsauthenticationpage.h
Generated by
1.9.1