ButeoSynchronizationFramework
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 #include <QObject>
30 #include <QList>
31 #include <QHash>
32 
33 namespace Buteo {
34 
35 class ProfileManagerPrivate;
36 
45 class ProfileManager: public QObject
46 {
47  Q_OBJECT
48 public:
49 
51  static const QString DEFAULT_PRIMARY_PROFILE_PATH;
52 
54  static const QString DEFAULT_SECONDARY_PROFILE_PATH;
55 
58  {
60  enum Type
61  {
64 
67 
70 
73  };
74 
77 
79  SearchCriteria(const SearchCriteria &aSource);
80 
83 
88  QString iSubProfileName;
89 
93  QString iSubProfileType;
94 
96  QString iKey;
97 
99  QString iValue;
100  };
101 
104  {
113  };
114 
123  ProfileManager(const QString &aPrimaryPath = DEFAULT_PRIMARY_PROFILE_PATH,
124  const QString &aSecondaryPath = DEFAULT_SECONDARY_PROFILE_PATH);
125 
128  ~ProfileManager();
129 
135  QStringList profileNames(const QString &aType);
136 
148  SyncProfile *syncProfile(const QString &aName);
149 
156 
165 
181  QList<SyncProfile*> getSyncProfilesByData(const QString &aSubProfileName,
182  const QString &aSubProfileType,
183  const QString &aKey = "", const QString &aValue = "");
184 
193  const QList<SearchCriteria> &aCriteria);
194 
207  const QString &aStorageName, bool aStorageMustBeEnabled = false);
208 
218  const QString &aStorageName);
219 
226  void expand(Profile &aProfile);
227 
233  bool saveLog(const SyncLog &aLog);
234 
244  bool saveSyncResults(QString aProfileName, const SyncResults &aResults);
245 
255  Profile *profile(const QString &aName, const QString &aType);
256 
265  Profile *profileFromXml(const QString &aProfileAsXml);
266 
275  SyncProfile *createTempSyncProfile (const QString &btAddress, bool &saveNewProfile);
276 
286  QString updateProfile(const Profile &aProfile);
287 
296  bool removeProfile(const QString &aProfileId);
297 
304  bool rename(const QString &aName, const QString &aNewName);
305 
314  void enableStorages (Profile &aProfile, QMap<QString , bool> &aStorageMap, bool *aModified = NULL);
315 
324  void setStoragesVisible(Profile &aProfile, QMap<QString, bool> &aStorageMap, bool *aModified = NULL);
325 
332  void saveRemoteTargetId (Profile &aProfile,const QString& aId);
333 
340  bool setSyncSchedule(QString aProfileId , QString aScheduleAsXml);
341 
346  void addRetriesInfo(const SyncProfile* aProfile);
347 
353  QDateTime getNextRetryInterval(const SyncProfile* aProfile);
354 
360  void retriesDone(const QString& aProfileName);
361 
362 #ifdef SYNCFW_UNIT_TESTS
363  friend class ProfileManagerTest;
364 #endif
365 
366 signals:
367 
377  void signalProfileChanged(QString aProfileName, int aChangeType , QString aProfileAsXml);
378 
379 private:
380 
381  ProfileManager& operator=(const ProfileManager &aRhs);
382 
383  ProfileManagerPrivate *d_ptr;
384 
385  QHash<QString, QList<quint32> > iSyncRetriesInfo;
386 };
387 
388 }
389 
390 #endif // PROFILEMANAGER_H
bool saveLog(const SyncLog &aLog)
Saves the given synchronization log.
Definition: ProfileManager.cpp:963
This class represents a single profile, a collection of settings or data releated to some entity...
Definition: Profile.h:52
void enableStorages(Profile &aProfile, QMap< QString, bool > &aStorageMap, bool *aModified=NULL)
Enables sync'd storages in profile.
Definition: ProfileManager.cpp:811
Sub-profile (and key) exists.
Definition: ProfileManager.h:63
QString iKey
Key name. If this is empty, key comparison is not made.
Definition: ProfileManager.h:96
Profile * profileFromXml(const QString &aProfileAsXml)
Gets a profile object from an xml document.
Definition: ProfileManager.cpp:717
ProfileChangeType
Enum to indicate the change type of the Profile Operation.
Definition: ProfileManager.h:103
Key value is not equal.
Definition: ProfileManager.h:72
SearchCriteria()
Constructor.
Definition: ProfileManager.cpp:323
ProfileManager(const QString &aPrimaryPath=DEFAULT_PRIMARY_PROFILE_PATH, const QString &aSecondaryPath=DEFAULT_SECONDARY_PROFILE_PATH)
Constructor.
Definition: ProfileManager.cpp:337
Contains information about a completed synchronization session.
Definition: SyncResults.h:58
a New Profile has been added
Definition: ProfileManager.h:106
Definition: AccountsHelper.h:31
QList< SyncProfile * > getSyncProfilesByStorage(const QString &aStorageName, bool aStorageMustBeEnabled=false)
Gets profiles based on supported storages.
Definition: ProfileManager.cpp:618
static const QString DEFAULT_SECONDARY_PROFILE_PATH
Secondary profile path where profiles will be searched.
Definition: ProfileManager.h:54
SyncProfile * syncProfile(const QString &aName)
Gets a sync profile.
Definition: ProfileManager.cpp:357
QStringList profileNames(const QString &aType)
Gets the names of all available profiles with the given type.
Definition: ProfileManager.cpp:390
Type iType
Search criteria type.
Definition: ProfileManager.h:82
void expand(Profile &aProfile)
Expands the given profile.
Definition: ProfileManager.cpp:918
History of completed synchronization sessions and their results.
Definition: SyncLog.h:44
QList< SyncProfile * > allVisibleSyncProfiles()
Gets all visible sync profiles.
Definition: ProfileManager.cpp:444
void saveRemoteTargetId(Profile &aProfile, const QString &aId)
Sets remote target in profile.
Definition: ProfileManager.cpp:1004
Profile has been Removed.
Definition: ProfileManager.h:110
QList< SyncProfile * > getSyncProfilesByData(const QString &aSubProfileName, const QString &aSubProfileType, const QString &aKey="", const QString &aValue="")
Gets profiles with matching data.
Definition: ProfileManager.cpp:465
ProfileManager is responsible for storing and retrieving the profiles.
Definition: ProfileManager.h:45
void setStoragesVisible(Profile &aProfile, QMap< QString, bool > &aStorageMap, bool *aModified=NULL)
Sets storage subprofiles hidden status for the given profile.
Definition: ProfileManager.cpp:836
QList< SyncProfile * > allSyncProfiles()
Gets all sync profiles.
Definition: ProfileManager.cpp:425
static const QString DEFAULT_PRIMARY_PROFILE_PATH
Primary profile path where profiles will be searched.
Definition: ProfileManager.h:51
void addRetriesInfo(const SyncProfile *aProfile)
checks if a profile has retries info and stores the same
Definition: ProfileManager.cpp:1239
Key value is equal.
Definition: ProfileManager.h:69
bool rename(const QString &aName, const QString &aNewName)
Renames a profile, and the associated log too.
Definition: ProfileManager.cpp:1015
bool removeProfile(const QString &aProfileId)
Deletes a profile from the persistent storage.
Definition: ProfileManager.cpp:863
QDateTime getNextRetryInterval(const SyncProfile *aProfile)
gets the next retry after time for a sync profile
Definition: ProfileManager.cpp:1252
a Existing Profile has been modified
Definition: ProfileManager.h:108
QList< SyncProfile * > getSOCProfilesForStorage(const QString &aStorageName)
Gets profiles interested in sync on change for a storage.
Definition: ProfileManager.cpp:565
bool saveSyncResults(QString aProfileName, const SyncResults &aResults)
Saves the results of a sync session to the log.
Definition: ProfileManager.cpp:1047
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:1268
void signalProfileChanged(QString aProfileName, int aChangeType, QString aProfileAsXml)
Notifies about a change in profile.
Definition: moc_ProfileManager.cpp:125
Type
Enum to identify if a member type exists or not.
Definition: ProfileManager.h:60
~ProfileManager()
Destructor.
Definition: ProfileManager.cpp:344
QString iSubProfileName
Definition: ProfileManager.h:88
A top level synchronization profile.
Definition: SyncProfile.h:47
Sub-profile (or key) does not exist.
Definition: ProfileManager.h:66
QString updateProfile(const Profile &aProfile)
Updates the existing profile with the profile given as parameter and emits profileChanged() Signal wi...
Definition: ProfileManager.cpp:732
QString iSubProfileType
Definition: ProfileManager.h:93
SyncProfile * createTempSyncProfile(const QString &btAddress, bool &saveNewProfile)
Gets a temporary profile (saved if sync is sucessfull).
Definition: ProfileManager.cpp:759
Profile log file Modified.
Definition: ProfileManager.h:112
Profile * profile(const QString &aName, const QString &aType)
Gets a profile.
Definition: ProfileManager.cpp:351
bool setSyncSchedule(QString aProfileId, QString aScheduleAsXml)
Sets/Overwrites the schedule to a profile.
Definition: ProfileManager.cpp:1072
Definition: SyncBackupAdaptor.h:40
Search criteria for finding profiles.
Definition: ProfileManager.h:57
QString iValue
Key value. This must be given if criteria type is EQUAL or NOT_EQUAL.
Definition: ProfileManager.h:99