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.
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. Asks the communication to fetch new meeting data.
58 * Slot. Asks the communication to fetch new meeting data.
59 * \param aCurrentRoom The current room.
61 void shownWeekChanged( QDate aDate );
62 //! Slot. Handles errors.
64 * Slot. Handles errors and informs the UI by emitting the error() signal with the message in
66 * \param aCode The error code.
67 * \param aAddInfo Possible addition info.
69 void errorHandler( int aCode, const QString &aAddInfo = "" );
70 //! Slot. Fetches meetings from the server.
72 * Slot. Fetches meetings from the server. Parameters are hard coded: the meetings of the default
73 * room from current and +/- 2 weeks are fetched.
75 // void fetchMeetings();
76 //! Slot. Saves fetched meetings to the current instance's local storage.
78 * Slot. Saves fetched meetings to the current instance's local storage. Meetings are soted in a
79 * private QList, it is iterated through and signals are emitted if there is any new, updated or
81 * \param aMeetings The list of freshly fetched meetings.
83 void meetingsFetched( const QList<Meeting*>& );
84 //! Slot. Checks the availability of all the rooms.
86 * Slot. Checks the availability of all the rooms by iterating through the current object's local
87 * room storage and calling the roomStatusInfoNeeded() separately on each of them.
89 void checkStatusOfAllRooms();
90 //! Slot for receiving the failure event of operation mode changing.
92 * Slot. Receives the failure event of operation mode changing.
94 void changeModeFailed();
95 //! Slot for receiving the cancel event of the progress bar.
97 * Receives the cancel event of the progress bar when meeting details requested.
99 void fetchMeetingDetails( Meeting *aMeeting );
100 void cancelFetchMeetingDetails();
102 void handleViewEvent();
103 void previousViewRestored();
105 //! Slot for dialog activation signal.
107 * This slot is used to inform that dialog is activated. It stops
108 * the idle time counter so screensaver is not activated while the
109 * dialog is displayed.
111 void dialogActivated();
112 //! Slot for dialog deactivation signal.
114 * This slot is used to inform that dialog is deactivated. It restarts
115 * the idle time counter so that the screensaver is being activated again
118 void dialogDeactivated();
120 void stopIdleTimeCounter();
121 void startIdleTimeCounter();
123 void changeDeviceMode();
125 void currentRoomChanged( Room *aRoom );
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 //! Slot. Fetches meetings from the server.
151 * Slot. Fetches meetings from the server, exact parameters are specified in the parameter list.
152 * \param aFrom Time from when the meetings need to be fetched.
153 * \param aUntil Time until when the meetings need to be fetched.
154 * \param aIn The room which meetings need to be fetched.
156 void fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, const Room *aIn );
157 //! Initialize configuration package.
159 * This method initializes configuration classes and
160 * connects signals from and to the engine.
162 void initConfiguration();
163 //! Initialize device package.
165 * This method initializes device manager and
166 * connects signals from and to the engine.
169 //! Initialize communication package.
171 * This method initializes the communication manager and
172 * connects signals from and to the engine.
174 void initCommunication();
175 //! Initialize user interface package.
177 * This method initializes the user interface and
178 * connects signals from and to the engine. This method
179 * makes the window manager visible and shows weekly
180 * view as the first view.
182 void initUserInterface();
183 //! Connects signal between objects.
185 * Signals that could not be connected while initializing different
186 * packages are connected here.
188 void connectSignals();
190 bool isMeetingInList(const QList<Meeting*> &aList, const Meeting *aMeeting);
193 static QTime endOfTheDay;
195 WindowManager *iWindowManager;
197 QTimer *iIdleTimeCounter;
199 Configuration *iConfiguration;
200 CommunicationManager *iCommunication;
201 DeviceManager *iDevice;
202 UIManager *iUIManager;
204 QTimer *iAutoRefresh;
206 QList<Meeting*> iMeetings;
209 bool iCommunicationFailed;
210 bool iCurrentWeekFetched;