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
63a71fad
Commit
63a71fad
authored
Jul 26, 2011
by
ivan.ilyin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:Sankore/Sankore-3.1
parents
2a693c50
32f979fe
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
538 additions
and
106 deletions
+538
-106
colorpicker.js
...ces/library/interactive/ColorPicker.wgt/js/colorpicker.js
+2
-2
app.js
resources/library/interactive/barre_prof.wgt/scripts/app.js
+18
-18
UBImportDocument.cpp
src/adaptors/UBImportDocument.cpp
+9
-5
UBDocumentPublisher.cpp
src/adaptors/publishing/UBDocumentPublisher.cpp
+247
-42
UBDocumentPublisher.h
src/adaptors/publishing/UBDocumentPublisher.h
+53
-0
main.cpp
src/core/main.cpp
+10
-4
UBUpdateDlg.cpp
src/gui/UBUpdateDlg.cpp
+133
-22
UBUpdateDlg.h
src/gui/UBUpdateDlg.h
+17
-6
UniboardSankoreTransition.cpp
src/transition/UniboardSankoreTransition.cpp
+34
-7
UniboardSankoreTransition.h
src/transition/UniboardSankoreTransition.h
+15
-0
No files found.
resources/library/interactive/ColorPicker.wgt/js/colorpicker.js
View file @
63a71fad
...
...
@@ -57,8 +57,8 @@
},
setNewColor
=
function
(
hsb
,
cal
)
{
$
(
cal
).
data
(
'colorpicker'
).
newColor
.
css
(
'backgroundColor'
,
'#'
+
HSBToHex
(
hsb
));
window
.
uniboard
.
setTool
(
'pen'
);
window
.
uniboard
.
setPenColor
(
'#'
+
HSBToHex
(
hsb
));
window
.
sankore
.
setTool
(
'pen'
);
window
.
sankore
.
setPenColor
(
'#'
+
HSBToHex
(
hsb
));
},
keyDown
=
function
(
ev
)
{
var
pressedKey
=
ev
.
charCode
||
ev
.
keyCode
||
-
1
;
...
...
resources/library/interactive/barre_prof.wgt/scripts/app.js
View file @
63a71fad
//
uniboard
= {
//
sankore
= {
// preference : function(){},
// setPreference : function(){}
// }
...
...
@@ -14,7 +14,7 @@ $(document).ready(function()
function
_init
()
{
w
.
setSplashContent
(
'<img src="custom_icon.png" alt="Click">'
);
w
.
setEditContent
(
'<textarea style="width: 100%; height: 100%;">'
+
(
window
.
uniboard
.
preference
(
"text"
)
||
'Type a note here'
)
+
'</textarea>'
);
w
.
setEditContent
(
'<textarea style="width: 100%; height: 100%;">'
+
(
window
.
sankore
.
preference
(
"text"
)
||
'Type a note here'
)
+
'</textarea>'
);
w
.
elements
.
containerEdit
.
find
(
"textarea"
).
tinymce
(
{
script_url
:
'tinymcejq/tiny_mce.js'
,
...
...
@@ -41,16 +41,16 @@ $(document).ready(function()
{
ed
.
onKeyUp
.
add
(
function
(
ed
,
e
)
{
if
(
window
.
uniboard
)
if
(
window
.
sankore
)
{
window
.
uniboard
.
setPreference
(
"text"
,
ed
.
getContent
());
window
.
sankore
.
setPreference
(
"text"
,
ed
.
getContent
());
}
});
ed
.
onExecCommand
.
add
(
function
(
ed
,
e
)
{
if
(
window
.
uniboard
)
if
(
window
.
sankore
)
{
window
.
uniboard
.
setPreference
(
"text"
,
ed
.
getContent
());
window
.
sankore
.
setPreference
(
"text"
,
ed
.
getContent
());
}
});
},
...
...
@@ -63,9 +63,9 @@ $(document).ready(function()
});
w
.
modeView
();
// init view mode
w
.
modeEdit
();
// init edit mode
if
(
window
.
uniboard
.
preference
(
"state"
)
==
'view'
)
// back to view mode if last state was it
if
(
window
.
sankore
.
preference
(
"state"
)
==
'view'
)
// back to view mode if last state was it
w
.
modeView
();
if
(
window
.
uniboard
.
preference
(
"is_splash"
)
==
'1'
)
if
(
window
.
sankore
.
preference
(
"is_splash"
)
==
'1'
)
w
.
modeSplash
(
true
);
w
.
allowResize
=
true
;
};
...
...
@@ -84,15 +84,15 @@ $(document).ready(function()
w
.
getWidth
=
function
()
{
var
res
=
360
;
if
(
window
.
uniboard
&&
window
.
uniboard
.
preference
(
"width"
))
res
=
parseInt
(
window
.
uniboard
.
preference
(
"width"
));
if
(
window
.
sankore
&&
window
.
sankore
.
preference
(
"width"
))
res
=
parseInt
(
window
.
sankore
.
preference
(
"width"
));
return
res
;
};
w
.
getHeight
=
function
()
{
var
res
=
230
;
if
(
window
.
uniboard
&&
window
.
uniboard
.
preference
(
"height"
))
res
=
parseInt
(
window
.
uniboard
.
preference
(
"height"
));
if
(
window
.
sankore
&&
window
.
sankore
.
preference
(
"height"
))
res
=
parseInt
(
window
.
sankore
.
preference
(
"height"
));
return
res
;
};
...
...
@@ -121,24 +121,24 @@ $(document).ready(function()
w
.
elements
.
container
.
width
(
winwidth
);
w
.
elements
.
container
.
height
(
winheight
);
tinyMCE
.
activeEditor
.
theme
.
resizeTo
(
winwidth
,
winheight
-
98
);
if
(
window
.
uniboard
)
if
(
window
.
sankore
)
{
window
.
uniboard
.
setPreference
(
"width"
,
winwidth
);
window
.
uniboard
.
setPreference
(
"height"
,
winheight
-
33
);
window
.
sankore
.
setPreference
(
"width"
,
winwidth
);
window
.
sankore
.
setPreference
(
"height"
,
winheight
-
33
);
}
};
w
.
modeView
=
function
()
{
if
(
w
.
allowResize
)
window
.
uniboard
.
setPreference
(
"state"
,
"view"
);
window
.
sankore
.
setPreference
(
"state"
,
"view"
);
return
_super_modeView
.
call
(
this
);
}
w
.
modeEdit
=
function
()
{
if
(
w
.
allowResize
)
window
.
uniboard
.
setPreference
(
"state"
,
"edit"
);
window
.
sankore
.
setPreference
(
"state"
,
"edit"
);
return
_super_modeEdit
.
call
(
this
);
}
...
...
@@ -146,7 +146,7 @@ $(document).ready(function()
{
if
(
enable
==
undefined
)
enable
=
true
;
window
.
uniboard
.
setPreference
(
"is_splash"
,
(
w
.
allowResize
&&
enable
)?
1
:
0
);
window
.
sankore
.
setPreference
(
"is_splash"
,
(
w
.
allowResize
&&
enable
)?
1
:
0
);
return
_super_modeSplash
.
call
(
this
,
enable
);
}
...
...
src/adaptors/UBImportDocument.cpp
View file @
63a71fad
...
...
@@ -175,11 +175,15 @@ UBDocumentProxy* UBImportDocument::importFile(const QFile& pFile, const QString&
QString
documentRootFolder
=
expandFileToDir
(
pFile
,
path
);
if
(
!
documentRootFolder
.
length
()){
UBApplication
::
showMessage
(
tr
(
"Import of file %1 failed."
).
arg
(
fi
.
baseName
()));
return
0
;
}
else
{
UBDocumentProxy
*
newDocument
=
UBPersistenceManager
::
persistenceManager
()
->
createDocumentFromDir
(
documentRootFolder
);
UBApplication
::
showMessage
(
tr
(
"Import successful."
));
return
newDocument
;
}
}
...
...
src/adaptors/publishing/UBDocumentPublisher.cpp
View file @
63a71fad
...
...
@@ -63,6 +63,12 @@ UBDocumentPublisher::~UBDocumentPublisher()
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
UBSettings
*
settings
=
UBSettings
::
settings
();
...
...
@@ -73,7 +79,7 @@ void UBDocumentPublisher::publish()
login
(
mUsername
,
mPassword
);
//sendUbw();
}
}
void
UBDocumentPublisher
::
onLoginDone
()
...
...
@@ -573,23 +579,27 @@ void UBDocumentPublisher::init()
{
mCrlf
=
0x0d
;
mCrlf
+=
0x0a
;
mDocInfos
.
title
=
""
;
mDocInfos
.
description
=
""
;
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
)
{
QVariant
cookieHeader
=
reply
->
rawHeader
(
"Set-Cookie"
);
// First we concatenate all the Set-Cookie values (the packet can contains many of them)
QStringList
qslCookie
=
cookieHeader
.
toString
().
split
(
"
\n
"
);
...
...
@@ -601,11 +611,12 @@ void UBDocumentPublisher::onFinished(QNetworkReply *reply)
// Now we isolate every cookie value
QStringList
qslCookieVals
=
qsCookieValue
.
split
(
"; "
);
if
(
!
bLoginCookieSet
)
{
// Finally we create the cookies
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 +641,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()*/
);
...
...
@@ -645,19 +651,30 @@ void UBDocumentPublisher::onFinished(QNetworkReply *reply)
}
else
{
if
(
!
response
.
isEmpty
()){
// Display the iframe
mpWebView
->
setHtml
(
response
,
reply
->
url
());
UBApplication
::
applicationController
->
showSankoreWebDocument
();
if
(
response
.
isEmpty
())
{
// Verify that the UBW file has been sent correctly
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
{
// Redirect
QVariant
locationHeader
=
reply
->
rawHeader
(
"Location"
);
QNetworkRequest
req
(
QUrl
(
locationHeader
.
toString
()));
mpNetworkMgr
->
get
(
req
);
qDebug
()
<<
mpWebView
->
url
().
toString
();
UBApplication
::
showMessage
(
tr
(
"Failed to upload document on the web."
));
}
}
}
reply
->
deleteLater
();
...
...
@@ -693,6 +710,15 @@ void UBDocumentPublisher::sendUbw()
request
.
setRawHeader
(
"Accept-Language"
,
"en-US,*"
);
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
mpNetworkMgr
->
post
(
request
,
datatoSend
);
}
...
...
@@ -719,10 +745,189 @@ 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
;
}
}
// ---------------------------------------------------------
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 @
63a71fad
...
...
@@ -10,11 +10,62 @@
#define DOCPUBLICATION_URL "http://sankore.devxwiki.com/xwiki/bin/view/CreateResources/UniboardUpload"
#define XWIKI_ORIGIN_HEADER "http://sankore.devxwiki.com"
typedef
struct
{
QString
title
;
QString
description
;
}
sDocumentInfos
;
class
UBDocumentProxy
;
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
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
{
Q_OBJECT
;
...
...
@@ -42,6 +93,7 @@ private slots:
void
onLinkClicked
(
const
QUrl
&
url
);
void
onLoadFinished
(
bool
result
);
void
onLoginDone
();
void
onProxyAuthenticationRequired
(
const
QNetworkProxy
&
proxy
,
QAuthenticator
*
authenticator
);
private
:
...
...
@@ -65,6 +117,7 @@ private:
void
login
(
QString
username
,
QString
password
);
QString
mTmpZipFile
;
QList
<
QNetworkCookie
>
mCookies
;
sDocumentInfos
mDocInfos
;
};
#endif // UBDOCUMENTPUBLISHER_H
src/core/main.cpp
View file @
63a71fad
...
...
@@ -74,8 +74,14 @@ int main(int argc, char *argv[])
UBApplication
app
(
"Sankore 3.1"
,
argc
,
argv
);
//BUGFIX:
//when importing a sankore file that contains a non standard character
//the codecForLocale or the codecForCString is used to convert the file path
//into a const char*. This is why in french windows setup the codec name shouldn't be
//set to UTF-8. For example, setting UTF-8, will convert "Hati" into "Ha-ti.
QTextCodec
::
setCodecForTr
(
QTextCodec
::
codecForName
(
"UTF-8"
));
QTextCodec
::
setCodecForLocale
(
QTextCodec
::
codecForName
(
"UTF-8"
));
//
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
QTextCodec
::
setCodecForCStrings
(
QTextCodec
::
codecForName
(
"UTF-8"
));
QStringList
args
=
app
.
arguments
();
...
...
src/gui/UBUpdateDlg.cpp
View file @
63a71fad
...
...
@@ -7,61 +7,166 @@
UBUpdateDlg
::
UBUpdateDlg
(
QWidget
*
parent
,
int
nbFiles
,
const
QString
&
bkpPath
)
:
QDialog
(
parent
)
,
mMainLayout
(
NULL
)
,
mNbFilesLabel
(
NULL
)
,
mBkpLabel
(
NULL
)
,
mBkpPath
(
NULL
)
,
mBrowseBttn
(
NULL
)
,
mpDlgBttn
(
NULL
)
,
mLayout
(
NULL
)
,
mHLayout
(
NULL
)
,
mStackedWidget
(
NULL
)
,
mDialogWidget
(
NULL
)
,
mProgressWidget
(
NULL
)
,
mProgressLayout
(
NULL
)
,
mProgressLabel
(
NULL
)
{
setFixedSize
(
400
,
110
);
mDialogWidget
=
new
QWidget
(
this
);
mProgressWidget
=
new
QWidget
(
this
);
mStackedWidget
=
new
QStackedWidget
(
this
);
mStackedWidget
->
addWidget
(
mDialogWidget
);
mStackedWidget
->
addWidget
(
mProgressWidget
);
setFixedSize
(
450
,
110
);
setModal
(
true
);
setWindowTitle
(
tr
(
"Document updater"
));
setLayout
(
&
mLayout
);
mLayout
=
new
QVBoxLayout
();
setLayout
(
mLayout
);
QString
str
=
QString
::
number
(
nbFiles
);
str
.
append
(
tr
(
" files require an update."
));
mNbFilesLabel
.
setText
(
str
);
mLayout
.
addWidget
(
&
mNbFilesLabel
);
mBkpLabel
.
setText
(
tr
(
"Backup path: "
));
mBkpPath
.
setText
(
bkpPath
);
mBrowseBttn
.
setText
(
tr
(
"Browse"
));
mHLayout
.
addWidget
(
&
mBkpLabel
);
mHLayout
.
addWidget
(
&
mBkpPath
,
1
);
mHLayout
.
addWidget
(
&
mBrowseBttn
);
mLayout
.
addLayout
(
&
mHLayout
);
mpDlgBttn
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Ok
|
QDialogButtonBox
::
Cancel
,
Qt
::
Horizontal
,
this
);
mLayout
.
addWidget
(
mpDlgBttn
);
mNbFilesLabel
=
new
QLabel
(
mDialogWidget
);
mNbFilesLabel
->
setText
(
str
);
mLayout
->
addWidget
(
mNbFilesLabel
);
mBkpLabel
=
new
QLabel
(
mDialogWidget
);
mBkpLabel
->
setText
(
tr
(
"Backup path: "
));
mBkpPath
=
new
QLineEdit
(
mDialogWidget
);
mBkpPath
->
setText
(
bkpPath
);
mBrowseBttn
=
new
QPushButton
(
mDialogWidget
);
mBrowseBttn
->
setText
(
tr
(
"Browse"
));
mHLayout
=
new
QHBoxLayout
();
mHLayout
->
addWidget
(
mBkpLabel
);
mHLayout
->
addWidget
(
mBkpPath
,
1
);
mHLayout
->
addWidget
(
mBrowseBttn
);
mLayout
->
addLayout
(
mHLayout
);
mpDlgBttn
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Ok
|
QDialogButtonBox
::
Cancel
,
Qt
::
Horizontal
,
mDialogWidget
);
mLayout
->
addWidget
(
mpDlgBttn
);
mpDlgBttn
->
button
(
QDialogButtonBox
::
Ok
)
->
setText
(
tr
(
"Update"
));
mpDlgBttn
->
button
(
QDialogButtonBox
::
Cancel
)
->
setText
(
"Remind me later"
);
QObject
::
connect
(
&
mBrowseBttn
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onBrowse
()));
QObject
::
connect
(
mBrowseBttn
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onBrowse
()));
QObject
::
connect
(
mpDlgBttn
,
SIGNAL
(
accepted
()),
this
,
SLOT
(
onUpdate
()));
QObject
::
connect
(
mpDlgBttn
,
SIGNAL
(
rejected
()),
this
,
SLOT
(
reject
()));
mDialogWidget
->
setLayout
(
mLayout
);
mStackedWidget
->
setCurrentWidget
(
mDialogWidget
);
mMainLayout
=
new
QVBoxLayout
();
this
->
setLayout
(
mMainLayout
);
mMainLayout
->
addWidget
(
mStackedWidget
);
}
UBUpdateDlg
::~
UBUpdateDlg
()
{
if
(
NULL
!=
mpDlgBttn
)
if
(
NULL
!=
mpDlgBttn
)
{
delete
mpDlgBttn
;
mpDlgBttn
=
NULL
;
}
if
(
mNbFilesLabel
)
{
delete
mNbFilesLabel
;
mNbFilesLabel
=
NULL
;
}
if
(
mBkpLabel
)
{
delete
mBkpLabel
;
mBkpLabel
=
NULL
;
}
if
(
mBkpPath
)
{
delete
mBkpPath
;
mBkpPath
=
NULL
;
}
if
(
mBrowseBttn
)
{
delete
mBrowseBttn
;
mBrowseBttn
=
NULL
;
}
if
(
mProgressLabel
)
{
delete
mProgressLabel
;
mProgressLabel
=
NULL
;
}
if
(
mHLayout
)
{
delete
mHLayout
;
mHLayout
=
NULL
;
}
if
(
mLayout
)
{
delete
mLayout
;
mLayout
=
NULL
;
}
if
(
mProgressLayout
)
{
delete
mProgressLayout
;
mProgressLayout
=
NULL
;
}
if
(
mDialogWidget
)
{
delete
mDialogWidget
;
mDialogWidget
=
NULL
;
}
if
(
mProgressWidget
)
{
delete
mProgressWidget
;
mProgressWidget
=
NULL
;
}
if
(
mStackedWidget
)
{
delete
mStackedWidget
;
mStackedWidget
=
NULL
;
}
if
(
mMainLayout
)
{
delete
mMainLayout
;
mMainLayout
=
NULL
;
}
}
void
UBUpdateDlg
::
onBrowse
()
{
QString
qsSelectedDir
;
qsSelectedDir
=
QFileDialog
::
getExistingDirectory
(
this
,
tr
(
"Select a backup folder"
),
mBkpPath
.
text
());
mBkpPath
.
setText
(
qsSelectedDir
);
qsSelectedDir
=
QFileDialog
::
getExistingDirectory
(
this
,
tr
(
"Select a backup folder"
),
mBkpPath
->
text
());
mBkpPath
->
setText
(
qsSelectedDir
);
}
void
UBUpdateDlg
::
onUpdate
()
{
mProgressLabel
=
new
QLabel
(
mProgressWidget
);
mProgressLayout
=
new
QHBoxLayout
();
mProgressLayout
->
addWidget
(
mProgressLabel
);
mProgressWidget
->
setLayout
(
mProgressLayout
);
mStackedWidget
->
setCurrentWidget
(
mProgressWidget
);
emit
updateFiles
();
}
void
UBUpdateDlg
::
onFilesUpdated
(
bool
bResult
)
{
this
->
hide
();
QString
qsMsg
;
if
(
bResult
)
if
(
bResult
)
{
qsMsg
=
tr
(
"Files update successful!
\n
Please reboot the application to access the updated documents."
);
}
...
...
@@ -74,5 +179,11 @@ void UBUpdateDlg::onFilesUpdated(bool bResult)
QString
UBUpdateDlg
::
backupPath
()
{
return
mBkpPath
.
text
();
return
mBkpPath
->
text
();
}
void
UBUpdateDlg
::
transitioningFile
(
QString
fileName
)
{
mProgressLabel
->
setText
(
tr
(
"Updating file "
)
+
fileName
);
}
src/gui/UBUpdateDlg.h
View file @
63a71fad
...
...
@@ -8,6 +8,7 @@
#include <QDialogButtonBox>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QStackedWidget>
class
UBUpdateDlg
:
public
QDialog
{
...
...
@@ -27,15 +28,25 @@ signals:
private
slots
:
void
onBrowse
();
void
onUpdate
();
void
transitioningFile
(
QString
fileName
);
private
:
QLabel
mNbFilesLabel
;
QLabel
mBkpLabel
;
QLineEdit
mBkpPath
;
QPushButton
mBrowseBttn
;
QVBoxLayout
*
mMainLayout
;
QLabel
*
mNbFilesLabel
;
QLabel
*
mBkpLabel
;
QLineEdit
*
mBkpPath
;
QPushButton
*
mBrowseBttn
;
QDialogButtonBox
*
mpDlgBttn
;
QVBoxLayout
mLayout
;
QHBoxLayout
mHLayout
;
QVBoxLayout
*
mLayout
;
QHBoxLayout
*
mHLayout
;
QStackedWidget
*
mStackedWidget
;
QWidget
*
mDialogWidget
;
QWidget
*
mProgressWidget
;
QHBoxLayout
*
mProgressLayout
;
QLabel
*
mProgressLabel
;
};
#endif // UBUPDATEDLG_H
src/transition/UniboardSankoreTransition.cpp
View file @
63a71fad
...
...
@@ -8,9 +8,9 @@
UniboardSankoreTransition
::
UniboardSankoreTransition
(
QObject
*
parent
)
:
QObject
(
parent
)
,
mTransitionDlg
(
NULL
)
,
mThread
(
NULL
)
{
mOldSankoreDirectory
=
UBFileSystemUtils
::
normalizeFilePath
(
UBDesktopServices
::
storageLocation
(
QDesktopServices
::
DataLocation
));
qDebug
()
<<
mOldSankoreDirectory
;
mUniboardSourceDirectory
=
UBFileSystemUtils
::
normalizeFilePath
(
UBDesktopServices
::
storageLocation
(
QDesktopServices
::
DataLocation
));
#if defined(Q_WS_MACX)
...
...
@@ -28,6 +28,11 @@ UniboardSankoreTransition::~UniboardSankoreTransition()
delete
mTransitionDlg
;
mTransitionDlg
=
NULL
;
}
if
(
mThread
){
delete
mThread
;
mThread
=
NULL
;
}
}
void
UniboardSankoreTransition
::
rollbackDocumentsTransition
(
QFileInfoList
&
fileInfoList
)
...
...
@@ -56,7 +61,7 @@ void UniboardSankoreTransition::documentTransition()
QString
backupDirectoryPath
=
UBFileSystemUtils
::
normalizeFilePath
(
UBDesktopServices
::
storageLocation
(
QDesktopServices
::
DesktopLocation
));
if
(
fileInfoList
.
count
()
!=
0
){
mTransitionDlg
=
new
UBUpdateDlg
(
0
,
fileInfoList
.
count
(),
backupDirectoryPath
);
mTransitionDlg
=
new
UBUpdateDlg
(
NULL
,
fileInfoList
.
count
(),
backupDirectoryPath
);
connect
(
mTransitionDlg
,
SIGNAL
(
updateFiles
()),
this
,
SLOT
(
startDocumentTransition
()));
connect
(
this
,
SIGNAL
(
transitionFinished
(
bool
)),
mTransitionDlg
,
SLOT
(
onFilesUpdated
(
bool
)));
mTransitionDlg
->
show
();
...
...
@@ -65,6 +70,13 @@ void UniboardSankoreTransition::documentTransition()
}
void
UniboardSankoreTransition
::
startDocumentTransition
()
{
mThread
=
new
UniboardSankoreThread
(
this
);
mThread
->
start
();
connect
(
this
,
SIGNAL
(
transitioningFile
(
QString
)),
mTransitionDlg
,
SLOT
(
transitioningFile
(
QString
)));
}
void
UniboardSankoreTransition
::
executeTransition
()
{
bool
result
=
false
;
QString
backupDestinationPath
=
mTransitionDlg
->
backupPath
()
+
"/OldSankoreAndUniboardVersionsBackup"
;
...
...
@@ -78,14 +90,12 @@ void UniboardSankoreTransition::startDocumentTransition()
QFileInfoList
::
iterator
fileInfo
;
QString
sankoreDocumentDirectory
=
UBSettings
::
uniboardDocumentDirectory
();
QStringList
qslNewDocs
;
for
(
fileInfo
=
fileInfoList
.
begin
();
fileInfo
!=
fileInfoList
.
end
()
&&
result
;
fileInfo
+=
1
)
{
if
(
fileInfo
->
isDir
()
&&
(
fileInfo
->
fileName
().
startsWith
(
"Uniboard Document "
)
||
fileInfo
->
fileName
().
startsWith
(
"Sankore Document "
))){
QString
sankoreDocumentName
=
fileInfo
->
fileName
();
emit
transitioningFile
(
sankoreDocumentName
);
sankoreDocumentName
.
replace
(
"Uniboard"
,
"Sankore"
);
result
=
UBFileSystemUtils
::
copyDir
(
fileInfo
->
filePath
(),
sankoreDocumentDirectory
+
"/"
+
sankoreDocumentName
);
qslNewDocs
<<
sankoreDocumentName
;
}
}
...
...
@@ -100,6 +110,23 @@ void UniboardSankoreTransition::startDocumentTransition()
}
emit
transitionFinished
(
result
);
}
UniboardSankoreThread
::
UniboardSankoreThread
(
QObject
*
parent
)
:
QThread
(
parent
)
{
mTransitionDlg
->
hide
();
}
UniboardSankoreThread
::~
UniboardSankoreThread
()
{
}
void
UniboardSankoreThread
::
run
()
{
UniboardSankoreTransition
*
pTransition
=
dynamic_cast
<
UniboardSankoreTransition
*>
(
parent
());
pTransition
->
executeTransition
();
}
src/transition/UniboardSankoreTransition.h
View file @
63a71fad
...
...
@@ -3,9 +3,21 @@
#include <QObject>
#include <QFileInfo>
#include <QThread>
#include "gui/UBUpdateDlg.h"
#include "document/UBDocumentProxy.h"
class
UniboardSankoreThread
:
public
QThread
{
Q_OBJECT
public
:
UniboardSankoreThread
(
QObject
*
parent
=
0
);
~
UniboardSankoreThread
();
void
run
();
};
class
UniboardSankoreTransition
:
public
QObject
{
Q_OBJECT
...
...
@@ -13,6 +25,7 @@ public:
explicit
UniboardSankoreTransition
(
QObject
*
parent
=
0
);
~
UniboardSankoreTransition
();
void
documentTransition
();
void
executeTransition
();
private
:
...
...
@@ -22,10 +35,12 @@ private:
protected
:
QString
mUniboardSourceDirectory
;
QString
mOldSankoreDirectory
;
UniboardSankoreThread
*
mThread
;
signals
:
void
transitionFinished
(
bool
result
);
void
docAdded
(
UBDocumentProxy
*
doc
);
void
transitioningFile
(
QString
documentName
);
private
slots
:
void
startDocumentTransition
();
...
...
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