Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
b5c83d21
Commit
b5c83d21
authored
Jul 15, 2011
by
shibakaneki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Proxy management for the web publication
parent
537381db
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
12 deletions
+115
-12
UBDocumentPublisher.cpp
src/adaptors/publishing/UBDocumentPublisher.cpp
+92
-12
UBDocumentPublisher.h
src/adaptors/publishing/UBDocumentPublisher.h
+23
-0
No files found.
src/adaptors/publishing/UBDocumentPublisher.cpp
View file @
b5c83d21
...
...
@@ -38,7 +38,7 @@ UBDocumentPublisher::UBDocumentPublisher(UBDocumentProxy* pDocument, QObject *pa
,
mPublishingDocument
(
0
)
,
mUsername
(
""
)
,
mPassword
(
""
)
,
bLoginCookieSet
(
false
)
,
bLoginCookieSet
(
false
)
{
mpWebView
=
new
QWebView
(
0
);
UBApplication
::
mainWindow
->
addSankoreWebDocumentWidget
(
mpWebView
);
...
...
@@ -575,17 +575,21 @@ void UBDocumentPublisher::init()
mCrlf
+=
0x0a
;
mpNetworkMgr
=
new
QNetworkAccessManager
(
this
);
//mpCache = new QNetworkDiskCache(this);
//mpCache->setCacheDirectory("cache");
//mpNetworkMgr->setCache(mpCache);
mpCookieJar
=
new
QNetworkCookieJar
();
// QNetworkProxy* pProxy = UBSettings::settings()->httpProxy();
// if(NULL != pProxy)
// {
// mpNetworkMgr->setProxy(*pProxy);
// qDebug() << "Proxy set!";
// }
connect
(
mpNetworkMgr
,
SIGNAL
(
finished
(
QNetworkReply
*
)),
this
,
SLOT
(
onFinished
(
QNetworkReply
*
)));
connect
(
mpNetworkMgr
,
SIGNAL
(
proxyAuthenticationRequired
(
QNetworkProxy
,
QAuthenticator
*
)),
this
,
SLOT
(
onProxyAuthenticationRequired
(
QNetworkProxy
,
QAuthenticator
*
)));
}
void
UBDocumentPublisher
::
onFinished
(
QNetworkReply
*
reply
)
{
qDebug
()
<<
"[-[ Request finished! ]-]"
;
QByteArray
response
=
reply
->
readAll
();
if
(
!
bLoginCookieSet
)
...
...
@@ -605,7 +609,6 @@ void UBDocumentPublisher::onFinished(QNetworkReply *reply)
for
(
int
i
=
0
;
i
<
qslCookieVals
.
size
();
i
++
)
{
QString
cookieString
=
qslCookieVals
.
at
(
i
);
//qDebug() << "qslCookieVals.at(i): " << cookieString.replace("\"", "");
QStringList
qslCrntCookie
=
cookieString
.
split
(
"="
);
QNetworkCookie
crntCookie
;
if
(
qslCrntCookie
.
length
()
==
2
)
...
...
@@ -630,11 +633,6 @@ void UBDocumentPublisher::onFinished(QNetworkReply *reply)
}
QNetworkCookie
langCookie
(
"language"
,
"en"
);
mCookies
<<
langCookie
;
// DEBUG : Verify
for
(
int
i
=
0
;
i
<
mCookies
.
size
();
i
++
)
{
qDebug
()
<<
mCookies
.
at
(
i
).
name
()
<<
"="
<<
mCookies
.
at
(
i
).
value
();
}
// Set the cookiejar : it set the cookies that will be sent with every packet.
mpCookieJar
->
setCookiesFromUrl
(
mCookies
,
QUrl
(
DOCPUBLICATION_URL
)
/*reply->url()*/
);
...
...
@@ -657,7 +655,7 @@ void UBDocumentPublisher::onFinished(QNetworkReply *reply)
QNetworkRequest
req
(
QUrl
(
locationHeader
.
toString
()));
mpNetworkMgr
->
get
(
req
);
qDebug
()
<<
mpWebView
->
url
().
toString
();
//
qDebug() << mpWebView->url().toString();
}
}
reply
->
deleteLater
();
...
...
@@ -719,10 +717,92 @@ void UBDocumentPublisher::onLoadFinished(bool result)
Q_UNUSED
(
result
);
// [Basic Auth] This line says: if the user click on a link, do not interpret it.
//mpWebView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
mpWebView
->
page
()
->
setNetworkAccessManager
(
mpNetworkMgr
);
}
void
UBDocumentPublisher
::
onProxyAuthenticationRequired
(
const
QNetworkProxy
&
proxy
,
QAuthenticator
*
authenticator
)
{
Q_UNUSED
(
proxy
);
UBProxyLoginDlg
dlg
;
if
(
QDialog
::
Accepted
==
dlg
.
exec
())
{
authenticator
->
setUser
(
dlg
.
username
());
authenticator
->
setPassword
(
dlg
.
password
());
}
}
// ---------------------------------------------------------
UBProxyLoginDlg
::
UBProxyLoginDlg
(
QWidget
*
parent
,
const
char
*
name
)
:
QDialog
(
parent
)
,
mpLayout
(
NULL
)
,
mpUserLayout
(
NULL
)
,
mpPasswordLayout
(
NULL
)
,
mpButtons
(
NULL
)
,
mpUserLabel
(
NULL
)
,
mpPasswordLabel
(
NULL
)
,
mpUsername
(
NULL
)
,
mpPassword
(
NULL
)
{
setObjectName
(
name
);
setFixedSize
(
400
,
150
);
setWindowTitle
(
tr
(
"Proxy Login"
));
mpLayout
=
new
QVBoxLayout
();
setLayout
(
mpLayout
);
mpUserLayout
=
new
QHBoxLayout
();
mpLayout
->
addLayout
(
mpUserLayout
);
mpPasswordLayout
=
new
QHBoxLayout
();
mpLayout
->
addLayout
(
mpPasswordLayout
);
mpUserLabel
=
new
QLabel
(
tr
(
"Username:"
),
this
);
mpUsername
=
new
QLineEdit
(
this
);
mpUserLayout
->
addWidget
(
mpUserLabel
,
0
);
mpUserLayout
->
addWidget
(
mpUsername
,
1
);
mpPasswordLabel
=
new
QLabel
(
tr
(
"Password:"
),
this
);
mpPassword
=
new
QLineEdit
(
this
);
mpPasswordLayout
->
addWidget
(
mpPasswordLabel
,
0
);
mpPasswordLayout
->
addWidget
(
mpPassword
,
1
);
mpButtons
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Ok
|
QDialogButtonBox
::
Cancel
,
Qt
::
Horizontal
,
this
);
mpLayout
->
addWidget
(
mpButtons
);
connect
(
mpButtons
,
SIGNAL
(
accepted
()),
this
,
SLOT
(
accept
()));
connect
(
mpButtons
,
SIGNAL
(
rejected
()),
this
,
SLOT
(
reject
()));
}
UBProxyLoginDlg
::~
UBProxyLoginDlg
()
{
if
(
NULL
!=
mpLayout
)
{
delete
mpLayout
;
mpLayout
=
NULL
;
}
if
(
NULL
!=
mpButtons
)
{
delete
mpButtons
;
mpButtons
=
NULL
;
}
if
(
NULL
!=
mpUserLabel
)
{
delete
mpUserLabel
;
mpUserLabel
=
NULL
;
}
if
(
NULL
!=
mpPasswordLabel
)
{
delete
mpPasswordLabel
;
mpPasswordLabel
=
NULL
;
}
if
(
NULL
!=
mpUsername
)
{
delete
mpUsername
;
mpUsername
=
NULL
;
}
if
(
NULL
!=
mpPassword
)
{
delete
mpPassword
;
mpPassword
=
NULL
;
}
}
src/adaptors/publishing/UBDocumentPublisher.h
View file @
b5c83d21
...
...
@@ -15,6 +15,28 @@ class UBServerXMLHttpRequest;
class
UBGraphicsW3CWidgetItem
;
class
QWebView
;
class
UBProxyLoginDlg
:
public
QDialog
{
Q_OBJECT
public
:
UBProxyLoginDlg
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"ProxyLoginDlg"
);
~
UBProxyLoginDlg
();
QString
username
(){
return
mpUsername
->
text
();}
QString
password
(){
return
mpPassword
->
text
();}
private
:
QVBoxLayout
*
mpLayout
;
QHBoxLayout
*
mpUserLayout
;
QHBoxLayout
*
mpPasswordLayout
;
QDialogButtonBox
*
mpButtons
;
QLabel
*
mpUserLabel
;
QLabel
*
mpPasswordLabel
;
QLineEdit
*
mpUsername
;
QLineEdit
*
mpPassword
;
};
class
UBDocumentPublisher
:
public
UBAbstractPublisher
{
Q_OBJECT
;
...
...
@@ -42,6 +64,7 @@ private slots:
void
onLinkClicked
(
const
QUrl
&
url
);
void
onLoadFinished
(
bool
result
);
void
onLoginDone
();
void
onProxyAuthenticationRequired
(
const
QNetworkProxy
&
proxy
,
QAuthenticator
*
authenticator
);
private
:
...
...
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