Merged
authorMikko Siren <mikko.siren@ixonos.com>
Tue, 26 May 2009 07:54:06 +0000 (10:54 +0300)
committerMikko Siren <mikko.siren@ixonos.com>
Tue, 26 May 2009 07:54:06 +0000 (10:54 +0300)
15 files changed:
QtMeetings.pro
resources/xml/errortable.xml
src/BusinessLogic/Engine.cpp
src/BusinessLogic/Engine.h
src/IO/Communication/CommunicationManager.cpp
src/IO/Communication/CommunicationManager.h
src/IO/DeviceControl/DeviceConfigurator.cpp
src/IO/DeviceControl/DeviceManager.cpp
src/IO/DeviceControl/DeviceManager.h
src/IO/DeviceControl/OperationModeToggler.cpp [new file with mode: 0644]
src/IO/DeviceControl/OperationModeToggler.h [new file with mode: 0644]
src/UserInterface/Components/ScheduleWidget.cpp
src/UserInterface/Utils/ProgressBar.cpp
src/UserInterface/WindowManager.cpp
src/UserInterface/WindowManager.h

index 85e43bd..3ec3197 100644 (file)
@@ -13,7 +13,8 @@ INCLUDEPATH += src/Domain/ \
     src/UserInterface/Components/ \
     src/UserInterface/Utils/ \
     src/UserInterface/Views/
-HEADERS += src/UserInterface/Utils/ProgressBar.h \
+HEADERS += src/IO/DeviceControl/OperationModeToggler.h \
+    src/UserInterface/Utils/ProgressBar.h \
     src/Domain/Room.h \
     src/Domain/Meeting.h \
     src/Domain/Configuration/ConnectionSettings.h \
@@ -45,7 +46,8 @@ HEADERS += src/UserInterface/Utils/ProgressBar.h \
     src/UserInterface/Views/SettingsView.h \
     src/UserInterface/WindowManager.h \
     src/UserInterface/Views/ViewBase.h
-SOURCES += src/UserInterface/Utils/ProgressBar.cpp \
+SOURCES += src/IO/DeviceControl/OperationModeToggler.cpp \
+    src/UserInterface/Utils/ProgressBar.cpp \
     src/Domain/Room.cpp \
     src/Domain/Meeting.cpp \
     src/Domain/Configuration/ConnectionSettings.cpp \
@@ -82,7 +84,6 @@ RESOURCES += resources/BusinessLogic.qrc \
     resources/UserInterface.qrc
 CONFIG += link_pkgconfig
 PKGCONFIG += libalarm
-
 //DEFINES += DEBUG_OUTPUT_TO_FILE
 executable.files = qtmeetings
 executable.path = /usr/bin/
index 4afbc58..2c5d424 100644 (file)
@@ -27,5 +27,5 @@
        <error code="210">Error storing data of original automatic screen switching-off and dimming parameter values. Using the default values instead.</error>
        <error code="211">Error fetching data of original automatic screen switching-off and dimming parameter values. Using the default values instead.</error>
        <error code="212">Failed to change the operation mode. Error changing automatic screen switching-off and dimming parameter values.</error>
-       <error code="213">Failed to change the operation mode. Error restarting the device.</error>
+       <error code="213">Failed to change the operation mode. Error restarting the device. Restart device manually.</error>
 </errors>
index 0b68a03..0c76679 100644 (file)
@@ -191,6 +191,13 @@ void Engine::fetchMeetings()
 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 );
 }
 
@@ -258,9 +265,10 @@ void Engine::errorHandler( int aCode, const QString &aAddInfo )
 {
        qDebug() << "Engine::ErrorHandler, aCode: " << aCode;
        // inform UI about the problem
-       if( aCode >= 100 && aCode <= 110 )
+       if( aCode >= 100 && aCode <= 150 )
                qDebug() << "CommunicationManager signaled an error:" << aCode;
-//     iWindowManager->error( ErrorMapper::codeToString( aCode, aAddInfo ) );
+       // iWindowManager->closeProgressBar();
+       // iWindowManager->error( ErrorMapper::codeToString( aCode, aAddInfo ) );
 }
 
 void Engine::currentRoomChanged( Room *aCurrentRoom )
@@ -309,6 +317,10 @@ void Engine::passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus )
 //                     connect( iWindowManager, SIGNAL( progressBarCancelled() ), this, SLOT( progressBarCancelled() ) );
 //                     connect( iDevice, SIGNAL( changingMode( const QString & ) ),
 //                                     iWindowManager, SLOT( updateProgressBar( const QString & ) ) );
+                       // TODO : Connect the signal directory to progress bar dialog which should be instance in engine
+//                     connect( iDevice, SIGNAL( changingMode( const QString & ) ),
+//                                     iWindowManager, SLOT( updateProgressBar( const QString & ) ) );
+                       connect( iDevice, SIGNAL( changingModeFailed() ), this, SLOT( progressBarCancelled() ) );
                        iDevice->changeMode( true );
                        break;
                }
@@ -467,4 +479,10 @@ void Engine::previousViewRestored()
        {
                iIdleTimeCounter->start();
        }
-}
\ No newline at end of file
+}
+
+void Engine::fetchMeetingDetailsCancelled()
+{
+       iCommunication->cancelFetchMeetingDetails();
+       iWindowManager->closeProgressBar();
+}
index 4695738..70afcbc 100644 (file)
@@ -13,7 +13,6 @@ class Clock;
 class Configuration;
 class CommunicationManager;
 class Meeting;
-// class DeviceManager;
 class WeeklyViewWidget;
 class SettingsView;
 class RoomStatusIndicatorWidget;
@@ -127,6 +126,11 @@ private slots:
         * Slot. Receives the cancel event of the progress bar.
         */
        void progressBarCancelled();
+       //! Slot for receiving the cancel event of the progress bar.
+       /*!
+        *  Receives the cancel event of the progress bar when meeting details requested.
+        */
+       void fetchMeetingDetailsCancelled();
        
        void handleViewEvent();
        void previousViewRestored();
index 0a2ce77..8174ef7 100644 (file)
@@ -91,6 +91,17 @@ void CommunicationManager::fetchMeetingDetails( Meeting& aMeeting )
        }
 }
 
+void CommunicationManager::cancelFetchMeetingDetails()
+{
+       const RequestData *rd = NULL;
+       for( rd = findRequest( GetCalendarItem );rd != NULL; )
+       {
+               int id =  rd->requestId;
+               iCancelledRequests.append( id );
+               rd = findRequest( GetCalendarItem );
+       }
+}
+
 void CommunicationManager::getMeetingDetails( Meeting &aMeeting )
 {
        ReqMsgGetCalendarItem msg( aMeeting.secondaryId() );
@@ -109,6 +120,12 @@ void CommunicationManager::getMeetingDetails( Meeting &aMeeting )
 void CommunicationManager::requestFinished( int aRequestId, int aError )
 {
        RequestData* rd = takeRequest( aRequestId );
+       if( iCancelledRequests.contains( rd->requestId ) )
+       {
+               iCancelledRequests.removeAll( rd->requestId );
+               delete rd;
+               return;
+       }
        QByteArray* response = iFetchingCommunication->response( aRequestId );
        qDebug() << "CommunicationManager::requestFinished: id: " << aRequestId << " error: " << aError;
 
index a8d8185..6307c28 100644 (file)
@@ -51,6 +51,8 @@ public:
         *  \param aMeeting A meeting the detailed information is wanted.
        */
        void fetchMeetingDetails( Meeting &aMeeting );
+       //! Cancels all meeting detail requests.
+       void cancelFetchMeetingDetails();
 /* Not supported member functions which are using the modifying communication
        void setModifyCredentials( const QString &aUsername, const QString &aPassword ) {};
        void createMeeting( const Meeting &aMeeting ) {};
@@ -164,6 +166,8 @@ private:
        QList<Meeting*> iMeetings;
        //! Additional information about requests made to the Exchange server
        QList<RequestData*> iRequestInfos;
+       //! A flag that all meeting detail requests has been cancelled
+       QList<int> iCancelledRequests;
 };
 
 #endif /*COMMUNICATIONMANAGER_H_*/
index 4fa515e..76e17ce 100644 (file)
@@ -17,7 +17,7 @@ DeviceConfigurator::~DeviceConfigurator()
 }
 
 bool DeviceConfigurator::toggleScreenSwitchOff( bool aEnable )
-{
+{      
        qDebug() << "DeviceConfigurator::toggleScreenSwitchOff( bool )";
        QString command = "gconftool-2";
        QStringList args;
index c38647c..6c6eb27 100644 (file)
@@ -4,6 +4,7 @@
 #include "StartupSettings.h"
 #include "DeviceDataStorage.h"
 #include "DeviceConfigurator.h"
+#include "OperationModeToggler.h"
 
 #include <QtDebug>
 #include <QStringList>
@@ -19,6 +20,16 @@ DeviceManager::DeviceManager( StartupSettings *aSettings )
 DeviceManager::~DeviceManager()
 {
        qDebug() << "DeviceManager::~DeviceManager()";
+       delete iDataStorage;
+       iDataStorage = 0;
+       delete iAlarmSender;
+       iAlarmSender = 0;
+       delete iConfigurator;
+       iConfigurator = 0;
+       delete iDataStorage;
+       iDataStorage = 0;
+       delete iHWKeyListener;
+       iHWKeyListener = 0;
 }
 
 void DeviceManager::initDeviceManager()
@@ -68,83 +79,12 @@ void DeviceManager::changeMode( bool aChange )
                handleKeyPresses( true );
                return;
        }
-       
-       switch ( iMode )
-       {
-               case EmptyMode:
-                       // error occured. Mode cannot be changed
-                       errorSender( ModeNotFetched );
-                       handleKeyPresses( true );
-                       break;
-               case StandAloneMode:
-
-                       // change to KioskMode
-                       emit changingMode( "Changing to Kiosk mode" );
-                       while( 1 );
-
-                       // check if auto turn on/off functionality enabled and send turn on/off alarm events to alarm daemon
-                       if ( iSettings->isPowersavingEnabled() )
-                       {
-                               if ( !iAlarmSender->sendAlarms( iSettings->turnOnAt(), iSettings->turnOffAt() ) )
-                               {
-                                       handleKeyPresses( true );
-                                       return; //this is critical so returning if no success
-                               }
-                       }
-
-                       // - disable the certain hw keys (only "home"-hw-key at the moment)
-                       // - register init script to launch the application when ever the device is launched
-                       // - disable the screen "auto-switch-off" and "dimming"
-                       // - store info about the new operation mode
-                       if ( !iConfigurator->toggleHWKeys( false ) ||
-                                 !iConfigurator->toggleInitScript( true ) ||
-                                 !iConfigurator->toggleScreenSwitchOff( false ) ||
-                                 !this->storeOperationMode( KioskMode ) ||
-                                 !iConfigurator->restartDevice() )
-                       {
-
-                               // we have to roll back if something fails
-                               // of course rolling back may fail as well but it is impossible to catch
-                               iSendErrorMessages = false;
-                               iAlarmSender->removeAlarms();
-                               iConfigurator->toggleHWKeys( true );
-                               iConfigurator->toggleInitScript( false );
-                               iConfigurator->toggleScreenSwitchOff( true );
-                               iSendErrorMessages = true;
-                               handleKeyPresses( true );
-                               return;
-                       }
-                       break;
-
-               case KioskMode:
-                       // change to StandAloneInProgress mode
-
-                       // - enable the certain hw keys (only "home"-hw-key at the moment)
-                       // - unregister the init script
-                       // - enable the screen "auto-switch-off" and "dimming"
-                       // - store info about the new operation mode
-                       if (    !iConfigurator->toggleHWKeys( true ) ||
-                                 !iConfigurator->toggleScreenSwitchOff( true ) ||
-                                 !this->storeOperationMode( StandAloneModeInProgress ) ||
-                                 !iAlarmSender->removeStoredAlarms() ||
-                                 !iConfigurator->restartDevice() )
-                       {
-                               // we have to roll back if something fails
-                               // of course rolling back may fail as well but it is impossible to catch
-                               iSendErrorMessages = false;
-                               iConfigurator->toggleHWKeys( false );
-                               iConfigurator->toggleInitScript( true );
-                               iConfigurator->toggleScreenSwitchOff( false );
-                               this->storeOperationMode( KioskMode );
-                               iSendErrorMessages = true;
-                               handleKeyPresses( true );
-                               return;
-                       }
-
-                       break;
-               default: // StandAloneModeInProgress should never come in question
-                       break;
-       }
+       iModeToggler = new OperationModeToggler( iMode, iSettings, iAlarmSender, iConfigurator, iDataStorage );
+       connect( iModeToggler, SIGNAL( finished() ), this, SLOT( modeChanged() ) );
+       connect( iModeToggler, SIGNAL( error( DeviceManager::ErrorCode ) ), this, SLOT( errorSender( DeviceManager::ErrorCode ) ) );
+       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()
@@ -175,25 +115,13 @@ bool DeviceManager::setCurrentOperationMode()
        return true;
 }
 
-bool DeviceManager::storeOperationMode( OperationMode aMode )
-{
-       qDebug() << "DeviceManager::storeOperationMode( const OperationMode & )";
-       QStringList modeStrList;
-       QString str;
-       modeStrList.append( str.append( QString( "%1" ).arg( aMode ) ) );
-       if ( !iDataStorage->storeData( iDataStorage->dataSectionToString( DeviceDataStorage::DeviceMode ), modeStrList ) )
-       {
-               errorSender( ModeNotStored );
-               return false;
-       }
-       return true;
-}
-
 bool DeviceManager::finalizeStandAloneMode()
 {
        qDebug() << "DeviceManager::finalizeStandAloneMode()";
-       if ( !storeOperationMode( StandAloneMode ) || !iConfigurator->toggleInitScript( false ) )
+       if ( !OperationModeToggler::storeOperationMode( StandAloneMode, iDataStorage ) || !iConfigurator->toggleInitScript( false ) ) {
+               errorSender( DeviceManager::ModeNotStored );
                return false;
+       }
        return true;
 }
 
@@ -241,3 +169,23 @@ void DeviceManager::errorSender( DeviceManager::ErrorCode aErrorCode, const QStr
 
        emit error( ERROR_BASE + ( int )aErrorCode, aAddInfo ); 
 }
+
+void DeviceManager::toggleErrorSending( bool aToggle )
+{
+       iSendErrorMessages = aToggle;
+}
+
+void DeviceManager::modeChanged()
+{
+       if( iModeToggler != 0 ) {
+               if ( iModeToggler->success() ) //mode changing went well
+                       iConfigurator->restartDevice();
+               else
+                       emit changingModeFailed();
+               delete iModeToggler;
+               iModeToggler = 0;
+       }
+       
+       //in case device restarting fails we just continue
+       handleKeyPresses( true );
+}
\ No newline at end of file
index d318482..4d5aaa7 100644 (file)
@@ -9,6 +9,7 @@ class HWKeyListener;
 class StartupSettings;
 class DeviceDataStorage;
 class DeviceConfigurator;
+class OperationModeToggler;
 
 static const int ERROR_BASE=200;
 
@@ -105,8 +106,17 @@ signals:
         * \param aAddInfo Possible additional information.
         */
        void error( int aCode, const QString &aAddInfo );
-       
+       //! Signal. Emitted during the operation mode change to explain the current sub-change.
+       /*!
+        * Signal. Emitted during the operation mode change to explain the current sub-change. 
+        * \param aMessage Explains the sub-change
+        */
        void changingMode( const QString &aMessage );
+       //! Signal. Emitted if the operation mode change fails.
+       /*!
+        * Signal. Emitted if the operation mode change fails.
+        */
+       void changingModeFailed();
 
 private slots:
        //! Slot. Handles "full screen"-hardware key presses.
@@ -123,6 +133,18 @@ private slots:
         * \param aAddInfo The possible additional error text.
         */
        void errorSender( DeviceManager::ErrorCode aErrorCode, const QString &aAddInfo = "" );
+       //! Slot. Is called after the operation mode changing is finished.
+       /*!
+        * Slot. Is called after the operation mode changing is finished. If everything went fine, restarts
+        * the device. 
+        */
+       void modeChanged();
+       //! Slot. Toggles an attribute that indicates whether the errors should be sent.
+       /*!
+        * Slot. Toggles an attribute that indicates whether the errors should be sent.
+        * \param aToggle Indicates if the errors are wanted to be shown.
+        */
+       void toggleErrorSending( bool aToggle );
 
 private:
        //! Updates the internal indicator of the current operation mode.
@@ -133,14 +155,6 @@ private:
         * \return True if operation mode fetching succeeds; otherwise, false.
         */
        bool setCurrentOperationMode();
-       //! Stores the current operation mode.
-       /*!
-        * Stores the current operation mode by asking the DeviceDataStorage to write it to the internal
-        * data storage.
-        * \param aMode The operation mode that user wants to activate.
-        * \return True if operation mode storing succeeds; otherwise, false.
-        */
-       bool storeOperationMode( OperationMode aMode );
        //! Asks DeviceConfigurator to remove the deactivate script of the application.
        /*!
         * Asks DeviceConfigurator to remove the deactivate script of the application. Also asks
@@ -162,6 +176,7 @@ private:
        StartupSettings *iSettings;
        DeviceDataStorage *iDataStorage;
        DeviceConfigurator *iConfigurator;
+       OperationModeToggler *iModeToggler;
 
        OperationMode iMode;
        bool iSendErrorMessages;
diff --git a/src/IO/DeviceControl/OperationModeToggler.cpp b/src/IO/DeviceControl/OperationModeToggler.cpp
new file mode 100644 (file)
index 0000000..0f44687
--- /dev/null
@@ -0,0 +1,160 @@
+#include "OperationModeToggler.h"
+#include "DeviceManager.h"
+#include "StartupSettings.h"
+#include "AlarmSender.h"
+#include "DeviceConfigurator.h"
+#include "DeviceDataStorage.h"
+
+#include <QtDebug>
+
+OperationModeToggler::OperationModeToggler( 
+               DeviceManager::OperationMode aMode, 
+               StartupSettings *aSettings, 
+               AlarmSender *aAlarmSender, 
+               DeviceConfigurator *aConfigurator,
+               DeviceDataStorage *aDataStorage
+               ) :
+       iMode( aMode ),
+       iSettings( aSettings ),
+       iAlarmSender( aAlarmSender ),
+       iConfigurator( aConfigurator ),
+       iDataStorage( aDataStorage ),
+       iSuccess( true )
+{
+       qDebug() << "OperationModeToggler::OperationModeToggler( ... )";
+}
+
+OperationModeToggler::~OperationModeToggler()
+{
+       qDebug() << "OperationModeToggler::~OperationModeToggler()";
+}
+
+void OperationModeToggler::run()
+{
+       switch ( iMode )
+       {
+               case DeviceManager::EmptyMode:
+                       // error occured. Mode cannot be changed
+                       emit error( DeviceManager::ModeNotFetched );
+                       iSuccess = false;
+                       return;
+               case DeviceManager::StandAloneMode:
+                       
+                       // change to KioskMode
+                       
+                       // check if auto turn on/off functionality enabled and send turn on/off alarm events to alarm daemon
+                       if ( iSettings->isPowersavingEnabled() )
+                       {
+                               emit changingMode( "Sending the auto launch alarms to alarm daemon." );
+                               if ( !iAlarmSender->sendAlarms( iSettings->turnOnAt(), iSettings->turnOffAt() ) )
+                               {
+                                       iSuccess = false;
+                                       return; //this is critical so returning if no success
+                               }
+                       }
+                       
+                       // - disable the certain hw keys (only "home"-hw-key at the moment)
+                       // - register init script to launch the application when ever the device is launched
+                       // - disable the screen "auto-switch-off" and "dimming"
+                       // - store info about the new operation mode
+                       
+                       emit changingMode( "Disabling home hardware-key." );
+                       sleep( 2 );
+                       if( !iConfigurator->toggleHWKeys( false ) )
+                               iSuccess = false;
+                       if( iSuccess ) {
+                               emit changingMode( "Installing the application init start-up script." );
+                               sleep( 2 );
+                               if ( !iConfigurator->toggleInitScript( true ) )
+                                       iSuccess = false;
+                       }
+                       if( iSuccess ) {
+                               emit changingMode( "Disabling the screen switching off and dimming." );
+                               sleep( 2 );
+                               if( !iConfigurator->toggleScreenSwitchOff( false ) )
+                                       iSuccess = false;
+                       }
+                       if( iSuccess ) {
+                               emit changingMode( "Storing information about the new operation mode." );
+                               sleep( 2 );
+                               if( !storeOperationMode( DeviceManager::KioskMode, iDataStorage ) ) {
+                                       emit error( DeviceManager::ModeNotStored );
+                                       iSuccess = false;
+                               }       
+                       }
+                       if( !iSuccess ) {
+                               // 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 );
+                               iAlarmSender->removeAlarms();
+                               iConfigurator->toggleHWKeys( true );
+                               iConfigurator->toggleInitScript( false );
+                               iConfigurator->toggleScreenSwitchOff( true );
+                               emit toggleErrorSending( true );
+                               return;
+                       }
+                       break;
+
+               case DeviceManager::KioskMode:
+                       // change to StandAloneInProgress mode
+
+                       // - enable the certain hw keys (only "home"-hw-key at the moment)
+                       // - unregister the init script
+                       // - enable the screen "auto-switch-off" and "dimming"
+                       // - store info about the new operation mode
+                       emit changingMode( "Enabling home hardware-key." );
+                       sleep( 2 );
+                       if( !iConfigurator->toggleHWKeys( true ) )
+                               iSuccess = false;
+                       if( iSuccess ) {
+                               emit changingMode( "Enabling the screen switching off and dimming." );
+                               sleep( 2 );
+                               if( !iConfigurator->toggleScreenSwitchOff( true ) )
+                                       iSuccess = false;
+                       }
+                       if( iSuccess ) {
+                               emit changingMode( "Storing information about the new operation mode." );
+                               sleep( 2 );
+                               if( !storeOperationMode( DeviceManager::StandAloneModeInProgress, iDataStorage ) ) {
+                                       emit error( DeviceManager::ModeNotStored );
+                                       iSuccess = false;
+                               }
+                       }
+                       if( iSuccess ) {
+                               emit changingMode( "Removing the auto launch alarms from alarm daemon." );
+                               sleep( 2 );
+                               if( !iAlarmSender->removeStoredAlarms() )
+                                       iSuccess = false;
+                       }
+                       if( !iSuccess ) {
+                               // 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 );
+                               iConfigurator->toggleHWKeys( false );
+                               iConfigurator->toggleInitScript( true );
+                               iConfigurator->toggleScreenSwitchOff( false );
+                               storeOperationMode( DeviceManager::KioskMode, iDataStorage );
+                               emit toggleErrorSending( true );
+                               return;
+                       }
+                       break;
+               default: // StandAloneModeInProgress should never come in question
+                       break;
+       }
+}
+
+bool OperationModeToggler::success()
+{
+       return iSuccess;
+}
+                       
+bool OperationModeToggler::storeOperationMode( DeviceManager::OperationMode aMode, DeviceDataStorage *aDataStorage )
+{
+       qDebug() << "OperationModeToggler::storeOperationMode( const OperationMode & )";
+       QStringList modeStrList;
+       QString str;
+       modeStrList.append( str.append( QString( "%1" ).arg( aMode ) ) );
+       if ( !aDataStorage->storeData( aDataStorage->dataSectionToString( DeviceDataStorage::DeviceMode ), modeStrList ) )
+               return false;
+       return true;
+}
diff --git a/src/IO/DeviceControl/OperationModeToggler.h b/src/IO/DeviceControl/OperationModeToggler.h
new file mode 100644 (file)
index 0000000..0b22266
--- /dev/null
@@ -0,0 +1,83 @@
+#ifndef OPERATIONMODETOGGLER_H_
+#define OPERATIONMODETOGGLER_H_
+
+#include "DeviceManager.h"
+
+#include <QThread>
+
+class StartupSettings;
+class AlarmSender;
+class DeviceConfigurator;
+class DeviceDataStorage;
+
+class OperationModeToggler : public QThread
+{
+       Q_OBJECT
+       
+public:
+       //! Constructor.
+       /*!
+        * Constructor for HWKeyListener class
+        */
+       OperationModeToggler( 
+                       DeviceManager::OperationMode aMode, 
+                       StartupSettings *aSettings, 
+                       AlarmSender *aAlarmSender, 
+                       DeviceConfigurator *aConfigurator, 
+                       DeviceDataStorage *aDataStorage 
+                       );
+       
+       //! Destructor.
+       virtual ~OperationModeToggler();
+       //! Run method of the class.
+       /*!
+        * Run method of the class.
+        */
+       void run();
+       //! Returns the success status of the operation mode change.
+       /*!
+        * Returns the success status of the operation mode change.
+        */
+       bool success();
+       //! Stores the current operation mode.
+       /*!
+        * Stores the current operation mode by asking the DeviceDataStorage to write it to the internal
+        * data storage.
+        * \param aMode The operation mode that user wants to activate.
+        * \return True if operation mode storing succeeds; otherwise, false.
+        */
+       static bool storeOperationMode( DeviceManager::OperationMode aMode, DeviceDataStorage *aDataStorage );
+
+signals:
+       //! Signal. Emitted if an error occurs during operation mode fetching or reading.
+       /*!
+        * Signal. Emitted if an error occurs during operation mode fetching or reading. Note that other
+        * possible errors are sent by the other instances e.g. alarm sender sents it's own errors. 
+        * \param aCode The error code.
+        */
+       void error( DeviceManager::ErrorCode aCode );
+       //! Signal. Emitted if an error occurs during operation mode changing.
+       /*!
+        * Signal. Emitted if an error occurs during operation mode changing. If an error occurs, the operation
+        * mode changes made so far have to be rolled back. During this we don't want to show possible new
+        * errors. 
+        * \param aToggle Indicates if the errors are wanted to be shown.
+        */
+       void toggleErrorSending( bool aToggle );
+       //! Signal. Emitted during the operation mode change to explain the current sub-change.
+       /*!
+        * Signal. Emitted during the operation mode change to explain the current sub-change. 
+        * \param aMessage Explains the sub-change
+        */
+       void changingMode( const QString &aMessage );
+       
+private:
+       DeviceManager::OperationMode iMode;
+       StartupSettings *iSettings;
+       AlarmSender *iAlarmSender;
+       DeviceConfigurator *iConfigurator;
+       DeviceDataStorage *iDataStorage;
+       bool iSuccess; 
+};
+
+#endif /*OPERATIONMODETOGGLER_H_*/
index 425a26f..5318df7 100644 (file)
@@ -151,6 +151,7 @@ void ScheduleTableWidget::mouseMoveEvent( QMouseEvent* /* aEvent */ )
 void ScheduleTableWidget::mousePressEvent( QMouseEvent* aEvent )
 {
        activateMeeting( aEvent->x(), aEvent->y() );
+       iTabletBlocked = false;
 }
 
 void ScheduleTableWidget::populateMeetingList()
index 30f6056..6ab9fe2 100755 (executable)
@@ -17,7 +17,8 @@ ProgressBar::ProgressBar( const QString &aText, bool aCancellable, QWidget *aPar
 
        iProgress = new QProgressBar();
        iProgress->setMinimumWidth( 200 );
-       iProgress->setMaximum( 0 );
+       iProgress->setRange( 0, 0 );
+       iProgress->reset();
        iProgress->setTextVisible( false );
        
        QVBoxLayout *mainLayout = new QVBoxLayout;
@@ -31,7 +32,8 @@ ProgressBar::ProgressBar( const QString &aText, bool aCancellable, QWidget *aPar
                subLayout->addWidget( buttonCancel );
                connect( buttonCancel, SIGNAL( pressed() ), this, SIGNAL( cancel() ) );
        }
-       
+       mainLayout->addLayout( subLayout );
+       mainLayout->setAlignment( Qt::AlignCenter );
        setLayout( mainLayout );
 }
 
@@ -44,4 +46,4 @@ void ProgressBar::update( const QString &aMessage )
 {
        qDebug() << "ProgressBar::update( const QString & )";
        iLabel->setText( aMessage );
-}
\ No newline at end of file
+}
index 8685e6b..25a4cc8 100644 (file)
@@ -6,8 +6,6 @@
 
 #include <QtDebug>
 
-const int IDLE_TIME_MULTIPLIER = 60000; // Multiplies milliseconds to minutes
-
 WindowManager::WindowManager( QWidget *aParent ) :
                QWidget( aParent ),
                iApplicationName( tr( "Qt Meetings" ) ),
@@ -103,6 +101,13 @@ bool WindowManager::event(QEvent *event)
        return QWidget::event( event );
 }
 
+void WindowManager::error( const QString &aErrorMessage )
+{
+       qDebug() << "WindowManager::showErrorPopup";
+
+       PopUpMessageBox::error( 0, aErrorMessage );
+}
+
 void WindowManager::setFullscreen()
 {
        this->setWindowState( Qt::WindowFullScreen );
index 4fd592f..f361e41 100644 (file)
@@ -1,3 +1,4 @@
+<<<<<<< HEAD:src/UserInterface/WindowManager.h
 #ifndef WINDOWMANAGER_H_\r
 #define WINDOWMANAGER_H_\r
 \r
@@ -102,3 +103,191 @@ private:
 };\r
 \r
 #endif /*WINDOWMANAGER_H_*/\r
+=======
+#ifndef WINDOWMANAGER_H_
+#define WINDOWMANAGER_H_
+
+#include <QObject>
+#include <QTime>
+#include "Room.h"
+#include "Meeting.h"
+#include "PasswordDialog.h"
+#include "DeviceManager.h"
+
+class QTimer;
+class RoomStatusIndicatorWidget;
+class WeeklyViewWidget;
+class Engine;
+class MeetingInfoDialog;
+class SettingsView;
+class ProgressBar;
+class Configuration;
+
+//! UserInterface class. Behaves as a proxy between the user interface and application's business logic.
+/*!
+ * UserInterface class. Controls the whole user interface, starting with displaying the appropriate
+ * views. It behaves as a proxy between the user interface and application's business logic, it connects
+ * the specified components together and forwards the data to the correct place. It also manages the correct
+ * appearance of current views on the screen.
+ */
+class WindowManager : public QObject
+{
+       Q_OBJECT
+
+public:
+       //! Constructor.
+       /*!
+        * Constructor of WindowManager.
+        * \param aConfiguration The pointer to configuration.
+        */
+       WindowManager( Configuration *aConfiguration );
+       //! Destructor.
+       virtual ~WindowManager();
+       /*!
+        * Displays an error message
+        * \param aErrorMessage Message to be displayd
+        */
+       void error( const QString &aErrorMessage );
+       //! Updates the rooms status.
+       /*! 
+        * Forwards the signal of changed status to current view.
+        * \param aRoom Room which status is changed.
+        * \param aStatus Current status of room.
+        * \param aTime Time when status is changed.
+        */
+       void roomStatusChanged( Room *aRoom, Room::Status aStatus, QTime aTime );
+       //! Shows the password dialog.
+       /*!
+        * Shows the password dialog.
+        * \param aAdminPassword The correct password.
+        * \param aMessage The message to be shown in the password dialog.
+        */
+       void showPasswordDialog( QByteArray aAdminPassword, const QString &aMessage );
+       //! Closes the password dialog.
+       /*!
+        * Closes the password dialog.
+        */
+       void closePasswordDialog();
+       //! Displays the weekly view.
+       /*!
+        * Displays the weekly view.
+        */
+       void showWeeklyView();
+       //! Displays the meeting info dialog.
+       /*!
+        * Displays the meeting info dialog. 
+        * \param aMeeting Meeting to be displayd
+        */
+       void showMeetingInfo( Meeting *aMeeting );
+       //! Returns the pointer to the weekly view. 
+       /*!
+        * Returns the pointer to the weekly view.
+        */
+       WeeklyViewWidget * weeklyView();
+       //! Switches the views to full screen.
+       /*!
+        * Switches the views to full screen.
+        */
+       void fullScreen();
+       //! Shows the progress bar.
+       /*!
+        * Starts showing the progress bar.
+        * \param aText The text to be shown in progress bar.
+        *  \param aCancellable Is the Cancel button visible. By default not visible.
+        */
+       void showProgressBar( const QString &aText, bool aCancellable = false );
+       //! Closes the progress bar.
+       /*!
+        * Closes the progress bar.
+        */
+       void closeProgressBar();
+       
+       void insertMeeting( Meeting *aMeeting );
+       
+       void deleteMeeting( Meeting *aMeeting );
+
+signals:
+       //! Request current status of the room.
+       /*!
+        * Signal is emitted when there is need to check current status of room aRoom.
+        * \param aRoom Meetingroom which status is requested.
+        */
+       void roomStatusInfoNeeded( Room *aRoom );
+       //! Indicate that some user event has happened.
+       /*!
+        * Signal is emitted if some user event has happened.
+        */
+       void observedEventDetected();
+       //! Meeting activated.
+       /*!
+        * Signal is emitted when a meeting is clicked by the user.
+        * \param aMeeting actived meeting.
+        */
+       void meetingActivated( Meeting *aMeeting );
+       //! Signals if the shown week has been changed.
+       /*!
+        * Signal. Emitted if the shown week has been changed.
+        * \param aDate The first date of the shown week.
+        */
+       void shownWeekChanged( QDate aDate );
+       //! Signals change of the meeting room.
+       /*!
+        * Signal is emitted when meeting room is changed.
+        * \param aRoom Selected meeting room.
+        */
+       void currentRoomChanged( Room *aRoom );
+       //! Signals when the password dialog buttons are clicked.
+       /*!
+        * Signal is emitted when the password dialog buttons are clicked.
+        * \param aPasswordStatus The status of the password.
+        */
+       void passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus );
+       //! Signals when the cancel button in the progress bar is clicked.
+       /*!
+        * Signal is emitted when the cancel button in the progress bar is clicked.
+        */
+       void progressBarCancelled();
+       
+public slots:
+       //! Slot for displaying the screensaver (room status view).
+       /*!
+        * Slot. Displays the screensaver.
+        */
+       void showRoomStatus();
+       //! Slot for updating the time.
+       /*!
+        * Slot. Forwards the signal of changed time to current view.
+        * \param aCurrentDateTime Current date and time.
+        */
+       void distributeDateTimeInfo( QDateTime aCurrentDateTime );
+       
+       void updateProgressBar( const QString &aMessage );
+       
+private slots:
+       //! Displays the settings view
+       void showSettingsView();
+
+private:
+       //! Name of the application.
+       QString iApplicationName;
+       //! Defines whether the views should be shown as full screen 
+       bool iFullScreen;
+       //! Pointer to the configuration.
+       Configuration *iConfiguration;
+       //! Pointer to the weekly view.
+       WeeklyViewWidget *iWeeklyView;
+       //! Pointer to the screensaver (room status view).
+       RoomStatusIndicatorWidget *iRoomStatusView;
+       //! Pointer to the meeting info dialog
+       MeetingInfoDialog *iMeetingInfo;
+       //! Pointer to the settings view
+       SettingsView *iSettingsView;
+       //! Pointer to the progress bar
+       ProgressBar *iProgressBar;
+       //! Pointer to the password dialog.
+       PasswordDialog *iPasswordDialog;
+
+};
+
+#endif /*WINDOWMANAGER_H_*/
+>>>>>>> deb6aee06a80416a24a64c2ac6349a2341acdc39:src/UserInterface/WindowManager.h