1 #ifndef DEVICEMANAGER_H_
2 #define DEVICEMANAGER_H_
10 class DeviceDataStorage;
11 class DeviceConfigurator;
13 static const int ERROR_BASE=200;
15 //! DeviceControl class. The main class of the DeviceControl.
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.
20 class DeviceManager : public QObject
25 //! Enumeration of device modes
27 * Enumeration of device modes
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. */
37 //! Enumeration of errors
39 * Enumeration of errors
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 */
62 * Constructor to initialize a DeviceManager instance.
63 * \param aSettings Pointer to the start up configuration settings.
65 DeviceManager( StartupSettings *aSettings );
67 virtual ~DeviceManager();
68 //! Creates instances of AlarmSender, DeviceConfigurator, DeviceDataStorage and HWKeyListener classes.
70 * Creates instances of AlarmSender, DeviceConfigurator, DeviceDataStorage and HWKeyListener classes.
71 * Connects their signals to the correct errorSender( ... ) slot.
73 void initDeviceManager();
74 //! Gets the current operation mode.
76 * Gets the current operation mode of the application.
77 * \return enum value of the current operation mode.
79 DeviceManager::OperationMode currentOperationMode();
80 //! Gets the string value of an operation mode.
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.
86 QString operationModeToString( OperationMode aMode );
87 //! Changes the operation mode.
89 * Changes the operation mode.
90 * \param aChange To indicate if the mode should be changed or not
92 void changeMode( bool aChange );
95 //! Signal. Emitted if user tries to change the operation mode.
97 * Signal. Emitted if user tries to change the operation mode.
98 * \param aMode The operation mode that user wants to activate.
100 void changeModeOrdered( DeviceManager::OperationMode aMode );
101 //! Signal. Emitted if an error happens.
103 * Signal. Emitted if an error happens.
104 * \param aCode An error code defined by DeviceManager.
105 * \param aAddInfo Possible additional information.
107 void error( int aCode, const QString &aAddInfo );
109 void changingMode( const QString &aMessage );
112 //! Slot. Handles "full screen"-hardware key presses.
114 * Slot. Handles "full screen"-hardware key presses. Checks the current operation mode and concludes
115 * the next (desired) operation mode to be set. Emits a changeModeOrdered( DeviceManager::OperationMode )
118 void HWKeyFullScreenPressed();
119 //! Slot. Sends errors.
121 * Slot. Sends errors.
122 * \param aErrorCode The error code.
123 * \param aAddInfo The possible additional error text.
125 void errorSender( DeviceManager::ErrorCode aErrorCode, const QString &aAddInfo = "" );
128 //! Updates the internal indicator of the current operation mode.
130 * Updates the internal indicator of the current operation mode by asking the DeviceDataStorage to
131 * read it from the internal data storage. Calls finalizeStandAloneMode() method in case the mode is
132 * StandAloneModeInProgress.
133 * \return True if operation mode fetching succeeds; otherwise, false.
135 bool setCurrentOperationMode();
136 //! Stores the current operation mode.
138 * Stores the current operation mode by asking the DeviceDataStorage to write it to the internal
140 * \param aMode The operation mode that user wants to activate.
141 * \return True if operation mode storing succeeds; otherwise, false.
143 bool storeOperationMode( OperationMode aMode );
144 //! Asks DeviceConfigurator to remove the deactivate script of the application.
146 * Asks DeviceConfigurator to remove the deactivate script of the application. Also asks
147 * DeviceDataStorage to store the current operation mode (StandAloneMode) .
148 * \return True if operation mode storing and deactivation of the init script succeed; otherwise, false.
150 bool finalizeStandAloneMode();
151 //! Connects/disconnects the HWKeyListener signals to the private HWKeyFullScreenPressed() slot.
153 * Connects/disconnects the HWKeyListener signals to the private HWKeyFullScreenPressed() slot. In case
154 * a signal is caught the connection is disabled until the signal handling is finished.
155 * \param aHandle indicates if the signals should be connected or not.
157 void handleKeyPresses( bool aHandle );
160 AlarmSender *iAlarmSender;
161 HWKeyListener *iHWKeyListener;
162 StartupSettings *iSettings;
163 DeviceDataStorage *iDataStorage;
164 DeviceConfigurator *iConfigurator;
167 bool iSendErrorMessages;
171 #endif /*DEVICEMANAGER_H_*/