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 );
110 void changingMode( const QString &aMessage );
113 //! Slot. Handles "full screen"-hardware key presses.
115 * Slot. Handles "full screen"-hardware key presses. Checks the current operation mode and concludes
116 * the next (desired) operation mode to be set. Emits a changeModeOrdered( DeviceManager::OperationMode )
119 void HWKeyFullScreenPressed();
120 //! Slot. Sends errors.
122 * Slot. Sends errors.
123 * \param aErrorCode The error code.
124 * \param aAddInfo The possible additional error text.
126 void errorSender( DeviceManager::ErrorCode aErrorCode, const QString &aAddInfo = "" );
130 //! Updates the internal indicator of the current operation mode.
132 * Updates the internal indicator of the current operation mode by asking the DeviceDataStorage to
133 * read it from the internal data storage. Calls finalizeStandAloneMode() method in case the mode is
134 * StandAloneModeInProgress.
135 * \return True if operation mode fetching succeeds; otherwise, false.
137 bool setCurrentOperationMode();
138 //! Asks DeviceConfigurator to remove the deactivate script of the application.
140 * Asks DeviceConfigurator to remove the deactivate script of the application. Also asks
141 * DeviceDataStorage to store the current operation mode (StandAloneMode) .
142 * \return True if operation mode storing and deactivation of the init script succeed; otherwise, false.
144 bool finalizeStandAloneMode();
145 //! Connects/disconnects the HWKeyListener signals to the private HWKeyFullScreenPressed() slot.
147 * Connects/disconnects the HWKeyListener signals to the private HWKeyFullScreenPressed() slot. In case
148 * a signal is caught the connection is disabled until the signal handling is finished.
149 * \param aHandle indicates if the signals should be connected or not.
151 void handleKeyPresses( bool aHandle );
152 void toggleErrorSending( bool aToggle );
155 AlarmSender *iAlarmSender;
156 HWKeyListener *iHWKeyListener;
157 StartupSettings *iSettings;
158 DeviceDataStorage *iDataStorage;
159 DeviceConfigurator *iConfigurator;
160 OperationModeToggler *iModeToggler;
163 bool iSendErrorMessages;
167 #endif /*DEVICEMANAGER_H_*/