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
a060459e
Commit
a060459e
authored
Nov 06, 2015
by
Craig Watson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed obsolete QHttp functions; added new checkUpdate() and associated functions
parent
087738d5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
40 deletions
+42
-40
UBApplicationController.cpp
src/core/UBApplicationController.cpp
+39
-32
UBApplicationController.h
src/core/UBApplicationController.h
+1
-5
UBDownloadManager.cpp
src/core/UBDownloadManager.cpp
+2
-3
No files found.
src/core/UBApplicationController.cpp
View file @
a060459e
...
...
@@ -24,6 +24,7 @@
#include <QScriptValue>
#include <QScriptEngine>
#include <QUrl>
#include "UBApplicationController.h"
...
...
@@ -87,7 +88,6 @@ UBApplicationController::UBApplicationController(UBBoardView *pControlView,
,
mAutomaticCheckForUpdates
(
false
)
,
mCheckingForUpdates
(
false
)
,
mIsShowingDesktop
(
false
)
,
mHttp
(
0
)
{
mDisplayManager
=
new
UBDisplayManager
(
this
);
...
...
@@ -138,7 +138,6 @@ UBApplicationController::~UBApplicationController()
delete
mBlackScene
;
delete
mMirror
;
if
(
mHttp
)
delete
mHttp
;
delete
(
mOpenSankoreImporter
);
mOpenSankoreImporter
=
NULL
;
...
...
@@ -479,45 +478,53 @@ void UBApplicationController::showDesktop(bool dontSwitchFrontProcess)
UBDrawingController
::
drawingController
()
->
setStylusTool
(
UBStylusTool
::
Selector
);
}
void
UBApplicationController
::
checkUpdate
(
QString
urlString
)
{
if
(
mHttp
)
mHttp
->
deleteLater
(
);
QUrl
url
(
urlString
);
mHttp
=
new
QHttp
(
url
.
host
());
connect
(
mHttp
,
SIGNAL
(
requestFinished
(
int
,
bool
)),
this
,
SLOT
(
updateRequestFinished
(
int
,
bool
)));
connect
(
mHttp
,
SIGNAL
(
responseHeaderReceived
(
QHttpResponseHeader
)),
this
,
SLOT
(
updateHeaderReceived
(
QHttpResponseHeader
)));
mHttp
->
get
(
url
.
path
());
//connect(networkAccessManager, &QNetworkAccessManager::finished,
// this, &UBApplicationController::updateRequestFinished
);
connect
(
networkAccessManager
,
SIGNAL
(
finished
(
QNetworkReply
*
)),
this
,
SLOT
(
updateRequestFinished
(
QNetworkReply
*
)));
networkAccessManager
->
get
(
QNetworkRequest
(
QUrl
(
urlString
)));
}
void
UBApplicationController
::
updateHeaderReceived
(
QHttpResponseHeader
header
)
void
UBApplicationController
::
updateRequestFinished
(
QNetworkReply
*
reply
)
{
if
(
header
.
statusCode
()
==
302
&&
header
.
hasKey
(
"Location"
))
{
mHttp
->
close
()
;
checkUpdate
(
header
.
value
(
"Location"
))
;
if
(
reply
->
error
())
{
qWarning
()
<<
"HTTP Error"
;
return
;
}
// Check if we are being redirected. If so, call checkUpdate again
QVariant
redirect_target
=
reply
->
attribute
(
QNetworkRequest
::
RedirectionTargetAttribute
);
}
if
(
!
redirect_target
.
isNull
())
{
// The returned URL might be relative. resolved() creates an absolute url from it
QUrl
redirect_url
(
reply
->
url
().
resolved
(
redirect_target
.
toUrl
()));
void
UBApplicationController
::
updateRequestFinished
(
int
id
,
bool
error
)
{
if
(
error
){
qWarning
()
<<
"http command id"
<<
id
<<
"return an error"
;
}
else
{
QString
responseString
=
QString
(
mHttp
->
readAll
());
qDebug
()
<<
responseString
;
if
(
!
responseString
.
isEmpty
()
&&
responseString
.
contains
(
"version"
)
&&
responseString
.
contains
(
"url"
)){
mHttp
->
close
();
mHttp
->
deleteLater
();
mHttp
=
0
;
downloadJsonFinished
(
responseString
);
}
}
}
checkUpdate
(
redirect_url
.
toString
());
return
;
}
// No error and no redirect => we read the whole response
QString
responseString
=
QString
(
reply
->
readAll
());
qDebug
()
<<
responseString
;
if
(
!
responseString
.
isEmpty
()
&&
responseString
.
contains
(
"version"
)
&&
responseString
.
contains
(
"url"
))
{
reply
->
close
();
reply
->
deleteLater
();
downloadJsonFinished
(
responseString
);
}
}
void
UBApplicationController
::
downloadJsonFinished
(
QString
currentJson
)
...
...
src/core/UBApplicationController.h
View file @
a060459e
...
...
@@ -29,8 +29,6 @@
#define UBAPPLICATIONCONTROLLER_H_
#include <QtGui>
#include <QFtp>
#include <QHttpResponseHeader>
class
UBBoardView
;
...
...
@@ -146,8 +144,7 @@ class UBApplicationController : public QObject
void
checkAtLaunch
();
private
slots
:
void
updateRequestFinished
(
int
id
,
bool
error
);
void
updateHeaderReceived
(
QHttpResponseHeader
header
);
void
updateRequestFinished
(
QNetworkReply
*
reply
);
protected
:
...
...
@@ -186,7 +183,6 @@ class UBApplicationController : public QObject
QNetworkAccessManager
*
networkAccessManager
;
void
downloadJsonFinished
(
QString
updateString
);
QHttp
*
mHttp
;
};
#endif
/* UBAPPLICATIONCONTROLLER_H_ */
src/core/UBDownloadManager.cpp
View file @
a060459e
...
...
@@ -77,7 +77,7 @@ void UBAsyncLocalFileDownloader::run()
if
(
mDesc
.
originalSrcUrl
.
isEmpty
())
mDesc
.
originalSrcUrl
=
mDesc
.
srcUrl
;
QString
uuid
=
QUuid
::
createUuid
();
QString
uuid
=
QUuid
::
createUuid
()
.
toString
()
;
UBPersistenceManager
::
persistenceManager
()
->
addFileToDocument
(
UBApplication
::
boardController
->
selectedDocument
(),
mDesc
.
srcUrl
,
destDirectory
,
...
...
@@ -399,8 +399,7 @@ void UBDownloadManager::startFileDownload(sDownloadFileDesc desc)
connect
(
http
,
SIGNAL
(
downloadFinished
(
int
,
bool
,
QUrl
,
QUrl
,
QString
,
QByteArray
,
QPointF
,
QSize
,
bool
)),
this
,
SLOT
(
onDownloadFinished
(
int
,
bool
,
QUrl
,
QUrl
,
QString
,
QByteArray
,
QPointF
,
QSize
,
bool
)));
//the desc.srcUrl is encoded. So we have to decode it before.
QUrl
url
;
url
.
setEncodedUrl
(
desc
.
srcUrl
.
toUtf8
());
QUrl
url
=
QUrl
::
fromEncoded
(
desc
.
srcUrl
.
toUtf8
());
// We send here the request and store its reply in order to be able to cancel it if needed
mDownloads
[
desc
.
id
]
=
dynamic_cast
<
QObject
*>
(
http
->
get
(
url
,
desc
.
pos
,
desc
.
size
,
desc
.
isBackground
));
}
...
...
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