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#ifndef USE_DUMMY_SCHEDULER
27#ifdef USE_KEEPALIVE
28#include "BackgroundSync.h"
29#include "ProfileManager.h"
30#else
31#include "SyncAlarmInventory.h"
32#include "IPHeartBeat.h"
33#endif
34#endif
35#include <QObject>
36#include <QMap>
37#include <QSet>
38#include <QString>
39#include <QDateTime>
40#include <ctime>
41
42class QDateTime;
43#ifndef USE_DUMMY_SCHEDULER
44#ifdef USE_KEEPALIVE
45class BackgroundSync;
46#else
47class IPHeartBeat;
48#endif
49#endif
50
51namespace Buteo {
52
53class SyncSession;
54class SyncSchedulerTest;
55class SyncProfile;
56
58class SyncScheduler : public QObject
59{
60 Q_OBJECT
61
62public:
63
65 SyncScheduler(QObject *aParent = 0);
66
70 virtual ~SyncScheduler();
71
84 bool addProfile(const SyncProfile *aProfile);
85
86 /* Schedule a retry for a failed sync if the profile has retries enabled
87 *
88 * @param aProfile sync profile
89 * @param aNExtSyncTime retry after this duration
90 */
91 void addProfileForSyncRetry(const SyncProfile *aProfile, QDateTime aNextSyncTime);
92
100 void removeProfile(const QString &aProfileName);
101
102public slots:
113 void syncStatusChanged(const QString &aProfileName, int aStatus,
114 const QString &aMessage, int aMoreDetails);
115
116private slots:
117
118#ifndef USE_DUMMY_SCHEDULER
119#ifndef USE_KEEPALIVE
126 void doAlarmActions(int aAlarmEventID);
127#endif
128#endif
129
135 void doIPHeartbeatActions(QString aProfileName);
136
137#ifdef USE_KEEPALIVE
143 void rescheduleBackgroundActivity(const QString &aProfileName);
144#endif
145
146signals:
152 void syncNow(QString aProfileName);
153
159 void externalSyncChanged(QString aProfileName, bool aQuery = false);
160
161private: // functions
162
170 int setNextAlarm(const SyncProfile *aProfile, QDateTime aNextSyncTime = QDateTime());
171
175 void setupDBusAdaptor();
176
177#ifndef USE_DUMMY_SCHEDULER
178#ifndef USE_KEEPALIVE
183 void removeAlarmEvent(int aAlarmEvent);
184
188 void removeAllAlarms();
189#endif
190#endif
191
192private: // data
193
194 QSet<QString> iActiveBackgroundSyncProfiles;
195#ifndef USE_DUMMY_SCHEDULER
196#ifdef USE_KEEPALIVE
198 BackgroundSync *iBackgroundActivity;
199 ProfileManager iProfileManager;
200#else
202 QMap<QString, int> iSyncScheduleProfiles;
203
205 SyncAlarmInventory *iAlarmInventory;
206
208 IPHeartBeat *iIPHeartBeatMan;
209#endif
210#endif
211
212#ifdef SYNCFW_UNIT_TESTS
213 friend class SyncSchedulerTest;
214#endif
215
216};
217
218}
219
220#endif // SYNCSCHEDULER_H
BackgroundSync implementation.
Definition BackgroundSync.h:38
IPHeartBeat implementation.
Definition IPHeartBeat.h:39
ProfileManager is responsible for storing and retrieving the profiles.
Definition ProfileManager.h:46
A top level synchronization profile.
Definition SyncProfile.h:49
SyncScheduler Object to be used to set Schedule via the framework.
Definition SyncScheduler.h:59
void syncNow(QString aProfileName)
Signal emitted when a sync session should be launched based on the sync schedule settings of the prof...
Definition moc_SyncScheduler.cpp:162
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...
Definition moc_SyncScheduler.cpp:169
void syncStatusChanged(const QString &aProfileName, int aStatus, const QString &aMessage, int aMoreDetails)
Handles the sync status change signal from the synchronizer.
Definition SyncScheduler.cpp:175
virtual ~SyncScheduler()
Destructor.
Definition SyncScheduler.cpp:69
void removeProfile(const QString &aProfileName)
Removes the profile with the given name from the scheduler.
Definition SyncScheduler.cpp:149
bool addProfile(const SyncProfile *aProfile)
Adds a profile to the scheduler.
Definition SyncScheduler.cpp:106
Definition SyncBackupAdaptor.h:41
Class for storing alarms.
Definition SyncAlarmInventory.h:38