Merged and got it partly working
[qtmeetings] / src / BusinessLogic / Engine.cpp
index fb0fe9f..1a79851 100644 (file)
@@ -28,7 +28,8 @@ const int IDLE_TIME_MULTIPLIER = 60000; // Multiplies milliseconds to minutes
 
 
 Engine::Engine() :
-               iClock( 0 ), iConfiguration( 0 ), iCommunication( 0 )
+               iClock( 0 ), iConfiguration( 0 ), iCommunication( 0 ),
+               iWindowManager( 0 ), iUIManager( 0 )
 {
        qDebug() << "Engine::Engine()";
        
@@ -177,7 +178,7 @@ void Engine::fetchMeetings()
        fetchMeetings(iClock->datetime(), iClock->datetime().addDays( 7), room);
 }
 
-bool Engine::isMeetingInList( const QList<Meeting*> &aList, const Meeting *aMeeting )
+bool Engine::isMeetingInList(const QList<Meeting*> &aList, const Meeting *aMeeting)
 {
        qDebug()
                        << "Engine::isMeetingInList( const QList<Meeting*> &, const Meeting * )";
@@ -194,6 +195,7 @@ bool Engine::isMeetingInList( const QList<Meeting*> &aList, const Meeting *aMeet
 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++)
        {
@@ -203,8 +205,6 @@ void Engine::meetingsFetched(const QList<Meeting*> &aMeetings)
                        // add to the local database =)
                        Meeting* m = new Meeting( *(aMeetings.at( i )) );
                        iMeetings.append(m);
-                       // and signal the changes
-//                     iWeeklyView->insertMeeting( m );
                }
        }
 
@@ -215,8 +215,6 @@ void Engine::meetingsFetched(const QList<Meeting*> &aMeetings)
                if ( !isMeetingInList(aMeetings, iMeetings.at(i) ) )
                {
                        Meeting* m = iMeetings.takeAt(i);
-                       // signal the changes
-//                     iWeeklyView->deleteMeeting( m );
                        // delete the meeting from the local list
                        delete m;
                }
@@ -228,7 +226,10 @@ void Engine::meetingsFetched(const QList<Meeting*> &aMeetings)
 
 void Engine::errorHandler( int aCode, const QString &aAddInfo )
 {      
-       iWindowManager->error( ErrorMapper::codeToString( aCode, aAddInfo ) );
+       if ( iWindowManager != 0 )
+       {
+               iWindowManager->error( ErrorMapper::codeToString( aCode, aAddInfo ) );
+       }
 }
 
 void Engine::fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, const Room *aIn )
@@ -241,6 +242,8 @@ void Engine::fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, con
 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 );
 }