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