From: Jan Lapinkataja Date: Tue, 26 May 2009 09:30:04 +0000 (+0300) Subject: Enabled the error sending from Operation Mode changing. And corrected some possible... X-Git-Url: https://vcs.maemo.org/git/?p=qtmeetings;a=commitdiff_plain;h=c084f87d1751151c7f9e913776796a40c5cd5cb9 Enabled the error sending from Operation Mode changing. And corrected some possible bugs. (Task id 1168) --- diff --git a/src/BusinessLogic/Engine.cpp b/src/BusinessLogic/Engine.cpp index a61006c..25c3048 100644 --- a/src/BusinessLogic/Engine.cpp +++ b/src/BusinessLogic/Engine.cpp @@ -276,9 +276,11 @@ void Engine::errorHandler( int aCode, const QString &aAddInfo ) { qDebug() << "Engine::ErrorHandler, aCode: " << aCode; // inform UI about the problem - if( aCode >= 100 && aCode <= 150 ) + if( aCode >= 100 && aCode <= 150 ) { //communication errors + //we don't want these to close operation changing qDebug() << "CommunicationManager signaled an error:" << aCode; - iWindowManager->closeProgressBar(); + iWindowManager->closeProgressBar(); + } iWindowManager->error( ErrorMapper::codeToString( aCode, aAddInfo ) ); } @@ -323,11 +325,11 @@ void Engine::passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus ) { case PasswordDialog::Correct : { - iWindowManager->showProgressBar( "Changing current operation mode.", true ); - connect( iWindowManager, SIGNAL( progressBarCancelled() ), this, SLOT( progressBarCancelled() ) ); + iAutoRefresh->stop(); //we stop the metting updating + iWindowManager->showProgressBar( "Changing current operation mode." ); connect( iDevice, SIGNAL( changingMode( const QString & ) ), iWindowManager, SLOT( updateProgressBar( const QString & ) ) ); - connect( iDevice, SIGNAL( changingModeFailed() ), this, SLOT( progressBarCancelled() ) ); + connect( iDevice, SIGNAL( changeModeFailed() ), this, SLOT( changeModeFailed() ) ); iDevice->changeMode( true ); break; } @@ -344,12 +346,11 @@ void Engine::passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus ) } } -void Engine::progressBarCancelled() +void Engine::changeModeFailed() { - qDebug() << "Engine::progressBarCancelled()"; - //TODO: cancel the on-going event + qDebug() << "Engine::changeModeFailed()"; iWindowManager->closeProgressBar(); - iDevice->changeMode( false ); + iAutoRefresh->start(); //we start the metting updating } void Engine::fetchMeetingDetailsCancelled() diff --git a/src/BusinessLogic/Engine.h b/src/BusinessLogic/Engine.h index 461b437..5f99630 100644 --- a/src/BusinessLogic/Engine.h +++ b/src/BusinessLogic/Engine.h @@ -120,11 +120,11 @@ private slots: * \param aPasswordStatus The status of the password. */ void passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus ); - //! Slot for receiving the cancel event of the progress bar. + //! Slot for receiving the failure event of operation mode changing. /*! - * Slot. Receives the cancel event of the progress bar. + * Slot. Receives the failure event of operation mode changing. */ - void progressBarCancelled(); + void changeModeFailed(); //! Slot for receiving the cancel event of the progress bar. /*! * Receives the cancel event of the progress bar when meeting details requested. diff --git a/src/IO/DeviceControl/DeviceManager.cpp b/src/IO/DeviceControl/DeviceManager.cpp index 6c6eb27..92613b2 100644 --- a/src/IO/DeviceControl/DeviceManager.cpp +++ b/src/IO/DeviceControl/DeviceManager.cpp @@ -81,7 +81,8 @@ void DeviceManager::changeMode( bool aChange ) } 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( 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(); @@ -172,16 +173,18 @@ void DeviceManager::errorSender( DeviceManager::ErrorCode aErrorCode, const QStr void DeviceManager::toggleErrorSending( bool aToggle ) { + qDebug() << "DeviceManager::toggleErrorSending( bool )"; iSendErrorMessages = aToggle; } void DeviceManager::modeChanged() { + qDebug() << "DeviceManager::modeChanged()"; if( iModeToggler != 0 ) { if ( iModeToggler->success() ) //mode changing went well iConfigurator->restartDevice(); else - emit changingModeFailed(); + emit changeModeFailed(); delete iModeToggler; iModeToggler = 0; } diff --git a/src/IO/DeviceControl/DeviceManager.h b/src/IO/DeviceControl/DeviceManager.h index 4d5aaa7..267cf96 100644 --- a/src/IO/DeviceControl/DeviceManager.h +++ b/src/IO/DeviceControl/DeviceManager.h @@ -3,6 +3,7 @@ #include #include +#include class AlarmSender; class HWKeyListener; @@ -39,6 +40,7 @@ public: /*! * Enumeration of errors */ + enum ErrorCode { FileCreationFailed, /*!< File couldn't be created. */ @@ -116,7 +118,7 @@ signals: /*! * Signal. Emitted if the operation mode change fails. */ - void changingModeFailed(); + void changeModeFailed(); private slots: //! Slot. Handles "full screen"-hardware key presses. @@ -183,4 +185,6 @@ private: }; +Q_DECLARE_METATYPE( DeviceManager::ErrorCode ) + #endif /*DEVICEMANAGER_H_*/ diff --git a/src/IO/DeviceControl/OperationModeToggler.cpp b/src/IO/DeviceControl/OperationModeToggler.cpp index 0f44687..cfa5d5d 100644 --- a/src/IO/DeviceControl/OperationModeToggler.cpp +++ b/src/IO/DeviceControl/OperationModeToggler.cpp @@ -22,6 +22,15 @@ OperationModeToggler::OperationModeToggler( iSuccess( true ) { qDebug() << "OperationModeToggler::OperationModeToggler( ... )"; + + qRegisterMetaType("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() @@ -35,7 +44,7 @@ void OperationModeToggler::run() { case DeviceManager::EmptyMode: // error occured. Mode cannot be changed - emit error( DeviceManager::ModeNotFetched ); + createError( DeviceManager::ModeNotFetched ); iSuccess = false; return; case DeviceManager::StandAloneMode: @@ -78,7 +87,7 @@ void OperationModeToggler::run() emit changingMode( "Storing information about the new operation mode." ); sleep( 2 ); if( !storeOperationMode( DeviceManager::KioskMode, iDataStorage ) ) { - emit error( DeviceManager::ModeNotStored ); + createError( DeviceManager::ModeNotStored ); iSuccess = false; } } @@ -116,7 +125,7 @@ void OperationModeToggler::run() emit changingMode( "Storing information about the new operation mode." ); sleep( 2 ); if( !storeOperationMode( DeviceManager::StandAloneModeInProgress, iDataStorage ) ) { - emit error( DeviceManager::ModeNotStored ); + createError( DeviceManager::ModeNotStored ); iSuccess = false; } } @@ -145,6 +154,7 @@ void OperationModeToggler::run() bool OperationModeToggler::success() { + qDebug() << "OperationModeToggler::success()"; return iSuccess; } @@ -158,3 +168,11 @@ bool OperationModeToggler::storeOperationMode( DeviceManager::OperationMode aMod return false; return true; } + +void OperationModeToggler::createError( DeviceManager::ErrorCode aCode ) +{ + qDebug() << "OperationModeToggler::createError( DeviceManager::ErrorCode )"; + QString empty = ""; + emit error( aCode, empty ); +} + diff --git a/src/IO/DeviceControl/OperationModeToggler.h b/src/IO/DeviceControl/OperationModeToggler.h index 0b22266..77f9382 100644 --- a/src/IO/DeviceControl/OperationModeToggler.h +++ b/src/IO/DeviceControl/OperationModeToggler.h @@ -49,13 +49,13 @@ public: 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 happens. /*! - * 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. + * Signal. Emitted if an error happens. + * \param aCode An error code defined by DeviceManager. + * \param aAddInfo Possible additional information. */ - void error( DeviceManager::ErrorCode aCode ); + void error( DeviceManager::ErrorCode aCode, const QString &aAddInfo ); //! 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 @@ -70,6 +70,14 @@ signals: * \param aMessage Explains the sub-change */ void changingMode( const QString &aMessage ); + +private slots: + //! Slot. Emits an error signal. + /*! + * Slot. Emits an error signal. + * \param aCode The error code. + */ + void createError( DeviceManager::ErrorCode aCode ); private: DeviceManager::OperationMode iMode; diff --git a/src/UserInterface/WindowManager.cpp b/src/UserInterface/WindowManager.cpp index 924392e..dba36b3 100644 --- a/src/UserInterface/WindowManager.cpp +++ b/src/UserInterface/WindowManager.cpp @@ -190,7 +190,8 @@ void WindowManager::showProgressBar( const QString &aText, bool aCancellable ) iProgressBar = new ProgressBar( aText, aCancellable ); iProgressBar->setFixedSize( 600, 125 ); iProgressBar->show(); - connect( iProgressBar, SIGNAL( cancel() ), this, SIGNAL( progressBarCancelled() ) ); + if( aCancellable ) + connect( iProgressBar, SIGNAL( cancel() ), this, SIGNAL( progressBarCancelled() ) ); } //TODO connect connect( iWeeklyView, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );