Fixed the room status indicator view partly. Image is still not shown
[qtmeetings] / src / BusinessLogic / Engine.h
1 #ifndef ENGINE_H_
2 #define ENGINE_H_
3
4 #include <QObject>
5 #include <QDateTime>
6 #include "Room.h"
7 #include "WindowManager.h"
8 #include "DeviceManager.h"
9 #include "PasswordDialog.h"
10
11 class QTimer;
12 class Clock;
13 class Configuration;
14 class CommunicationManager;
15 class Meeting;
16 class UIManager;
17
18 //! BusinessLogic class. Contains all the business logic of the application.
19 /*!
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.
24  */
25 class Engine : public QObject
26 {
27         Q_OBJECT
28
29 public:
30         //! Constructor.
31         /*!
32          * Constructor to initialize an Engine instance.
33          */
34         Engine();
35         //! Destructor.
36         virtual ~Engine();
37         //! Gets default room of the application.
38         /*!
39          * Gets default room of the application.
40          * \return Pointer to the default Room instance.
41          */
42         Room* defaultRoom();
43
44 signals:
45
46         void roomStatusChanged( Room::Status aStatus, QTime aUntil );
47
48 private slots:
49         //! Slot. Closes the application.
50         /*!
51          * Slot. Closes the application.
52          */
53         void closeApplication();
54         //! Slot. Checks actual availability information of the specified room.
55         /*!
56          * Slot. Checks actual availability information of the specified room.
57          * \param aRoom The room which availability information is needed.
58          */
59         void roomStatusInfoNeeded( Room *aRoom );
60         //! Slot. Asks the communication to fetch new meeting data.
61         /*!
62          * Slot. Asks the communication to fetch new meeting data.
63          * \param aCurrentRoom The current room.
64          */
65         void shownWeekChanged( QDate aDate );
66         //! Slot. Handles errors.
67         /*!
68          * Slot. Handles errors and informs the UI by emitting the error() signal with the message in
69          * parameter.
70          * \param aCode The error code.
71          * \param aAddInfo Possible addition info.
72          */
73         void errorHandler( int aCode, const QString &aAddInfo = "" );
74         //! Slot. Saves fetched meetings to the current instance's local storage.
75         /*!
76          * Slot. Saves fetched meetings to the current instance's local storage. Meetings are soted in a
77          * private QList, it is iterated through and signals are emitted if there is any new, updated or
78          * deleted meeting.
79          * \param aMeetings The list of freshly fetched meetings.
80          */
81         void meetingsFetched( const QList<Meeting*>& );
82         //! Slot. Checks the availability of all the rooms.
83         /*!
84          * Slot. Checks the availability of all the rooms by iterating through the current object's local
85          * room storage and calling the roomStatusInfoNeeded() separately on each of them.
86          */
87         void checkStatusOfAllRooms();
88         //! Slot for receiving the failure event of operation mode changing.
89         /*!
90          * Slot. Receives the failure event of operation mode changing.
91          */
92         void changeModeFailed();
93         //! Slot for receiving the cancel event of the progress bar.
94         /*!
95          *  Receives the cancel event of the progress bar when meeting details requested.
96          */
97         void fetchMeetingDetails( Meeting *aMeeting );
98         void cancelFetchMeetingDetails();
99         
100         void handleViewEvent();
101         void previousViewRestored();
102         
103         //! Slot for dialog activation signal.
104         /*!
105          * This slot is used to inform that dialog is activated. It stops
106          * the idle time counter so screensaver is not activated while the
107          * dialog is displayed.
108          */
109         void dialogActivated();
110         //! Slot for dialog deactivation signal.
111         /*!
112          * This slot is used to inform that dialog is deactivated. It restarts
113          * the idle time counter so that the screensaver is being activated again
114          * as needed.
115          */
116         void dialogDeactivated();
117         
118         void stopIdleTimeCounter();
119         void startIdleTimeCounter();
120
121         void changeDeviceMode( bool aChange );
122         
123         void currentRoomChanged( Room *aRoom );
124         
125 private:
126         // Make the UIManager as friendly class so it can connect to private slots.
127         friend class UIManager;
128         
129         //! Provides the index of the Meeting instance which is at the specified time.
130         /*!
131          * Provides the index of the Meeting instance which is at the specified time. If there are
132          * overlapping meetings then returns one of then undetetministically.
133          * \param aRoom The room which meetings are looked through.
134          * \param aAt Date and time when the meeting is already going.
135          * \return Index of the meeting if found; otherwise, -1.
136          */
137         int indexOfMeetingAt( Room *aRoom, QDateTime aAt );
138         //! Provides the index of the Meeting instance which is starts the closest to the specified time.
139         /*!
140          * Provides the index of the Meeting instance which is starts the closest to the specified time.
141          * If there are overlapping meetings then returns one of then undetetministically.
142          * \param aRoom The room which meetings are looked through.
143          * \param aAt Date and time when the meeting is not yet started.
144          * \return Index of the meeting if found; otherwise, -1.
145          */
146         int indexOfMeetingAfter( Room *aRoom, QDateTime aAfter );
147         //! Slot. Fetches meetings from the server.
148         /*!
149          * Slot. Fetches meetings from the server, exact parameters are specified in the parameter list.
150          * \param aFrom Time from when the meetings need to be fetched.
151          * \param aUntil Time until when the meetings need to be fetched.
152          * \param aIn The room which meetings need to be fetched.
153          */
154         void fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, const Room *aIn );
155         //! Initialize configuration package.
156         /*!
157          * This method initializes configuration classes and
158          * connects signals from and to the engine.
159          */
160         void initConfiguration();
161         //! Initialize device package.
162         /*!
163          * This method initializes device manager and
164          * connects signals from and to the engine.
165          */
166         void initDevice();
167         //! Initialize communication package.
168         /*!
169          * This method initializes the communication manager and
170          * connects signals from and to the engine.
171          */
172         void initCommunication();
173         //! Initialize user interface package.
174         /*!
175          * This method initializes the user interface and
176          * connects signals from and to the engine. This method
177          * makes the window manager visible and shows weekly
178          * view as the first view.
179          */
180         void initUserInterface();
181         //! Connects signal between objects.
182         /*!
183          * Signals that could not be connected while initializing different
184          * packages are connected here.
185          */
186         void connectSignals();
187         
188         bool isMeetingInList(const QList<Meeting*> &aList, const Meeting *aMeeting);
189
190 private:
191         static QTime endOfTheDay;
192
193         WindowManager *iWindowManager;
194         
195         QTimer *iIdleTimeCounter;
196         Clock *iClock;
197         Configuration *iConfiguration;
198         CommunicationManager *iCommunication;
199         DeviceManager *iDevice;
200         UIManager *iUIManager;
201
202         QTimer *iAutoRefresh;
203
204         QList<Meeting*> iMeetings;
205         
206         Room *iCurrentRoom;
207 };
208
209 #endif /*ENGINE_H_*/