Buteo Synchronization Framework
SyncScheduler.h
1/*
2 * This file is part of buteo-syncfw package
3 *
4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5 *
6 * Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * version 2.1 as published by the Free Software Foundation.
11 *
12 * This library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 */
23#ifndef SYNCSCHEDULER_H
24#define SYNCSCHEDULER_H
25
26#if defined(USE_KEEPALIVE)
27#include "BackgroundSync.h"
28#include "ProfileManager.h"
29#elif defined(USE_IPHB)
30#include "SyncAlarmInventory.h"
31#include "IPHeartBeat.h"
32#endif
33
34#include <QObject>
35#include <QMap>
36#include <QSet>
37#include <QString>
38#include <QDateTime>
39
40#include <ctime>
41
42class QDateTime;
43
44#ifdef USE_KEEPALIVE
45class BackgroundSync;
46#elif defined(USE_IPHB)
47class IPHeartBeat;
48#endif
49
50namespace Buteo {
51
52class SyncSession;
53class SyncSchedulerTest;
54class SyncProfile;
55
57class SyncScheduler : public QObject
58{
59 Q_OBJECT
60
61public:
63 SyncScheduler(QObject *aParent = 0);
64
68 virtual ~SyncScheduler();
69
82 bool addProfile(const SyncProfile *aProfile);
83
84 /* Schedule a retry for a failed sync if the profile has retries enabled
85 *
86 * @param aProfile sync profile
87 * @param aNExtSyncTime retry after this duration
88 */
89 void addProfileForSyncRetry(const SyncProfile *aProfile, QDateTime aNextSyncTime);
90
98 void removeProfile(const QString &aProfileName);
99
100public slots:
111 void syncStatusChanged(const QString &aProfileName, int aStatus,
112 const QString &aMessage, int aMoreDetails);
113
114private slots:
115#if defined(USE_IPHB)
121
122 void doAlarmActions(int aAlarmEventID);
123#endif
124
130 void doIPHeartbeatActions(QString aProfileName);
131
132#if defined(USE_KEEPALIVE)
138 void rescheduleBackgroundActivity(const QString &aProfileName);
139#endif
140
141signals:
147 void syncNow(QString aProfileName);
148
154 void externalSyncChanged(QString aProfileName, bool aQuery = false);
155
156private: // functions
164 int setNextAlarm(const SyncProfile *aProfile, QDateTime aNextSyncTime = QDateTime());
165
169 void setupDBusAdaptor();
170
171#if defined(USE_IPHB)
176 void removeAlarmEvent(int aAlarmEvent);
177
181 void removeAllAlarms();
182#endif
183
184private: // data
185 QSet<QString> iActiveBackgroundSyncProfiles;
186
187#if defined(USE_KEEPALIVE)
189 BackgroundSync *iBackgroundActivity;
190 ProfileManager iProfileManager;
191#elif defined(USE_IPHB)
193 QMap<QString, int> iSyncScheduleProfiles;
194
196 SyncAlarmInventory *iAlarmInventory;
197
199 IPHeartBeat *iIPHeartBeatMan;
200#endif
201
202#ifdef SYNCFW_UNIT_TESTS
203 friend class SyncSchedulerTest;
204#endif
205
206};
207
208}
209
210#endif // SYNCSCHEDULER_H
BackgroundSync implementation.
Definition BackgroundSync.h:39
IPHeartBeat implementation.
Definition IPHeartBeat.h:39
ProfileManager is responsible for storing and retrieving the profiles.
Definition ProfileManager.h:47
A top level synchronization profile.
Definition SyncProfile.h:49
void syncNow(QString aProfileName)
Signal emitted when a sync session should be launched based on the sync schedule settings of the prof...
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...
SyncScheduler(QObject *aParent=0)
Constructor.
Definition SyncScheduler.cpp:38
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
virtual ~SyncScheduler()
Destructor.
Definition SyncScheduler.cpp:65
void removeProfile(const QString &aProfileName)
Removes the profile with the given name from the scheduler.
Definition SyncScheduler.cpp:140
bool addProfile(const SyncProfile *aProfile)
Adds a profile to the scheduler.
Definition SyncScheduler.cpp:98
Class representing a single sync session.
Definition SyncSession.h:44
Definition SyncBackupAdaptor.h:41
Class for storing alarms.
Definition SyncAlarmInventory.h:38