Merge branch 'master' into error_procedur
authorlampehe-local <henri.lampela@ixonos.com>
Thu, 10 Jun 2010 12:07:40 +0000 (15:07 +0300)
committerlampehe-local <henri.lampela@ixonos.com>
Thu, 10 Jun 2010 12:07:40 +0000 (15:07 +0300)
Conflicts:
src/gps/gpspositionprivate.cpp
src/gps/gpspositionprivateliblocation.cpp

25 files changed:
res/languages/situare_fi.qm
res/languages/situare_fi.ts
src/common.h
src/engine/engine.cpp
src/engine/engine.h
src/facebookservice/facebookauthentication.cpp
src/facebookservice/facebookauthentication.h
src/gps/gpsposition.h
src/gps/gpspositionprivate.cpp
src/gps/gpspositionprivateliblocation.cpp
src/gps/gpspositionprivatestub.cpp
src/map/mapengine.cpp
src/map/mapengine.h
src/map/mapfetcher.cpp
src/map/mapfetcher.h
src/situareservice/imagefetcher.cpp
src/situareservice/imagefetcher.h
src/situareservice/situareservice.cpp
src/situareservice/situareservice.h
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/userinfo.cpp
src/ui/userinfo.h
src/ui/userinfopanel.cpp
src/ui/userinfopanel.h

index 0e944cd..7ba275a 100644 (file)
Binary files a/res/languages/situare_fi.qm and b/res/languages/situare_fi.qm differ
index 13307f8..c03deab 100644 (file)
 <context>
     <name>GPSPositionPrivate</name>
     <message>
-        <location filename="../../src/gps/gpspositionprivate.cpp" line="56"/>
-        <location filename="../../src/gps/gpspositionprivateliblocation.cpp" line="59"/>
         <source>Unable to use GPS</source>
-        <translation>GPS ei käytössä</translation>
+        <translation type="obsolete">GPS ei käytössä</translation>
     </message>
 </context>
 <context>
 <context>
     <name>MainWindow</name>
     <message>
-        <location filename="../../src/ui/mainwindow.cpp" line="88"/>
+        <location filename="../../src/ui/mainwindow.cpp" line="87"/>
+        <source>Automatic location update</source>
+        <translation>Automaattinen paikan päivitys</translation>
+    </message>
+    <message>
+        <location filename="../../src/ui/mainwindow.cpp" line="94"/>
         <source>Situare</source>
         <translation>Situare</translation>
     </message>
     <message>
-        <location filename="../../src/ui/mainwindow.cpp" line="375"/>
-        <location filename="../../src/ui/mainwindow.cpp" line="634"/>
+        <location filename="../../src/ui/mainwindow.cpp" line="398"/>
+        <location filename="../../src/ui/mainwindow.cpp" line="657"/>
         <source>Login</source>
         <translation>Kirjaudu</translation>
     </message>
     <message>
-        <location filename="../../src/ui/mainwindow.cpp" line="380"/>
+        <location filename="../../src/ui/mainwindow.cpp" line="403"/>
         <source>Settings</source>
         <translation>Asetukset</translation>
     </message>
     <message>
-        <location filename="../../src/ui/mainwindow.cpp" line="385"/>
+        <location filename="../../src/ui/mainwindow.cpp" line="408"/>
         <source>GPS</source>
         <translation>GPS</translation>
     </message>
     <message>
-        <location filename="../../src/ui/mainwindow.cpp" line="392"/>
+        <location filename="../../src/ui/mainwindow.cpp" line="415"/>
         <source>Auto centering</source>
         <translation>Automaattinen keskitys</translation>
     </message>
     <message>
-        <location filename="../../src/ui/mainwindow.cpp" line="398"/>
+        <location filename="../../src/ui/mainwindow.cpp" line="421"/>
         <source>Main</source>
         <translation>Päävalikko</translation>
     </message>
     <message>
-        <location filename="../../src/ui/mainwindow.cpp" line="403"/>
+        <location filename="../../src/ui/mainwindow.cpp" line="426"/>
         <source>Menu</source>
         <translation>Valikko</translation>
     </message>
     <message>
-        <location filename="../../src/ui/mainwindow.cpp" line="506"/>
+        <location filename="../../src/ui/mainwindow.cpp" line="529"/>
         <source>GPS timeout</source>
         <translation>GPS pyyntö aikakatkaistiin</translation>
     </message>
     <message>
-        <location filename="../../src/ui/mainwindow.cpp" line="628"/>
+        <location filename="../../src/ui/mainwindow.cpp" line="651"/>
         <source>Logout</source>
         <translation>Kirjaudu ulos</translation>
     </message>
 <context>
     <name>QObject</name>
     <message>
-        <location filename="../../src/common.h" line="52"/>
         <source>Session expired. Please login again</source>
-        <translation>Istunto vanhentunut. Kirjaudu uudelleen</translation>
+        <translation type="obsolete">Istunto vanhentunut. Kirjaudu uudelleen</translation>
     </message>
     <message>
-        <location filename="../../src/common.h" line="53"/>
         <source>Invalid E-mail address or password</source>
-        <translation>Virheellinen sähköpostiosoite tai salasana</translation>
+        <translation type="obsolete">Virheellinen sähköpostiosoite tai salasana</translation>
     </message>
     <message>
-        <location filename="../../src/common.h" line="54"/>
         <source>Update failed, please try again</source>
-        <translation>Päivitys epäonnistui. Yritä uudelleen</translation>
+        <translation type="obsolete">Päivitys epäonnistui. Yritä uudelleen</translation>
     </message>
     <message>
-        <location filename="../../src/common.h" line="55"/>
         <source>Data retrieval failed, please try again</source>
         <oldsource>Data retrieval failed, plaease try again</oldsource>
-        <translation>Tiedon haku epäonnistui. Yritä uudelleen</translation>
+        <translation type="obsolete">Tiedon haku epäonnistui. Yritä uudelleen</translation>
     </message>
     <message>
-        <location filename="../../src/common.h" line="56"/>
         <source>Address retrieval failed, please try again</source>
-        <translation>Osoitteen haku epäonnistui. Yritä uudelleen</translation>
+        <translation type="obsolete">Osoitteen haku epäonnistui. Yritä uudelleen</translation>
     </message>
     <message>
-        <location filename="../../src/common.h" line="57"/>
         <source>Image download failed</source>
-        <translation>Kuvan haku epäonnistui</translation>
+        <translation type="obsolete">Kuvan haku epäonnistui</translation>
     </message>
 </context>
 <context>
     <name>SettingsDialog</name>
     <message>
-        <location filename="../../src/ui/settingsdialog.cpp" line="44"/>
+        <location filename="../../src/ui/settingsdialog.cpp" line="41"/>
         <source>Settings</source>
         <translation>Asetukset</translation>
     </message>
     <message>
-        <location filename="../../src/ui/settingsdialog.cpp" line="50"/>
+        <location filename="../../src/ui/settingsdialog.cpp" line="47"/>
         <source>Use automatic location update</source>
         <translation>Sijainnin automaattinen päivitys</translation>
     </message>
     <message>
-        <location filename="../../src/ui/settingsdialog.cpp" line="57"/>
-        <location filename="../../src/ui/settingsdialog.cpp" line="89"/>
+        <location filename="../../src/ui/settingsdialog.cpp" line="54"/>
+        <location filename="../../src/ui/settingsdialog.cpp" line="86"/>
         <source>Update interval</source>
         <translation>Päivitysväli</translation>
     </message>
     <message>
-        <location filename="../../src/ui/settingsdialog.cpp" line="138"/>
+        <location filename="../../src/ui/settingsdialog.cpp" line="131"/>
         <source>%1 min</source>
         <translation>%1 min</translation>
     </message>
 <context>
     <name>SituareEngine</name>
     <message>
-        <location filename="../../src/engine/engine.cpp" line="136"/>
+        <location filename="../../src/engine/engine.cpp" line="140"/>
         <source>Auto centering disabled</source>
         <translation>Automaattinen keskitys pois päältä</translation>
     </message>
     <message>
+        <location filename="../../src/engine/engine.cpp" line="185"/>
+        <source>Do you want to enable automatic location update with %1 min update interval?</source>
+        <translation>Asetetaanko automaattinen paikan päivitys %1 minuutin välein päälle?</translation>
+    </message>
+    <message>
+        <location filename="../../src/engine/engine.cpp" line="190"/>
+        <source>Automatic location update enabled</source>
+        <translation>Automaattinen paikan päivitys päällä</translation>
+    </message>
+    <message>
+        <location filename="../../src/engine/engine.cpp" line="211"/>
+        <source>Connection refused by the server</source>
+        <translation>Palvelin ei vastaa pyyntöihin</translation>
+    </message>
+    <message>
+        <location filename="../../src/engine/engine.cpp" line="214"/>
+        <source>Connection closed by the server</source>
+        <translation>Palvelin sulki yhteyden</translation>
+    </message>
+    <message>
+        <location filename="../../src/engine/engine.cpp" line="217"/>
+        <source>Remote server not found</source>
+        <translation>Palvelinta ei löydy</translation>
+    </message>
+    <message>
         <location filename="../../src/engine/engine.cpp" line="220"/>
-        <location filename="../../src/engine/engine.cpp" line="228"/>
+        <source>Connection timed out</source>
+        <translation>Yhteys aikakatkaistiin</translation>
+    </message>
+    <message>
+        <location filename="../../src/engine/engine.cpp" line="223"/>
+        <source>Session expired. Please login again</source>
+        <translation>Istunto vanhentunut. Kirjaudu uudelleen</translation>
+    </message>
+    <message>
+        <location filename="../../src/engine/engine.cpp" line="226"/>
+        <source>Invalid E-mail address or password</source>
+        <translation>Virheellinen sähköpostiosoite tai salasana</translation>
+    </message>
+    <message>
+        <location filename="../../src/engine/engine.cpp" line="229"/>
+        <source>Update failed, please try again</source>
+        <translation>Päivitys epäonnistui. Yritä uudelleen</translation>
+    </message>
+    <message>
+        <location filename="../../src/engine/engine.cpp" line="232"/>
+        <source>Data retrieval failed, please try again</source>
+        <translation>Tiedon haku epäonnistui. Yritä uudelleen</translation>
+    </message>
+    <message>
+        <location filename="../../src/engine/engine.cpp" line="235"/>
+        <source>Address retrieval failed, please try again</source>
+        <translation>Osoitteen haku epäonnistui. Yritä uudelleen</translation>
+    </message>
+    <message>
+        <location filename="../../src/engine/engine.cpp" line="238"/>
+        <source>Image download failed</source>
+        <translation>Kuvan haku epäonnistui</translation>
+    </message>
+    <message>
+        <location filename="../../src/engine/engine.cpp" line="242"/>
+        <source>GPS initialization failed</source>
+        <translation>GPS alustus epäonnistui</translation>
+    </message>
+    <message>
+        <location filename="../../src/engine/engine.cpp" line="279"/>
+        <location filename="../../src/engine/engine.cpp" line="287"/>
         <source>GPS enabled</source>
         <translation>GPS päällä</translation>
     </message>
     <message>
-        <location filename="../../src/engine/engine.cpp" line="221"/>
-        <location filename="../../src/engine/engine.cpp" line="231"/>
+        <location filename="../../src/engine/engine.cpp" line="280"/>
+        <location filename="../../src/engine/engine.cpp" line="290"/>
         <source>Auto centering enabled</source>
         <translation>Automaattinen keskitys päällä</translation>
     </message>
 <context>
     <name>UpdateLocationDialog</name>
     <message>
-        <location filename="../../src/ui/updatelocation/updatelocationdialog.cpp" line="31"/>
+        <location filename="../../src/ui/updatelocation/updatelocationdialog.cpp" line="34"/>
         <source>Update Location</source>
         <translation>Päivitä sijainti</translation>
     </message>
     <message>
-        <location filename="../../src/ui/updatelocation/updatelocationdialog.cpp" line="43"/>
+        <location filename="../../src/ui/updatelocation/updatelocationdialog.cpp" line="71"/>
         <source>Publish on Facebook</source>
         <translation>Julkaise Facebookissa</translation>
     </message>
     <message>
-        <location filename="../../src/ui/updatelocation/updatelocationdialog.cpp" line="49"/>
+        <location filename="../../src/ui/updatelocation/updatelocationdialog.cpp" line="77"/>
         <source>Send</source>
         <translation>Lähetä</translation>
     </message>
     <message>
-        <location filename="../../src/ui/updatelocation/updatelocationdialog.cpp" line="52"/>
+        <location filename="../../src/ui/updatelocation/updatelocationdialog.cpp" line="82"/>
         <source>Location:</source>
         <translation>Sijainti:</translation>
     </message>
     <message>
-        <location filename="../../src/ui/updatelocation/updatelocationdialog.cpp" line="53"/>
+        <location filename="../../src/ui/updatelocation/updatelocationdialog.cpp" line="42"/>
         <source>Message:</source>
         <translation>Viesti:</translation>
     </message>
 <context>
     <name>UserInfo</name>
     <message>
-        <location filename="../../src/ui/userinfo.cpp" line="342"/>
+        <location filename="../../src/ui/userinfo.cpp" line="340"/>
         <source>Location update failed
 
 Your message is saved to textbox until sending will succeed</source>
index 66d3b47..6888b48 100644 (file)
@@ -50,12 +50,17 @@ const QString INTERVAL2 = "&cancel_url=";
 const QString SITUARE_LOGIN_FAILURE = "http://www.facebook.com/connect/login_failure.html";
 const QString FACEBOOK_LOGIN_ENDING = "&fbconnect=true&return_session=true&";
 
-// Error messages
-const QString SESSION_EXPIRED = QObject::tr("Session expired. Please login again");
-const QString LOGIN_FAILED = QObject::tr("Invalid E-mail address or password");
-const QString UPDATE_FAILED = QObject::tr("Update failed, please try again");
-const QString DATA_RETRIEVAL_FAILED = QObject::tr("Data retrieval failed, please try again");
-const QString ADDRESS_RETRIEVAL_FAILED = QObject::tr("Address retrieval failed, please try again");
-const QString DOWNLOAD_FAILED = QObject::tr("Image download failed");
+// Situare errors
+namespace SituareError {
+    enum errors {
+        SESSION_EXPIRED = 10,
+        LOGIN_FAILED,
+        UPDATE_FAILED,
+        DATA_RETRIEVAL_FAILED,
+        ADDRESS_RETRIEVAL_FAILED,
+        DOWNLOAD_FAILED,
+        GPS_INITIALIZATION_FAILED
+    };
+}
 
 #endif // COMMON_H
index bf396bb..5f5c23a 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <QMessageBox>
+#include <QNetworkReply>
 
 #include "common.h"
 #include "facebookservice/facebookauthentication.h"
@@ -208,13 +209,52 @@ void SituareEngine::enableAutomaticLocationUpdate(bool enabled, int updateInterv
     }
 }
 
-void SituareEngine::error(const QString &error)
+void SituareEngine::error(const int error)
 {
     qDebug() << __PRETTY_FUNCTION__;    
 
-    m_ui->buildInformationBox(error, true);
+    switch(error)
+    {
+    case QNetworkReply::ConnectionRefusedError:
+        m_ui->buildInformationBox(tr("Connection refused by the server"), true);
+        break;
+    case QNetworkReply::RemoteHostClosedError:
+        m_ui->buildInformationBox(tr("Connection closed by the server"), true);
+        break;
+    case QNetworkReply::HostNotFoundError:
+        m_ui->buildInformationBox(tr("Remote server not found"), true);
+        break;
+    case QNetworkReply::TimeoutError:
+        m_ui->buildInformationBox(tr("Connection timed out"), true);
+        break;
+    case SituareError::SESSION_EXPIRED:
+        m_ui->buildInformationBox(tr("Session expired. Please login again"), true);
+        break;
+    case SituareError::LOGIN_FAILED:
+        m_ui->buildInformationBox(tr("Invalid E-mail address or password"), true);
+        break;
+    case SituareError::UPDATE_FAILED:
+        m_ui->buildInformationBox(tr("Update failed, please try again"), true);
+        break;
+    case SituareError::DATA_RETRIEVAL_FAILED:
+        m_ui->buildInformationBox(tr("Data retrieval failed, please try again"), true);
+        break;
+    case SituareError::ADDRESS_RETRIEVAL_FAILED:
+        m_ui->buildInformationBox(tr("Address retrieval failed, please try again"), true);
+        break;
+    case SituareError::DOWNLOAD_FAILED:
+        m_ui->buildInformationBox(tr("Image download failed"), true);
+        break;
+    case SituareError::GPS_INITIALIZATION_FAILED:
+        enableGPS(false);
+        m_ui->buildInformationBox(tr("GPS initialization failed"), true);
+        break;
+    default:
+        qCritical() << "QNetworkReply::NetworkError :" << error;
+        break;
+    }
 
-    if(error.compare(SESSION_EXPIRED) == 0) {
+    if(error == SituareError::SESSION_EXPIRED) {
         m_facebookAuthenticator->clearAccountInformation(true); // keep username = true
         m_ui->loggedIn(false);
         m_ui->loginFailed();
@@ -380,8 +420,8 @@ void SituareEngine::signalsFromFacebookAuthenticator()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    connect(m_facebookAuthenticator, SIGNAL(error(QString)),
-            this, SLOT(error(QString)));
+    connect(m_facebookAuthenticator, SIGNAL(error(int)),
+            this, SLOT(error(int)));
 
     connect(m_facebookAuthenticator, SIGNAL(credentialsReady(FacebookCredentials)),
             m_situareService, SLOT(credentialsReady(FacebookCredentials)));
@@ -412,8 +452,8 @@ void SituareEngine::signalsFromGPS()
     connect(m_gps, SIGNAL(timeout()),
             m_ui, SLOT(gpsTimeout()));
 
-    connect(m_gps, SIGNAL(error(QString)),
-            this, SLOT(error(QString)));
+    connect(m_gps, SIGNAL(error(int)),
+            this, SLOT(error(int)));
 
     connect(m_gps, SIGNAL(position(QPointF,qreal)),
             this, SLOT(saveGPSPosition(QPointF)));
@@ -423,6 +463,9 @@ void SituareEngine::signalsFromMainWindow()
 {
     qDebug() << __PRETTY_FUNCTION__;    
 
+    connect(m_ui, SIGNAL(error(int)),
+            this, SLOT(error(int)));
+
     connect(m_ui, SIGNAL(fetchUsernameFromSettings()),
             this, SLOT(fetchUsernameFromSettings()));
 
@@ -476,9 +519,6 @@ void SituareEngine::signalsFromMainWindow()
     connect(m_ui, SIGNAL(refreshUserData()),
             this, SLOT(refreshUserData()));
 
-    connect (m_ui, SIGNAL(notificateUpdateFailing(QString)),
-             this, SLOT(error(QString)));
-
     connect(m_ui, SIGNAL(findUser(QPointF)),
             m_mapEngine, SLOT(setViewLocation(QPointF)));
 
@@ -491,8 +531,8 @@ void SituareEngine::signalsFromMapEngine()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    connect(m_mapEngine, SIGNAL(error(QString)),
-            this, SLOT(error(QString)));
+    connect(m_mapEngine, SIGNAL(error(int)),
+            this, SLOT(error(int)));
 
     connect(m_mapEngine, SIGNAL(locationChanged(QPoint)),
             m_ui, SIGNAL(centerToSceneCoordinates(QPoint)));
@@ -520,8 +560,8 @@ void SituareEngine::signalsFromSituareService()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    connect(m_situareService, SIGNAL(error(QString)),
-            this, SLOT(error(QString)));
+    connect(m_situareService, SIGNAL(error(int)),
+            this, SLOT(error(int)));
 
     connect(m_situareService, SIGNAL(reverseGeoReady(QString)),
             m_ui, SIGNAL(reverseGeoReady(QString)));
@@ -535,8 +575,8 @@ void SituareEngine::signalsFromSituareService()
     connect(m_situareService, SIGNAL(updateWasSuccessful()),
             m_ui, SIGNAL(updateWasSuccessful()));
 
-    connect(m_situareService, SIGNAL(error(QString)),
-            m_ui, SIGNAL(messageSendingFailed(QString)));
+    connect(m_situareService, SIGNAL(error(int)),
+            m_ui, SIGNAL(messageSendingFailed(int)));
 }
 
 void SituareEngine::updateWasSuccessful()
index 529bfdc..2b93fda 100644 (file)
@@ -68,12 +68,18 @@ public:
  * MEMBER FUNCTIONS AND SLOTS
  ******************************************************************************/
 public slots:
+//    /**
+//    * @brief Slot to intercept error signal from ImageFetcher and SituareService
+//    *
+//    * @param error Error message
+//    */
+//    void error(const QString &error);
     /**
     * @brief Slot to intercept error signal from ImageFetcher and SituareService
     *
     * @param error Error message
     */
-    void error(const QString &error);
+    void error(const int error);
 
     /**
     * @brief Slot to intercept signal when username is fetched from settings
index f529bd5..9d0eab7 100644 (file)
@@ -165,12 +165,12 @@ bool FacebookAuthentication::updateCredentials(const QUrl &url)
             qDebug() << callbackUrl;
             clearAccountInformation(true);
             if(m_freshLogin) {
-                emit error(LOGIN_FAILED);
+                emit error(SituareError::LOGIN_FAILED);
                 emit loginFailure();
             }
             else {
                 m_freshLogin = true;
-                emit error(SESSION_EXPIRED);
+                emit error(SituareError::SESSION_EXPIRED);
             }
         }
         else if(callbackUrl.indexOf(LOGIN_PAGE) == 0) {
index 4455cf9..06ec2c4 100644 (file)
@@ -110,9 +110,9 @@ signals:
     /**
     * @brief Signals error
     *
-    * @param error error message
+    * @param error error code
     */
-    void error(const QString &error);
+    void error(const int error);
 
     /**
     * @brief This signal is emitted if updateCredentials method finds credentials from URL.
index 387e3ae..be69bf1 100644 (file)
@@ -113,9 +113,9 @@ signals:
     /**
     * @brief Signal for error.
     *
-    * @param message error code
+    * @param error error code
     */
-    void error(int code);
+    void error(const int error);
 
     /**
     * @brief Signal for position information.
index 68791b8..21421c7 100644 (file)
@@ -25,6 +25,7 @@
 #include <QDebug>
 #include <QTimer>
 
+#include "common.h"
 #include "gpscommon.h"
 #include "gpsposition.h"
 #include "gpspositionprivate.h"
@@ -62,7 +63,7 @@ void GPSPositionPrivate::setMode(GPSPosition::Mode mode, const QString &filePath
 
         if (!m_gpsSource) {
             m_initialized = false;
-            emit m_parent->error(123);
+            emit m_parent->error(SituareError::GPS_INITIALIZATION_FAILED);
             return;
         }
     }
index 2590fa1..b10a898 100644 (file)
@@ -25,6 +25,7 @@
 #include <QDebug>
 #include <QTimer>
 
+#include "common.h"
 #include "gpscommon.h"
 #include "gpsposition.h"
 #include "gpspositionprivateliblocation.h"
@@ -63,9 +64,9 @@ void GPSPositionPrivate::setMode(GPSPosition::Mode mode, const QString &filePath
     if (mode == GPSPosition::Default) {
         m_liblocationWrapper = new LiblocationWrapper(this);
 
-        if (!m_liblocationWrapper) {
+        if (!m_liblocationWrapper) {     
             m_initialized = false;
-            emit m_parent->error(123);  ///Change to correct error code
+            emit m_parent->error(SituareError::GPS_INITIALIZATION_FAILED);
             return;
         }
     }
@@ -147,7 +148,7 @@ void GPSPositionPrivate::locationError(const QString &errorMessage)
 
     Q_UNUSED(errorMessage);
 
-    emit m_parent->error(123);
+    emit m_parent->error(SituareError::GPS_INITIALIZATION_FAILED);
 }
 
 void GPSPositionPrivate::setUpdateInterval(int interval)
index 41f6a59..8f23493 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <QDebug>
 
+#include "common.h"
 #include "gpsposition.h"
 #include "gpspositionprivatestub.h"
 
@@ -65,7 +66,7 @@ void GPSPositionPrivate::start()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    emit m_parent->error(123);
+    emit m_parent->error(SituareError::GPS_INITIALIZATION_FAILED);
 }
 
 void GPSPositionPrivate::stop()
index 140e250..3a46239 100644 (file)
@@ -61,8 +61,8 @@ MapEngine::MapEngine(QObject *parent)
             m_mapFetcher, SLOT(enqueueFetchMapImage(int, int, int)));
     connect(m_mapFetcher, SIGNAL(mapImageReceived(int, int, int, QPixmap)),
             this, SLOT(mapImageReceived(int, int, int, QPixmap)));
-    connect(m_mapFetcher, SIGNAL(error(QString)),
-            this, SIGNAL(error(QString)));
+    connect(m_mapFetcher, SIGNAL(error(int)),
+            this, SIGNAL(error(int)));
 
     m_ownLocation = new OwnLocationItem();
     m_ownLocation->hide(); // hide until first location info is received
index 94681a7..9bb207b 100644 (file)
@@ -317,9 +317,9 @@ signals:
     /**
     * @brief Signals error
     *
-    * @param error error message
+    * @param error error code
     */
-    void error(const QString &error);
+    void error(const int error);
 
     /**
     * @brief Signal for image fetching.
index c4a89dc..c6e2263 100644 (file)
@@ -127,7 +127,7 @@ void MapFetcher::downloadFinished(QNetworkReply *reply)
             emit mapImageReceived(zoomLevel, x, y, QPixmap::fromImage(image));
         }
         else {
-            emit error(DOWNLOAD_FAILED);
+            emit error(SituareError::DOWNLOAD_FAILED);
         }
 
         m_currentDownloads.removeAll(reply);
index 702f953..e530e61 100644 (file)
@@ -181,9 +181,9 @@ signals:
     * @brief Signal which is emitted when there is error
     * in network reply.
     *
-    * @param message error message
+    * @param error error code
     */
-    void error(const QString &message);
+    void error(const int error);
 
 /*******************************************************************************
  * DATA MEMBERS
index 00d885a..7cb5a94 100644 (file)
@@ -77,7 +77,7 @@ void ImageFetcher::downloadFinished(QNetworkReply *reply)
             emit imageReceived(url, image);
         }
         else {
-            emit error(DOWNLOAD_FAILED);
+            emit error(SituareError::DOWNLOAD_FAILED);
         }
 
         m_currentDownloads.removeAll(reply);
index 39bdd9c..ef7d503 100644 (file)
@@ -93,9 +93,9 @@ signals:
     * @brief Signal which is emitted when there is error
     * in network reply.
     *
-    * @param message error message
+    * @param error error code
     */
-    void error(const QString &message);
+    void error(const int error);
 
 /*******************************************************************************
  * DATA MEMBERS
index 3a0c225..0c8d52e 100644 (file)
@@ -47,8 +47,8 @@ SituareService::SituareService(QObject *parent)
             m_imageFetcher, SLOT(fetchImage(QUrl)));
     connect(m_imageFetcher, SIGNAL(imageReceived(QUrl,QPixmap)),
             this, SLOT(imageReceived(QUrl, QPixmap)));
-    connect(m_imageFetcher, SIGNAL(error(QString)),
-            this, SIGNAL(error(QString)));
+    connect(m_imageFetcher, SIGNAL(error(int)),
+            this, SIGNAL(error(int)));
 }
 
 SituareService::~SituareService()
@@ -249,7 +249,7 @@ void SituareService::requestFinished(QNetworkReply *reply)
         qDebug() << "BytesAvailable: " << reply->bytesAvailable();
 
         if (reply->error()) {
-            emit error(reply->errorString());
+            emit error(reply->error());
         } else {
             qint64 max = reply->size();
             QByteArray replyArray = reply->read(max);
@@ -257,13 +257,13 @@ void SituareService::requestFinished(QNetworkReply *reply)
 
             if(replyArray == ERROR_LAT.toAscii()) {
                 qDebug() << "Error: " << ERROR_LAT;
-                emit error(UPDATE_FAILED);
+                emit error(SituareError::UPDATE_FAILED);
             } else if(replyArray == ERROR_LON.toAscii()) {
                 qDebug() << "Error: " << ERROR_LON;
-                emit error(UPDATE_FAILED);
+                emit error(SituareError::UPDATE_FAILED);
             } else if(replyArray.contains(ERROR_SESSION.toAscii())) {
                 qDebug() << "Error: " << ERROR_SESSION;
-                emit error(SESSION_EXPIRED);
+                emit error(SituareError::SESSION_EXPIRED);
             } else if(replyArray.startsWith(OPENING_BRACE_MARK.toAscii())) {
                 qDebug() << "JSON string";
                 parseUserData(replyArray);
@@ -272,7 +272,7 @@ void SituareService::requestFinished(QNetworkReply *reply)
                     emit updateWasSuccessful();
                 } else {
                     // session credentials are invalid
-                    emit error(SESSION_EXPIRED);
+                    emit error(SituareError::SESSION_EXPIRED);
                 }
             } else {
                 // Street address ready
index fa94371..1b40c14 100644 (file)
@@ -189,9 +189,9 @@ signals:
     /**
     * @brief Signals error
     *
-    * @param error error message
+    * @param error error code
     */
-    void error(const QString &error);
+    void error(const int error);
 
     /**
     * @brief Signal for image fetching
index ac9c6b6..fc2d0c1 100644 (file)
@@ -319,11 +319,11 @@ void MainWindow::buildUserInfoPanel()
     connect(this, SIGNAL(updateWasSuccessful()),
             m_userPanel, SIGNAL(updateWasSuccessful()));
 
-    connect(this, SIGNAL(messageSendingFailed(QString)),
-            m_userPanel, SIGNAL(messageSendingFailed(QString)));
+    connect(this, SIGNAL(messageSendingFailed(int)),
+            m_userPanel, SIGNAL(messageSendingFailed(int)));
 
-    connect(m_userPanel, SIGNAL(notificateUpdateFailing(QString)),
-            this, SIGNAL(notificateUpdateFailing(QString)));
+    connect(m_userPanel, SIGNAL(notificateUpdateFailing(QString, bool)),
+            this, SLOT(buildInformationBox(QString, bool)));
 }
 
 void MainWindow::buildWebView()
@@ -909,7 +909,7 @@ void MainWindow::webViewRequestFinished(QNetworkReply *reply)
     qDebug() << __PRETTY_FUNCTION__;
 
     if(reply->error()) {
-        qDebug() << reply->error() << reply->errorString();
+        emit error(reply->error());
         toggleProgressIndicator(false);
     }
 }
index 90b08dd..714240b 100644 (file)
@@ -83,14 +83,6 @@ private:
  ******************************************************************************/
 public:
     /**
-    * @brief Builds information box with message.
-    *
-    * @param message Information message
-    * @param modal Modal = true, non-modal false
-    */
-    void buildInformationBox(const QString &message, bool modal=false);
-
-    /**
     * @brief Clears cookie jar
     *
     */
@@ -148,6 +140,14 @@ public:
 
 public slots:
     /**
+    * @brief Builds information box with message.
+    *
+    * @param message Information message
+    * @param modal Modal = true, non-modal false
+    */
+    void buildInformationBox(const QString &message, bool modal=false);
+
+    /**
     * @brief Slot to intercept signal when login has failed (loginFailure signal)
     *
     */
@@ -406,6 +406,13 @@ signals:
     void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs);
 
     /**
+    * @brief Signals error
+    *
+    * @param error Error code
+    */
+    void error(const int error);
+
+    /**
     * @brief Signal for requesting username from settings
     *
     */
@@ -475,8 +482,10 @@ signals:
     * @brief Signal that informs that user's message/location failed to update on Situare server
     *        This signal is originally sended from SituareService with name error
     *        Signal is renamed on MainWindow
+    *
+    * @param error error code
     */
-    void messageSendingFailed(const QString &error);
+    void messageSendingFailed(const int error);
 
     /**
       * @brief Forwarding signal from MapEngine to MapView
@@ -484,13 +493,6 @@ signals:
     void minZoomLevelReached();
 
     /**
-    * @brief Signal that used to inform user that his message/location update tp Situare server
-    *        was failed.
-    *        This signal is originally sended from UserInfo
-    */
-    void notificateUpdateFailing(const QString &message);
-
-    /**
      * @brief Forwarding signal from MapEngine to MapScale
      */
     void newMapResolution(qreal scale);
index 794df19..a609dd9 100644 (file)
@@ -49,6 +49,7 @@ const int LABEL_MAX_WIDTH = BACKGROUND_WIDTH - 3 * MARGIN - ICON_WIDTH + 130;
 UserInfo::UserInfo(QWidget *parent)
     : QWidget(parent),
       m_expanded(false),
+      m_messageUpdateVerified(false),
       m_updateLocation(0)
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -327,17 +328,17 @@ QString UserInfo::shortenText(const QLabel *label, const QString &text, int text
    return labelMetrics.elidedText(textParam, Qt::ElideRight, textMaxWidth);
 }
 
-void UserInfo::verifyMessageUpdateFailure(const QString &errorMessage)
+void UserInfo::verifyMessageUpdateFailure(const int error)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    Q_UNUSED(errorMessage);
+    Q_UNUSED(error);
 
     if (!m_messageUpdateVerified) {
 
         if (m_messageText != m_backupMessage && !m_backupMessage.isEmpty())
             emit notificateUpdateFailing(tr("Location update failed\n\nYour message is saved to "
-                                            "textbox until sending will succeed"));
+                                            "textbox until sending will succeed"), true);
     }
 
     m_messageUpdateVerified = true;
index 17f1181..7455089 100644 (file)
@@ -147,9 +147,9 @@ public slots:
     * @brief Emits signal to inform user about failed message/location update.
     *        Contains logic to send signal only after failed message/location update.
     *
-    * @param errorMessage from Situare server. Message is not used in this function
+    * @param error from Situare server. Error is not used in this function
     */
-    void verifyMessageUpdateFailure(const QString &errorMessage);
+    void verifyMessageUpdateFailure(const int error);
 
 private:
 
@@ -203,18 +203,13 @@ signals:
     void findUser(const QPointF &coordinates);
 
     /**
-    * @brief Signal that informs that user's message/location failed to update on Situare server
-    *        This signal is originally sended from SituareService with name error
-    *        Signal is renamed on MainWindow
-    */
-    void messageSendingFailed(const QString &error);
-
-    /**
     * @brief Signal that used to inform user that his message/location update tp Situare server
     *        was failed.
     *        This signal is originally sended from UserInfo
+    * @param message message for notification
+    * @param modal true if modal notification otherwice false
     */
-    void notificateUpdateFailing(const QString &message);
+    void notificateUpdateFailing(const QString &message, bool modal);
 
     /**
     * @brief Signal for refreshing user data.
index 639d3a7..6cf98af 100644 (file)
@@ -67,14 +67,11 @@ UserInfoPanel::UserInfoPanel(QWidget *parent)
     connect(this, SIGNAL(updateWasSuccessful()),
             m_userInfo, SLOT(clearUpdateLocationDialogData()));
 
-    connect(this, SIGNAL(messageSendingFailed(QString)),
-            m_userInfo, SIGNAL(messageSendingFailed(QString)));
+    connect (this, SIGNAL(messageSendingFailed(int)),
+             m_userInfo, SLOT(verifyMessageUpdateFailure(int)));
 
-    connect (this, SIGNAL(messageSendingFailed(QString)),
-             m_userInfo, SLOT(verifyMessageUpdateFailure(QString)));
-
-    connect (m_userInfo, SIGNAL(notificateUpdateFailing(QString)),
-             this, SIGNAL(notificateUpdateFailing(QString)));
+    connect (m_userInfo, SIGNAL(notificateUpdateFailing(QString, bool)),
+             this, SIGNAL(notificateUpdateFailing(QString, bool)));
 }
 
 void UserInfoPanel::userDataReceived(User *user)
index b23c915..02f2713 100644 (file)
@@ -73,15 +73,19 @@ signals:
     * @brief Signal that informs that user's message/location failed to update on Situare server
     *        This signal is originally sended from SituareService with name error
     *        Signal is renamed on MainWindow
+    *
+    * @param error Error code
     */
-    void messageSendingFailed(const QString &error);
+    void messageSendingFailed(const int error);
 
     /**
     * @brief Signal that used to inform user that his message/location update tp Situare server
     *        was failed.
     *        This signal is originally sended from UserInfo
+    * @param message message for notification
+    * @param modal true if modal notification otherwice false
     */
-    void notificateUpdateFailing(const QString &message);
+    void notificateUpdateFailing(const QString &message, bool modal);
 
     /**
     * @brief Signal for refreshing user data.