MAP_IMAGE_DOWNLOAD_FAILED, // map image download failed from OSM
GPS_INITIALIZATION_FAILED, // GPS intialization failed
UNKNOWN_REPLY, // unknown reply from situare server
- INVALID_JSON // JSON parsing failed i.e. invalid JSON string
+ INVALID_JSON, // JSON parsing failed i.e. invalid JSON string
+ CONNECTION_ERROR // connection error
};
}
void SituareEngine::error(const int error)
{
- qDebug() << __PRETTY_FUNCTION__;
+ qWarning() << __PRETTY_FUNCTION__;
switch(error)
{
case QNetworkReply::TimeoutError:
m_ui->buildInformationBox(tr("Connection timed out"), true);
break;
+ case QNetworkReply::UnknownNetworkError:
+ m_ui->buildInformationBox(tr("Network error. Please connect to network"), true);
+ m_ui->toggleProgressIndicator(false);
+ break;
case SituareError::SESSION_EXPIRED:
m_ui->buildInformationBox(tr("Session expired. Please login again"), true);
m_facebookAuthenticator->clearAccountInformation(true); // keep username = true
#include <QNetworkRequest>
#include <QNetworkAccessManager>
#include <QDebug>
+#include <QTimer>
#include "networkhandler.h"
#include "networkaccessmanager.h"
#include "networkreply.h"
+#include "common.h"
NetworkAccessManager *NetworkAccessManager::m_instance = 0;
}
}
-QNetworkReply *NetworkAccessManager::get(const QNetworkRequest &request)
+QNetworkReply *NetworkAccessManager::get(const QNetworkRequest &request, bool onlineRequestsOnly)
{
qDebug() << __PRETTY_FUNCTION__;
m_requestQueue.append(request);
m_networkHandler->connect();
QNetworkReply *reply = new NetworkReply(request, this);
- m_offlineReplyQueue.insert(request.url().toString(), reply);
+
+ if (onlineRequestsOnly) {
+ ((NetworkReply*)reply)->setErrorCode(QNetworkReply::UnknownNetworkError);
+ emit finished(reply);
+ }
+ else {
+ m_offlineReplyQueue.insert(request.url().toString(), reply);
+ }
+
return reply;
}
//Connected, use normal get method.
* @param request QNetworkRequest
* @return QNetworkReply
*/
- QNetworkReply *get(const QNetworkRequest &request);
+ QNetworkReply *get(const QNetworkRequest &request, bool onlineRequestsOnly = false);
/**
* @brief Sets cache.
void NetworkHandlerPrivate::stateChanged(const QDBusMessage &message)
{
- qDebug() << __PRETTY_FUNCTION__;
+ qDebug() << __PRETTY_FUNCTION__ << message;
if (message.arguments().count() > CONNECTION_STATE_INDEX) {
setRequest(request);
}
+void NetworkReply::abort()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+}
+
qint64 NetworkReply::readData(char *data, qint64 maxlen)
{
qDebug() << __PRETTY_FUNCTION__;
return -1;
}
-void NetworkReply::abort()
+void NetworkReply::setErrorCode(QNetworkReply::NetworkError errorCode)
{
qDebug() << __PRETTY_FUNCTION__;
+
+ setError(errorCode, "");
}
*/
NetworkReply(const QNetworkRequest &request, QObject *parent = 0);
+ /**
+ * @brief Set error code
+ *
+ * @param errorCode QNetworkReply::NetworkError
+ */
+ void setErrorCode(QNetworkReply::NetworkError errorCode);
+
/*******************************************************************************
* BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
******************************************************************************/
protected:
/**
+ * @brief Aborts the operation.
+ */
+ void abort();
+
+ /**
* @brief Reads data from the device.
*
* @param data data is read into this
*/
qint64 readData(char *data, qint64 maxlen);
- /**
- * @brief Aborts the operation.
- */
- void abort();
-
/*******************************************************************************
* DATA MEMBERS
******************************************************************************/
m_networkManager = NetworkAccessManager::instance();
connect(m_networkManager, SIGNAL(finished(QNetworkReply*)),
- this, SLOT(requestFinished(QNetworkReply*)));
+ this, SLOT(requestFinished(QNetworkReply*)), Qt::QueuedConnection);
m_imageFetcher = new ImageFetcher(NetworkAccessManager::instance(), this);
connect(this, SIGNAL(fetchImage(QUrl)),
request.setAttribute(QNetworkRequest::CacheSaveControlAttribute, false);
request.setRawHeader(cookieType.toAscii(), cookie.toUtf8());
- QNetworkReply *reply = m_networkManager->get(request);
+ QNetworkReply *reply = m_networkManager->get(request, true);
m_currentRequests.append(reply);
}
user/user.h
QT += network \
webkit
+
DEFINES += QT_NO_DEBUG_OUTPUT
simulator {
HEADERS += network/networkhandlerprivate.h
QT += dbus
CONFIG += icd2
- SOURCES += gps/gpspositionprivateliblocation.cpp \
- gps/liblocationwrapper.cpp \
- gps/geopositioninfo.cpp \
- gps/geocoordinate.cpp
- HEADERS += gps/gpspositionprivateliblocation.h \
- gps/liblocationwrapper.h \
- gps/geopositioninfo.h \
- gps/geocoordinate.h
- CONFIG += link_pkgconfig
- PKGCONFIG += glib-2.0 liblocation
+# SOURCES += gps/gpspositionprivateliblocation.cpp \
+# gps/liblocationwrapper.cpp \
+# gps/geopositioninfo.cpp \
+# gps/geocoordinate.cpp
+# HEADERS += gps/gpspositionprivateliblocation.h \
+# gps/liblocationwrapper.h \
+# gps/geopositioninfo.h \
+# gps/geocoordinate.h
+# CONFIG += link_pkgconfig
+# PKGCONFIG += glib-2.0 liblocation
+ SOURCES += gps/gpspositionprivatestub.cpp
+ HEADERS += gps/gpspositionprivatestub.h
} else {
SOURCES += gps/gpspositionprivatestub.cpp \
network/networkhandlerprivatestub.cpp