7 #include "WindowManager.h"
8 #include "DeviceManager.h"
9 #include "PasswordDialog.h"
14 class CommunicationManager;
16 class WeeklyViewWidget;
18 class RoomStatusIndicatorWidget;
20 class MeetingInfoDialog;
22 //! BusinessLogic class. Contains all the business logic of the application.
24 * BusinessLogic class. Contains all the business logic of the application. It is responsible
25 * for connecting user interface to lower application layers (IO).
27 class Engine : public QObject
34 * Constructor to initialize an Engine instance.
39 //! Gets default room of the application.
41 * Gets default room of the application.
42 * \return Pointer to the default Room instance.
48 void meetingDetailsFetched( Meeting *aDetailedMeeting );
51 //! Slot. Closes the application.
53 * Slot. Closes the application.
55 void closeApplication();
56 //! Slot. Checks actual availability information of the specified room.
58 * Slot. Checks actual availability information of the specified room.
59 * \param aRoom The room which availability information is needed.
61 void roomStatusInfoNeeded( Room *aRoom );
62 //! Slot. Asks the communication to fetch new meeting data.
64 * Slot. Asks the communication to fetch new meeting data.
65 * \param aCurrentRoom The current room.
67 void currentRoomChanged( Room *aCurrentRoom );
68 //! Slot. Asks the communication to fetch new meeting data.
70 * Slot. Asks the communication to fetch new meeting data.
71 * \param aCurrentRoom The current room.
73 void shownWeekChanged( QDate aDate );
74 //! Slot. Handles errors.
76 * Slot. Handles errors and informs the UI by emitting the error() signal with the message in
78 * \param aCode The error code.
79 * \param aAddInfo Possible addition info.
81 void errorHandler( int aCode, const QString &aAddInfo = "" );
82 //! Slot. Fetches meetings from the server.
84 * Slot. Fetches meetings from the server. Parameters are hard coded: the meetings of the default
85 * room from current and +/- 2 weeks are fetched.
88 //! Slot. Saves fetched meetings to the current instance's local storage.
90 * Slot. Saves fetched meetings to the current instance's local storage. Meetings are soted in a
91 * private QList, it is iterated through and signals are emitted if there is any new, updated or
93 * \param aMeetings The list of freshly fetched meetings.
95 void meetingsFetched( const QList<Meeting*>& );
97 void meetingDetailsFetched( Meeting &aDetailedMeeting );
99 //! Slot. Checks the availability of all the rooms.
101 * Slot. Checks the availability of all the rooms by iterating through the current object's local
102 * room storage and calling the roomStatusInfoNeeded() separately on each of them.
104 void checkStatusOfAllRooms();
105 //! Slot for popping up the confirmation dialog to change the current operation mode
107 * Slot. Asks Window manager to pop up a confirmation dialog.
108 * \param aMode The operation mode to be changed to
110 void changeModeOrdered( DeviceManager::OperationMode aMode );
111 //! Slot. Fetches meeting details from the server.
113 * Slot. Fetches meeting details from the server.
114 * \param aMeeting The meeting.
116 void fetchMeetingDetails( Meeting *aMeeting );
117 //! Slot for receiving the status of the entered password
119 * Slot. Receives the status of the entered password and makes the DeviceManager to change the
120 * operation mode if the password is correct.
121 * \param aPasswordStatus The status of the password.
123 void passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus );
124 //! Slot for receiving the cancel event of the progress bar.
126 * Slot. Receives the cancel event of the progress bar.
128 void progressBarCancelled();
129 //! Slot for receiving the cancel event of the progress bar.
131 * Receives the cancel event of the progress bar when meeting details requested.
133 void fetchMeetingDetailsCancelled();
135 void handleViewEvent();
136 void previousViewRestored();
137 void settingsViewRequested();
139 void idleTimerTimeout();
141 void settingsOkClicked();
143 //! Slot for dialog activation signal.
145 * This slot is used to inform that dialog is activated. It stops
146 * the idle time counter so screensaver is not activated while the
147 * dialog is displayed.
149 void dialogActivated();
150 //! Slot for dialog deactivation signal.
152 * This slot is used to inform that dialog is deactivated. It restarts
153 * the idle time counter so that the screensaver is being activated again
156 void dialogDeactivated();
159 //! Provides the index of the Meeting instance which is at the specified time.
161 * Provides the index of the Meeting instance which is at the specified time. If there are
162 * overlapping meetings then returns one of then undetetministically.
163 * \param aRoom The room which meetings are looked through.
164 * \param aAt Date and time when the meeting is already going.
165 * \return Index of the meeting if found; otherwise, -1.
167 int indexOfMeetingAt( Room *aRoom, QDateTime aAt );
168 //! Provides the index of the Meeting instance which is starts the closest to the specified time.
170 * Provides the index of the Meeting instance which is starts the closest to the specified time.
171 * If there are overlapping meetings then returns one of then undetetministically.
172 * \param aRoom The room which meetings are looked through.
173 * \param aAt Date and time when the meeting is not yet started.
174 * \return Index of the meeting if found; otherwise, -1.
176 int indexOfMeetingAfter( Room *aRoom, QDateTime aAfter );
177 //! Indicates if the QList contains the Meeting or not.
179 * Indicates if the QList contains the Meeting or not.
180 * \param aList List of meetings.
181 * \param aMeeting The meeting which is seeked in the list for.
182 * \return True if contains; otherwise, false.
184 static bool isMeetingInList( const QList<Meeting*> &aList, const Meeting *aMeeting );
185 //! Slot. Fetches meetings from the server.
187 * Slot. Fetches meetings from the server, exact parameters are specified in the parameter list.
188 * \param aFrom Time from when the meetings need to be fetched.
189 * \param aUntil Time until when the meetings need to be fetched.
190 * \param aIn The room which meetings need to be fetched.
192 void fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, const Room *aIn );
193 //! Initialize configuration package.
195 * This method initializes configuration classes and
196 * connects signals from and to the engine.
198 void initConfiguration();
199 //! Initialize device package.
201 * This method initializes device manager and
202 * connects signals from and to the engine.
205 //! Initialize communication package.
207 * This method initializes the communication manager and
208 * connects signals from and to the engine.
210 void initCommunication();
211 //! Initialize user interface package.
213 * This method initializes the user interface and
214 * connects signals from and to the engine. This method
215 * makes the window manager visible and shows weekly
216 * view as the first view.
218 void initUserInterface();
219 //! Connects signal between objects.
221 * Signals that could not be connected while initializing different
222 * packages are connected here.
224 void connectSignals();
227 static QTime endOfTheDay;
229 WindowManager *iWindowManager;
230 WeeklyViewWidget *iWeeklyView;
231 SettingsView *iSettingsView;
232 RoomStatusIndicatorWidget *iRoomStatusIndicator;
234 PasswordDialog *iPasswordDialog;
235 MeetingInfoDialog *iMeetingInfoDialog;
237 QTimer *iIdleTimeCounter;
239 Configuration *iConfiguration;
240 CommunicationManager *iCommunication;
241 DeviceManager *iDevice;
243 QTimer *iAutoRefresh;
245 QList<Meeting*> iMeetings;