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