7 #include "WindowManager.h"
12 class CommunicationManager;
16 //! BusinessLogic class. Contains all the business logic of the application.
18 * BusinessLogic class. Contains all the business logic of the application. It is responsible
19 * for connecting user interface to lower application layers (IO).
21 class Engine : public QObject
28 * Constructor to initialize an Engine instance.
33 //! Gets default room of the application.
35 * Gets default room of the application.
36 * \return Pointer to the default Room instance.
42 void meetingDetailsFetched( Meeting *aDetailedMeeting );
45 //! Slot. Closes the application.
47 * Slot. Closes the application.
49 void closeApplication();
50 //! Slot. Checks actual availability information of the specified room.
52 * Slot. Checks actual availability information of the specified room.
53 * \param aRoom The room which availability information is needed.
55 void roomStatusInfoNeeded( Room *aRoom );
56 //! Slot. Indicates that some user event has happened.
58 * Slot. Indicates that some user event has happened.
60 void observedEventDetected();
61 //! Slot. Asks the communication to fetch new meeting data.
63 * Slot. Asks the communication to fetch new meeting data.
64 * \param aCurrentRoom The current room.
66 void currentRoomChanged( Room *aCurrentRoom );
67 //! Slot. Asks the communication to fetch new meeting data.
69 * Slot. Asks the communication to fetch new meeting data.
70 * \param aCurrentRoom The current room.
72 void shownWeekChanged( QDate aDate );
73 //! Slot. Handles errors.
75 * Slot. Handles errors and informs the UI by emitting the error() signal with the message in
77 * \param aCode The error code.
78 * \param aAddInfo Possible addition info.
80 void errorHandler( int aCode, const QString &aAddInfo = "" );
81 //! Slot. Fetches meetings from the server.
83 * Slot. Fetches meetings from the server. Parameters are hard coded: the meetings of the default
84 * room from current and +/- 2 weeks are fetched.
87 //! Slot. Saves fetched meetings to the current instance's local storage.
89 * Slot. Saves fetched meetings to the current instance's local storage. Meetings are soted in a
90 * private QList, it is iterated through and signals are emitted if there is any new, updated or
92 * \param aMeetings The list of freshly fetched meetings.
94 void meetingsFetched( const QList<Meeting*>& );
96 void meetingDetailsFetched( Meeting &aDetailedMeeting );
98 //! Slot. Checks the availability of all the rooms.
100 * Slot. Checks the availability of all the rooms by iterating through the current object's local
101 * room storage and calling the roomStatusInfoNeeded() separately on each of them.
103 void checkStatusOfAllRooms();
104 //! Slot for popping up the confirmation dialog to change the current operation mode
106 * Slot. Asks Window manager to pop up a confirmation dialog.
107 * \param aMode The operation mode to be changed to
109 void changeModeOrdered( DeviceManager::OperationMode aMode );
110 //! Slot. Fetches meeting details from the server.
112 * Slot. Fetches meeting details from the server.
113 * \param aMeeting The meeting.
115 void fetchMeetingDetails( Meeting *aMeeting );
116 //! Slot for receiving the status of the entered password
118 * Slot. Receives the status of the entered password and makes the DeviceManager to change the
119 * operation mode if the password is correct.
120 * \param aPasswordStatus The status of the password.
122 void passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus );
123 //! Slot for receiving the cancel event of the progress bar.
125 * Slot. Receives the cancel event of the progress bar.
127 void progressBarCancelled();
128 //! Slot for receiving the cancel event of the progress bar.
130 * Receives the cancel event of the progress bar when meeting details requested.
132 void fetchMeetingDetailsCancelled();
135 //! Provides the index of the Meeting instance which is at the specified time.
137 * Provides the index of the Meeting instance which is at the specified time. If there are
138 * overlapping meetings then returns one of then undetetministically.
139 * \param aRoom The room which meetings are looked through.
140 * \param aAt Date and time when the meeting is already going.
141 * \return Index of the meeting if found; otherwise, -1.
143 int indexOfMeetingAt( Room *aRoom, QDateTime aAt );
144 //! Provides the index of the Meeting instance which is starts the closest to the specified time.
146 * Provides the index of the Meeting instance which is starts the closest to the specified time.
147 * If there are overlapping meetings then returns one of then undetetministically.
148 * \param aRoom The room which meetings are looked through.
149 * \param aAt Date and time when the meeting is not yet started.
150 * \return Index of the meeting if found; otherwise, -1.
152 int indexOfMeetingAfter( Room *aRoom, QDateTime aAfter );
153 //! Indicates if the QList contains the Meeting or not.
155 * Indicates if the QList contains the Meeting or not.
156 * \param aList List of meetings.
157 * \param aMeeting The meeting which is seeked in the list for.
158 * \return True if contains; otherwise, false.
160 static bool isMeetingInList( const QList<Meeting*> &aList, const Meeting *aMeeting );
161 //! Slot. Fetches meetings from the server.
163 * Slot. Fetches meetings from the server, exact parameters are specified in the parameter list.
164 * \param aFrom Time from when the meetings need to be fetched.
165 * \param aUntil Time until when the meetings need to be fetched.
166 * \param aIn The room which meetings need to be fetched.
168 void fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, const Room *aIn );
171 static QTime endOfTheDay;
173 WindowManager *iWindowManager;
174 QTimer *iIdleTimeCounter;
176 Configuration *iConfiguration;
177 CommunicationManager *iCommunication;
178 DeviceManager *iDevice;
180 QTimer *iAutoRefresh;
182 QList<Meeting*> iMeetings;