iWindowManager( 0 ), iUIManager( 0 )
{
qDebug() << "Engine::Engine()";
+ iCommunicationFailed = false;
+ iCurrentWeekFetched = false;
initConfiguration();
initDevice();
//initialize idle time counter
iIdleTimeCounter = new QTimer();
- iIdleTimeCounter->setSingleShot( true );
- // iIdleTimeCounter->setInterval( IDLE_TIME_MULTIPLIER * iConfiguration->displaySettings()->screensaver() );
- iIdleTimeCounter->setInterval( 10000 );
+ iIdleTimeCounter->setSingleShot( true);
+ iIdleTimeCounter->setInterval(IDLE_TIME_MULTIPLIER * iConfiguration->displaySettings()->screensaver() );
iIdleTimeCounter->start();
// create application clock
iAutoRefresh->setInterval(iConfiguration->connectionSettings()->refreshInterval() * 1000);
iAutoRefresh->start();
connect( iAutoRefresh, SIGNAL( timeout() ), iAutoRefresh, SLOT( start() ) );
- connect( iAutoRefresh, SIGNAL( timeout() ), this, SLOT( fetchMeetings() ) );
+ // connect( iAutoRefresh, SIGNAL( timeout() ), this, SLOT( fetchMeetings() ) );
if( iDevice->currentOperationMode() == DeviceManager::KioskMode )
{
connectSignals();
- QTimer::singleShot( 0, this, SLOT( fetchMeetings() ) );
+ // QTimer::singleShot( 0, this, SLOT( fetchMeetings() ) );
// TODO: continue implementation
}
int indexOfNextMeeting = indexOfMeetingAfter(aRoom, iClock->datetime() );
// if there is no meeting, then status is Free; otherwise Busy
- Room::Status
- status =
- (indexOfCurrentMeeting == -1 ) ? Room::FreeStatus : Room::BusyStatus;
+ Room::Status status = (indexOfCurrentMeeting == -1 ) ? Room::FreeStatus : Room::BusyStatus;
// if room is Busy, then check end time, otherwise...
QTime until = (status == Room::BusyStatus ) ? iMeetings.at( indexOfCurrentMeeting )->endsAt().time() :
// ...if there is meeting following on the same day then check end time, otherwise end is the of the working day
- ((indexOfNextMeeting != -1 ) ? iMeetings.at( indexOfNextMeeting )->startsAt().time() : Engine::endOfTheDay );
+ ( ( indexOfNextMeeting != -1 ) ? iMeetings.at( indexOfNextMeeting )->startsAt().time() : Engine::endOfTheDay );
//currently works only for deafult room
// if( aRoom->equals( *(defaultRoom() ) ) )
// iWindowManager->roomStatusChanged( aRoom, status, until );
}
+/*
void Engine::fetchMeetings()
{
- Room *room = defaultRoom();
- qDebug() << "Engine::fetchMeetings for " << room->name();
- fetchMeetings(iClock->datetime(), iClock->datetime().addDays( 7), room);
+ 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 );
}
+*/
-bool Engine::isMeetingInList( const QList<Meeting*> &aList, const Meeting *aMeeting )
+void Engine::fetchMeetingDetails( Meeting *aMeeting )
{
- qDebug()
- << "Engine::isMeetingInList( const QList<Meeting*> &, const Meeting * )";
- for (int i = 0; i < aList.count(); i++)
- {
- if (aMeeting->equals( *(aList.at(i))) )
- {
- return true;
- }
- }
- return false;
+ 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 );
}
-void Engine::meetingsFetched(const QList<Meeting*> &aMeetings)
+void Engine::meetingsFetched( const QList<Meeting*> &aMeetings )
{
qDebug() << "Engine::meetingsFetched( const QList<Meeting*> & )";
- // check if there is any new meeting in the list came from the server -> added
- for (int i = 0; i < aMeetings.count(); i++)
+ // TODO: should check if this week's meetings were fetched
+ if( iCommunicationFailed || !iCurrentWeekFetched )
{
- // if the (i)th meeting is not in the local meeting list
- if ( !isMeetingInList(iMeetings, aMeetings.at(i) ) )
- {
- // add to the local database =)
- Meeting* m = new Meeting( *(aMeetings.at( i )) );
- iMeetings.append(m);
- // and signal the changes
- }
+ iCurrentWeekFetched = true;
+ iCommunicationFailed = false;
+ iUIManager->connectionEstablished();
}
- // check if there is any meeting NOT in the list came from the server -> deleted
- for (int i = 0; i < iMeetings.count(); i++)
+ for ( int i = 0; i < iMeetings.count(); ++i )
{
- // if the (i)th meeting is in the local but NOT in the server's meeting list
- if ( !isMeetingInList(aMeetings, iMeetings.at(i) ) )
- {
- Meeting* m = iMeetings.takeAt(i);
- // signal the changes
- // delete the meeting from the local list
- delete m;
- }
+ Meeting* m = iMeetings.takeAt( i );
+ delete m;
+ }
+ iMeetings.clear();
+ for ( int i = 0; i < aMeetings.count(); ++i ) {
+ Meeting* m = new Meeting( *( aMeetings.at( i ) ) );
+ iMeetings.append( m );
}
// refresh room status info
- roomStatusInfoNeeded(defaultRoom() );
+ roomStatusInfoNeeded( 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 ) );
iCommunication->fetchMeetings(aFrom, aUntil, *aIn);
}
-void Engine::fetchMeetingDetails(Meeting *aMeeting)
-{
- qDebug() << "[Engine::fetchMeetingDetails] <TODO : METHOD NOT IMPLEMENTED>";
- Meeting tempMeeting(aMeeting->primaryId(), aMeeting->room(), aMeeting->startsAt(), aMeeting->endsAt() );
- iCommunication->fetchMeetingDetails( tempMeeting );
-// Meeting tempMeeting = aMeeting;
-// iCommunication->fetchMeetingDetails( tempMeeting );
-}
-
void Engine::cancelFetchMeetingDetails()
{
iCommunication->cancelFetchMeetingDetails();
{
QTimer::singleShot( 0, this, SLOT( closeApplication() ) );
}
+ iCurrentRoom = iConfiguration->defaultRoom();
}
void Engine::connectSignals()
iIdleTimeCounter->start();
}
}
+
+void Engine::currentRoomChanged(Room *aRoom)
+{
+ iCurrentRoom = aRoom;
+}
\ No newline at end of file