0b222663ee36c514fc7d0d4be13fdd736a763efc
[qtmeetings] / src / IO / DeviceControl / OperationModeToggler.h
1 #ifndef OPERATIONMODETOGGLER_H_
2 #define OPERATIONMODETOGGLER_H_
3
4 #include "DeviceManager.h"
5
6 #include <QThread>
7
8 class StartupSettings;
9 class AlarmSender;
10 class DeviceConfigurator;
11 class DeviceDataStorage;
12
13 class OperationModeToggler : public QThread
14 {
15         Q_OBJECT
16         
17 public:
18         //! Constructor.
19         /*!
20          * Constructor for HWKeyListener class
21          */
22         OperationModeToggler( 
23                         DeviceManager::OperationMode aMode, 
24                         StartupSettings *aSettings, 
25                         AlarmSender *aAlarmSender, 
26                         DeviceConfigurator *aConfigurator, 
27                         DeviceDataStorage *aDataStorage 
28                         );
29         
30         //! Destructor.
31         virtual ~OperationModeToggler();
32         //! Run method of the class.
33         /*!
34          * Run method of the class.
35          */
36         void run();
37         //! Returns the success status of the operation mode change.
38         /*!
39          * Returns the success status of the operation mode change.
40          */
41         bool success();
42         //! Stores the current operation mode.
43         /*!
44          * Stores the current operation mode by asking the DeviceDataStorage to write it to the internal
45          * data storage.
46          * \param aMode The operation mode that user wants to activate.
47          * \return True if operation mode storing succeeds; otherwise, false.
48          */
49         static bool storeOperationMode( DeviceManager::OperationMode aMode, DeviceDataStorage *aDataStorage );
50
51 signals:
52         //! Signal. Emitted if an error occurs during operation mode fetching or reading.
53         /*!
54          * Signal. Emitted if an error occurs during operation mode fetching or reading. Note that other
55          * possible errors are sent by the other instances e.g. alarm sender sents it's own errors. 
56          * \param aCode The error code.
57          */
58         void error( DeviceManager::ErrorCode aCode );
59         //! Signal. Emitted if an error occurs during operation mode changing.
60         /*!
61          * Signal. Emitted if an error occurs during operation mode changing. If an error occurs, the operation
62          * mode changes made so far have to be rolled back. During this we don't want to show possible new
63          * errors. 
64          * \param aToggle Indicates if the errors are wanted to be shown.
65          */
66         void toggleErrorSending( bool aToggle );
67         //! Signal. Emitted during the operation mode change to explain the current sub-change.
68         /*!
69          * Signal. Emitted during the operation mode change to explain the current sub-change. 
70          * \param aMessage Explains the sub-change
71          */
72         void changingMode( const QString &aMessage );
73         
74 private:
75         DeviceManager::OperationMode iMode;
76         StartupSettings *iSettings;
77         AlarmSender *iAlarmSender;
78         DeviceConfigurator *iConfigurator;
79         DeviceDataStorage *iDataStorage;
80         bool iSuccess; 
81 };
82
83 #endif /*OPERATIONMODETOGGLER_H_*/