#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) \
( ( 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 );
}
// 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
}
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 );
{
qDebug() << "[Engine::currentRoomChanged] <invoked>";
iCurrentRoom = aRoom;
-}
+}
\ No newline at end of file
//! 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
{
signals:
- void roomStatusChanged( Room::Status aStatus, QTime aUntil );
-
private slots:
//! Slot. Closes the application.
/*!
* \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
void stopIdleTimeCounter();
void startIdleTimeCounter();
- void changeDeviceMode( bool aChange );
+ void changeDeviceMode();
void currentRoomChanged( Room *aRoom );
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()
void UIManager::createProgressBar()
{
iProgressBar = new ProgressBar( tr("CHANGE THIS"), true );
-
// Connect to UIManager
connect( iProgressBar, SIGNAL( cancel() ), this, SLOT( progressBarCancelled() ) );
// Connect to Engine
{
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 ) );
{
iWeeklyView->setCurrentDateTime( aDateTime );
}
- if ( iRoomStatusIndicator != 0 )
- {
- iRoomStatusIndicator->setCurrentTime( aDateTime.time() );
- }
}
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;
}
bool DeviceConfigurator::toggleScreenSwitchOff( bool aEnable )
{
qDebug() << "DeviceConfigurator::toggleScreenSwitchOff( bool )";
+ emit configuringError( DeviceManager::ScreenSettingsNotChanged );
+ return false;
QString command = "gconftool-2";
QStringList args;
QByteArray result;
#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 * )";
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 ) ) );
iMode = EmptyMode;
iHWKeyListener = new HWKeyListener();
- connect( iHWKeyListener, SIGNAL( HWKeyFullScreenPressed() ), this, SLOT( HWKeyFullScreenPressed() ) );
- //handleKeyPresses( true );
- iIgnoreHWKeyPresses = false;
+ handleHWKeyPresses( true );
}
DeviceManager::OperationMode DeviceManager::currentOperationMode()
}
}
-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()
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 )
{
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() ) );
}
//! 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.
* \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;
OperationMode iMode;
bool iSendErrorMessages;
- bool iIgnoreHWKeyPresses;
};
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()
if ( !iAlarmSender->sendAlarms( iSettings->turnOnAt(), iSettings->turnOffAt() ) )
{
iSuccess = false;
+ emit changingMode( "Rolling back changes..." );
return; //this is critical so returning if no success
}
}
// 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 );
// 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 );
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 );
{
qDebug() << "ProgressBar::ProgressBar( const QString &, bool, QWidget *)";
setWindowTitle( aTitle );
+
setModal( true );
iProgress = new QProgressBar();
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
}\r
setPalette( createPalette( aStatus ) );\r
}\r
-\r
-void RoomStatusIndicatorWidget::currentRoomChanged( Room *aRoom )\r
-{\r
- iDefaultRoomLabel->setText( aRoom->name() );\r
-}\r
* \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