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. This class handles
21 * the logic of the application according received calls to the slots. This class also maintains
22 * the instances of managers, timers and its own set of meeting list. The managers handles
23 * their tasks in more detailed manner.
25 class Engine : public QObject
32 * Constructor to initialize an Engine instance.
37 //! Gets default room of the application.
39 * Gets default room of the application.
40 * \return Pointer to the default Room instance.
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. Saves fetched meetings to the current instance's local storage.
74 * Slot. Saves fetched meetings to the current instance's local storage. Meetings are soted in a
75 * private QList, it is iterated through and signals are emitted if there is any new, updated or
77 * \param aMeetings The list of freshly fetched meetings.
79 void meetingsFetched( const QList<Meeting*>& );
80 //! Slot. Checks the availability of all the rooms.
82 * Slot. Checks the availability of all the rooms by iterating through the current object's local
83 * room storage and calling the roomStatusInfoNeeded() separately on each of them.
85 void checkStatusOfAllRooms();
86 //! Slot for receiving the failure event of operation mode changing.
88 * Slot. Receives the failure event of operation mode changing.
90 void changeModeFailed();
91 //! Slot for receiving the cancel event of the progress bar.
93 * Receives the cancel event of the progress bar when meeting details requested.
95 void fetchMeetingDetails( Meeting *aMeeting );
96 void cancelFetchMeetingDetails();
98 void handleViewEvent();
99 void previousViewRestored();
101 //! Slot for dialog activation signal.
103 * This slot is used to inform that dialog is activated. It stops
104 * the idle time counter so screensaver is not activated while the
105 * dialog is displayed.
107 void dialogActivated();
108 //! Slot for dialog deactivation signal.
110 * This slot is used to inform that dialog is deactivated. It restarts
111 * the idle time counter so that the screensaver is being activated again
114 void dialogDeactivated();
116 void stopIdleTimeCounter();
117 void startIdleTimeCounter();
119 void changeDeviceMode( bool aChange );
121 void currentRoomChanged( Room *aRoom );
124 // Make the UIManager as friendly class so it can connect to private slots.
125 friend class UIManager;
127 //! Provides the index of the Meeting instance which is at the specified time.
129 * Provides the index of the Meeting instance which is at the specified time. If there are
130 * overlapping meetings then returns one of then undetetministically.
131 * \param aRoom The room which meetings are looked through.
132 * \param aAt Date and time when the meeting is already going.
133 * \return Index of the meeting if found; otherwise, -1.
135 int indexOfMeetingAt( Room *aRoom, QDateTime aAt );
136 //! Provides the index of the Meeting instance which is starts the closest to the specified time.
138 * Provides the index of the Meeting instance which is starts the closest to the specified time.
139 * If there are overlapping meetings then returns one of then undetetministically.
140 * \param aRoom The room which meetings are looked through.
141 * \param aAt Date and time when the meeting is not yet started.
142 * \return Index of the meeting if found; otherwise, -1.
144 int indexOfMeetingAfter( Room *aRoom, QDateTime aAfter );
145 //! Slot. Fetches meetings from the server.
147 * Slot. Fetches meetings from the server, exact parameters are specified in the parameter list.
148 * \param aFrom Time from when the meetings need to be fetched.
149 * \param aUntil Time until when the meetings need to be fetched.
150 * \param aIn The room which meetings need to be fetched.
152 void fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, const Room *aIn );
153 //! Initialize configuration package.
155 * This method initializes configuration classes and
156 * connects signals from and to the engine.
158 void initConfiguration();
159 //! Initialize device package.
161 * This method initializes device manager and
162 * connects signals from and to the engine.
165 //! Initialize communication package.
167 * This method initializes the communication manager and
168 * connects signals from and to the engine.
170 void initCommunication();
171 //! Initialize user interface package.
173 * This method initializes the user interface and
174 * connects signals from and to the engine. This method
175 * makes the window manager visible and shows weekly
176 * view as the first view.
178 void initUserInterface();
179 //! Connects signal between objects.
181 * Signals that could not be connected while initializing different
182 * packages are connected here.
184 void connectSignals();
186 bool isMeetingInList(const QList<Meeting*> &aList, const Meeting *aMeeting);
189 static QTime endOfTheDay;
191 WindowManager *iWindowManager;
193 QTimer *iIdleTimeCounter;
195 Configuration *iConfiguration;
196 CommunicationManager *iCommunication;
197 DeviceManager *iDevice;
198 UIManager *iUIManager;
200 QTimer *iAutoRefresh;
202 QList<Meeting*> iMeetings;