Progress bar related updating
[qtmeetings] / src / IO / DeviceControl / DeviceManager.h
1 #ifndef DEVICEMANAGER_H_
2 #define DEVICEMANAGER_H_
3
4 #include <QObject>
5 #include <QStringList>
6
7 class AlarmSender;
8 class HWKeyListener;
9 class StartupSettings;
10 class DeviceDataStorage;
11 class DeviceConfigurator;
12 class OperationModeToggler;
13
14 static const int ERROR_BASE=200;
15
16 //! DeviceControl class. The main class of the DeviceControl.
17 /*!
18  * DeviceControl class. The main class of the DeviceControl. Responsible to communicate between the
19  * BusinessLogic and the device. Takes care of the operation mode changes of the application.
20  */
21 class DeviceManager : public QObject
22 {
23         Q_OBJECT
24
25 public:
26         //! Enumeration of device modes
27         /*!
28          * Enumeration of device modes
29          */
30         enum OperationMode
31         {
32                 KioskMode, /*!< Device is in kiosk mode. */
33                 StandAloneModeInProgress, /*!< Device is in stand alone mode. */
34                 StandAloneMode, /*!< Device is in stand alone mode. */
35                 EmptyMode /*!< Application cannot read the mode. */
36         };
37
38         //! Enumeration of errors
39         /*!
40          * Enumeration of errors
41          */
42         enum ErrorCode
43         {
44                 FileCreationFailed, /*!< File couldn't be created. */
45                 OldAlarmsNotRemoved, /*!< Previously sent old alarm events cannot be removed. */
46                 NewAlarmsNotSent, /*!< New alarms cannot be sent. */
47                 NewAlarmsNotStored, /*!< Information about new sent alarms cannot be stored. */
48                 ScreenSettingsNotStored, /*!< Configuration parameters of screen options cannot be stored. */
49                 ScreenSettingsNotFetched, /*!< Configuration parameters of screen options cannot be fetched. */
50                 ScreenSettingsNotChanged, /*!< Configuration parameters of screen options cannot be changed. */
51                 KeySettingsNotFetched, /*!< Configuration parameters of hw key options cannot be fetched. */
52                 KeySettingsNotStored, /*!< Configuration parameters of hw key options cannot be stored. */
53                 KeySettingsNotChanged, /*!< Configuration parameters of hw key options cannot be changed. */
54                 InitScriptNotChanged, /*!< Init script to auto launch the application was not registered/unregistered */
55                 ModeNotFetched, /*!< Information about the current operation mode cannot be fetched */
56                 ModeNotStored, /*!< Information about the new opration mode cannot be stored */
57                 DeviceNotRestarted /*!< Device cannot be restarted */
58         };
59
60 public:
61         //! Constructor.
62         /*!
63          * Constructor to initialize a DeviceManager instance.
64          * \param aSettings Pointer to the start up configuration settings.
65          */
66         DeviceManager( StartupSettings *aSettings );
67         //! Destructor.
68         virtual ~DeviceManager();
69         //! Creates instances of AlarmSender, DeviceConfigurator, DeviceDataStorage and HWKeyListener classes.
70         /*!
71          * Creates instances of AlarmSender, DeviceConfigurator, DeviceDataStorage and HWKeyListener classes.
72          * Connects their signals to the correct errorSender( ... ) slot.
73          */
74         void initDeviceManager();
75         //! Gets the current operation mode.
76         /*!
77          * Gets the current operation mode of the application.
78          * \return enum value of the current operation mode.
79          */
80         DeviceManager::OperationMode currentOperationMode();
81         //! Gets the string value of an operation mode.
82         /*!
83          * Gets the string value of an operation mode.
84          * \param aMode The enum value of the operation mode.
85          * \return QString value of the current operation mode.
86          */
87         QString operationModeToString( OperationMode aMode );
88         //! Changes the operation mode.
89         /*!
90          * Changes the operation mode.
91          * \param aChange To indicate if the mode should be changed or not
92          */
93         void changeMode( bool aChange );
94
95 signals:
96         //! Signal. Emitted if user tries to change the operation mode.
97         /*!
98          * Signal. Emitted if user tries to change the operation mode.
99          * \param aMode The operation mode that user wants to activate.
100          */
101         void changeModeOrdered( DeviceManager::OperationMode aMode );
102         //! Signal. Emitted if an error happens.
103         /*!
104          * Signal. Emitted if an error happens.
105          * \param aCode An error code defined by DeviceManager.
106          * \param aAddInfo Possible additional information.
107          */
108         void error( int aCode, const QString &aAddInfo );
109         //! Signal. Emitted during the operation mode change to explain the current sub-change.
110         /*!
111          * Signal. Emitted during the operation mode change to explain the current sub-change. 
112          * \param aMessage Explains the sub-change
113          */
114         void changingMode( const QString &aMessage );
115         //! Signal. Emitted if the operation mode change fails.
116         /*!
117          * Signal. Emitted if the operation mode change fails.
118          */
119         void changingModeFailed();
120
121 private slots:
122         //! Slot. Handles "full screen"-hardware key presses.
123         /*!
124          * Slot. Handles "full screen"-hardware key presses. Checks the current operation mode and concludes
125          * the next (desired) operation mode to be set. Emits a changeModeOrdered( DeviceManager::OperationMode )
126          * signal.
127          */
128         void HWKeyFullScreenPressed();
129         //! Slot. Sends errors.
130         /*!
131          * Slot. Sends errors.
132          * \param aErrorCode The error code.
133          * \param aAddInfo The possible additional error text.
134          */
135         void errorSender( DeviceManager::ErrorCode aErrorCode, const QString &aAddInfo = "" );
136         //! Slot. Is called after the operation mode changing is finished.
137         /*!
138          * Slot. Is called after the operation mode changing is finished. If everything went fine, restarts
139          * the device. 
140          */
141         void modeChanged();
142         //! Slot. Toggles an attribute that indicates whether the errors should be sent.
143         /*!
144          * Slot. Toggles an attribute that indicates whether the errors should be sent.
145          * \param aToggle Indicates if the errors are wanted to be shown.
146          */
147         void toggleErrorSending( bool aToggle );
148
149 private:
150         //! Updates the internal indicator of the current operation mode.
151         /*!
152          * Updates the internal indicator of the current operation mode by asking the DeviceDataStorage to
153          * read it from the internal data storage. Calls finalizeStandAloneMode() method in case the mode is
154          * StandAloneModeInProgress.
155          * \return True if operation mode fetching succeeds; otherwise, false.
156          */
157         bool setCurrentOperationMode();
158         //! Asks DeviceConfigurator to remove the deactivate script of the application.
159         /*!
160          * Asks DeviceConfigurator to remove the deactivate script of the application. Also asks
161          * DeviceDataStorage to store the current operation mode (StandAloneMode) .
162          * \return True if operation mode storing and deactivation of the init script succeed; otherwise, false.
163          */
164         bool finalizeStandAloneMode();
165         //! Connects/disconnects the HWKeyListener signals to the private HWKeyFullScreenPressed() slot.
166         /*!
167          * Connects/disconnects the HWKeyListener signals to the private HWKeyFullScreenPressed() slot. In case
168          * a signal is caught the connection is disabled until the signal handling is finished.
169          * \param aHandle indicates if the signals should be connected or not.
170          */
171         void handleKeyPresses( bool aHandle );
172
173 private:
174         AlarmSender *iAlarmSender;
175         HWKeyListener *iHWKeyListener;
176         StartupSettings *iSettings;
177         DeviceDataStorage *iDataStorage;
178         DeviceConfigurator *iConfigurator;
179         OperationModeToggler *iModeToggler;
180
181         OperationMode iMode;
182         bool iSendErrorMessages;
183
184 };
185
186 #endif /*DEVICEMANAGER_H_*/