Operation mode changing related defects corrected.
authorJan Lapinkataja <jan.lapinkataja@ixonos.com>
Fri, 29 May 2009 10:04:46 +0000 (13:04 +0300)
committerJan Lapinkataja <jan.lapinkataja@ixonos.com>
Fri, 29 May 2009 10:04:46 +0000 (13:04 +0300)
src/BusinessLogic/Engine.cpp
src/BusinessLogic/Engine.h
src/BusinessLogic/UIManager.cpp
src/IO/DeviceControl/DeviceConfigurator.cpp
src/IO/DeviceControl/DeviceManager.cpp
src/IO/DeviceControl/DeviceManager.h
src/IO/DeviceControl/OperationModeToggler.cpp
src/UserInterface/Utils/PasswordDialog.cpp
src/UserInterface/Utils/ProgressBar.cpp
src/UserInterface/Views/RoomStatusIndicatorWidget.cpp
src/UserInterface/Views/RoomStatusIndicatorWidget.h

index 5499005..a31a963 100644 (file)
@@ -16,7 +16,7 @@
 #include <QtDebug>
 
 QTime Engine::endOfTheDay = QTime( 23, 59, 0, 0); // end of the day is 11:59pm
-const int IDLE_TIME_MULTIPLIER = 5000; // Multiplies milliseconds to minutes
+const int IDLE_TIME_MULTIPLIER = 60000; // Multiplies milliseconds to minutes
 
 // Macro to help deleting objects. This could be global.
 #define QT_DELETE(X) \
@@ -164,15 +164,31 @@ void Engine::roomStatusInfoNeeded(Room *aRoom)
        ( ( indexOfNextMeeting != -1 ) ? iMeetings.at( indexOfNextMeeting )->startsAt().time() : Engine::endOfTheDay );
 
        //currently works only for deafult room
-       if ( aRoom->equals( *(iCurrentRoom) ) )
-       {
-               emit roomStatusChanged( status, until );
-       }
+//     if( aRoom->equals( *(defaultRoom() ) ) )
+//             iWindowManager->roomStatusChanged( aRoom, status, until );
+}
+
+/*
+void Engine::fetchMeetings()
+{
+       qDebug() << "Engine::fetchMeetings for " << iCurrentRoom;
+       QDateTime from( iWindowManager->weeklyView()->beginnigOfShownWeek() );
+       QDateTime to( from.addDays( 7 ) );
+       // fetchMeetings( from, to, iWindowManager->weeklyView()->currentRoom() );
+       // Signal is connected to the currentRoomChanged slot which keeps the iCurrentRoom up to date
+       fetchMeetings( from, to, iCurrentRoom );
 }
+*/
 
 void Engine::fetchMeetingDetails( Meeting *aMeeting )
 {
        qDebug() << "Engine::fetchMeetingDetails( Meeting* )";
+/*     iWindowManager->showProgressBar(tr("Please Wait"), true);
+       iWindowManager->updateProgressBar(tr("Fetching Meeting Details...") );
+       connect(iWindowManager, 
+       SIGNAL( progressBarCancelled() ), this, 
+       SLOT( fetchMeetingDetailsCancelled() ));
+       iCommunication->fetchMeetingDetails( *aMeeting); */
        iCommunication->fetchMeetingDetails( *aMeeting );
 }
 
@@ -224,20 +240,16 @@ void Engine::shownWeekChanged( QDate aFrom )
 //     fetchMeetings( from, to, iWindowManager->weeklyView()->currentRoom() );
 }
 
-void Engine::changeDeviceMode( bool aChange )
+void Engine::changeDeviceMode()
 {
-       if ( aChange )
-       {
-               connect( iDevice, SIGNAL( changingModeFailed() ), this, SLOT( changeModeFailed() ) );
-               iAutoRefresh->stop(); // Stop the meeting update
-       }
-       iDevice->changeMode( aChange );
+       connect( iDevice, SIGNAL( changeModeFailed() ), this, SLOT( changeModeFailed() ) );
+       iAutoRefresh->stop(); // Stop the meeting update
+       iDevice->changeMode();
 }
 
 void Engine::changeModeFailed()
 {
        qDebug() << "Engine::progressBarCancelled()";
-       iDevice->changeMode( false );
        iAutoRefresh->start(); //we start the metting updating
 }
 
@@ -253,7 +265,7 @@ void Engine::initUserInterface()
        connect( iWindowManager, SIGNAL( eventDetected() ), this, SLOT( handleViewEvent() ) );
        connect( iWindowManager, SIGNAL( previousViewRestored() ), iUIManager, SLOT( previousViewRestored() ) );
 //     connect( iWindowManager, SIGNAL( dialogActivated() ), this, SLOT( dialogActivated() ) );
-       connect( iWindowManager, SIGNAL( dialogDeactivated() ), this, SLOT( dialogDeactivated() ) );
+//     connect( iWindowManager, SIGNAL( dialogDeactivated() ), this, SLOT( dialogDeactivated() ) );
        
        // Show the UI
        iWindowManager->setWindowState( Qt::WindowMaximized );
@@ -358,4 +370,4 @@ void Engine::currentRoomChanged(Room *aRoom)
 {
        qDebug() << "[Engine::currentRoomChanged] <invoked>";
        iCurrentRoom = aRoom;
-}
+}
\ No newline at end of file
index b6bd8dd..dc538ec 100644 (file)
@@ -17,10 +17,8 @@ class UIManager;
 
 //! BusinessLogic class. Contains all the business logic of the application.
 /*!
- * BusinessLogic class. Contains all the business logic of the application. This class handles
- * the logic of the application according received calls to the slots. This class also maintains
- * the instances of managers, timers and its own set of meeting list. The managers handles
- * their tasks in more detailed manner.
+ * BusinessLogic class. Contains all the business logic of the application. It is responsible
+ * for connecting user interface to lower application layers (IO).
  */
 class Engine : public QObject
 {
@@ -43,8 +41,6 @@ public:
 
 signals:
 
-       void roomStatusChanged( Room::Status aStatus, QTime aUntil );
-
 private slots:
        //! Slot. Closes the application.
        /*!
@@ -71,6 +67,12 @@ private slots:
         * \param aAddInfo Possible addition info.
         */
        void errorHandler( int aCode, const QString &aAddInfo = "" );
+       //! Slot. Fetches meetings from the server.
+       /*!
+        * Slot. Fetches meetings from the server. Parameters are hard coded: the meetings of the default
+        * room from current and +/- 2 weeks are fetched.
+        */
+//     void fetchMeetings();
        //! Slot. Saves fetched meetings to the current instance's local storage.
        /*!
         * Slot. Saves fetched meetings to the current instance's local storage. Meetings are soted in a
@@ -118,7 +120,7 @@ private slots:
        void stopIdleTimeCounter();
        void startIdleTimeCounter();
 
-       void changeDeviceMode( bool aChange );
+       void changeDeviceMode();
        
        void currentRoomChanged( Room *aRoom );
        
index 517a715..ab3d93e 100644 (file)
@@ -89,11 +89,7 @@ void UIManager::createSettingsView()
 
 void UIManager::createRoomStatusIndicator()
 {
-       iRoomStatusIndicator = new RoomStatusIndicatorWidget( iEngine->defaultRoom(), Room::FreeStatus, QTime::currentTime().addSecs(100000000), iEngine->iConfiguration->displaySettings()->timeFormat() );
-       
-       // Connect engine signals
-       connect( iEngine, SIGNAL( roomStatusChanged( Room::Status, QTime ) ), iRoomStatusIndicator, SLOT( statusChanged( Room::Status, QTime ) ) );
-       connect( iWeeklyView, SIGNAL( currentRoomChanged( Room * ) ), iRoomStatusIndicator, SLOT( currentRoomChanged( Room * ) ) );
+       iRoomStatusIndicator = new RoomStatusIndicatorWidget( iEngine->defaultRoom(), Room::FreeStatus, QTime::currentTime(), iEngine->iConfiguration->displaySettings()->dateFormat() );
 }
 
 void UIManager::createPasswordDialog()
@@ -105,7 +101,6 @@ void UIManager::createPasswordDialog()
 void UIManager::createProgressBar()
 {
        iProgressBar = new ProgressBar( tr("CHANGE THIS"), true );
-       
        // Connect to UIManager
        connect( iProgressBar, SIGNAL( cancel() ), this, SLOT( progressBarCancelled() ) );
        // Connect to Engine
@@ -183,10 +178,8 @@ void UIManager::meetingDetailsFetched(Meeting &aDetailedMeeting)
                {
                        iProgressBar->close(); // Close it in case it's visible
                }
-               iEngine->stopIdleTimeCounter(); // Timer restarted when the dialog is dismissed.
                MeetingInfoDialog *tmp = new MeetingInfoDialog( &aDetailedMeeting );
                iWindowManager->showDialog( static_cast<QDialog *>( tmp ) );
-               
 // TODO : We should use the member variable and implement correctly the setMeeting() method !!!
 //             iMeetingInfo->setMeeting( &aDetailedMeeting );
 //             iWindowManager->showDialog( static_cast<QDialog *>( iMeetingInfo ) );
@@ -246,10 +239,6 @@ void UIManager::updateTime(QDateTime aDateTime)
        {
                iWeeklyView->setCurrentDateTime( aDateTime );
        }
-       if ( iRoomStatusIndicator != 0 )
-       {
-               iRoomStatusIndicator->setCurrentTime( aDateTime.time() );
-       }
 }
 
 void UIManager::passwordEntered( PasswordDialog::PasswordStatus aStatus )
@@ -265,12 +254,12 @@ void UIManager::passwordEntered( PasswordDialog::PasswordStatus aStatus )
                                iWindowManager->showDialog( static_cast<QDialog *>( iProgressBar ), false );
                        }
                        // ... and initiate the mode changing
-                       iEngine->changeDeviceMode( true );
+                       iEngine->changeDeviceMode();
                        break;
                case PasswordDialog::Incorrect:
                        iWindowManager->error( tr("Incorrect Password") );
+                       break;
                case PasswordDialog::Canceled:
-                       iEngine->changeDeviceMode( false );
                        break;
        }
        
index 76e17ce..4ac495e 100644 (file)
@@ -19,6 +19,8 @@ DeviceConfigurator::~DeviceConfigurator()
 bool DeviceConfigurator::toggleScreenSwitchOff( bool aEnable )
 {      
        qDebug() << "DeviceConfigurator::toggleScreenSwitchOff( bool )";
+       emit configuringError( DeviceManager::ScreenSettingsNotChanged );
+       return false;
        QString command = "gconftool-2";
        QStringList args;
        QByteArray result;
index 2180083..518a7d3 100644 (file)
@@ -9,7 +9,13 @@
 #include <QtDebug>
 #include <QStringList>
 
-DeviceManager::DeviceManager( StartupSettings *aSettings )
+DeviceManager::DeviceManager( StartupSettings *aSettings ) :
+       iAlarmSender( 0 ),
+       iHWKeyListener( 0 ),
+       iSettings( 0 ),
+       iDataStorage( 0 ),
+       iConfigurator( 0 ),
+       iModeToggler( 0 )
 {
        qDebug() << "DeviceManager::DeviceManager( StartupSettings * )";
 
@@ -35,6 +41,9 @@ DeviceManager::~DeviceManager()
 void DeviceManager::initDeviceManager()
 {
        qDebug() << "DeviceManager::init()";
+       
+       qRegisterMetaType<DeviceManager::ErrorCode>("DeviceManager::ErrorCode");
+       
        iDataStorage = new DeviceDataStorage();
        connect( iDataStorage, SIGNAL( dataStorageInitFailed( DeviceManager::ErrorCode ) ),
                        this, SLOT( errorSender( DeviceManager::ErrorCode ) ) );
@@ -51,9 +60,7 @@ void DeviceManager::initDeviceManager()
                iMode = EmptyMode;
 
        iHWKeyListener = new HWKeyListener();
-       connect( iHWKeyListener, SIGNAL( HWKeyFullScreenPressed() ), this, SLOT( HWKeyFullScreenPressed() ) );
-       //handleKeyPresses( true );
-       iIgnoreHWKeyPresses = false;
+       handleHWKeyPresses( true );
 }
 
 DeviceManager::OperationMode DeviceManager::currentOperationMode()
@@ -74,21 +81,18 @@ QString DeviceManager::operationModeToString( OperationMode aMode )
        }
 }
 
-void DeviceManager::changeMode( bool aChange )
+void DeviceManager::changeMode()
 {
        qDebug() << "void DeviceManager::changeMode()";
-       if( !aChange ) {
-               //handleKeyPresses( true );
-               iIgnoreHWKeyPresses = false;
-               return;
+       if( iModeToggler == 0 ) {
+               iModeToggler = new OperationModeToggler( iMode, iSettings, iAlarmSender, iConfigurator, iDataStorage );
+               connect( iModeToggler, SIGNAL( finished() ), this, SLOT( modeChanged() ) );
+               connect( iModeToggler, SIGNAL( error( DeviceManager::ErrorCode, const QString & ) ),
+                               this, SLOT( errorSender( DeviceManager::ErrorCode, const QString & ) ) );
+               connect( iModeToggler, SIGNAL( changingMode( const QString & ) ), this, SIGNAL( changingMode( const QString & ) ) );
+               connect( iModeToggler, SIGNAL( toggleErrorSending( bool ) ), this, SLOT( toggleErrorSending( bool ) ) );
+               iModeToggler->start();
        }
-       iModeToggler = new OperationModeToggler( iMode, iSettings, iAlarmSender, iConfigurator, iDataStorage );
-       connect( iModeToggler, SIGNAL( finished() ), this, SLOT( modeChanged() ) );
-       connect( iModeToggler, SIGNAL( error( DeviceManager::ErrorCode, const QString & ) ),
-                       this, SLOT( errorSender( DeviceManager::ErrorCode, const QString & ) ) );
-       connect( iModeToggler, SIGNAL( changingMode( const QString & ) ), this, SIGNAL( changingMode( const QString & ) ) );
-       connect( iModeToggler, SIGNAL( toggleErrorSending( bool ) ), this, SLOT( toggleErrorSending( bool ) ) );
-       iModeToggler->start();
 }
 
 bool DeviceManager::setCurrentOperationMode()
@@ -129,41 +133,26 @@ bool DeviceManager::finalizeStandAloneMode()
        return true;
 }
 
-void DeviceManager::handleKeyPresses( bool aHandle )
-{
-       qDebug() << "DeviceManager::handleKeyPresses( bool )";
-       if ( !aHandle )
-               disconnect( iHWKeyListener, SIGNAL( HWKeyFullScreenPressed() ), this, SLOT( HWKeyFullScreenPressed() ) );
-       else
-               connect( iHWKeyListener, SIGNAL( HWKeyFullScreenPressed() ), this, SLOT( HWKeyFullScreenPressed() ) );
-}
-
 void DeviceManager::HWKeyFullScreenPressed()
 {
        qDebug() << "DeviceManager::HWKeyFullScreenPressed()";
-       
+       handleHWKeyPresses( false );
        // no more key presses before this one is handled
        //handleKeyPresses( false );
-       if( !iIgnoreHWKeyPresses ) {
-               iIgnoreHWKeyPresses = true;
-               OperationMode nextMode;
-               switch ( iMode )
-               {
-                       case KioskMode:
-                               nextMode = StandAloneMode;
-                               break;
-                       case StandAloneMode:
-                               nextMode = KioskMode;
-                               break;
-                       default:
-                               nextMode = EmptyMode;
-                               break;
-               }
-               if ( nextMode != EmptyMode )
-                       emit changeModeOrdered( nextMode );
-               else
-                       iIgnoreHWKeyPresses = false;
+       OperationMode nextMode;
+       switch ( iMode ) {
+               case KioskMode:
+                       nextMode = StandAloneMode;
+                       break;
+               case StandAloneMode:
+                       nextMode = KioskMode;
+                       break;
+               default:
+                       nextMode = EmptyMode;
+                       break;
        }
+       if ( nextMode != EmptyMode )
+               emit changeModeOrdered( nextMode );
 }
 
 void DeviceManager::errorSender( DeviceManager::ErrorCode aErrorCode, const QString &aAddInfo )
@@ -186,14 +175,24 @@ void DeviceManager::modeChanged()
 {
        qDebug() << "DeviceManager::modeChanged()";
        if( iModeToggler != 0 ) {
-               if ( iModeToggler->success() ) //mode changing went well
+               if ( iModeToggler->success() ) {//mode changing went well
+                       emit changingMode( "Restarting device" );
+                       sleep( 2 );
                        iConfigurator->restartDevice();
+               }
                else
                        emit changeModeFailed();
                delete iModeToggler;
                iModeToggler = 0;
        }
-       
-       //in case device restarting fails we just continue
-       iIgnoreHWKeyPresses = false;
+       handleHWKeyPresses( true );
+}
+
+void DeviceManager::handleHWKeyPresses( bool aToggle )
+{
+       qDebug() << "DeviceManager::handleHWKeyPresses( bool )";
+       if( aToggle )
+               connect( iHWKeyListener, SIGNAL( HWKeyFullScreenPressed() ), this, SLOT( HWKeyFullScreenPressed() ) );
+       else
+               disconnect( iHWKeyListener, SIGNAL( HWKeyFullScreenPressed() ), this, SLOT( HWKeyFullScreenPressed() ) );
 }
index d6d4d41..2c7531a 100644 (file)
@@ -90,9 +90,9 @@ public:
        //! Changes the operation mode.
        /*!
         * Changes the operation mode.
-        * \param aChange To indicate if the mode should be changed or not
         */
-       void changeMode( bool aChange );
+       void changeMode();
+       void handleHWKeyPresses( bool aToggle );
 
 signals:
        //! Signal. Emitted if user tries to change the operation mode.
@@ -164,13 +164,6 @@ private:
         * \return True if operation mode storing and deactivation of the init script succeed; otherwise, false.
         */
        bool finalizeStandAloneMode();
-       //! Connects/disconnects the HWKeyListener signals to the private HWKeyFullScreenPressed() slot.
-       /*!
-        * Connects/disconnects the HWKeyListener signals to the private HWKeyFullScreenPressed() slot. In case
-        * a signal is caught the connection is disabled until the signal handling is finished.
-        * \param aHandle indicates if the signals should be connected or not.
-        */
-       void handleKeyPresses( bool aHandle );
 
 private:
        AlarmSender *iAlarmSender;
@@ -182,7 +175,6 @@ private:
 
        OperationMode iMode;
        bool iSendErrorMessages;
-       bool iIgnoreHWKeyPresses;
 
 };
 
index cfa5d5d..14f13aa 100644 (file)
@@ -22,15 +22,6 @@ OperationModeToggler::OperationModeToggler(
        iSuccess( true )
 {
        qDebug() << "OperationModeToggler::OperationModeToggler( ... )";
-       
-       qRegisterMetaType<DeviceManager::ErrorCode>("DeviceManager::ErrorCode");
-       
-       connect( iAlarmSender, SIGNAL( alarmSendingFailed( DeviceManager::ErrorCode, const QString& ) ),
-                       this, SIGNAL( error( DeviceManager::ErrorCode, const QString& ) ) );
-       connect( iConfigurator, SIGNAL( configuringError( DeviceManager::ErrorCode ) ),
-                       this, SLOT( createError( DeviceManager::ErrorCode ) ) );
-       connect( iDataStorage, SIGNAL( dataStorageInitFailed( DeviceManager::ErrorCode ) ),
-                       this, SLOT( createError( DeviceManager::ErrorCode ) ) );
 }
 
 OperationModeToggler::~OperationModeToggler()
@@ -58,6 +49,7 @@ void OperationModeToggler::run()
                                if ( !iAlarmSender->sendAlarms( iSettings->turnOnAt(), iSettings->turnOffAt() ) )
                                {
                                        iSuccess = false;
+                                       emit changingMode( "Rolling back changes..." );
                                        return; //this is critical so returning if no success
                                }
                        }
@@ -95,6 +87,7 @@ void OperationModeToggler::run()
                                // we have to roll back if something fails
                                // of course rolling back may fail as well but it is impossible to catch
                                emit toggleErrorSending( false );
+                               emit changingMode( "Rolling back changes..." );
                                iAlarmSender->removeAlarms();
                                iConfigurator->toggleHWKeys( true );
                                iConfigurator->toggleInitScript( false );
@@ -139,6 +132,7 @@ void OperationModeToggler::run()
                                // we have to roll back if something fails
                                // of course rolling back may fail as well but it is impossible to catch
                                emit toggleErrorSending( false );
+                               emit changingMode( "Rolling back changes..." );
                                iConfigurator->toggleHWKeys( false );
                                iConfigurator->toggleInitScript( true );
                                iConfigurator->toggleScreenSwitchOff( false );
index 9041ecf..064c7d3 100644 (file)
@@ -48,8 +48,8 @@ PasswordDialog::PasswordDialog( const QString &aPassword, const QString &aText,
        layout->addLayout( buttonLayout );
 
        // Connect the user action signals to corresponding slots
-       connect( buttonOK, SIGNAL( pressed() ), this, SLOT( okButtonPressed() ) );
-       connect( buttonCancel, SIGNAL( pressed() ), this, SLOT( cancelButtonPressed() ) );
+       connect( buttonOK, SIGNAL( released() ), this, SLOT( okButtonPressed() ) );
+       connect( buttonCancel, SIGNAL( released() ), this, SLOT( cancelButtonPressed() ) );
 
        // Enable the layout
        setLayout( layout );
index 198fb65..dd9f94f 100755 (executable)
@@ -13,6 +13,7 @@ ProgressBar::ProgressBar( const QString &aTitle, bool aCancellable, QWidget *aPa
 {
        qDebug() << "ProgressBar::ProgressBar( const QString &, bool, QWidget *)";
        setWindowTitle( aTitle );
+       
        setModal( true );
 
        iProgress = new QProgressBar();
index 694663e..c903bc0 100644 (file)
@@ -13,7 +13,6 @@ QTime RoomStatusIndicatorWidget::endOfTheDay = QTime( 23, 59, 0, 0 );
 RoomStatusIndicatorWidget::RoomStatusIndicatorWidget( Room *aDefaultRoom, Room::Status aStatus, QTime aUntil, QString aTimeFormat, QWidget *aParent ) :\r
                ViewBase( ViewBase::ObservedView, aParent ), iTimeFormat( aTimeFormat )\r
 {\r
-       \r
        QFont importantTextFont;\r
        //importantTextFont.setBold( true );\r
        importantTextFont.setPointSize( 20 );\r
@@ -119,8 +118,3 @@ void RoomStatusIndicatorWidget::statusChanged( const Room::Status aStatus, const
        }\r
        setPalette( createPalette( aStatus ) );\r
 }\r
-\r
-void RoomStatusIndicatorWidget::currentRoomChanged( Room *aRoom )\r
-{\r
-       iDefaultRoomLabel->setText( aRoom->name() );\r
-}\r
index 47c73fa..c20ce45 100644 (file)
@@ -55,12 +55,6 @@ public slots:
         * \param aUntil The new time until the specified status is valid.\r
         */\r
        void statusChanged( const Room::Status aStatus, const QTime aUntil );\r
-       //! Changed the current room.\r
-       /*!\r
-        * This slot is used to inform that current room is changed and it changes\r
-        * the room name label.\r
-        */\r
-       void currentRoomChanged( Room *aRoom );\r
        \r
        void viewResized(const QSize &newSize, const QSize &oldSize) { }\r
 \r