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();
130 //! Provides the index of the Meeting instance which is at the specified time.
132 * Provides the index of the Meeting instance which is at the specified time. If there are
133 * overlapping meetings then returns one of then undetetministically.
134 * \param aRoom The room which meetings are looked through.
135 * \param aAt Date and time when the meeting is already going.
136 * \return Index of the meeting if found; otherwise, -1.
138 int indexOfMeetingAt( Room *aRoom, QDateTime aAt );
139 //! Provides the index of the Meeting instance which is starts the closest to the specified time.
141 * Provides the index of the Meeting instance which is starts the closest to the specified time.
142 * If there are overlapping meetings then returns one of then undetetministically.
143 * \param aRoom The room which meetings are looked through.
144 * \param aAt Date and time when the meeting is not yet started.
145 * \return Index of the meeting if found; otherwise, -1.
147 int indexOfMeetingAfter( Room *aRoom, QDateTime aAfter );
148 //! Indicates if the QList contains the Meeting or not.
150 * Indicates if the QList contains the Meeting or not.
151 * \param aList List of meetings.
152 * \param aMeeting The meeting which is seeked in the list for.
153 * \return True if contains; otherwise, false.
155 static bool isMeetingInList( const QList<Meeting*> &aList, const Meeting *aMeeting );
156 //! Slot. Fetches meetings from the server.
158 * Slot. Fetches meetings from the server, exact parameters are specified in the parameter list.
159 * \param aFrom Time from when the meetings need to be fetched.
160 * \param aUntil Time until when the meetings need to be fetched.
161 * \param aIn The room which meetings need to be fetched.
163 void fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, const Room *aIn );
166 static QTime endOfTheDay;
168 WindowManager *iWindowManager;
169 QTimer *iIdleTimeCounter;
171 Configuration *iConfiguration;
172 CommunicationManager *iCommunication;
173 DeviceManager *iDevice;
175 QTimer *iAutoRefresh;
177 QList<Meeting*> iMeetings;