7 #include "WindowManager.h"
8 #include "DeviceManager.h"
9 #include "PasswordDialog.h"
14 class CommunicationManager;
18 //! BusinessLogic class. Contains all the business logic of the application.
20 * BusinessLogic class. Contains all the business logic of the application. It is responsible
21 * for connecting user interface to lower application layers (IO).
23 class Engine : public QObject
30 * Constructor to initialize an Engine instance.
35 //! Gets default room of the application.
37 * Gets default room of the application.
38 * \return Pointer to the default Room instance.
44 void meetingDetailsFetched( Meeting *aDetailedMeeting );
47 //! Slot. Closes the application.
49 * Slot. Closes the application.
51 void closeApplication();
52 //! Slot. Checks actual availability information of the specified room.
54 * Slot. Checks actual availability information of the specified room.
55 * \param aRoom The room which availability information is needed.
57 void roomStatusInfoNeeded( Room *aRoom );
58 //! Slot. Asks the communication to fetch new meeting data.
60 * Slot. Asks the communication to fetch new meeting data.
61 * \param aCurrentRoom The current room.
63 void shownWeekChanged( QDate aDate );
64 //! Slot. Handles errors.
66 * Slot. Handles errors and informs the UI by emitting the error() signal with the message in
68 * \param aCode The error code.
69 * \param aAddInfo Possible addition info.
71 void errorHandler( int aCode, const QString &aAddInfo = "" );
72 //! Slot. Fetches meetings from the server.
74 * Slot. Fetches meetings from the server. Parameters are hard coded: the meetings of the default
75 * room from current and +/- 2 weeks are fetched.
78 //! Slot. Saves fetched meetings to the current instance's local storage.
80 * Slot. Saves fetched meetings to the current instance's local storage. Meetings are soted in a
81 * private QList, it is iterated through and signals are emitted if there is any new, updated or
83 * \param aMeetings The list of freshly fetched meetings.
85 void meetingsFetched( const QList<Meeting*>& );
86 //! Slot. Checks the availability of all the rooms.
88 * Slot. Checks the availability of all the rooms by iterating through the current object's local
89 * room storage and calling the roomStatusInfoNeeded() separately on each of them.
91 void checkStatusOfAllRooms();
92 //! Slot for receiving the failure event of operation mode changing.
94 * Slot. Receives the failure event of operation mode changing.
96 void changeModeFailed();
97 //! Slot for receiving the cancel event of the progress bar.
99 * Receives the cancel event of the progress bar when meeting details requested.
101 void fetchMeetingDetails( Meeting *aMeeting );
102 void cancelFetchMeetingDetails();
104 void handleViewEvent();
105 void previousViewRestored();
107 //! Slot for dialog activation signal.
109 * This slot is used to inform that dialog is activated. It stops
110 * the idle time counter so screensaver is not activated while the
111 * dialog is displayed.
113 void dialogActivated();
114 //! Slot for dialog deactivation signal.
116 * This slot is used to inform that dialog is deactivated. It restarts
117 * the idle time counter so that the screensaver is being activated again
120 void dialogDeactivated();
122 void stopIdleTimeCounter();
123 void startIdleTimeCounter();
125 void changeDeviceMode( bool aChange );
128 // Make the UIManager as friendly class so it can connect to private slots.
129 friend class UIManager;
131 //! Provides the index of the Meeting instance which is at the specified time.
133 * Provides the index of the Meeting instance which is at the specified time. If there are
134 * overlapping meetings then returns one of then undetetministically.
135 * \param aRoom The room which meetings are looked through.
136 * \param aAt Date and time when the meeting is already going.
137 * \return Index of the meeting if found; otherwise, -1.
139 int indexOfMeetingAt( Room *aRoom, QDateTime aAt );
140 //! Provides the index of the Meeting instance which is starts the closest to the specified time.
142 * Provides the index of the Meeting instance which is starts the closest to the specified time.
143 * If there are overlapping meetings then returns one of then undetetministically.
144 * \param aRoom The room which meetings are looked through.
145 * \param aAt Date and time when the meeting is not yet started.
146 * \return Index of the meeting if found; otherwise, -1.
148 int indexOfMeetingAfter( Room *aRoom, QDateTime aAfter );
149 //! Indicates if the QList contains the Meeting or not.
151 * Indicates if the QList contains the Meeting or not.
152 * \param aList List of meetings.
153 * \param aMeeting The meeting which is seeked in the list for.
154 * \return True if contains; otherwise, false.
156 static bool isMeetingInList( const QList<Meeting*> &aList, const Meeting *aMeeting );
157 //! Slot. Fetches meetings from the server.
159 * Slot. Fetches meetings from the server, exact parameters are specified in the parameter list.
160 * \param aFrom Time from when the meetings need to be fetched.
161 * \param aUntil Time until when the meetings need to be fetched.
162 * \param aIn The room which meetings need to be fetched.
164 void fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, const Room *aIn );
165 //! Initialize configuration package.
167 * This method initializes configuration classes and
168 * connects signals from and to the engine.
170 void initConfiguration();
171 //! Initialize device package.
173 * This method initializes device manager and
174 * connects signals from and to the engine.
177 //! Initialize communication package.
179 * This method initializes the communication manager and
180 * connects signals from and to the engine.
182 void initCommunication();
183 //! Initialize user interface package.
185 * This method initializes the user interface and
186 * connects signals from and to the engine. This method
187 * makes the window manager visible and shows weekly
188 * view as the first view.
190 void initUserInterface();
191 //! Connects signal between objects.
193 * Signals that could not be connected while initializing different
194 * packages are connected here.
196 void connectSignals();
199 static QTime endOfTheDay;
201 WindowManager *iWindowManager;
203 QTimer *iIdleTimeCounter;
205 Configuration *iConfiguration;
206 CommunicationManager *iCommunication;
207 DeviceManager *iDevice;
208 UIManager *iUIManager;
210 QTimer *iAutoRefresh;
212 QList<Meeting*> iMeetings;