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
d61aa6d9
Commit
d61aa6d9
authored
Jul 21, 2011
by
shibakaneki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated the web publication
parent
b5c83d21
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
186 additions
and
31 deletions
+186
-31
UBDocumentPublisher.cpp
src/adaptors/publishing/UBDocumentPublisher.cpp
+156
-31
UBDocumentPublisher.h
src/adaptors/publishing/UBDocumentPublisher.h
+30
-0
No files found.
src/adaptors/publishing/UBDocumentPublisher.cpp
View file @
d61aa6d9
...
@@ -63,6 +63,12 @@ UBDocumentPublisher::~UBDocumentPublisher()
...
@@ -63,6 +63,12 @@ UBDocumentPublisher::~UBDocumentPublisher()
void
UBDocumentPublisher
::
publish
()
void
UBDocumentPublisher
::
publish
()
{
{
UBPublicationDlg
dlg
;
if
(
QDialog
::
Accepted
==
dlg
.
exec
())
{
mDocInfos
.
title
=
dlg
.
title
();
mDocInfos
.
description
=
dlg
.
description
();
//check that the username and password are stored on preferences
//check that the username and password are stored on preferences
UBSettings
*
settings
=
UBSettings
::
settings
();
UBSettings
*
settings
=
UBSettings
::
settings
();
...
@@ -73,7 +79,7 @@ void UBDocumentPublisher::publish()
...
@@ -73,7 +79,7 @@ void UBDocumentPublisher::publish()
login
(
mUsername
,
mPassword
);
login
(
mUsername
,
mPassword
);
//sendUbw();
//sendUbw();
}
}
}
void
UBDocumentPublisher
::
onLoginDone
()
void
UBDocumentPublisher
::
onLoginDone
()
...
@@ -573,6 +579,8 @@ void UBDocumentPublisher::init()
...
@@ -573,6 +579,8 @@ void UBDocumentPublisher::init()
{
{
mCrlf
=
0x0d
;
mCrlf
=
0x0d
;
mCrlf
+=
0x0a
;
mCrlf
+=
0x0a
;
mDocInfos
.
title
=
""
;
mDocInfos
.
description
=
""
;
mpNetworkMgr
=
new
QNetworkAccessManager
(
this
);
mpNetworkMgr
=
new
QNetworkAccessManager
(
this
);
mpCookieJar
=
new
QNetworkCookieJar
();
mpCookieJar
=
new
QNetworkCookieJar
();
...
@@ -592,8 +600,6 @@ void UBDocumentPublisher::onFinished(QNetworkReply *reply)
...
@@ -592,8 +600,6 @@ void UBDocumentPublisher::onFinished(QNetworkReply *reply)
{
{
QByteArray
response
=
reply
->
readAll
();
QByteArray
response
=
reply
->
readAll
();
if
(
!
bLoginCookieSet
)
{
QVariant
cookieHeader
=
reply
->
rawHeader
(
"Set-Cookie"
);
QVariant
cookieHeader
=
reply
->
rawHeader
(
"Set-Cookie"
);
// First we concatenate all the Set-Cookie values (the packet can contains many of them)
// First we concatenate all the Set-Cookie values (the packet can contains many of them)
QStringList
qslCookie
=
cookieHeader
.
toString
().
split
(
"
\n
"
);
QStringList
qslCookie
=
cookieHeader
.
toString
().
split
(
"
\n
"
);
...
@@ -605,6 +611,8 @@ void UBDocumentPublisher::onFinished(QNetworkReply *reply)
...
@@ -605,6 +611,8 @@ void UBDocumentPublisher::onFinished(QNetworkReply *reply)
// Now we isolate every cookie value
// Now we isolate every cookie value
QStringList
qslCookieVals
=
qsCookieValue
.
split
(
"; "
);
QStringList
qslCookieVals
=
qsCookieValue
.
split
(
"; "
);
if
(
!
bLoginCookieSet
)
{
// Finally we create the cookies
// Finally we create the cookies
for
(
int
i
=
0
;
i
<
qslCookieVals
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
qslCookieVals
.
size
();
i
++
)
{
{
...
@@ -643,19 +651,30 @@ void UBDocumentPublisher::onFinished(QNetworkReply *reply)
...
@@ -643,19 +651,30 @@ void UBDocumentPublisher::onFinished(QNetworkReply *reply)
}
}
else
else
{
{
if
(
!
response
.
isEmpty
()){
if
(
response
.
isEmpty
())
// Display the iframe
{
mpWebView
->
setHtml
(
response
,
reply
->
url
());
// Verify that the UBW file has been sent correctly
UBApplication
::
applicationController
->
showSankoreWebDocument
();
bool
bTransferOk
=
false
;
for
(
int
j
=
0
;
j
<=
qslCookieVals
.
size
();
j
++
)
{
if
(
qslCookieVals
.
at
(
j
).
startsWith
(
"assetStatus"
))
{
QStringList
qslAsset
=
qslCookieVals
.
at
(
j
).
split
(
"="
);
if
(
qslAsset
.
at
(
1
)
==
"UPLOADED"
)
{
bTransferOk
=
true
;
break
;
}
}
}
if
(
bTransferOk
)
{
UBApplication
::
showMessage
(
tr
(
"Document uploaded correctly on the web."
));
}
}
else
else
{
{
// Redirect
UBApplication
::
showMessage
(
tr
(
"Failed to upload document on the web."
));
QVariant
locationHeader
=
reply
->
rawHeader
(
"Location"
);
}
QNetworkRequest
req
(
QUrl
(
locationHeader
.
toString
()));
mpNetworkMgr
->
get
(
req
);
// qDebug() << mpWebView->url().toString();
}
}
}
}
reply
->
deleteLater
();
reply
->
deleteLater
();
...
@@ -691,6 +710,15 @@ void UBDocumentPublisher::sendUbw()
...
@@ -691,6 +710,15 @@ void UBDocumentPublisher::sendUbw()
request
.
setRawHeader
(
"Accept-Language"
,
"en-US,*"
);
request
.
setRawHeader
(
"Accept-Language"
,
"en-US,*"
);
request
.
setRawHeader
(
"Referer"
,
DOCPUBLICATION_URL
);
request
.
setRawHeader
(
"Referer"
,
DOCPUBLICATION_URL
);
QNetworkCookie
titleCookie
(
"title"
,
mDocInfos
.
title
.
toAscii
().
constData
());
QNetworkCookie
descCookie
(
"description"
,
mDocInfos
.
description
.
remove
(
"
\n
"
).
toAscii
().
constData
());
mCookies
<<
titleCookie
;
mCookies
<<
descCookie
;
mpCookieJar
->
setCookiesFromUrl
(
mCookies
,
QUrl
(
DOCPUBLICATION_URL
));
mpNetworkMgr
->
setCookieJar
(
mpCookieJar
);
// Send the file
// Send the file
mpNetworkMgr
->
post
(
request
,
datatoSend
);
mpNetworkMgr
->
post
(
request
,
datatoSend
);
}
}
...
@@ -806,3 +834,100 @@ UBProxyLoginDlg::~UBProxyLoginDlg()
...
@@ -806,3 +834,100 @@ UBProxyLoginDlg::~UBProxyLoginDlg()
mpPassword
=
NULL
;
mpPassword
=
NULL
;
}
}
}
}
// ---------------------------------------------------------
UBPublicationDlg
::
UBPublicationDlg
(
QWidget
*
parent
,
const
char
*
name
)
:
QDialog
(
parent
)
,
mpLayout
(
NULL
)
,
mpTitleLayout
(
NULL
)
,
mpTitleLabel
(
NULL
)
,
mpTitle
(
NULL
)
,
mpDescLabel
(
NULL
)
,
mpDescription
(
NULL
)
,
mpButtons
(
NULL
)
{
setObjectName
(
name
);
setWindowTitle
(
tr
(
"Publish document on the web"
));
resize
(
500
,
300
);
mpLayout
=
new
QVBoxLayout
();
setLayout
(
mpLayout
);
mpTitleLabel
=
new
QLabel
(
tr
(
"Title:"
),
this
);
mpTitle
=
new
QLineEdit
(
this
);
mpTitleLayout
=
new
QHBoxLayout
();
mpTitleLayout
->
addWidget
(
mpTitleLabel
,
0
);
mpTitleLayout
->
addWidget
(
mpTitle
,
1
);
mpLayout
->
addLayout
(
mpTitleLayout
,
0
);
mpDescLabel
=
new
QLabel
(
tr
(
"Description:"
),
this
);
mpLayout
->
addWidget
(
mpDescLabel
,
0
);
mpDescription
=
new
QTextEdit
(
this
);
mpLayout
->
addWidget
(
mpDescription
,
1
);
mpButtons
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Cancel
|
QDialogButtonBox
::
Ok
,
Qt
::
Horizontal
,
this
);
mpButtons
->
button
(
QDialogButtonBox
::
Ok
)
->
setText
(
tr
(
"Publish"
));
mpLayout
->
addWidget
(
mpButtons
);
mpButtons
->
button
(
QDialogButtonBox
::
Ok
)
->
setEnabled
(
false
);
connect
(
mpButtons
,
SIGNAL
(
accepted
()),
this
,
SLOT
(
accept
()));
connect
(
mpButtons
,
SIGNAL
(
rejected
()),
this
,
SLOT
(
reject
()));
connect
(
mpTitle
,
SIGNAL
(
textChanged
(
QString
)),
this
,
SLOT
(
onTextChanged
()));
connect
(
mpDescription
,
SIGNAL
(
textChanged
()),
this
,
SLOT
(
onTextChanged
()));
}
UBPublicationDlg
::~
UBPublicationDlg
()
{
if
(
NULL
!=
mpTitleLabel
)
{
delete
mpTitleLabel
;
mpTitleLabel
=
NULL
;
}
if
(
NULL
!=
mpTitle
)
{
delete
mpTitle
;
mpTitle
=
NULL
;
}
if
(
NULL
!=
mpDescLabel
)
{
delete
mpDescLabel
;
mpDescLabel
=
NULL
;
}
if
(
NULL
!=
mpDescription
)
{
delete
mpDescription
;
mpDescription
=
NULL
;
}
if
(
NULL
!=
mpButtons
)
{
delete
mpButtons
;
mpButtons
=
NULL
;
}
if
(
NULL
!=
mpTitleLayout
)
{
delete
mpTitleLayout
;
mpTitleLayout
=
NULL
;
}
if
(
NULL
!=
mpLayout
)
{
delete
mpLayout
;
mpLayout
=
NULL
;
}
}
void
UBPublicationDlg
::
onTextChanged
()
{
bool
bPublishButtonState
=
false
;
if
(
mpTitle
->
text
()
!=
""
&&
mpDescription
->
document
()
->
toPlainText
()
!=
""
)
{
bPublishButtonState
=
true
;
}
else
{
bPublishButtonState
=
false
;
}
mpButtons
->
button
(
QDialogButtonBox
::
Ok
)
->
setEnabled
(
bPublishButtonState
);
}
src/adaptors/publishing/UBDocumentPublisher.h
View file @
d61aa6d9
...
@@ -10,6 +10,12 @@
...
@@ -10,6 +10,12 @@
#define DOCPUBLICATION_URL "http://sankore.devxwiki.com/xwiki/bin/view/CreateResources/UniboardUpload"
#define DOCPUBLICATION_URL "http://sankore.devxwiki.com/xwiki/bin/view/CreateResources/UniboardUpload"
#define XWIKI_ORIGIN_HEADER "http://sankore.devxwiki.com"
#define XWIKI_ORIGIN_HEADER "http://sankore.devxwiki.com"
typedef
struct
{
QString
title
;
QString
description
;
}
sDocumentInfos
;
class
UBDocumentProxy
;
class
UBDocumentProxy
;
class
UBServerXMLHttpRequest
;
class
UBServerXMLHttpRequest
;
class
UBGraphicsW3CWidgetItem
;
class
UBGraphicsW3CWidgetItem
;
...
@@ -36,6 +42,29 @@ private:
...
@@ -36,6 +42,29 @@ private:
QLineEdit
*
mpPassword
;
QLineEdit
*
mpPassword
;
};
};
class
UBPublicationDlg
:
public
QDialog
{
Q_OBJECT
public
:
UBPublicationDlg
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBPublicationDlg"
);
~
UBPublicationDlg
();
QString
title
(){
return
mpTitle
->
text
();}
QString
description
(){
return
mpDescription
->
document
()
->
toPlainText
();}
private
slots
:
void
onTextChanged
();
private
:
QVBoxLayout
*
mpLayout
;
QHBoxLayout
*
mpTitleLayout
;
QLabel
*
mpTitleLabel
;
QLineEdit
*
mpTitle
;
QLabel
*
mpDescLabel
;
QTextEdit
*
mpDescription
;
QDialogButtonBox
*
mpButtons
;
};
class
UBDocumentPublisher
:
public
UBAbstractPublisher
class
UBDocumentPublisher
:
public
UBAbstractPublisher
{
{
...
@@ -88,6 +117,7 @@ private:
...
@@ -88,6 +117,7 @@ private:
void
login
(
QString
username
,
QString
password
);
void
login
(
QString
username
,
QString
password
);
QString
mTmpZipFile
;
QString
mTmpZipFile
;
QList
<
QNetworkCookie
>
mCookies
;
QList
<
QNetworkCookie
>
mCookies
;
sDocumentInfos
mDocInfos
;
};
};
#endif // UBDOCUMENTPUBLISHER_H
#endif // UBDOCUMENTPUBLISHER_H
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