Buteo Synchronization Framework: ProfileManager.h Source File

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#include <QObject>
30#include <QList>
31#include <QHash>
32
33namespace Buteo {
34
35class ProfileManagerPrivate;
36
45 class ProfileManager: public QObject
46{
47 Q_OBJECT
48public:
50 struct SearchCriteria {
52 enum Type {
54 EXISTS,
55
57 NOT_EXISTS,
58
60 EQUAL,
61
63 NOT_EQUAL
64 };
65
67 SearchCriteria();
68
70 SearchCriteria(const SearchCriteria &aSource);
71
73 Type iType;
74
79 QString iSubProfileName;
80
84 QString iSubProfileType;
85
87 QString iKey;
88
90 QString iValue;
91 };
92
94 enum ProfileChangeType {
96 PROFILE_ADDED = 0,
98 PROFILE_MODIFIED,
100 PROFILE_REMOVED,
102 PROFILE_LOGS_MODIFIED
103 };
104
113 ProfileManager(const QString &aPrimaryPath = QString(),
114 const QString &aSecondaryPath = QString());
115
118 ~ProfileManager();
119
125 QStringList profileNames(const QString &aType);
126
138 SyncProfile *syncProfile(const QString &aName);
139
145 QList<SyncProfile *> allSyncProfiles();
146
154 QList<SyncProfile *> allVisibleSyncProfiles();
155
171 QList<SyncProfile *> getSyncProfilesByData(const QString &aSubProfileName,
172 const QString &aSubProfileType,
173 const QString &aKey = "", const QString &aValue = "");
174
182 QList<SyncProfile *> getSyncProfilesByData(
183 const QList<SearchCriteria> &aCriteria);
184
196 QList<SyncProfile *> getSyncProfilesByStorage(
197 const QString &aStorageName, bool aStorageMustBeEnabled = false);
198
207 QList<SyncProfile *> getSOCProfilesForStorage(
208 const QString &aStorageName);
209
216 void expand(Profile &aProfile);
217
223 bool saveLog(const SyncLog &aLog);
224
234 bool saveSyncResults(QString aProfileName, const SyncResults &aResults);
235
245 Profile *profile(const QString &aName, const QString &aType);
246
255 Profile *profileFromXml(const QString &aProfileAsXml);
256
265 SyncProfile *createTempSyncProfile (const QString &btAddress, bool &saveNewProfile);
266
276 QString updateProfile(const Profile &aProfile);
277
286 bool removeProfile(const QString &aProfileId);
287
294 bool rename(const QString &aName, const QString &aNewName);
295
304 void enableStorages (Profile &aProfile, QMap<QString, bool> &aStorageMap, bool *aModified = NULL);
305
314 void setStoragesVisible(Profile &aProfile, QMap<QString, bool> &aStorageMap, bool *aModified = NULL);
315
322 void saveRemoteTargetId (Profile &aProfile, const QString &aId);
323
330 bool setSyncSchedule(QString aProfileId, QString aScheduleAsXml);
331
336 void addRetriesInfo(const SyncProfile *aProfile);
337
343 QDateTime getNextRetryInterval(const SyncProfile *aProfile);
344
350 void retriesDone(const QString &aProfileName);
351
352#ifdef SYNCFW_UNIT_TESTS
353 friend class ProfileManagerTest;
354#endif
355
356signals:
357
367 void signalProfileChanged(QString aProfileName, int aChangeType, QString aProfileAsXml);
368
369private:
370
371 ProfileManager &operator=(const ProfileManager &aRhs);
372
373 ProfileManagerPrivate *d_ptr;
374
375 QHash<QString, QList<quint32> > iSyncRetriesInfo;
376};
377
378}
379
380#endif // PROFILEMANAGER_H
Buteo::ProfileManager
ProfileManager is responsible for storing and retrieving the profiles.
Definition: ProfileManager.h:46
Buteo::ProfileManager::allVisibleSyncProfiles
QList< SyncProfile * > allVisibleSyncProfiles()
Gets all visible sync profiles.
Definition: ProfileManager.cpp:398
Buteo::ProfileManager::enableStorages
void enableStorages(Profile &aProfile, QMap< QString, bool > &aStorageMap, bool *aModified=NULL)
Enables sync'd storages in profile.
Definition: ProfileManager.cpp:738
Buteo::ProfileManager::expand
void expand(Profile &aProfile)
Expands the given profile.
Definition: ProfileManager.cpp:839
Buteo::ProfileManager::saveLog
bool saveLog(const SyncLog &aLog)
Saves the given synchronization log.
Definition: ProfileManager.cpp:878
Buteo::ProfileManager::getSOCProfilesForStorage
QList< SyncProfile * > getSOCProfilesForStorage(const QString &aStorageName)
Gets profiles interested in sync on change for a storage.
Definition: ProfileManager.cpp:499
Buteo::ProfileManager::profileFromXml
Profile * profileFromXml(const QString &aProfileAsXml)
Gets a profile object from an xml document.
Definition: ProfileManager.cpp:643
Buteo::ProfileManager::allSyncProfiles
QList< SyncProfile * > allSyncProfiles()
Gets all sync profiles.
Definition: ProfileManager.cpp:381
Buteo::ProfileManager::getSyncProfilesByStorage
QList< SyncProfile * > getSyncProfilesByStorage(const QString &aStorageName, bool aStorageMustBeEnabled=false)
Gets profiles based on supported storages.
Definition: ProfileManager.cpp:552
Buteo::ProfileManager::saveSyncResults
bool saveSyncResults(QString aProfileName, const SyncResults &aResults)
Saves the results of a sync session to the log.
Definition: ProfileManager.cpp:957
Buteo::ProfileManager::updateProfile
QString updateProfile(const Profile &aProfile)
Updates the existing profile with the profile given as parameter and emits profileChanged() Signal wi...
Definition: ProfileManager.cpp:661
Buteo::ProfileManager::~ProfileManager
~ProfileManager()
Destructor.
Definition: ProfileManager.cpp:303
Buteo::ProfileManager::syncProfile
SyncProfile * syncProfile(const QString &aName)
Gets a sync profile.
Definition: ProfileManager.cpp:316
Buteo::ProfileManager::profile
Profile * profile(const QString &aName, const QString &aType)
Gets a profile.
Definition: ProfileManager.cpp:310
Buteo::ProfileManager::rename
bool rename(const QString &aName, const QString &aNewName)
Renames a profile, and the associated log too.
Definition: ProfileManager.cpp:928
Buteo::ProfileManager::setStoragesVisible
void setStoragesVisible(Profile &aProfile, QMap< QString, bool > &aStorageMap, bool *aModified=NULL)
Sets storage subprofiles hidden status for the given profile.
Definition: ProfileManager.cpp:763
Buteo::ProfileManager::createTempSyncProfile
SyncProfile * createTempSyncProfile(const QString &btAddress, bool &saveNewProfile)
Gets a temporary profile (saved if sync is sucessfull).
Definition: ProfileManager.cpp:694
Buteo::ProfileManager::removeProfile
bool removeProfile(const QString &aProfileId)
Deletes a profile from the persistent storage.
Definition: ProfileManager.cpp:790
Buteo::ProfileManager::profileNames
QStringList profileNames(const QString &aType)
Gets the names of all available profiles with the given type.
Definition: ProfileManager.cpp:349
Buteo::ProfileManager::getSyncProfilesByData
QList< SyncProfile * > getSyncProfilesByData(const QString &aSubProfileName, const QString &aSubProfileType, const QString &aKey="", const QString &aValue="")
Gets profiles with matching data.
Definition: ProfileManager.cpp:415
Buteo::ProfileManager::ProfileManager
ProfileManager(const QString &aPrimaryPath=QString(), const QString &aSecondaryPath=QString())
Constructor.
Definition: ProfileManager.cpp:295
Buteo::ProfileManager::getNextRetryInterval
QDateTime getNextRetryInterval(const SyncProfile *aProfile)
gets the next retry after time for a sync profile
Definition: ProfileManager.cpp:1131
Buteo::ProfileManager::retriesDone
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:1146
Buteo::ProfileManager::setSyncSchedule
bool setSyncSchedule(QString aProfileId, QString aScheduleAsXml)
Sets/Overwrites the schedule to a profile.
Definition: ProfileManager.cpp:981
Buteo::ProfileManager::addRetriesInfo
void addRetriesInfo(const SyncProfile *aProfile)
checks if a profile has retries info and stores the same
Definition: ProfileManager.cpp:1120
Buteo::ProfileManager::saveRemoteTargetId
void saveRemoteTargetId(Profile &aProfile, const QString &aId)
Sets remote target in profile.
Definition: ProfileManager.cpp:917
Buteo::ProfileManager::ProfileChangeType
ProfileChangeType
Enum to indicate the change type of the Profile Operation.
Definition: ProfileManager.h:94
Buteo::ProfileManager::PROFILE_LOGS_MODIFIED
@ PROFILE_LOGS_MODIFIED
Profile log file Modified.
Definition: ProfileManager.h:102
Buteo::ProfileManager::PROFILE_MODIFIED
@ PROFILE_MODIFIED
a Existing Profile has been modified
Definition: ProfileManager.h:98
Buteo::ProfileManager::PROFILE_ADDED
@ PROFILE_ADDED
a New Profile has been added
Definition: ProfileManager.h:96
Buteo::ProfileManager::PROFILE_REMOVED
@ PROFILE_REMOVED
Profile has been Removed.
Definition: ProfileManager.h:100
Buteo::ProfileManager::signalProfileChanged
void signalProfileChanged(QString aProfileName, int aChangeType, QString aProfileAsXml)
Notifies about a change in profile.
Definition: moc_ProfileManager.cpp:132
Buteo::Profile
This class represents a single profile, a collection of settings or data releated to some entity.
Definition: Profile.h:53
Buteo::SyncLog
History of completed synchronization sessions and their results.
Definition: SyncLog.h:45
Buteo::SyncProfile
A top level synchronization profile.
Definition: SyncProfile.h:49
Buteo::SyncResults
Contains information about a completed synchronization session.
Definition: SyncResults.h:62
QList
Definition: SyncBackupAdaptor.h:40
QMap< QString, bool >
Buteo::ProfileManager::SearchCriteria
Search criteria for finding profiles.
Definition: ProfileManager.h:50
Buteo::ProfileManager::SearchCriteria::iValue
QString iValue
Key value. This must be given if criteria type is EQUAL or NOT_EQUAL.
Definition: ProfileManager.h:90
Buteo::ProfileManager::SearchCriteria::iKey
QString iKey
Key name. If this is empty, key comparison is not made.
Definition: ProfileManager.h:87
Buteo::ProfileManager::SearchCriteria::Type
Type
Enum to identify if a member type exists or not.
Definition: ProfileManager.h:52
Buteo::ProfileManager::SearchCriteria::EXISTS
@ EXISTS
Sub-profile (and key) exists.
Definition: ProfileManager.h:54
Buteo::ProfileManager::SearchCriteria::EQUAL
@ EQUAL
Key value is equal.
Definition: ProfileManager.h:60
Buteo::ProfileManager::SearchCriteria::NOT_EXISTS
@ NOT_EXISTS
Sub-profile (or key) does not exist.
Definition: ProfileManager.h:57
Buteo::ProfileManager::SearchCriteria::NOT_EQUAL
@ NOT_EQUAL
Key value is not equal.
Definition: ProfileManager.h:63
Buteo::ProfileManager::SearchCriteria::iSubProfileName
QString iSubProfileName
Definition: ProfileManager.h:79
Buteo::ProfileManager::SearchCriteria::SearchCriteria
SearchCriteria()
Constructor.
Definition: ProfileManager.cpp:281
Buteo::ProfileManager::SearchCriteria::iType
Type iType
Search criteria type.
Definition: ProfileManager.h:73
Buteo::ProfileManager::SearchCriteria::iSubProfileType
QString iSubProfileType
Definition: ProfileManager.h:84