#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) \
iWindowManager( 0 ), iUIManager( 0 )
{
qDebug() << "Engine::Engine()";
+ iCommunicationFailed = false;
+ iCurrentWeekFetched = false;
initConfiguration();
initDevice();
for (int i = 0; i < iConfiguration->rooms().count(); i++)
{
// and check the status
- roomStatusInfoNeeded(iConfiguration->rooms().at(i) );
+ roomStatusInfoNeeded( iConfiguration->rooms().at(i) );
}
}
void Engine::meetingsFetched( const QList<Meeting*> &aMeetings )
{
qDebug() << "Engine::meetingsFetched( const QList<Meeting*> & )";
-
- for ( int i = 0; i < iMeetings.count(); ++i ) {
+ // TODO: should check if this week's meetings were fetched
+ if( iCommunicationFailed || !iCurrentWeekFetched )
+ {
+ iCurrentWeekFetched = true;
+ iCommunicationFailed = false;
+ iUIManager->connectionEstablished();
+ }
+
+ for ( int i = 0; i < iMeetings.count(); ++i )
+ {
Meeting* m = iMeetings.takeAt( i );
delete m;
}
}
// refresh room status info
- roomStatusInfoNeeded( defaultRoom() );
+ roomStatusInfoNeeded( iCurrentRoom /*defaultRoom()*/ );
}
void Engine::errorHandler( int aCode, const QString &aAddInfo )
{
+ if( aCode >= 100 && aCode < 150 )
+ {
+ iCommunicationFailed = true;
+ if ( iUIManager != 0 ) iUIManager->connectionLost();
+ }
if ( iWindowManager != 0 )
{
iWindowManager->error( ErrorMapper::codeToString( aCode, aAddInfo ) );
QDateTime from( aFrom );
QDateTime to( aFrom.addDays( 7 ), QTime( 23, 59 ) );
qDebug() << "[Engine::shownWeekChanged] <From " << aFrom.toString( "d.m. h:mm" ) << " to " << to.toString( "d.m. h:mm" ) << ">";
- iCommunication->fetchMeetings( from, to, *defaultRoom() );
-// fetchMeetings( from, to, iWindowManager->weeklyView()->currentRoom() );
+ iCommunication->fetchMeetings( from, to, *iCurrentRoom/*defaultRoom()*/ );
}
-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( dialogActivated() ), this, SLOT( dialogActivated() ) );
connect( iWindowManager, SIGNAL( dialogDeactivated() ), this, SLOT( dialogDeactivated() ) );
// Show the UI
void Engine::handleViewEvent()
{
- if ( iIdleTimeCounter != 0 )
+ if ( iIdleTimeCounter != 0 && iIdleTimeCounter->isActive())
{
// Restart the idle time counter when view event is received
iIdleTimeCounter->stop();
{
qDebug() << "[Engine::currentRoomChanged] <invoked>";
iCurrentRoom = aRoom;
+ roomStatusInfoNeeded( iCurrentRoom );
}