}
}
-void SituareEngine::error(const int error)
+void SituareEngine::error(const int context, const int error)
{
qDebug() << __PRETTY_FUNCTION__;
switch(error)
{
- case QNetworkReply::ConnectionRefusedError:
+ case SituareError::ERROR_GENERAL:
+ if(context == ErrorContext::SITUARE) {
+ m_ui->toggleProgressIndicator(false);
+ m_ui->buildInformationBox(tr("Unknown server error"), true);
+ }
+ break;
+ case SituareError::ERROR_MISSING_ARGUMENT | QNetworkReply::ConnectionRefusedError :
m_ui->toggleProgressIndicator(false);
- m_ui->buildInformationBox(tr("Connection refused by the server"), true);
+ if(context == ErrorContext::SITUARE) {
+ m_ui->buildInformationBox(tr("Missing argument from request"), true);
+ } else if(context == ErrorContext::NETWORK) {
+ m_ui->buildInformationBox(tr("Connection refused by the server"), true);
+ }
break;
case QNetworkReply::RemoteHostClosedError:
- m_ui->toggleProgressIndicator(false);
- m_ui->buildInformationBox(tr("Connection closed by the server"), true);
+ if(context == ErrorContext::NETWORK) {
+ m_ui->toggleProgressIndicator(false);
+ m_ui->buildInformationBox(tr("Connection closed by the server"), true);
+ }
break;
case QNetworkReply::HostNotFoundError:
- m_ui->toggleProgressIndicator(false);
- m_ui->buildInformationBox(tr("Remote server not found"), true);
+ if(context == ErrorContext::NETWORK) {
+ m_ui->toggleProgressIndicator(false);
+ m_ui->buildInformationBox(tr("Remote server not found"), true);
+ }
break;
case QNetworkReply::TimeoutError:
- m_ui->toggleProgressIndicator(false);
- m_ui->buildInformationBox(tr("Connection timed out"), true);
+ if(context == ErrorContext::NETWORK) {
+ m_ui->toggleProgressIndicator(false);
+ m_ui->buildInformationBox(tr("Connection timed out"), true);
+ }
break;
case SituareError::SESSION_EXPIRED:
m_ui->buildInformationBox(tr("Session expired. Please login again"), true);
enableGPS(false);
m_ui->buildInformationBox(tr("GPS initialization failed"), true);
break;
- case SituareError::UNKNOWN_REPLY:
- m_ui->toggleProgressIndicator(false);
- m_ui->buildInformationBox(tr("Unknown server response"), true);
- break;
case SituareError::INVALID_JSON:
m_ui->buildInformationBox(tr("Malformatted reply from server"), true);
m_ui->loggedIn(false);
m_facebookAuthenticator->clearAccountInformation(false); // clean all
break;
+ case SituareError::ERROR_GEOLOCATION_SERVER_UNAVAILABLE:
+ m_ui->toggleProgressIndicator(false);
+ m_ui->buildInformationBox(tr("Geolocation server not responding"), true);
+ break;
+ case SituareError::ERROR_GEOLOCATION_REQUEST_FAIL:
+ m_ui->toggleProgressIndicator(false);
+ m_ui->buildInformationBox(tr("Geolocation request failed, please try again"), true);
+ break;
+ case SituareError::ERROR_GEOLOCATION_LONLAT_INVALID:
+ m_ui->toggleProgressIndicator(false);
+ m_ui->buildInformationBox(tr("Invalid lat/lon value, please try again"), true);
+ break;
default:
m_ui->toggleProgressIndicator(false);
- qCritical() << "QNetworkReply::NetworkError :" << error;
+ if(context == ErrorContext::NETWORK)
+ qCritical() << "QNetworkReply::NetworkError: " << error;
+ else
+ qCritical() << "Unknown error: " << error;
+
break;
}
}
{
qDebug() << __PRETTY_FUNCTION__;
- connect(m_facebookAuthenticator, SIGNAL(error(int)),
- this, SLOT(error(int)));
+ connect(m_facebookAuthenticator, SIGNAL(error(int, int)),
+ this, SLOT(error(int, int)));
connect(m_facebookAuthenticator, SIGNAL(credentialsReady(FacebookCredentials)),
m_situareService, SLOT(credentialsReady(FacebookCredentials)));
connect(m_gps, SIGNAL(timeout()),
m_ui, SLOT(gpsTimeout()));
- connect(m_gps, SIGNAL(error(int)),
- this, SLOT(error(int)));
+ connect(m_gps, SIGNAL(error(int, int)),
+ this, SLOT(error(int, int)));
connect(m_gps, SIGNAL(position(QPointF,qreal)),
this, SLOT(saveGPSPosition(QPointF)));
{
qDebug() << __PRETTY_FUNCTION__;
- connect(m_ui, SIGNAL(error(int)),
- this, SLOT(error(int)));
+ connect(m_ui, SIGNAL(error(int, int)),
+ this, SLOT(error(int, int)));
connect(m_ui, SIGNAL(fetchUsernameFromSettings()),
this, SLOT(fetchUsernameFromSettings()));
{
qDebug() << __PRETTY_FUNCTION__;
- connect(m_mapEngine, SIGNAL(error(int)),
- this, SLOT(error(int)));
+ connect(m_mapEngine, SIGNAL(error(int, int)),
+ this, SLOT(error(int, int)));
connect(m_mapEngine, SIGNAL(locationChanged(QPoint)),
m_ui, SIGNAL(centerToSceneCoordinates(QPoint)));
{
qDebug() << __PRETTY_FUNCTION__;
- connect(m_situareService, SIGNAL(error(int)),
- this, SLOT(error(int)));
+ connect(m_situareService, SIGNAL(error(int, int)),
+ this, SLOT(error(int, int)));
- connect(m_situareService, SIGNAL(error(int)),
+ connect(m_situareService, SIGNAL(error(int, int)),
m_ui, SIGNAL(messageSendingFailed(int)));
connect(m_situareService, SIGNAL(reverseGeoReady(QString)),