Buteo Synchronization Framework
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-2019 Jolla Ltd.
6  * Copyright (C) 2020 Open Mobile Platform LLC.
7  *
8  * Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public License
12  * version 2.1 as published by the Free Software Foundation.
13  *
14  * This library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22  * 02110-1301 USA
23  *
24  */
25 
26 #ifndef SYNCPROFILE_H
27 #define SYNCPROFILE_H
28 
29 #include "Profile.h"
30 #include "SyncLog.h"
31 #include "SyncSchedule.h"
32 #include "SyncCommonDefs.h"
33 
34 namespace Buteo {
35 
36 class SyncProfilePrivate;
37 
48 class SyncProfile : public Profile
49 {
50 public:
52  enum SyncType {
55 
59  };
60 
65 
68 
71  };
72 
77 
80 
83 
86  };
87 
92 
95 
98  };
99 
104 
107 
110 
113  };
114 
119  explicit SyncProfile(const QString &aName);
120 
125  explicit SyncProfile(const QDomElement &aRoot);
126 
131  SyncProfile(const SyncProfile &aSource);
132 
134  ~SyncProfile();
135 
140  virtual SyncProfile *clone() const;
141 
142 
145  virtual void setName(const QString &aName);
146 
149  virtual void setName(const QStringList &aKeys);
150 
151 
153  virtual QDomElement toXml(QDomDocument &aDoc, bool aLocalOnly = true) const;
154 
160  virtual bool syncExternallyEnabled() const;
161 
166  virtual bool rushEnabled() const;
167 
175  virtual bool syncExternallyDuringRush() const;
176 
181  virtual bool inExternalSyncRushPeriod(QDateTime aDateTime = QDateTime::currentDateTime()) const;
182 
187  QDateTime lastSyncTime() const;
188 
194  QDateTime lastSuccessfulSyncTime() const;
195 
201  virtual QDateTime nextSyncTime(QDateTime aDateTime = QDateTime::currentDateTime()) const;
202 
209  QDateTime nextRushSwitchTime(const QDateTime &aFromTime) const;
210 
215  const SyncResults *lastResults() const;
216 
221  SyncLog *log() const;
222 
229  void setLog(SyncLog *aLog);
230 
236  void addResults(const SyncResults &aResults);
237 
242  SyncType syncType() const;
243 
248  void setSyncType(SyncType aType);
249 
254  QStringList storageBackendNames() const;
255 
260  SyncSchedule syncSchedule() const;
261 
266  void setSyncSchedule(const SyncSchedule &aSchedule);
267 
273 
281 
286  //const Profile *serviceProfile() const;
287 
292  //Profile *serviceProfile();
293 
298  const Profile *clientProfile() const;
299 
305 
310  const Profile *serverProfile() const;
311 
317 
323 
329 
335 
341 
346  void setSyncDirection(SyncDirection aDirection);
347 
353 
359 
364  QString serviceName() const;
365 
373  quint32 syncOnChangeAfter() const;
374 
379  bool isSOCProfile() const;
380 
381  bool hasRetries() const;
382  QList<quint32> retryIntervals() const;
383 
392 
393 private:
394 
395  SyncProfile &operator=(const SyncProfile &aRhs);
396 
397  SyncProfilePrivate *d_ptr;
398 };
399 
400 }
401 
402 #endif // SYNCPROFILE_H
This class represents a single profile, a collection of settings or data releated to some entity.
Definition: Profile.h:53
History of completed synchronization sessions and their results.
Definition: SyncLog.h:45
A top level synchronization profile.
Definition: SyncProfile.h:49
virtual QDomElement toXml(QDomDocument &aDoc, bool aLocalOnly=true) const
Definition: SyncProfile.cpp:165
SyncLog * log() const
Gets the synchronization log associated with this profile.
Definition: SyncProfile.cpp:287
SyncDirection syncDirection() const
Gets sync direction (two way, to destination, from destination).
Definition: SyncProfile.cpp:507
QStringList storageBackendNames() const
Gets the names of storage backends used by this profile.
Definition: SyncProfile.cpp:354
const Profile * serverProfile() const
Get the first server sub-profile.
Definition: SyncProfile.cpp:435
QList< const Profile * > storageProfiles() const
Get the storage sub-profiles.
Definition: SyncProfile.cpp:459
void setLog(SyncLog *aLog)
Sets the synchronization log for this profile.
Definition: SyncProfile.cpp:292
void setSyncType(SyncType aType)
Sets the sync type of this profile (manual/scheduled).
Definition: SyncProfile.cpp:315
quint32 syncOnChangeAfter() const
If a profiles is interested in SOC, this gets the the SOC after time from that profile....
Definition: SyncProfile.cpp:545
DestinationType destinationType() const
Gets sync destination type (device or online).
Definition: SyncProfile.cpp:485
virtual bool syncExternallyDuringRush() const
Checks if external rush schedule is to be obeyed.
Definition: SyncProfile.cpp:221
virtual bool syncExternallyEnabled() const
Checks if schedule is controlled by a external process (e.g always-up-to-date).
Definition: SyncProfile.cpp:211
const Profile * clientProfile() const
Get the first service sub-profile.
Definition: SyncProfile.cpp:411
bool isSOCProfile() const
checks if a profile has SOC enabled
Definition: SyncProfile.cpp:530
const SyncResults * lastResults() const
Gets the results of the last sync from the sync log.
Definition: SyncProfile.cpp:278
QDateTime lastSyncTime() const
Gets the time of last completed sync session with this profile.
Definition: SyncProfile.cpp:232
QList< Profile * > storageProfilesNonConst()
Get the storage sub-profiles.
Definition: SyncProfile.cpp:472
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:227
ConflictResolutionPolicy
Conflict resolution policy for device-to-device syncs.
Definition: SyncProfile.h:89
@ CR_POLICY_PREFER_REMOTE_CHANGES
Prefer remote data in conflict situation.
Definition: SyncProfile.h:94
@ CR_POLICY_PREFER_LOCAL_CHANGES
Prefer local data in conflict situation.
Definition: SyncProfile.h:91
@ CR_POLICY_UNDEFINED
Conflict resolution policy is undefined.
Definition: SyncProfile.h:97
SyncDirection
Sync direction for device-to-device syncs.
Definition: SyncProfile.h:74
@ SYNC_DIRECTION_TWO_WAY
Two way sync.
Definition: SyncProfile.h:76
@ SYNC_DIRECTION_FROM_REMOTE
Data is copied from remote device only.
Definition: SyncProfile.h:79
@ SYNC_DIRECTION_TO_REMOTE
Data is copied to remote device only.
Definition: SyncProfile.h:82
@ SYNC_DIRECTION_UNDEFINED
Sync direction is not defined.
Definition: SyncProfile.h:85
SyncSchedule syncSchedule() const
Gets sync schedule settings.
Definition: SyncProfile.cpp:320
QDateTime nextRushSwitchTime(const QDateTime &aFromTime) const
Gets next time to switch rush/off-rush schedule intervals.
Definition: SyncProfile.cpp:269
QString serviceName() const
Get the service name of profile.
virtual bool rushEnabled() const
Checks if rush/off-rush schedule is enabled.
Definition: SyncProfile.cpp:216
virtual void setName(const QString &aName)
Sets the name for the profile and associated log.
Definition: SyncProfile.cpp:188
SyncProfile(const QString &aName)
Constructs an empty SyncProfile with the given name.
Definition: SyncProfile.cpp:120
virtual SyncProfile * clone() const
Creates a clone of the sync profile.
Definition: SyncProfile.cpp:160
QDateTime lastSuccessfulSyncTime() const
Gets the time of the last successful sync session for this profile.
Definition: SyncProfile.cpp:244
virtual QDateTime nextSyncTime(QDateTime aDateTime=QDateTime::currentDateTime()) const
Gets the next scheduled sync time.
Definition: SyncProfile.cpp:255
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:656
void setSyncSchedule(const SyncSchedule &aSchedule)
Sets sync schedule settings.
Definition: SyncProfile.cpp:325
~SyncProfile()
Destructor.
Definition: SyncProfile.cpp:154
SyncType syncType() const
Gets the sync type of this profile.
Definition: SyncProfile.cpp:307
void setConflictResolutionPolicy(ConflictResolutionPolicy aPolicy)
Set conflict resolution policy.
Definition: SyncProfile.cpp:618
ConflictResolutionPolicy conflictResolutionPolicy() const
Gets conflict resolution policy.
Definition: SyncProfile.cpp:597
SyncType
Synchronization types.
Definition: SyncProfile.h:52
@ SYNC_MANUAL
Synchronization is started manually.
Definition: SyncProfile.h:54
@ SYNC_SCHEDULED
Definition: SyncProfile.h:58
DestinationType
Sync destination type.
Definition: SyncProfile.h:62
@ DESTINATION_TYPE_DEVICE
Destination is a device (N95, Harmattan, OviSuite etc.)
Definition: SyncProfile.h:64
@ DESTINATION_TYPE_UNDEFINED
Destination type is not defined.
Definition: SyncProfile.h:70
@ DESTINATION_TYPE_ONLINE
Destination is an online service.
Definition: SyncProfile.h:67
void addResults(const SyncResults &aResults)
Adds synchronization results to the log.
Definition: SyncProfile.cpp:298
void setSyncDirection(SyncDirection aDirection)
Sets sync direction.
Definition: SyncProfile.cpp:565
CurrentSyncStatus
Current status enum.
Definition: SyncProfile.h:101
@ SYNC_SUCCESS
SYNC_SUCCESS - the last sync has been successful.
Definition: SyncProfile.h:106
@ SYNC_FAILED
SYNC_FAILED - the last sync has failed.
Definition: SyncProfile.h:109
@ SYNC_NEVER_HAPPENED
NOT_SYNCED - no sync has been done for the profile yet.
Definition: SyncProfile.h:103
@ SYNC_CANCLLED
SYNC_CANCELLED - the last sync has been cancelled.
Definition: SyncProfile.h:112
QList< Sync::InternetConnectionType > internetConnectionTypes() const
Gets allowed connection types.
Definition: SyncProfile.cpp:330
void setInternetConnectionTypes(const QList< Sync::InternetConnectionType > &aTypes)
Sets the internet connection types on which this profile can be synced.
Definition: SyncProfile.cpp:345
Contains information about a completed synchronization session.
Definition: SyncResults.h:59
Class for handling sync schedule settings.
Definition: SyncSchedule.h:54
Definition: SyncBackupAdaptor.h:40