ButeoSynchronizationFramework
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 <QDateTime>
36 #include <ctime>
37 
38 class QDateTime;
39 #ifdef USE_KEEPALIVE
40 class BackgroundSync;
41 #else
42 class IPHeartBeat;
43 #endif
44 
45 namespace Buteo {
46 
47 class SyncSession;
48 class SyncSchedulerTest;
49 class SyncProfile;
50 
52 class SyncScheduler : public QObject
53 {
54  Q_OBJECT
55 
56 public:
57 
59  SyncScheduler(QObject *aParent = 0);
60 
64  virtual ~SyncScheduler();
65 
78  bool addProfile(const SyncProfile* aProfile);
79 
80  /* Schedule a retry for a failed sync if the profile has retries enabled
81  *
82  * @param aProfile sync profile
83  * @param aNExtSyncTime retry after this duration
84  */
85  void addProfileForSyncRetry(const SyncProfile* aProfile, QDateTime aNextSyncTime);
86 
94  void removeProfile(const QString &aProfileName);
95 
96 private slots:
97 
98 #ifndef USE_KEEPALIVE
99 
105  void doAlarmActions(int aAlarmEventID);
106 #endif
107 
113  void doIPHeartbeatActions(QString aProfileName);
114 
115 #ifdef USE_KEEPALIVE
116 
121  void rescheduleBackgroundActivity(const QString& aProfileName);
122 #endif
123 
124 signals:
130  void syncNow(QString aProfileName);
131 
137  void externalSyncChanged(const SyncProfile* aProfile, bool aQuery=false);
138 
139 private: // functions
140 
148  int setNextAlarm(const SyncProfile* aProfile, QDateTime aNextSyncTime = QDateTime());
149 
153  void setupDBusAdaptor();
154 
155 #ifndef USE_KEEPALIVE
156 
160  void removeAlarmEvent(int aAlarmEvent);
161 
165  void removeAllAlarms();
166 #endif
167 
168 private: // data
169 
170 #ifdef USE_KEEPALIVE
171  BackgroundSync *iBackgroundActivity;
173  ProfileManager iProfileManager;
174 #else
175  QMap<QString, int> iSyncScheduleProfiles;
177 
179  SyncAlarmInventory *iAlarmInventory;
180 
182  IPHeartBeat* iIPHeartBeatMan;
183 #endif
184 
185 #ifdef SYNCFW_UNIT_TESTS
186  friend class SyncSchedulerTest;
187 #endif
188 
189 };
190 
191 }
192 
193 #endif // SYNCSCHEDULER_H
void externalSyncChanged(const SyncProfile *aProfile, 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:164
SyncScheduler(QObject *aParent=0)
Constructor.
Definition: SyncScheduler.cpp:37
bool addProfile(const SyncProfile *aProfile)
Adds a profile to the scheduler.
Definition: SyncScheduler.cpp:101
void removeProfile(const QString &aProfileName)
Removes the profile with the given name from the scheduler.
Definition: SyncScheduler.cpp:143
BackgroundSync implementation.
Definition: BackgroundSync.h:37
Definition: AccountsHelper.h:31
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:157
ProfileManager is responsible for storing and retrieving the profiles.
Definition: ProfileManager.h:45
virtual ~SyncScheduler()
Destructor.
Definition: SyncScheduler.cpp:64
SyncScheduler Object to be used to set Schedule via the framework.
Definition: SyncScheduler.h:52
IPHeartBeat implementation.
Definition: IPHeartBeat.h:38
A top level synchronization profile.
Definition: SyncProfile.h:47
Class for storing alarms.
Definition: SyncAlarmInventory.h:37