mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-25 05:38:46 -05:00
Attempt to recover from network failures
QNetworkAccessManager which is used for all network traffic does not automatically recover from network outages. This patch tries to reestablish network accessibility before any requests are attempted. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6471 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
ad50294454
commit
2994a924e5
@ -49,6 +49,11 @@ public:
|
|||||||
|
|
||||||
void display (QUrl const& url, QString const& name_we)
|
void display (QUrl const& url, QString const& name_we)
|
||||||
{
|
{
|
||||||
|
if (QNetworkAccessManager::Accessible != qnam_->networkAccessible ()) {
|
||||||
|
// try and recover network access for QNAM
|
||||||
|
qnam_->setNetworkAccessible (QNetworkAccessManager::Accessible);
|
||||||
|
}
|
||||||
|
|
||||||
// try and find a localized manual
|
// try and find a localized manual
|
||||||
auto lang = QLocale::system ().name ();
|
auto lang = QLocale::system ().name ();
|
||||||
// try for language and country first
|
// try for language and country first
|
||||||
|
@ -109,6 +109,11 @@ bool RemoteFile::sync (QUrl const& url, bool local, bool force)
|
|||||||
|
|
||||||
void RemoteFile::download (QUrl const& url)
|
void RemoteFile::download (QUrl const& url)
|
||||||
{
|
{
|
||||||
|
if (QNetworkAccessManager::Accessible != network_manager_->networkAccessible ()) {
|
||||||
|
// try and recover network access for QNAM
|
||||||
|
network_manager_->setNetworkAccessible (QNetworkAccessManager::Accessible);
|
||||||
|
}
|
||||||
|
|
||||||
QNetworkRequest request {url};
|
QNetworkRequest request {url};
|
||||||
request.setRawHeader ("User-Agent", "WSJT Sample Downloader");
|
request.setRawHeader ("User-Agent", "WSJT Sample Downloader");
|
||||||
request.setOriginatingObject (this);
|
request.setOriginatingObject (this);
|
||||||
|
19
wsprnet.cpp
19
wsprnet.cpp
@ -207,14 +207,18 @@ QString WSPRNet::urlEncodeSpot(QHash<QString,QString> const& query)
|
|||||||
|
|
||||||
void WSPRNet::work()
|
void WSPRNet::work()
|
||||||
{
|
{
|
||||||
if (!urlQueue.isEmpty()) {
|
if (!urlQueue.isEmpty()) {
|
||||||
QUrl url(urlQueue.dequeue());
|
if (QNetworkAccessManager::Accessible != networkManager->networkAccessible ()) {
|
||||||
QNetworkRequest request(url);
|
// try and recover network access for QNAM
|
||||||
m_outstandingRequests << networkManager->get(request);
|
networkManager->setNetworkAccessible (QNetworkAccessManager::Accessible);
|
||||||
emit uploadStatus(QString {"Uploading Spot %1/%2"}.arg (m_urlQueueSize - urlQueue.size()).arg (m_urlQueueSize));
|
|
||||||
} else {
|
|
||||||
uploadTimer->stop();
|
|
||||||
}
|
}
|
||||||
|
QUrl url(urlQueue.dequeue());
|
||||||
|
QNetworkRequest request(url);
|
||||||
|
m_outstandingRequests << networkManager->get(request);
|
||||||
|
emit uploadStatus(QString {"Uploading Spot %1/%2"}.arg (m_urlQueueSize - urlQueue.size()).arg (m_urlQueueSize));
|
||||||
|
} else {
|
||||||
|
uploadTimer->stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WSPRNet::abortOutstandingRequests () {
|
void WSPRNet::abortOutstandingRequests () {
|
||||||
@ -222,4 +226,5 @@ void WSPRNet::abortOutstandingRequests () {
|
|||||||
for (auto& request : m_outstandingRequests) {
|
for (auto& request : m_outstandingRequests) {
|
||||||
request->abort ();
|
request->abort ();
|
||||||
}
|
}
|
||||||
|
m_urlQueueSize = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user