ButeoSynchronizationFramework
SyncProfile.h
1 /*
2  * This file is part of buteo-syncfw package
3  *
4  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5  * Copyright (C) 2014-2015 Jolla Ltd
6  *
7  * Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * version 2.1 as published by the Free Software Foundation.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  */
24 
25 #ifndef SYNCPROFILE_H
26 #define SYNCPROFILE_H
27 
28 #include "Profile.h"
29 #include "SyncLog.h"
30 #include "SyncSchedule.h"
31 
32 
33 namespace Buteo {
34 
35 class SyncProfilePrivate;
36 
47 class SyncProfile : public Profile
48 {
49 public:
51  enum SyncType
52  {
55 
59  };
60 
63  {
66 
69 
72  };
73 
76  {
79 
82 
85 
88  };
89 
92  {
95 
98 
101  };
102 
105  {
108 
111 
114 
117  };
118 
123  explicit SyncProfile(const QString &aName);
124 
129  explicit SyncProfile(const QDomElement &aRoot);
130 
135  SyncProfile(const SyncProfile &aSource);
136 
138  ~SyncProfile();
139 
144  virtual SyncProfile *clone() const;
145 
146 
149  virtual void setName(const QString &aName);
150 
153  virtual void setName(const QStringList &aKeys);
154 
155 
157  virtual QDomElement toXml(QDomDocument &aDoc, bool aLocalOnly = true) const;
158 
164  virtual bool syncExternallyEnabled() const;
165 
170  virtual bool rushEnabled() const;
171 
179  virtual bool syncExternallyDuringRush() const;
180 
185  virtual bool inExternalSyncRushPeriod(QDateTime aDateTime = QDateTime::currentDateTime()) const;
186 
191  QDateTime lastSyncTime() const;
192 
198  QDateTime lastSuccessfulSyncTime() const;
199 
205  virtual QDateTime nextSyncTime(QDateTime aDateTime = QDateTime::currentDateTime()) const;
206 
213  QDateTime nextRushSwitchTime(const QDateTime& aFromTime) const;
214 
219  const SyncResults *lastResults() const;
220 
225  SyncLog *log() const;
226 
233  void setLog(SyncLog *aLog);
234 
240  void addResults(const SyncResults &aResults);
241 
246  SyncType syncType() const;
247 
252  void setSyncType(SyncType aType);
253 
258  QStringList storageBackendNames() const;
259 
264  SyncSchedule syncSchedule() const;
265 
270  void setSyncSchedule(const SyncSchedule &aSchedule);
271 
276  //const Profile *serviceProfile() const;
277 
282  //Profile *serviceProfile();
283 
288  const Profile *clientProfile() const;
289 
295 
300  const Profile *serverProfile() const;
301 
307 
313 
319 
325 
331 
336  void setSyncDirection(SyncDirection aDirection);
337 
343 
349 
354  QString serviceName() const;
355 
363  quint32 syncOnChangeAfter() const;
364 
369  bool isSOCProfile() const;
370 
371  bool hasRetries() const;
372  QList<quint32> retryIntervals() const;
373 
382 
383 private:
384 
385  SyncProfile& operator=(const SyncProfile &aRhs);
386 
387  SyncProfilePrivate *d_ptr;
388 };
389 
390 }
391 
392 #endif // SYNCPROFILE_H
Prefer remote data in conflict situation.
Definition: SyncProfile.h:97
void setSyncDirection(SyncDirection aDirection)
Sets sync direction.
Definition: SyncProfile.cpp:595
Class for handling sync schedule settings.
Definition: SyncSchedule.h:52
This class represents a single profile, a collection of settings or data releated to some entity...
Definition: Profile.h:52
CurrentSyncStatus
Current status enum.
Definition: SyncProfile.h:104
void setSyncType(SyncType aType)
Sets the sync type of this profile (manual/scheduled).
Definition: SyncProfile.cpp:339
virtual QDateTime nextSyncTime(QDateTime aDateTime=QDateTime::currentDateTime()) const
Gets the next scheduled sync time.
Definition: SyncProfile.cpp:273
const Profile * clientProfile() const
Get the first service sub-profile.
Definition: SyncProfile.cpp:413
SyncType
Synchronization types.
Definition: SyncProfile.h:51
const Profile * serverProfile() const
Get the first server sub-profile.
Definition: SyncProfile.cpp:441
QList< const Profile * > storageProfiles() const
Get the storage sub-profiles.
Definition: SyncProfile.cpp:469
~SyncProfile()
Destructor.
Definition: SyncProfile.cpp:161
Definition: SyncProfile.h:58
NOT_SYNCED - no sync has been done for the profile yet.
Definition: SyncProfile.h:107
QDateTime nextRushSwitchTime(const QDateTime &aFromTime) const
Gets next time to switch rush/off-rush schedule intervals.
Definition: SyncProfile.cpp:289
void setSyncSchedule(const SyncSchedule &aSchedule)
Sets sync schedule settings.
Definition: SyncProfile.cpp:349
QList< Profile * > storageProfilesNonConst()
Get the storage sub-profiles.
Definition: SyncProfile.cpp:484
virtual void setName(const QString &aName)
Sets the name for the profile and associated log.
Definition: SyncProfile.cpp:199
QDateTime lastSuccessfulSyncTime() const
Gets the time of the last successful sync session for this profile.
Definition: SyncProfile.cpp:256
Contains information about a completed synchronization session.
Definition: SyncResults.h:58
Data is copied to remote device only.
Definition: SyncProfile.h:84
Definition: AccountsHelper.h:31
Destination type is not defined.
Definition: SyncProfile.h:71
SYNC_SUCCESS - the last sync has been successful.
Definition: SyncProfile.h:110
void setConflictResolutionPolicy(ConflictResolutionPolicy aPolicy)
Set conflict resolution policy.
Definition: SyncProfile.cpp:658
ConflictResolutionPolicy
Conflict resolution policy for device-to-device syncs.
Definition: SyncProfile.h:91
DestinationType
Sync destination type.
Definition: SyncProfile.h:62
History of completed synchronization sessions and their results.
Definition: SyncLog.h:44
bool isSOCProfile() const
checks if a profile has SOC enabled
Definition: SyncProfile.cpp:557
virtual bool inExternalSyncRushPeriod(QDateTime aDateTime=QDateTime::currentDateTime()) const
Checks if a given time is inside rush hour and if the sync is controlled by a external process...
Definition: SyncProfile.cpp:238
SYNC_CANCELLED - the last sync has been cancelled.
Definition: SyncProfile.h:116
virtual bool rushEnabled() const
Checks if rush/off-rush schedule is enabled.
Definition: SyncProfile.cpp:227
void addResults(const SyncResults &aResults)
Adds synchronization results to the log.
Definition: SyncProfile.cpp:322
SyncLog * log() const
Gets the synchronization log associated with this profile.
Definition: SyncProfile.cpp:311
SyncDirection syncDirection() const
Gets sync direction (two way, to destination, from destination).
Definition: SyncProfile.cpp:526
Data is copied from remote device only.
Definition: SyncProfile.h:81
SyncDirection
Sync direction for device-to-device syncs.
Definition: SyncProfile.h:75
QStringList storageBackendNames() const
Gets the names of storage backends used by this profile.
Definition: SyncProfile.cpp:354
void setLog(SyncLog *aLog)
Sets the synchronization log for this profile.
Definition: SyncProfile.cpp:316
SyncSchedule syncSchedule() const
Gets sync schedule settings.
Definition: SyncProfile.cpp:344
virtual QDomElement toXml(QDomDocument &aDoc, bool aLocalOnly=true) const
Definition: SyncProfile.cpp:172
SYNC_FAILED - the last sync has failed.
Definition: SyncProfile.h:113
Sync direction is not defined.
Definition: SyncProfile.h:87
CurrentSyncStatus currentSyncStatus() const
Gives the current status of the sync as an enum value If the current status of ongoing syncs is requi...
Definition: SyncProfile.cpp:700
Synchronization is started manually.
Definition: SyncProfile.h:54
const SyncResults * lastResults() const
Gets the results of the last sync from the sync log.
Definition: SyncProfile.cpp:299
quint32 syncOnChangeAfter() const
If a profiles is interested in SOC, this gets the the SOC after time from that profile. The time should be in seconds and a value of 0 means sync immediately afer change.
Definition: SyncProfile.cpp:573
QDateTime lastSyncTime() const
Gets the time of last completed sync session with this profile.
Definition: SyncProfile.cpp:243
QString serviceName() const
Get the service name of profile.
Two way sync.
Definition: SyncProfile.h:78
A top level synchronization profile.
Definition: SyncProfile.h:47
virtual bool syncExternallyDuringRush() const
Checks if external rush schedule is to be obeyed.
Definition: SyncProfile.cpp:232
DestinationType destinationType() const
Gets sync destination type (device or online).
Definition: SyncProfile.cpp:499
Conflict resolution policy is undefined.
Definition: SyncProfile.h:100
ConflictResolutionPolicy conflictResolutionPolicy() const
Gets conflict resolution policy.
Definition: SyncProfile.cpp:631
Destination is an online service.
Definition: SyncProfile.h:68
Destination is a device (N95, Harmattan, OviSuite etc.)
Definition: SyncProfile.h:65
virtual SyncProfile * clone() const
Creates a clone of the sync profile.
Definition: SyncProfile.cpp:167
Prefer local data in conflict situation.
Definition: SyncProfile.h:94
virtual bool syncExternallyEnabled() const
Checks if schedule is controlled by a external process (e.g always-up-to-date).
Definition: SyncProfile.cpp:222
Definition: SyncBackupAdaptor.h:40
SyncType syncType() const
Gets the sync type of this profile.
Definition: SyncProfile.cpp:332
SyncProfile(const QString &aName)
Constructs an empty SyncProfile with the given name.
Definition: SyncProfile.cpp:124