ProfileManager.h
/*
* This file is part of buteo-syncfw package
*
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef PROFILEMANAGER_H
#define PROFILEMANAGER_H
#include "SyncProfile.h"
#include "Profile.h"
#include <QObject>
#include <QList>
#include <QHash>
namespace Buteo {
class ProfileManagerPrivate;
class ProfileManager: public QObject
{
Q_OBJECT
public:
struct SearchCriteria {
enum Type {
EXISTS,
NOT_EXISTS,
EQUAL,
NOT_EQUAL
};
SearchCriteria();
SearchCriteria(const SearchCriteria &aSource);
SearchCriteria &operator=(const SearchCriteria &other);
Type iType;
QString iSubProfileName;
QString iSubProfileType;
QString iKey;
QString iValue;
};
enum ProfileChangeType {
PROFILE_ADDED = 0,
PROFILE_MODIFIED,
PROFILE_REMOVED,
PROFILE_LOGS_MODIFIED
};
ProfileManager();
~ProfileManager();
QStringList profileNames(const QString &aType);
SyncProfile *syncProfile(const QString &aName);
QList<SyncProfile *> allSyncProfiles();
QList<SyncProfile *> allVisibleSyncProfiles();
QList<SyncProfile *> getSyncProfilesByData(const QString &aSubProfileName,
const QString &aSubProfileType,
const QString &aKey = "", const QString &aValue = "");
QList<SyncProfile *> getSyncProfilesByData(const QList<SearchCriteria> &aCriteria);
QList<SyncProfile *> getSyncProfilesByStorage(const QString &aStorageName, bool aStorageMustBeEnabled = false);
QList<SyncProfile *> getSOCProfilesForStorage(const QString &aStorageName);
void expand(Profile &aProfile);
bool saveLog(const SyncLog &aLog);
bool saveSyncResults(QString aProfileName, const SyncResults &aResults);
Profile *profile(const QString &aName, const QString &aType);
SyncProfile *createTempSyncProfile (const QString &btAddress, bool &saveNewProfile);
QString updateProfile(const Profile &aProfile);
bool removeProfile(const QString &aProfileId);
bool rename(const QString &aName, const QString &aNewName);
void enableStorages (Profile &aProfile, QMap<QString, bool> &aStorageMap, bool *aModified = nullptr);
void setStoragesVisible(Profile &aProfile, QMap<QString, bool> &aStorageMap, bool *aModified = nullptr);
void saveRemoteTargetId (Profile &aProfile, const QString &aId);
bool setSyncSchedule(QString aProfileId, QString aScheduleAsXml);
void addRetriesInfo(const SyncProfile *aProfile);
QDateTime getNextRetryInterval(const SyncProfile *aProfile);
void retriesDone(const QString &aProfileName);
#ifdef SYNCFW_UNIT_TESTS
friend class ProfileManagerTest;
#endif
// for testing purposes only
// configPath is the root of primary profile directory, used for writing changes
// systemConfigPath is for read-only system profiles
void setPaths(const QString &configPath, const QString &systemConfigPath);
static Profile *profileFromXml(const QString &aProfileAsXml);
signals:
void signalProfileChanged(QString aProfileName, int aChangeType, QString aProfileAsXml);
private:
ProfileManager &operator=(const ProfileManager &aRhs);
ProfileManagerPrivate *d_ptr;
};
}
#endif // PROFILEMANAGER_H
Buteo::ProfileManager::allVisibleSyncProfiles
QList< SyncProfile * > allVisibleSyncProfiles()
Gets all visible sync profiles.
Definition ProfileManager.cpp:403
Buteo::ProfileManager::expand
void expand(Profile &aProfile)
Expands the given profile.
Definition ProfileManager.cpp:843
Buteo::ProfileManager::saveLog
bool saveLog(const SyncLog &aLog)
Saves the given synchronization log.
Definition ProfileManager.cpp:880
Buteo::ProfileManager::getSOCProfilesForStorage
QList< SyncProfile * > getSOCProfilesForStorage(const QString &aStorageName)
Gets profiles interested in sync on change for a storage.
Definition ProfileManager.cpp:502
Buteo::ProfileManager::profileFromXml
static Profile * profileFromXml(const QString &aProfileAsXml)
Gets a profile object from an xml document.
Definition ProfileManager.cpp:647
Buteo::ProfileManager::allSyncProfiles
QList< SyncProfile * > allSyncProfiles()
Gets all sync profiles.
Definition ProfileManager.cpp:386
Buteo::ProfileManager::getSyncProfilesByStorage
QList< SyncProfile * > getSyncProfilesByStorage(const QString &aStorageName, bool aStorageMustBeEnabled=false)
Gets profiles based on supported storages.
Definition ProfileManager.cpp:555
Buteo::ProfileManager::saveSyncResults
bool saveSyncResults(QString aProfileName, const SyncResults &aResults)
Saves the results of a sync session to the log.
Definition ProfileManager.cpp:958
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:665
Buteo::ProfileManager::enableStorages
void enableStorages(Profile &aProfile, QMap< QString, bool > &aStorageMap, bool *aModified=nullptr)
Enables sync'd storages in profile.
Definition ProfileManager.cpp:744
Buteo::ProfileManager::~ProfileManager
~ProfileManager()
Destructor.
Definition ProfileManager.cpp:291
Buteo::ProfileManager::syncProfile
SyncProfile * syncProfile(const QString &aName)
Gets a sync profile.
Definition ProfileManager.cpp:320
Buteo::ProfileManager::profile
Profile * profile(const QString &aName, const QString &aType)
Gets a profile.
Definition ProfileManager.cpp:315
Buteo::ProfileManager::rename
bool rename(const QString &aName, const QString &aNewName)
Renames a profile, and the associated log too.
Definition ProfileManager.cpp:929
Buteo::ProfileManager::createTempSyncProfile
SyncProfile * createTempSyncProfile(const QString &btAddress, bool &saveNewProfile)
Gets a temporary profile (saved if sync is sucessfull).
Definition ProfileManager.cpp:698
Buteo::ProfileManager::removeProfile
bool removeProfile(const QString &aProfileId)
Deletes a profile from the persistent storage.
Definition ProfileManager.cpp:794
Buteo::ProfileManager::profileNames
QStringList profileNames(const QString &aType)
Gets the names of all available profiles with the given type.
Definition ProfileManager.cpp:354
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:420
Buteo::ProfileManager::getNextRetryInterval
QDateTime getNextRetryInterval(const SyncProfile *aProfile)
gets the next retry after time for a sync profile
Definition ProfileManager.cpp:1129
Buteo::ProfileManager::setStoragesVisible
void setStoragesVisible(Profile &aProfile, QMap< QString, bool > &aStorageMap, bool *aModified=nullptr)
Sets storage subprofiles hidden status for the given profile.
Definition ProfileManager.cpp:768
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:1143
Buteo::ProfileManager::setSyncSchedule
bool setSyncSchedule(QString aProfileId, QString aScheduleAsXml)
Sets/Overwrites the schedule to a profile.
Definition ProfileManager.cpp:982
Buteo::ProfileManager::addRetriesInfo
void addRetriesInfo(const SyncProfile *aProfile)
checks if a profile has retries info and stores the same
Definition ProfileManager.cpp:1118
Buteo::ProfileManager::saveRemoteTargetId
void saveRemoteTargetId(Profile &aProfile, const QString &aId)
Sets remote target in profile.
Definition ProfileManager.cpp:919
Buteo::ProfileManager::ProfileChangeType
ProfileChangeType
Enum to indicate the change type of the Profile Operation.
Definition ProfileManager.h:93
Buteo::ProfileManager::PROFILE_LOGS_MODIFIED
@ PROFILE_LOGS_MODIFIED
Profile log file Modified.
Definition ProfileManager.h:101
Buteo::ProfileManager::PROFILE_MODIFIED
@ PROFILE_MODIFIED
a Existing Profile has been modified
Definition ProfileManager.h:97
Buteo::ProfileManager::PROFILE_ADDED
@ PROFILE_ADDED
a New Profile has been added
Definition ProfileManager.h:95
Buteo::ProfileManager::PROFILE_REMOVED
@ PROFILE_REMOVED
Profile has been Removed.
Definition ProfileManager.h:99
Buteo::ProfileManager::signalProfileChanged
void signalProfileChanged(QString aProfileName, int aChangeType, QString aProfileAsXml)
Notifies about a change in profile.
Buteo::ProfileManager::ProfileManager
ProfileManager()
Constructor.
Definition ProfileManager.cpp:285
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:67
QList
Definition SyncBackupAdaptor.h:40
QMap
Definition SyncBackupAdaptor.h:41
Buteo::ProfileManager::SearchCriteria
Search criteria for finding profiles.
Definition ProfileManager.h:51
Buteo::ProfileManager::SearchCriteria::iValue
QString iValue
Key value. This must be given if criteria type is EQUAL or NOT_EQUAL.
Definition ProfileManager.h:89
Buteo::ProfileManager::SearchCriteria::iKey
QString iKey
Key name. If this is empty, key comparison is not made.
Definition ProfileManager.h:86
Buteo::ProfileManager::SearchCriteria::Type
Type
Enum to identify if a member type exists or not.
Definition ProfileManager.h:53
Buteo::ProfileManager::SearchCriteria::EXISTS
@ EXISTS
Sub-profile (and key) exists.
Definition ProfileManager.h:55
Buteo::ProfileManager::SearchCriteria::EQUAL
@ EQUAL
Key value is equal.
Definition ProfileManager.h:59
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:61
Buteo::ProfileManager::SearchCriteria::iSubProfileName
QString iSubProfileName
Definition ProfileManager.h:78
Buteo::ProfileManager::SearchCriteria::SearchCriteria
SearchCriteria()
Constructor.
Definition ProfileManager.cpp:256
Buteo::ProfileManager::SearchCriteria::iType
Type iType
Search criteria type.
Definition ProfileManager.h:72
Buteo::ProfileManager::SearchCriteria::iSubProfileType
QString iSubProfileType
Definition ProfileManager.h:83