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 #ifdef USE_KEEPALIVE
27 #include "BackgroundSync.h"
28 #include "ProfileManager.h"
29 #else
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 
40 class QDateTime;
41 #ifdef USE_KEEPALIVE
42 class BackgroundSync;
43 #else
44 class IPHeartBeat;
45 #endif
46 
47 namespace Buteo {
48 
49 class SyncSession;
50 class SyncSchedulerTest;
51 class SyncProfile;
52 
54 class SyncScheduler : public QObject
55 {
56  Q_OBJECT
57 
58 public:
59 
61  SyncScheduler(QObject *aParent = 0);
62 
66  virtual ~SyncScheduler();
67 
80  bool addProfile(const SyncProfile *aProfile);
81 
82  /* Schedule a retry for a failed sync if the profile has retries enabled
83  *
84  * @param aProfile sync profile
85  * @param aNExtSyncTime retry after this duration
86  */
87  void addProfileForSyncRetry(const SyncProfile *aProfile, QDateTime aNextSyncTime);
88 
96  void removeProfile(const QString &aProfileName);
97 
98 public slots:
109  void syncStatusChanged(const QString &aProfileName, int aStatus,
110  const QString &aMessage, int aMoreDetails);
111 
112 private slots:
113 
114 #ifndef USE_KEEPALIVE
121  void doAlarmActions(int aAlarmEventID);
122 #endif
123 
129  void doIPHeartbeatActions(QString aProfileName);
130 
131 #ifdef USE_KEEPALIVE
137  void rescheduleBackgroundActivity(const QString &aProfileName);
138 #endif
139 
140 signals:
146  void syncNow(QString aProfileName);
147 
153  void externalSyncChanged(QString aProfileName, bool aQuery = false);
154 
155 private: // functions
156 
164  int setNextAlarm(const SyncProfile *aProfile, QDateTime aNextSyncTime = QDateTime());
165 
169  void setupDBusAdaptor();
170 
171 #ifndef USE_KEEPALIVE
176  void removeAlarmEvent(int aAlarmEvent);
177 
181  void removeAllAlarms();
182 #endif
183 
184 private: // data
185 
186  QSet<QString> iActiveBackgroundSyncProfiles;
187 #ifdef USE_KEEPALIVE
189  BackgroundSync *iBackgroundActivity;
190  ProfileManager iProfileManager;
191 #else
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: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:167
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:174
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:162
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:138
bool addProfile(const SyncProfile *aProfile)
Adds a profile to the scheduler.
Definition: SyncScheduler.cpp:98
Class for storing alarms.
Definition: SyncAlarmInventory.h:38