6 #include <alarmd/alarm_event.h>
8 #include "DeviceDataStorage.h"
13 //! DeviceControl class. Sends and removes the alarms of the alarm daemon.
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".
19 class AlarmSender : public QObject
26 * Constructor to initialize an AlarmSender instance
27 * \param aDataStorage Pointer to the DataStorage class instance.
29 AlarmSender( DeviceDataStorage *aDataStorage );
31 virtual ~AlarmSender();
34 //! Signal. Emitted if error occured during sending the alarms.
36 * Signal. Emitted if error occured during sending the alarms.
37 * \param aErrorCode The error code.
38 * \param aAddInfo The additional error text.
40 void alarmSendingFailed( DeviceManager::ErrorCode aErrorCode, const QString &aAddInfo );
43 //! Slot. Consists and sends the alarms to the alarm daemon.
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
52 bool sendAlarms( QTime aTurnOnAt, QTime aTurnOffAt, int aDays = 5 );
53 //! Slot. Removes the alarms from the alarm daemon.
55 * Slot. Removes the alarms from the alarm daemon. Asks DeviceDataStorage to remove information
56 * about the sent alarms.
59 //! Slot. Removes the alarms from the alarm daemon.
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
65 bool removeStoredAlarms();
68 //! Finds the first possible point of time to set the first alarms.
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
73 * \param aTime The time of the turning on/off alarm.
74 * \return The date of the first alarm.
76 QDateTime findFirstTime( const int &aDays, const QTime &aTime );
77 //! Counts days from the received date to the next working day.
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
83 int daysToNextWorkingDay( const QDateTime &aDateTime );
84 //! Handles the result of an sent alarm.
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.
92 bool handleCookie( cookie_t aCookie, QString &aErrorText );
93 //! Maps the received aErrorCode parameter to a certain error message.
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.
99 QString mapError( alarm_error_t aErrorCode );
102 DeviceDataStorage *iDataStorage;
103 QStringList iSentAlarms;
107 #endif /*ALARMSENDER_H_*/