Merge commit 'refs/1_0_6_candidate' of https://git.maemo.org/projects/qtmeetings...
[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 happens.
53         /*!
54          * Signal. Emitted if an error happens.
55          * \param aCode An error code defined by DeviceManager.
56          * \param aAddInfo Possible additional information.
57          */
58         void error( DeviceManager::ErrorCode aCode, const QString &aAddInfo );
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 slots:
75         //! Slot. Emits an error signal.
76         /*!
77          * Slot. Emits an error signal. 
78          * \param aCode The error code.
79          */
80         void createError( DeviceManager::ErrorCode aCode );
81         
82 private:
83         DeviceManager::OperationMode iMode;
84         StartupSettings *iSettings;
85         AlarmSender *iAlarmSender;
86         DeviceConfigurator *iConfigurator;
87         DeviceDataStorage *iDataStorage;
88         bool iSuccess; 
89 };
90
91 #endif /*OPERATIONMODETOGGLER_H_*/