SyncScheduler.h
/*
* This file is part of buteo-syncfw package
*
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef SYNCSCHEDULER_H
#define SYNCSCHEDULER_H
#if defined(USE_KEEPALIVE)
#include "BackgroundSync.h"
#include "ProfileManager.h"
#elif defined(USE_IPHB)
#include "SyncAlarmInventory.h"
#include "IPHeartBeat.h"
#endif
#include <QObject>
#include <QMap>
#include <QSet>
#include <QString>
#include <QDateTime>
#include <ctime>
class QDateTime;
#ifdef USE_KEEPALIVE
class BackgroundSync;
#elif defined(USE_IPHB)
class IPHeartBeat;
#endif
namespace Buteo {
class SyncSession;
class SyncSchedulerTest;
class SyncProfile;
class SyncScheduler : public QObject
{
Q_OBJECT
public:
SyncScheduler(QObject *aParent = 0);
virtual ~SyncScheduler();
bool addProfile(const SyncProfile *aProfile);
/* Schedule a retry for a failed sync if the profile has retries enabled
*
* @param aProfile sync profile
* @param aNExtSyncTime retry after this duration
*/
void addProfileForSyncRetry(const SyncProfile *aProfile, QDateTime aNextSyncTime);
void removeProfile(const QString &aProfileName);
public slots:
void syncStatusChanged(const QString &aProfileName, int aStatus,
const QString &aMessage, int aMoreDetails);
private slots:
#if defined(USE_IPHB)
void doAlarmActions(int aAlarmEventID);
#endif
void doIPHeartbeatActions(QString aProfileName);
#if defined(USE_KEEPALIVE)
void rescheduleBackgroundActivity(const QString &aProfileName);
#endif
signals:
void syncNow(QString aProfileName);
void externalSyncChanged(QString aProfileName, bool aQuery = false);
private: // functions
int setNextAlarm(const SyncProfile *aProfile, QDateTime aNextSyncTime = QDateTime());
void setupDBusAdaptor();
#if defined(USE_IPHB)
void removeAlarmEvent(int aAlarmEvent);
void removeAllAlarms();
#endif
private: // data
QSet<QString> iActiveBackgroundSyncProfiles;
#if defined(USE_KEEPALIVE)
BackgroundSync *iBackgroundActivity;
ProfileManager iProfileManager;
#elif defined(USE_IPHB)
QMap<QString, int> iSyncScheduleProfiles;
SyncAlarmInventory *iAlarmInventory;
IPHeartBeat *iIPHeartBeatMan;
#endif
#ifdef SYNCFW_UNIT_TESTS
friend class SyncSchedulerTest;
#endif
};
}
#endif // SYNCSCHEDULER_H
BackgroundSync
BackgroundSync implementation.
Definition BackgroundSync.h:39
Buteo::IPHeartBeat
IPHeartBeat implementation.
Definition IPHeartBeat.h:39
Buteo::ProfileManager
ProfileManager is responsible for storing and retrieving the profiles.
Definition ProfileManager.h:47
Buteo::SyncProfile
A top level synchronization profile.
Definition SyncProfile.h:49
Buteo::SyncScheduler::syncNow
void syncNow(QString aProfileName)
Signal emitted when a sync session should be launched based on the sync schedule settings of the prof...
Buteo::SyncScheduler::externalSyncChanged
void externalSyncChanged(QString aProfileName, bool aQuery=false)
Signal emitted when a sync session should be launched based on the sync schedule settings of the prof...
Buteo::SyncScheduler::SyncScheduler
SyncScheduler(QObject *aParent=0)
Constructor.
Definition SyncScheduler.cpp:38
Buteo::SyncScheduler::syncStatusChanged
void syncStatusChanged(const QString &aProfileName, int aStatus, const QString &aMessage, int aMoreDetails)
Handles the sync status change signal from the synchronizer.
Definition SyncScheduler.cpp:164
Buteo::SyncScheduler::~SyncScheduler
virtual ~SyncScheduler()
Destructor.
Definition SyncScheduler.cpp:65
Buteo::SyncScheduler::removeProfile
void removeProfile(const QString &aProfileName)
Removes the profile with the given name from the scheduler.
Definition SyncScheduler.cpp:140
Buteo::SyncScheduler::addProfile
bool addProfile(const SyncProfile *aProfile)
Adds a profile to the scheduler.
Definition SyncScheduler.cpp:98
Buteo::SyncSession
Class representing a single sync session.
Definition SyncSession.h:44
QMap
Definition SyncBackupAdaptor.h:41
SyncAlarmInventory
Class for storing alarms.
Definition SyncAlarmInventory.h:38