Status bar fixed
[qtmeetings] / src / BusinessLogic / Engine.cpp
index e46ddc9..6207440 100644 (file)
@@ -32,8 +32,7 @@ Engine::Engine() :
                iWindowManager( 0 ), iUIManager( 0 )
 {
        qDebug() << "Engine::Engine()";
-       iCommunicationFailed = false;
-       iCurrentWeekFetched = false;
+       iCommunicationFailed = true;
        
        initConfiguration();
        initDevice();
@@ -184,10 +183,14 @@ void Engine::fetchMeetingDetails( Meeting *aMeeting )
 void Engine::meetingsFetched( const QList<Meeting*> &aMeetings )
 {
        qDebug() << "Engine::meetingsFetched( const QList<Meeting*> & )";
-       // TODO: should check if this week's meetings were fetched
-       if( iCommunicationFailed || !iCurrentWeekFetched )
+       QTime c = QTime::currentTime();
+       iLastCommunication.setHMS( c.hour(), c.minute(), c.second() );
+
+       qDebug() << "Error length: "<< iCommunicationError.length();
+       qDebug() << "Error: "<< iCommunicationError;
+
+       if( iCommunicationError.length() == 0 )
        {
-               iCurrentWeekFetched = true;
                iCommunicationFailed = false;
                iUIManager->connectionEstablished();
        }
@@ -210,10 +213,10 @@ void Engine::meetingsFetched( const QList<Meeting*> &aMeetings )
 
 void Engine::errorHandler( int aCode, const QString &aAddInfo )
 {      
+       iCommunicationFailed = true;
+
        if( aCode >= 100 && aCode < 150 )
        {
-               iCommunicationFailed = true;
-
                if ( iUIManager != 0 )
                        {
                                iUIManager->connectionLost();
@@ -221,14 +224,31 @@ void Engine::errorHandler( int aCode, const QString &aAddInfo )
        }
        if ( iWindowManager != 0 )
        {
-               iWindowManager->error( ErrorMapper::codeToString( aCode, aAddInfo ) );
+               iCommunicationError = ErrorMapper::codeToString( aCode, aAddInfo );
+               //iWindowManager->error( ErrorMapper::codeToString( aCode, aAddInfo ) );
        }
 }
 
+bool Engine::connected()
+{
+       return !iCommunicationFailed;
+}
+
+QTime Engine::lastUpdated()
+{
+       return iLastCommunication;
+}
+
+QString Engine::errorMessage()
+{
+       return iCommunicationError;
+}
+
 void Engine::fetchMeetings( const int aWeek, const int aYear, const Room *aIn )
 {
        qDebug()
                        << "Engine::fetchMeetings( const int aWeek, const int aYear, const Room * )";
+       iCommunicationError = "";
        iCommunication->fetchMeetings(aWeek, aYear, *aIn);
 }
 
@@ -240,6 +260,7 @@ void Engine::cancelFetchMeetingDetails()
 void Engine::shownWeekChanged( QDate aFrom )
 {
        qDebug() << "[Engine::shownWeekChanged] <Invoked>";
+       iCommunicationError = "";
        iCommunication->fetchMeetings( aFrom.weekNumber(), aFrom.year(), *iCurrentRoom/*defaultRoom()*/ );
 }