7 #include "WindowManager.h"
8 #include "DeviceManager.h"
9 #include "PasswordDialog.h"
14 class CommunicationManager;
16 // class DeviceManager;
17 class WeeklyViewWidget;
19 class RoomStatusIndicatorWidget;
21 class MeetingInfoDialog;
23 //! BusinessLogic class. Contains all the business logic of the application.
25 * BusinessLogic class. Contains all the business logic of the application. It is responsible
26 * for connecting user interface to lower application layers (IO).
28 class Engine : public QObject
35 * Constructor to initialize an Engine instance.
40 //! Gets default room of the application.
42 * Gets default room of the application.
43 * \return Pointer to the default Room instance.
49 void meetingDetailsFetched( Meeting *aDetailedMeeting );
52 //! Slot. Closes the application.
54 * Slot. Closes the application.
56 void closeApplication();
57 //! Slot. Checks actual availability information of the specified room.
59 * Slot. Checks actual availability information of the specified room.
60 * \param aRoom The room which availability information is needed.
62 void roomStatusInfoNeeded( Room *aRoom );
63 //! Slot. Asks the communication to fetch new meeting data.
65 * Slot. Asks the communication to fetch new meeting data.
66 * \param aCurrentRoom The current room.
68 void currentRoomChanged( Room *aCurrentRoom );
69 //! Slot. Asks the communication to fetch new meeting data.
71 * Slot. Asks the communication to fetch new meeting data.
72 * \param aCurrentRoom The current room.
74 void shownWeekChanged( QDate aDate );
75 //! Slot. Handles errors.
77 * Slot. Handles errors and informs the UI by emitting the error() signal with the message in
79 * \param aCode The error code.
80 * \param aAddInfo Possible addition info.
82 void errorHandler( int aCode, const QString &aAddInfo = "" );
83 //! Slot. Fetches meetings from the server.
85 * Slot. Fetches meetings from the server. Parameters are hard coded: the meetings of the default
86 * room from current and +/- 2 weeks are fetched.
89 //! Slot. Saves fetched meetings to the current instance's local storage.
91 * Slot. Saves fetched meetings to the current instance's local storage. Meetings are soted in a
92 * private QList, it is iterated through and signals are emitted if there is any new, updated or
94 * \param aMeetings The list of freshly fetched meetings.
96 void meetingsFetched( const QList<Meeting*>& );
98 void meetingDetailsFetched( Meeting &aDetailedMeeting );
100 //! Slot. Checks the availability of all the rooms.
102 * Slot. Checks the availability of all the rooms by iterating through the current object's local
103 * room storage and calling the roomStatusInfoNeeded() separately on each of them.
105 void checkStatusOfAllRooms();
106 //! Slot for popping up the confirmation dialog to change the current operation mode
108 * Slot. Asks Window manager to pop up a confirmation dialog.
109 * \param aMode The operation mode to be changed to
111 void changeModeOrdered( DeviceManager::OperationMode aMode );
112 //! Slot. Fetches meeting details from the server.
114 * Slot. Fetches meeting details from the server.
115 * \param aMeeting The meeting.
117 void fetchMeetingDetails( Meeting *aMeeting );
118 //! Slot for receiving the status of the entered password
120 * Slot. Receives the status of the entered password and makes the DeviceManager to change the
121 * operation mode if the password is correct.
122 * \param aPasswordStatus The status of the password.
124 void passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus );
125 //! Slot for receiving the cancel event of the progress bar.
127 * Slot. Receives the cancel event of the progress bar.
129 void progressBarCancelled();
131 void handleViewEvent();
132 void previousViewRestored();
133 void settingsViewRequested();
135 void idleTimerTimeout();
137 void settingsOkClicked();
139 //! Slot for dialog activation signal.
141 * This slot is used to inform that dialog is activated. It stops
142 * the idle time counter so screensaver is not activated while the
143 * dialog is displayed.
145 void dialogActivated();
146 //! Slot for dialog deactivation signal.
148 * This slot is used to inform that dialog is deactivated. It restarts
149 * the idle time counter so that the screensaver is being activated again
152 void dialogDeactivated();
155 //! Provides the index of the Meeting instance which is at the specified time.
157 * Provides the index of the Meeting instance which is at the specified time. If there are
158 * overlapping meetings then returns one of then undetetministically.
159 * \param aRoom The room which meetings are looked through.
160 * \param aAt Date and time when the meeting is already going.
161 * \return Index of the meeting if found; otherwise, -1.
163 int indexOfMeetingAt( Room *aRoom, QDateTime aAt );
164 //! Provides the index of the Meeting instance which is starts the closest to the specified time.
166 * Provides the index of the Meeting instance which is starts the closest to the specified time.
167 * If there are overlapping meetings then returns one of then undetetministically.
168 * \param aRoom The room which meetings are looked through.
169 * \param aAt Date and time when the meeting is not yet started.
170 * \return Index of the meeting if found; otherwise, -1.
172 int indexOfMeetingAfter( Room *aRoom, QDateTime aAfter );
173 //! Indicates if the QList contains the Meeting or not.
175 * Indicates if the QList contains the Meeting or not.
176 * \param aList List of meetings.
177 * \param aMeeting The meeting which is seeked in the list for.
178 * \return True if contains; otherwise, false.
180 static bool isMeetingInList( const QList<Meeting*> &aList, const Meeting *aMeeting );
181 //! Slot. Fetches meetings from the server.
183 * Slot. Fetches meetings from the server, exact parameters are specified in the parameter list.
184 * \param aFrom Time from when the meetings need to be fetched.
185 * \param aUntil Time until when the meetings need to be fetched.
186 * \param aIn The room which meetings need to be fetched.
188 void fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, const Room *aIn );
189 //! Initialize configuration package.
191 * This method initializes configuration classes and
192 * connects signals from and to the engine.
194 void initConfiguration();
195 //! Initialize device package.
197 * This method initializes device manager and
198 * connects signals from and to the engine.
201 //! Initialize communication package.
203 * This method initializes the communication manager and
204 * connects signals from and to the engine.
206 void initCommunication();
207 //! Initialize user interface package.
209 * This method initializes the user interface and
210 * connects signals from and to the engine. This method
211 * makes the window manager visible and shows weekly
212 * view as the first view.
214 void initUserInterface();
215 //! Connects signal between objects.
217 * Signals that could not be connected while initializing different
218 * packages are connected here.
220 void connectSignals();
223 static QTime endOfTheDay;
225 WindowManager *iWindowManager;
226 WeeklyViewWidget *iWeeklyView;
227 SettingsView *iSettingsView;
228 RoomStatusIndicatorWidget *iRoomStatusIndicator;
230 PasswordDialog *iPasswordDialog;
231 MeetingInfoDialog *iMeetingInfoDialog;
233 QTimer *iIdleTimeCounter;
235 Configuration *iConfiguration;
236 CommunicationManager *iCommunication;
237 DeviceManager *iDevice;
239 QTimer *iAutoRefresh;
241 QList<Meeting*> iMeetings;