Doxygen documentation added
[qtmeetings] / src / IO / DeviceControl / AlarmSender.h
1 #ifndef ALARMSENDER_H_
2 #define ALARMSENDER_H_
3
4 extern "C"
5 {
6 #include <alarmd/alarm_event.h>
7 }
8 #include "DeviceDataStorage.h"
9
10 #include <QObject>
11 #include <QTime>
12
13 //! DeviceControl class. Sends and removes the alarms of the alarm daemon.
14 /*!
15  * DeviceControl class. Sends and removes the alarms of the alarm daemon. The alarms make it possible
16  * to rurn on and off the device in the desired points of time. This optional functionality is supported
17  * in the "kiosk mode".
18  */
19 class AlarmSender : public QObject
20 {
21         Q_OBJECT
22
23 public:
24         //! Constructor.
25         /*!
26          * Constructor to initialize an AlarmSender instance
27          * \param aDataStorage Pointer to the DataStorage class instance.
28          */
29         AlarmSender( DeviceDataStorage *aDataStorage );
30         //! Destructor.
31         virtual ~AlarmSender();
32
33 signals:
34         //! Signal. Emitted if error occured during sending the alarms.
35         /*!
36          * Signal. Emitted if error occured during sending the alarms.
37          * \param aErrorCode The error code.
38          * \param aAddInfo The additional error text.
39          */
40         void alarmSendingFailed( DeviceManager::ErrorCode aErrorCode, const QString &aAddInfo );
41
42 public slots:
43         //! Slot. Consists and sends the alarms to the alarm daemon.
44         /*!
45          * Slot. Consists and sends the alarms to the alarm daemon. Asks DeviceDataStorage to store the
46          * information about the sent alarms.
47          * \param aTurnOnAt The time the device is desired to be turned on.
48          * \param aTurnOffAt The time the device is desired to be turned off.
49          * \param aDays The days to indicate if the device is wanted to be turned on/off every day (7) or
50          * just weekdays (5).
51          */
52         bool sendAlarms( QTime aTurnOnAt, QTime aTurnOffAt, int aDays = 5 );
53         //! Slot. Removes the alarms from the alarm daemon.
54         /*!
55          * Slot. Removes the alarms from the alarm daemon. Asks DeviceDataStorage to remove information
56          * about the sent alarms.
57          */
58         void removeAlarms();
59         //! Slot. Removes the alarms from the alarm daemon.
60         /*!
61          * Slot. Removes the alarms from the alarm daemon. Asks DeviceDataStorage to fetch information about
62          * the stored alarms. After removing those alarms, asks DeviceDataStorage to remove information
63          * about the alarms.
64          */
65         bool removeStoredAlarms();
66
67 private:
68         //! Finds the first possible point of time to set the first alarms.
69         /*!
70          * Finds the first possible point of time to set the first alarms.
71          * \param aDays The days to indicate if the device is wanted to be turned on/off every day (7) or
72          * just weekdays (5).
73          * \param aTime The time of the turning on/off alarm.
74          * \return The date of the first alarm.
75          */
76         QDateTime findFirstTime( const int &aDays, const QTime &aTime );
77         //! Counts days from the received date to the next working day.
78         /*!
79          * Returns the day count from the received date to the next working day.
80          * \param aDateTime The date from where to count the days
81          * \return The amount of days
82          */
83         int daysToNextWorkingDay( const QDateTime &aDateTime );
84         //! Handles the result of an sent alarm.
85         /*!
86          * Handles the result of an sent alarm. Updates the received aErrorText parameter in case the alarm
87          * sending fails. If not, it updates the internal list of succesfully sent alarms.
88          * \param aCookie The result of an sent alarm.
89          * \param aErrorText The result of an sent alarm.
90          * \return True if alarm sending succeeds; otherwise, false.
91          */
92         bool handleCookie( cookie_t aCookie, QString &aErrorText );
93         //! Maps the received aErrorCode parameter to a certain error message.
94         /*!
95          * Maps the received aErrorCode parameter to a certain error message.
96          * \param aErrorCode The error code for the alarm sending failure.
97          * \return The mapped error message.
98          */
99         QString mapError( alarm_error_t aErrorCode );
100
101 private:
102         DeviceDataStorage *iDataStorage;
103         QStringList iSentAlarms;
104
105 };
106
107 #endif /*ALARMSENDER_H_*/