Buteo Synchronization Framework
ProfileManager.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
24#ifndef PROFILEMANAGER_H
25#define PROFILEMANAGER_H
26
27#include "SyncProfile.h"
28#include "Profile.h"
29
30#include <QObject>
31#include <QList>
32#include <QHash>
33
34namespace Buteo {
35
36class ProfileManagerPrivate;
37
46class ProfileManager: public QObject
47{
48 Q_OBJECT
49public:
63
66
68 SearchCriteria(const SearchCriteria &aSource);
69 SearchCriteria &operator=(const SearchCriteria &other);
70
73
79
84
86 QString iKey;
87
89 QString iValue;
90 };
91
103
107
111
117 QStringList profileNames(const QString &aType);
118
130 SyncProfile *syncProfile(const QString &aName);
131
138
147
163 QList<SyncProfile *> getSyncProfilesByData(const QString &aSubProfileName,
164 const QString &aSubProfileType,
165 const QString &aKey = "", const QString &aValue = "");
166
175
187 QList<SyncProfile *> getSyncProfilesByStorage(const QString &aStorageName, bool aStorageMustBeEnabled = false);
188
197 QList<SyncProfile *> getSOCProfilesForStorage(const QString &aStorageName);
198
205 void expand(Profile &aProfile);
206
212 bool saveLog(const SyncLog &aLog);
213
223 bool saveSyncResults(QString aProfileName, const SyncResults &aResults);
224
234 Profile *profile(const QString &aName, const QString &aType);
235
244 SyncProfile *createTempSyncProfile (const QString &btAddress, bool &saveNewProfile);
245
255 QString updateProfile(const Profile &aProfile);
256
265 bool removeProfile(const QString &aProfileId);
266
273 bool rename(const QString &aName, const QString &aNewName);
274
283 void enableStorages (Profile &aProfile, QMap<QString, bool> &aStorageMap, bool *aModified = nullptr);
284
293 void setStoragesVisible(Profile &aProfile, QMap<QString, bool> &aStorageMap, bool *aModified = nullptr);
294
301 void saveRemoteTargetId (Profile &aProfile, const QString &aId);
302
309 bool setSyncSchedule(QString aProfileId, QString aScheduleAsXml);
310
315 void addRetriesInfo(const SyncProfile *aProfile);
316
322 QDateTime getNextRetryInterval(const SyncProfile *aProfile);
323
329 void retriesDone(const QString &aProfileName);
330
331#ifdef SYNCFW_UNIT_TESTS
332 friend class ProfileManagerTest;
333#endif
334 // for testing purposes only
335 // configPath is the root of primary profile directory, used for writing changes
336 // systemConfigPath is for read-only system profiles
337 void setPaths(const QString &configPath, const QString &systemConfigPath);
338
347 static Profile *profileFromXml(const QString &aProfileAsXml);
348
349signals:
358 void signalProfileChanged(QString aProfileName, int aChangeType, QString aProfileAsXml);
359
360private:
361 ProfileManager &operator=(const ProfileManager &aRhs);
362 ProfileManagerPrivate *d_ptr;
363};
364
365}
366
367#endif // PROFILEMANAGER_H
QList< SyncProfile * > allVisibleSyncProfiles()
Gets all visible sync profiles.
Definition ProfileManager.cpp:403
void expand(Profile &aProfile)
Expands the given profile.
Definition ProfileManager.cpp:843
bool saveLog(const SyncLog &aLog)
Saves the given synchronization log.
Definition ProfileManager.cpp:880
QList< SyncProfile * > getSOCProfilesForStorage(const QString &aStorageName)
Gets profiles interested in sync on change for a storage.
Definition ProfileManager.cpp:502
static Profile * profileFromXml(const QString &aProfileAsXml)
Gets a profile object from an xml document.
Definition ProfileManager.cpp:647
QList< SyncProfile * > allSyncProfiles()
Gets all sync profiles.
Definition ProfileManager.cpp:386
QList< SyncProfile * > getSyncProfilesByStorage(const QString &aStorageName, bool aStorageMustBeEnabled=false)
Gets profiles based on supported storages.
Definition ProfileManager.cpp:555
bool saveSyncResults(QString aProfileName, const SyncResults &aResults)
Saves the results of a sync session to the log.
Definition ProfileManager.cpp:958
QString updateProfile(const Profile &aProfile)
Updates the existing profile with the profile given as parameter and emits profileChanged() Signal wi...
Definition ProfileManager.cpp:665
void enableStorages(Profile &aProfile, QMap< QString, bool > &aStorageMap, bool *aModified=nullptr)
Enables sync'd storages in profile.
Definition ProfileManager.cpp:744
~ProfileManager()
Destructor.
Definition ProfileManager.cpp:291
SyncProfile * syncProfile(const QString &aName)
Gets a sync profile.
Definition ProfileManager.cpp:320
Profile * profile(const QString &aName, const QString &aType)
Gets a profile.
Definition ProfileManager.cpp:315
bool rename(const QString &aName, const QString &aNewName)
Renames a profile, and the associated log too.
Definition ProfileManager.cpp:929
SyncProfile * createTempSyncProfile(const QString &btAddress, bool &saveNewProfile)
Gets a temporary profile (saved if sync is sucessfull).
Definition ProfileManager.cpp:698
bool removeProfile(const QString &aProfileId)
Deletes a profile from the persistent storage.
Definition ProfileManager.cpp:794
QStringList profileNames(const QString &aType)
Gets the names of all available profiles with the given type.
Definition ProfileManager.cpp:354
QList< SyncProfile * > getSyncProfilesByData(const QString &aSubProfileName, const QString &aSubProfileType, const QString &aKey="", const QString &aValue="")
Gets profiles with matching data.
Definition ProfileManager.cpp:420
QDateTime getNextRetryInterval(const SyncProfile *aProfile)
gets the next retry after time for a sync profile
Definition ProfileManager.cpp:1129
void setStoragesVisible(Profile &aProfile, QMap< QString, bool > &aStorageMap, bool *aModified=nullptr)
Sets storage subprofiles hidden status for the given profile.
Definition ProfileManager.cpp:768
void retriesDone(const QString &aProfileName)
call this to indicate that retries have to stop for a certain sync for a profile - either the no....
Definition ProfileManager.cpp:1143
bool setSyncSchedule(QString aProfileId, QString aScheduleAsXml)
Sets/Overwrites the schedule to a profile.
Definition ProfileManager.cpp:982
void addRetriesInfo(const SyncProfile *aProfile)
checks if a profile has retries info and stores the same
Definition ProfileManager.cpp:1118
void saveRemoteTargetId(Profile &aProfile, const QString &aId)
Sets remote target in profile.
Definition ProfileManager.cpp:919
ProfileChangeType
Enum to indicate the change type of the Profile Operation.
Definition ProfileManager.h:93
@ PROFILE_LOGS_MODIFIED
Profile log file Modified.
Definition ProfileManager.h:101
@ PROFILE_MODIFIED
a Existing Profile has been modified
Definition ProfileManager.h:97
@ PROFILE_ADDED
a New Profile has been added
Definition ProfileManager.h:95
@ PROFILE_REMOVED
Profile has been Removed.
Definition ProfileManager.h:99
void signalProfileChanged(QString aProfileName, int aChangeType, QString aProfileAsXml)
Notifies about a change in profile.
ProfileManager()
Constructor.
Definition ProfileManager.cpp:285
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
Contains information about a completed synchronization session.
Definition SyncResults.h:67
Definition SyncBackupAdaptor.h:40
Definition SyncBackupAdaptor.h:41
Search criteria for finding profiles.
Definition ProfileManager.h:51
QString iValue
Key value. This must be given if criteria type is EQUAL or NOT_EQUAL.
Definition ProfileManager.h:89
QString iKey
Key name. If this is empty, key comparison is not made.
Definition ProfileManager.h:86
Type
Enum to identify if a member type exists or not.
Definition ProfileManager.h:53
@ EXISTS
Sub-profile (and key) exists.
Definition ProfileManager.h:55
@ EQUAL
Key value is equal.
Definition ProfileManager.h:59
@ NOT_EXISTS
Sub-profile (or key) does not exist.
Definition ProfileManager.h:57
@ NOT_EQUAL
Key value is not equal.
Definition ProfileManager.h:61
QString iSubProfileName
Definition ProfileManager.h:78
SearchCriteria()
Constructor.
Definition ProfileManager.cpp:256
Type iType
Search criteria type.
Definition ProfileManager.h:72
QString iSubProfileType
Definition ProfileManager.h:83