1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
#ifndef SYNCONCHANGESCHEDULER_H
#define SYNCONCHANGESCHEDULER_H
#include <QObject>
#include <QHash>
#include <QStringList>
#include "SyncScheduler.h"
namespace Buteo {
class SyncProfile;
class SyncOnChangeScheduler : public SyncScheduler
{
Q_OBJECT
public:
/*! \brief constructor
*/
SyncOnChangeScheduler();
/*! \brief destructor
*/
~SyncOnChangeScheduler();
/*! \brief Call this method to schedule SOC for a profile
*
* There are 3 scheduling criteria - SOC after info from the
* profile, default SOC after and sync now.
*
* The profile is first checked for sync on change after time, which
* should be specified in seconds (0 means sync now). If none is specified
* then we use a default of DEFAULT_SOC_AFTER_TIME
*
* If the profile has already been added and if it's SOC is scheduled,
* calling this method again will just use the previous schedule, and in
* this case the method will return false.
*
* Once the SOC is initiated (by sending a syncNow signal), the profile is
* removed automatically
*
* @param aProfile pointer to sync profile
* @return true if SOC could be scheduled, false otherwise
*/
bool addProfile(const SyncProfile *aProfile);
/*! \brief call this method to disable SOC that has been scheduled
* for a certain profile
*
* @param aProfileName name of the profile
*/
void removeProfile(const QString &aProfileName);
private Q_SLOTS:
/*! \brief slot to initiate sync when timeout criterion is being used
* and the timeout occurs
*
* @param aProfile sync profile
*/
void sync(const SyncProfile *aProfile);
private:
QStringList iSOCProfileNames;
QMap<QString, QObject *> iSOCTimers;
};
class SyncOnChangeTimer : public QObject
{
Q_OBJECT
public:
/*! \brief constructor
*/
SyncOnChangeTimer(const SyncProfile *aProfile, const quint32 &aTimeout);
/*! \brief destructor
*/
~SyncOnChangeTimer();
/*! \brief fire the timer
*/
void fire();
Q_SIGNALS:
/*! \brief emit this signal when the timeout occurs
*
* @param aProfile sync profile
*/
void timeout(const SyncProfile *aProfile);
private Q_SLOTS:
/*! \brief slot corresponding to timeout
*/
void onTimeout();
private:
const SyncProfile *iSyncProfile;
quint32 iTimeout;
};
}
#endif
|