ProgressBar connections modified + Progress Bar class itself updated
[qtmeetings] / src / BusinessLogic / Engine.cpp
index e529799..2f9d3cd 100644 (file)
@@ -21,6 +21,7 @@ const int IDLE_TIME_MULTIPLIER = 60000; // Multiplies milliseconds to minutes
 Engine::Engine() :
                iClock( 0 ), iConfiguration( Configuration::instance() ), iCommunication( 0 )
 {
+       qDebug() << "Engine::Engine()";
        // if reading of configuration fails, signal that initialization failed
        if ( iConfiguration == 0 )
        {
@@ -37,7 +38,7 @@ Engine::Engine() :
        connect( iWindowManager, SIGNAL( shownWeekChanged( QDate ) ), this, SLOT( shownWeekChanged( QDate ) ) );
        connect( iWindowManager, SIGNAL( passwordEntered( PasswordDialog::PasswordStatus ) ),
                        this, SLOT( passwordEntered( PasswordDialog::PasswordStatus ) ) );
-       connect( iWindowManager, SIGNAL( progressBarCancelled() ), this, SLOT( progressBarCancelled() ) );
+
        
        // initialize communication
        iCommunication = new CommunicationManager( *(iConfiguration->connectionSettings()) );
@@ -83,6 +84,7 @@ Engine::Engine() :
 
 Engine::~Engine()
 {
+       qDebug() << "Engine::~Engine()";
        while ( !iMeetings.isEmpty() )
                delete iMeetings.takeFirst();
        iIdleTimeCounter->stop();
@@ -105,6 +107,7 @@ void Engine::closeApplication()
 
 void Engine::observedEventDetected()
 {
+       qDebug() << "Engine::observedEventDetected()";
        iWindowManager->showWeeklyView();
        // prepare to restart idle counter
        if ( iIdleTimeCounter->isActive() )
@@ -117,11 +120,13 @@ void Engine::observedEventDetected()
 
 Room* Engine::defaultRoom()
 {
+       qDebug() << "Engine::defaultRoom()";
        return iConfiguration->defaultRoom();
 }
 
 void Engine::checkStatusOfAllRooms()
 {
+       qDebug() << "Engine::checkStatusOfAllRooms()";
        // iterate trough on the rooms
        for ( int i = 0; i < iConfiguration->rooms().count(); i++ )
        {
@@ -132,6 +137,7 @@ void Engine::checkStatusOfAllRooms()
 
 int Engine::indexOfMeetingAt( Room *aRoom, QDateTime aAt )
 {
+       qDebug() << "Engine::indexOfMeetingAt( Room *, QDateTime )";
        for ( int i = 0; i < iMeetings.count(); i++ )
        {
                // exchange server ensures that there is only one meeting in a room at a specified time
@@ -147,6 +153,7 @@ int Engine::indexOfMeetingAt( Room *aRoom, QDateTime aAt )
 
 int Engine::indexOfMeetingAfter( Room *aRoom, QDateTime aAfter )
 {
+       qDebug() << "Engine::indexOfMeetingAfter( Room *, QDateTime )";
        // seeks for the next meeting on the SAME DAY
        int min = -1;
        for ( int i = 0; i < iMeetings.count(); i++ )
@@ -169,6 +176,7 @@ int Engine::indexOfMeetingAfter( Room *aRoom, QDateTime aAfter )
 
 void Engine::roomStatusInfoNeeded( Room *aRoom )
 {
+       qDebug() << "Engine::roomStatusInfoNeeded( Room * )";
        if ( aRoom == 0 )
        {
                return;
@@ -198,11 +206,13 @@ void Engine::fetchMeetings()
 
 void Engine::fetchMeetingDetails( Meeting *aMeeting )
 {
+       qDebug() << "Engine::fetchMeetingDetails( Meeting* )";
        iCommunication->fetchMeetingDetails( *aMeeting );
 }
 
 bool Engine::isMeetingInList( const QList<Meeting*> &aList, const Meeting *aMeeting )
 {
+       qDebug() << "Engine::isMeetingInList( const QList<Meeting*> &, const Meeting * )";
        for ( int i = 0; i < aList.count(); i++ )
        {
                if ( aMeeting->equals( *(aList.at( i )) ) )
@@ -215,6 +225,7 @@ bool Engine::isMeetingInList( const QList<Meeting*> &aList, const Meeting *aMeet
 
 void Engine::meetingsFetched( const QList<Meeting*> &aMeetings )
 {
+       qDebug() << "Engine::meetingsFetched( const QList<Meeting*> & )";
        // check if there is any new meeting in the list came from the server -> added
        for ( int i = 0; i < aMeetings.count(); i++ )
        {
@@ -249,6 +260,7 @@ void Engine::meetingsFetched( const QList<Meeting*> &aMeetings )
 
 void Engine::meetingDetailsFetched( Meeting &aDetailedMeeting )
 {
+       qDebug() << "Engine::meetingDetailsFetched( Meeting & )";
        iWindowManager->showMeetingInfo( &aDetailedMeeting );
 }
 
@@ -271,12 +283,13 @@ void Engine::currentRoomChanged( Room *aCurrentRoom )
 
 void Engine::fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, const Room *aIn )
 {
-       qDebug() << "Engine::fetchMeetings";
+       qDebug() << "Engine::fetchMeetings( const QDateTime &, const QDateTime &, const Room * )";
        iCommunication->fetchMeetings( aFrom, aUntil, *aIn );
 }
 
 void Engine::shownWeekChanged( QDate aFrom )
 {
+       qDebug() << "Engine::shownWeekChanged( QDate )";
        QDateTime from( aFrom );
        QDateTime to( aFrom.addDays( 7 ), QTime( 23, 59 ) );
        qDebug() << "Engine::shownWeekChanged " << aFrom.toString( "d.m. h:mm" ) << " to " << to.toString( "d.m. h:mm" );
@@ -284,7 +297,8 @@ void Engine::shownWeekChanged( QDate aFrom )
 }
 
 void Engine::changeModeOrdered( DeviceManager::OperationMode aMode )
-{
+{      
+       qDebug() << "Engine::changeModeOrdered( DeviceManager::OperationMode )";
        QString message = tr( "You are about to change operation mode to %1." )
                                .arg( iDevice->operationModeToString( aMode ) );
        
@@ -301,24 +315,29 @@ void Engine::passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus )
                case PasswordDialog::Correct :
                {
                        iWindowManager->showProgressBar( "Changing current operation mode." );
+                       connect( iWindowManager, SIGNAL( progressBarCancelled() ), this, SLOT( progressBarCancelled() ) );
+                       connect( iDevice, SIGNAL( changingMode( const QString & ) ),
+                                       iWindowManager, SLOT( updateProgressBar( const QString & ) ) );
+                       iDevice->changeMode( true );
                        break;
                }
                case PasswordDialog::Incorrect :
                {
                        iWindowManager->error( tr( "Incorrect password." ) );
-                       iDevice->handleKeyPresses( true );
+                       iDevice->changeMode( false );
                        break;
                }
                default : //case PasswordDialog::Canceled
                {
-                       iDevice->handleKeyPresses( true );
+                       iDevice->changeMode( false );
                }
        }
 }
 
 void Engine::progressBarCancelled()
 {
+       qDebug() << "Engine::progressBarCancelled()";
        //TODO: cancel the on-going event
        iWindowManager->closeProgressBar();
-       iDevice->handleKeyPresses( true );
+       iDevice->changeMode( false );
 }