Merge branch 'master' of https://git.maemo.org/projects/qtmeetings
[qtmeetings] / src / BusinessLogic / Engine.cpp
index cc021ca..aac84d4 100644 (file)
@@ -32,6 +32,8 @@ Engine::Engine() :
                iWindowManager( 0 ), iUIManager( 0 )
 {
        qDebug() << "Engine::Engine()";
+       iCommunicationFailed = false;
+       iCurrentWeekFetched = false;
        
        initConfiguration();
        initDevice();
@@ -107,7 +109,7 @@ void Engine::checkStatusOfAllRooms()
        for (int i = 0; i < iConfiguration->rooms().count(); i++)
        {
                // and check the status
-               roomStatusInfoNeeded(iConfiguration->rooms().at(i) );
+               roomStatusInfoNeeded( iConfiguration->rooms().at(i) );
        }
 }
 
@@ -179,8 +181,16 @@ void Engine::fetchMeetingDetails( Meeting *aMeeting )
 void Engine::meetingsFetched( const QList<Meeting*> &aMeetings )
 {
        qDebug() << "Engine::meetingsFetched( const QList<Meeting*> & )";
-       
-       for ( int i = 0; i < iMeetings.count(); ++i ) {
+       // TODO: should check if this week's meetings were fetched
+       if( iCommunicationFailed || !iCurrentWeekFetched )
+       {
+               iCurrentWeekFetched = true;
+               iCommunicationFailed = false;
+               iUIManager->connectionEstablished();
+       }
+
+       for ( int i = 0; i < iMeetings.count(); ++i ) 
+       {
                Meeting* m = iMeetings.takeAt( i );
                delete m;
        }
@@ -196,6 +206,11 @@ void Engine::meetingsFetched( const QList<Meeting*> &aMeetings )
 
 void Engine::errorHandler( int aCode, const QString &aAddInfo )
 {      
+       if( aCode >= 100 && aCode < 150 )
+       {
+               iCommunicationFailed = true;
+               if ( iUIManager != 0 ) iUIManager->connectionLost();
+       }
        if ( iWindowManager != 0 )
        {
                iWindowManager->error( ErrorMapper::codeToString( aCode, aAddInfo ) );
@@ -354,4 +369,4 @@ void Engine::currentRoomChanged(Room *aRoom)
        qDebug() << "[Engine::currentRoomChanged] <invoked>";
        iCurrentRoom = aRoom;
        roomStatusInfoNeeded( iCurrentRoom );
-}
\ No newline at end of file
+}