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#include <QObject>
34#include <QMap>
35#include <QSet>
36#include <QString>
37#include <QDateTime>
38#include <ctime>
39
40class QDateTime;
41#ifdef USE_KEEPALIVE
42class BackgroundSync;
43#elif defined(USE_IPHB)
44class IPHeartBeat;
45#endif
46
47namespace Buteo {
48
49class SyncSession;
50class SyncSchedulerTest;
51class SyncProfile;
52
54class SyncScheduler : public QObject
55{
56 Q_OBJECT
57
58public:
60 SyncScheduler(QObject *aParent = 0);
61
65 virtual ~SyncScheduler();
66
79 bool addProfile(const SyncProfile *aProfile);
80
81 /* Schedule a retry for a failed sync if the profile has retries enabled
82 *
83 * @param aProfile sync profile
84 * @param aNExtSyncTime retry after this duration
85 */
86 void addProfileForSyncRetry(const SyncProfile *aProfile, QDateTime aNextSyncTime);
87
95 void removeProfile(const QString &aProfileName);
96
97public slots:
108 void syncStatusChanged(const QString &aProfileName, int aStatus,
109 const QString &aMessage, int aMoreDetails);
110
111private slots:
112#if defined(USE_IPHB)
119 void doAlarmActions(int aAlarmEventID);
120#endif
121
127 void doIPHeartbeatActions(QString aProfileName);
128
129#if defined(USE_KEEPALIVE)
135 void rescheduleBackgroundActivity(const QString &aProfileName);
136#endif
137
138signals:
144 void syncNow(QString aProfileName);
145
151 void externalSyncChanged(QString aProfileName, bool aQuery = false);
152
153private: // functions
161 int setNextAlarm(const SyncProfile *aProfile, QDateTime aNextSyncTime = QDateTime());
162
166 void setupDBusAdaptor();
167
168#if defined(USE_IPHB)
173 void removeAlarmEvent(int aAlarmEvent);
174
178 void removeAllAlarms();
179#endif
180
181private: // data
182 QSet<QString> iActiveBackgroundSyncProfiles;
183#if defined(USE_KEEPALIVE)
185 BackgroundSync *iBackgroundActivity;
186 ProfileManager iProfileManager;
187#elif defined(USE_IPHB)
189 QMap<QString, int> iSyncScheduleProfiles;
190
192 SyncAlarmInventory *iAlarmInventory;
193
195 IPHeartBeat *iIPHeartBeatMan;
196#endif
197
198#ifdef SYNCFW_UNIT_TESTS
199 friend class SyncSchedulerTest;
200#endif
201
202};
203
204}
205
206#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:55
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: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
Definition SyncBackupAdaptor.h:41
Class for storing alarms.
Definition SyncAlarmInventory.h:38