Use CApplication::isNetworkAccessible() wherever possible

Up to now we had a mixture of different methods to detect whether
network is connected, accessible or both. Even if they implied a
different meaning, they were all doing the same and internally
referred to almost the same code. Almost, since our implementation
of CNetworkUtils::hasConnectedInterface refers to code from Qt 4.4.
However, all of them returned a boolean status whether a network
interface is generally up or not. Instead of maintaining our own
version, use Qt functions.

refs #869
This commit is contained in:
Roland Winklmeier
2017-01-24 14:08:38 +01:00
committed by Mathew Sutcliffe
parent 10f9c9c50a
commit 64a47da67f
5 changed files with 6 additions and 6 deletions

View File

@@ -539,7 +539,7 @@ namespace BlackCore
QNetworkReply *CApplication::postToNetwork(const QNetworkRequest &request, QHttpMultiPart *multiPart, const CSlot<void(QNetworkReply *)> &callback)
{
if (!this->isNetworkConnectedAndAccessible()) { return nullptr; }
if (!this->isNetworkAccessible()) { return nullptr; }
if (QThread::currentThread() != this->m_accessManager.thread())
{
multiPart->moveToThread(this->m_accessManager.thread());
@@ -1176,7 +1176,7 @@ namespace BlackCore
QNetworkReply *CApplication::httpRequestImpl(const QNetworkRequest &request, const BlackMisc::CSlot<void (QNetworkReply *)> &callback, int maxRedirects, std::function<QNetworkReply *(QNetworkAccessManager &, const QNetworkRequest &)> requestOrPostMethod)
{
if (this->m_shutdown) { return nullptr; }
if (!this->isNetworkConnectedAndAccessible()) { return nullptr; }
if (!this->isNetworkAccessible()) { return nullptr; }
QWriteLocker locker(&m_accessManagerLock);
Q_ASSERT_X(QCoreApplication::instance()->thread() == m_accessManager.thread(), Q_FUNC_INFO, "Network manager supposed to be in main thread");
if (QThread::currentThread() != this->m_accessManager.thread())