1 #ifndef DEVICEMANAGER_H_
2 #define DEVICEMANAGER_H_
10 class StartupSettings;
11 class DeviceDataStorage;
12 class DeviceConfigurator;
13 class OperationModeToggler;
15 static const int ERROR_BASE=200;
17 //! DeviceControl class. The main class of the DeviceControl.
19 * DeviceControl class. The main class of the DeviceControl. Responsible to communicate between the
20 * BusinessLogic and the device. Takes care of the operation mode changes of the application.
22 class DeviceManager : public QObject
27 //! Enumeration of device modes
29 * Enumeration of device modes
33 KioskMode, /*!< Device is in kiosk mode. */
34 StandAloneModeInProgress, /*!< Device is in stand alone mode. */
35 StandAloneMode, /*!< Device is in stand alone mode. */
36 EmptyMode /*!< Application cannot read the mode. */
39 //! Enumeration of errors
41 * Enumeration of errors
46 FileCreationFailed, /*!< File couldn't be created. */
47 OldAlarmsNotRemoved, /*!< Previously sent old alarm events cannot be removed. */
48 NewAlarmsNotSent, /*!< New alarms cannot be sent. */
49 NewAlarmsNotStored, /*!< Information about new sent alarms cannot be stored. */
50 ScreenSettingsNotStored, /*!< Configuration parameters of screen options cannot be stored. */
51 ScreenSettingsNotFetched, /*!< Configuration parameters of screen options cannot be fetched. */
52 ScreenSettingsNotChanged, /*!< Configuration parameters of screen options cannot be changed. */
53 KeySettingsNotFetched, /*!< Configuration parameters of hw key options cannot be fetched. */
54 KeySettingsNotStored, /*!< Configuration parameters of hw key options cannot be stored. */
55 KeySettingsNotChanged, /*!< Configuration parameters of hw key options cannot be changed. */
56 InitScriptNotChanged, /*!< Init script to auto launch the application was not registered/unregistered */
57 ModeNotFetched, /*!< Information about the current operation mode cannot be fetched */
58 ModeNotStored, /*!< Information about the new opration mode cannot be stored */
59 DeviceNotRestarted /*!< Device cannot be restarted */
65 * Constructor to initialize a DeviceManager instance.
66 * \param aSettings Pointer to the start up configuration settings.
68 DeviceManager( StartupSettings *aSettings );
70 virtual ~DeviceManager();
71 //! Creates instances of AlarmSender, DeviceConfigurator, DeviceDataStorage and HWKeyListener classes.
73 * Creates instances of AlarmSender, DeviceConfigurator, DeviceDataStorage and HWKeyListener classes.
74 * Connects their signals to the correct errorSender( ... ) slot.
76 void initDeviceManager();
77 //! Gets the current operation mode.
79 * Gets the current operation mode of the application.
80 * \return enum value of the current operation mode.
82 DeviceManager::OperationMode currentOperationMode();
83 //! Gets the string value of an operation mode.
85 * Gets the string value of an operation mode.
86 * \param aMode The enum value of the operation mode.
87 * \return QString value of the current operation mode.
89 QString operationModeToString( OperationMode aMode );
90 //! Changes the operation mode.
92 * Changes the operation mode.
93 * \param aChange To indicate if the mode should be changed or not
95 void changeMode( bool aChange );
98 //! Signal. Emitted if user tries to change the operation mode.
100 * Signal. Emitted if user tries to change the operation mode.
101 * \param aMode The operation mode that user wants to activate.
103 void changeModeOrdered( DeviceManager::OperationMode aMode );
104 //! Signal. Emitted if an error happens.
106 * Signal. Emitted if an error happens.
107 * \param aCode An error code defined by DeviceManager.
108 * \param aAddInfo Possible additional information.
110 void error( int aCode, const QString &aAddInfo );
111 //! Signal. Emitted during the operation mode change to explain the current sub-change.
113 * Signal. Emitted during the operation mode change to explain the current sub-change.
114 * \param aMessage Explains the sub-change
116 void changingMode( const QString &aMessage );
117 //! Signal. Emitted if the operation mode change fails.
119 * Signal. Emitted if the operation mode change fails.
121 void changeModeFailed();
124 //! Slot. Handles "full screen"-hardware key presses.
126 * Slot. Handles "full screen"-hardware key presses. Checks the current operation mode and concludes
127 * the next (desired) operation mode to be set. Emits a changeModeOrdered( DeviceManager::OperationMode )
130 void HWKeyFullScreenPressed();
131 //! Slot. Sends errors.
133 * Slot. Sends errors.
134 * \param aErrorCode The error code.
135 * \param aAddInfo The possible additional error text.
137 void errorSender( DeviceManager::ErrorCode aErrorCode, const QString &aAddInfo = "" );
138 //! Slot. Is called after the operation mode changing is finished.
140 * Slot. Is called after the operation mode changing is finished. If everything went fine, restarts
144 //! Slot. Toggles an attribute that indicates whether the errors should be sent.
146 * Slot. Toggles an attribute that indicates whether the errors should be sent.
147 * \param aToggle Indicates if the errors are wanted to be shown.
149 void toggleErrorSending( bool aToggle );
152 //! Updates the internal indicator of the current operation mode.
154 * Updates the internal indicator of the current operation mode by asking the DeviceDataStorage to
155 * read it from the internal data storage. Calls finalizeStandAloneMode() method in case the mode is
156 * StandAloneModeInProgress.
157 * \return True if operation mode fetching succeeds; otherwise, false.
159 bool setCurrentOperationMode();
160 //! Asks DeviceConfigurator to remove the deactivate script of the application.
162 * Asks DeviceConfigurator to remove the deactivate script of the application. Also asks
163 * DeviceDataStorage to store the current operation mode (StandAloneMode) .
164 * \return True if operation mode storing and deactivation of the init script succeed; otherwise, false.
166 bool finalizeStandAloneMode();
167 //! Connects/disconnects the HWKeyListener signals to the private HWKeyFullScreenPressed() slot.
169 * Connects/disconnects the HWKeyListener signals to the private HWKeyFullScreenPressed() slot. In case
170 * a signal is caught the connection is disabled until the signal handling is finished.
171 * \param aHandle indicates if the signals should be connected or not.
173 void handleKeyPresses( bool aHandle );
176 AlarmSender *iAlarmSender;
177 HWKeyListener *iHWKeyListener;
178 StartupSettings *iSettings;
179 DeviceDataStorage *iDataStorage;
180 DeviceConfigurator *iConfigurator;
181 OperationModeToggler *iModeToggler;
184 bool iSendErrorMessages;
188 Q_DECLARE_METATYPE( DeviceManager::ErrorCode )
190 #endif /*DEVICEMANAGER_H_*/