1 #ifndef DEVICEMANAGER_H_
2 #define DEVICEMANAGER_H_
10 class DeviceDataStorage;
11 class DeviceConfigurator;
12 class OperationModeToggler;
14 static const int ERROR_BASE=200;
16 //! DeviceControl class. The main class of the DeviceControl.
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.
21 class DeviceManager : public QObject
26 //! Enumeration of device modes
28 * Enumeration of device modes
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. */
38 //! Enumeration of errors
40 * Enumeration of errors
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 */
63 * Constructor to initialize a DeviceManager instance.
64 * \param aSettings Pointer to the start up configuration settings.
66 DeviceManager( StartupSettings *aSettings );
68 virtual ~DeviceManager();
69 //! Creates instances of AlarmSender, DeviceConfigurator, DeviceDataStorage and HWKeyListener classes.
71 * Creates instances of AlarmSender, DeviceConfigurator, DeviceDataStorage and HWKeyListener classes.
72 * Connects their signals to the correct errorSender( ... ) slot.
74 void initDeviceManager();
75 //! Gets the current operation mode.
77 * Gets the current operation mode of the application.
78 * \return enum value of the current operation mode.
80 DeviceManager::OperationMode currentOperationMode();
81 //! Gets the string value of an operation mode.
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.
87 QString operationModeToString( OperationMode aMode );
88 //! Changes the operation mode.
90 * Changes the operation mode.
91 * \param aChange To indicate if the mode should be changed or not
93 void changeMode( bool aChange );
96 //! Signal. Emitted if user tries to change the operation mode.
98 * Signal. Emitted if user tries to change the operation mode.
99 * \param aMode The operation mode that user wants to activate.
101 void changeModeOrdered( DeviceManager::OperationMode aMode );
102 //! Signal. Emitted if an error happens.
104 * Signal. Emitted if an error happens.
105 * \param aCode An error code defined by DeviceManager.
106 * \param aAddInfo Possible additional information.
108 void error( int aCode, const QString &aAddInfo );
109 //! Signal. Emitted during the operation mode change to explain the current sub-change.
111 * Signal. Emitted during the operation mode change to explain the current sub-change.
112 * \param aMessage Explains the sub-change
114 void changingMode( const QString &aMessage );
115 //! Signal. Emitted if the operation mode change fails.
117 * Signal. Emitted if the operation mode change fails.
119 void changingModeFailed();
122 //! Slot. Handles "full screen"-hardware key presses.
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 )
128 void HWKeyFullScreenPressed();
129 //! Slot. Sends errors.
131 * Slot. Sends errors.
132 * \param aErrorCode The error code.
133 * \param aAddInfo The possible additional error text.
135 void errorSender( DeviceManager::ErrorCode aErrorCode, const QString &aAddInfo = "" );
136 //! Slot. Is called after the operation mode changing is finished.
138 * Slot. Is called after the operation mode changing is finished. If everything went fine, restarts
142 //! Slot. Toggles an attribute that indicates whether the errors should be sent.
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.
147 void toggleErrorSending( bool aToggle );
150 //! Updates the internal indicator of the current operation mode.
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.
157 bool setCurrentOperationMode();
158 //! Asks DeviceConfigurator to remove the deactivate script of the application.
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.
164 bool finalizeStandAloneMode();
165 //! Connects/disconnects the HWKeyListener signals to the private HWKeyFullScreenPressed() slot.
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.
171 void handleKeyPresses( bool aHandle );
174 AlarmSender *iAlarmSender;
175 HWKeyListener *iHWKeyListener;
176 StartupSettings *iSettings;
177 DeviceDataStorage *iDataStorage;
178 DeviceConfigurator *iConfigurator;
179 OperationModeToggler *iModeToggler;
182 bool iSendErrorMessages;
186 #endif /*DEVICEMANAGER_H_*/