Buteo Synchronization Framework
Classes | Public Types | Signals | Public Member Functions | List of all members
Buteo::ProfileManager Class Reference

ProfileManager is responsible for storing and retrieving the profiles. More...

#include <ProfileManager.h>

Inheritance diagram for Buteo::ProfileManager:

Classes

struct  SearchCriteria
 Search criteria for finding profiles. More...
 

Public Types

enum  ProfileChangeType { PROFILE_ADDED = 0 , PROFILE_MODIFIED , PROFILE_REMOVED , PROFILE_LOGS_MODIFIED }
 Enum to indicate the change type of the Profile Operation. More...
 

Signals

void signalProfileChanged (QString aProfileName, int aChangeType, QString aProfileAsXml)
 Notifies about a change in profile.
 

Public Member Functions

 ProfileManager ()
 Constructor.
 
 ~ProfileManager ()
 Destructor.
 
QStringList profileNames (const QString &aType)
 Gets the names of all available profiles with the given type.
 
SyncProfilesyncProfile (const QString &aName)
 Gets a sync profile.
 
QList< SyncProfile * > allSyncProfiles ()
 Gets all sync profiles.
 
QList< SyncProfile * > allVisibleSyncProfiles ()
 Gets all visible sync profiles.
 
QList< SyncProfile * > getSyncProfilesByData (const QString &aSubProfileName, const QString &aSubProfileType, const QString &aKey="", const QString &aValue="")
 Gets profiles with matching data.
 
QList< SyncProfile * > getSyncProfilesByData (const QList< SearchCriteria > &aCriteria)
 Gets profiles with matching data.
 
QList< SyncProfile * > getSyncProfilesByStorage (const QString &aStorageName, bool aStorageMustBeEnabled=false)
 Gets profiles based on supported storages.
 
QList< SyncProfile * > getSOCProfilesForStorage (const QString &aStorageName)
 Gets profiles interested in sync on change for a storage.
 
void expand (Profile &aProfile)
 Expands the given profile.
 
bool saveLog (const SyncLog &aLog)
 Saves the given synchronization log.
 
bool saveSyncResults (QString aProfileName, const SyncResults &aResults)
 Saves the results of a sync session to the log.
 
Profileprofile (const QString &aName, const QString &aType)
 Gets a profile.
 
ProfileprofileFromXml (const QString &aProfileAsXml)
 Gets a profile object from an xml document.
 
SyncProfilecreateTempSyncProfile (const QString &btAddress, bool &saveNewProfile)
 Gets a temporary profile (saved if sync is sucessfull).
 
QString updateProfile (const Profile &aProfile)
 Updates the existing profile with the profile given as parameter and emits profileChanged() Signal with appropriate value depening if profile was newly added (0) or updated (1)
 
bool removeProfile (const QString &aProfileId)
 Deletes a profile from the persistent storage.
 
bool rename (const QString &aName, const QString &aNewName)
 Renames a profile, and the associated log too.
 
void enableStorages (Profile &aProfile, QMap< QString, bool > &aStorageMap, bool *aModified=NULL)
 Enables sync'd storages in profile.
 
void setStoragesVisible (Profile &aProfile, QMap< QString, bool > &aStorageMap, bool *aModified=NULL)
 Sets storage subprofiles hidden status for the given profile.
 
void saveRemoteTargetId (Profile &aProfile, const QString &aId)
 Sets remote target in profile.
 
bool setSyncSchedule (QString aProfileId, QString aScheduleAsXml)
 Sets/Overwrites the schedule to a profile.
 
void addRetriesInfo (const SyncProfile *aProfile)
 checks if a profile has retries info and stores the same
 
QDateTime getNextRetryInterval (const SyncProfile *aProfile)
 gets the next retry after time for a sync profile
 
void retriesDone (const QString &aProfileName)
 call this to indicate that retries have to stop for a certain sync for a profile - either the no. of retry attempts exhausted or one of the retries succeeded
 
void setPaths (const QString &configPath, const QString &systemConfigPath)
 

Detailed Description

ProfileManager is responsible for storing and retrieving the profiles.

It also constructs top level profiles by loading and merging all referenced sub-profiles. The ProfileManager hides the actual storage from the user, so that it makes no difference if the profiles are stored to simple XML-files or to a database. Profiles can be queried by name and type.

Member Enumeration Documentation

◆ ProfileChangeType

Enum to indicate the change type of the Profile Operation.

Enumerator
PROFILE_ADDED 

a New Profile has been added

PROFILE_MODIFIED 

a Existing Profile has been modified

PROFILE_REMOVED 

Profile has been Removed.

PROFILE_LOGS_MODIFIED 

Profile log file Modified.

Member Function Documentation

◆ addRetriesInfo()

void ProfileManager::addRetriesInfo ( const SyncProfile * aProfile)

checks if a profile has retries info and stores the same

Parameters
aProfilesync profile

◆ allSyncProfiles()

QList< SyncProfile * > ProfileManager::allSyncProfiles ( )

Gets all sync profiles.

Returns
The list of sync profiles. Caller is responsible for deleting the returned profile objects.

◆ allVisibleSyncProfiles()

QList< SyncProfile * > ProfileManager::allVisibleSyncProfiles ( )

Gets all visible sync profiles.

Returns all sync profiles that should be visible in sync ui. A profile is visible if it has not been explicitly set as hidden.

Returns
The list of sync profiles. Caller is responsible for deleting the returned profile objects.

◆ createTempSyncProfile()

SyncProfile * ProfileManager::createTempSyncProfile ( const QString & btAddress,
bool & saveNewProfile )

Gets a temporary profile (saved if sync is sucessfull).

Parameters
btAddressAddress of the remote device bt address/usb .
saveNewProfileIf to save the profile or not (e.g pc suite profile)
Returns
Pointer to the profile. Changes made to the profile are not saved to profile storage, unless save function of this class is called

◆ enableStorages()

void ProfileManager::enableStorages ( Profile & aProfile,
QMap< QString, bool > & aStorageMap,
bool * aModified = NULL )

Enables sync'd storages in profile.

Parameters
aProfileProfile of the remote device
aStorageMapMap of storage names(hcalendar, hcontacts) and if sync enabled value true/false
aModifiedWhether the profile was updated as a result of this function call, and thus requires writing to disk

◆ expand()

void ProfileManager::expand ( Profile & aProfile)

Expands the given profile.

Loads and merges all sub-profiles that are referenced from the main profile.

Parameters
aProfileName of the profile to expand.

◆ getNextRetryInterval()

QDateTime ProfileManager::getNextRetryInterval ( const SyncProfile * aProfile)

gets the next retry after time for a sync profile

Parameters
aProfilesync profile
Returns
next retry interval

◆ getSOCProfilesForStorage()

QList< SyncProfile * > ProfileManager::getSOCProfilesForStorage ( const QString & aStorageName)

Gets profiles interested in sync on change for a storage.

Returns all enabled and visible sync profiles of online destinations Device-to-device sync profiles are not returned.

Parameters
aStorageNameName of the storage
Returns
List of matching profiles. Caller is responsible for deleting the returned profile objects.

◆ getSyncProfilesByData() [1/2]

QList< SyncProfile * > ProfileManager::getSyncProfilesByData ( const QList< SearchCriteria > & aCriteria)

Gets profiles with matching data.

Parameters
aCriteriaList of criteria to use in the search. Each criterion in the list has to match for a profile to be returned as a result.
Returns
List of matching profiles. Caller is responsible for deleting the returned profile objects.

◆ getSyncProfilesByData() [2/2]

QList< SyncProfile * > ProfileManager::getSyncProfilesByData ( const QString & aSubProfileName,
const QString & aSubProfileType,
const QString & aKey = "",
const QString & aValue = "" )

Gets profiles with matching data.

Parameters
aSubProfileNameName of a required sub-profile. If this is given, the sub-profile must exist and key comparison is made with the keys of the sub-profile.
aSubProfileTypeType of a required sub-profile. If this is given but sub-profile name is empty, the first sub-profile with matching type is used in comparison.
aKeyName of a required key. If this is empty, key comparison is not made and existance of the sub-profile is enough.
aValueValue of the required key. If this is empty, any value is accepted as long as the key itself exists.
Returns
List of matching profiles. Caller is responsible for deleting the returned profile objects.

◆ getSyncProfilesByStorage()

QList< SyncProfile * > ProfileManager::getSyncProfilesByStorage ( const QString & aStorageName,
bool aStorageMustBeEnabled = false )

Gets profiles based on supported storages.

Returns all enabled and visible sync profiles of online destinations that support the given storage. Device-to-device sync profiles are not returned.

Parameters
aStorageNameName of the storage that must be supported.
aStorageMustBeEnabledTrue if the supported storage must be also enabled. Only enabled storages are included in sync session.
Returns
List of matching profiles. Caller is responsible for deleting the returned profile objects.

◆ profile()

Profile * ProfileManager::profile ( const QString & aName,
const QString & aType )

Gets a profile.

Parameters
aNameName of the profile to get.
aTypeType of the profile to get.
Returns
Pointer to the profile. If the profile is not found, NULL is returned. Caller is responsible for deleting the returned object. Changes made to the profile are not saved to profile storage, unless updateProfile function of this class is called

◆ profileFromXml()

Profile * ProfileManager::profileFromXml ( const QString & aProfileAsXml)

Gets a profile object from an xml document.

Parameters
aProfileAsXmlName of the profile to get.
Returns
Pointer to the profile. If the xml is not valid, NULL is returned. Caller is responsible for deleting the returned object. Changes made to the profile are not saved to profile storage, unless updateProfile function of this class is called

◆ profileNames()

QStringList ProfileManager::profileNames ( const QString & aType)

Gets the names of all available profiles with the given type.

Parameters
aTypeType of the profiles to get.
Returns
The list of profile names.

◆ removeProfile()

bool ProfileManager::removeProfile ( const QString & aProfileId)

Deletes a profile from the persistent storage.

This will emit a signalProfileChanged with ChangeType as Removed if Removal is successful NOTE: only Sync Profiles can be updated using ProfileManger

Parameters
aProfileIdProfile to be remove.
Returns
Success indicator.

◆ rename()

bool ProfileManager::rename ( const QString & aName,
const QString & aNewName )

Renames a profile, and the associated log too.

Parameters
aNameThe old name of the profile
aNewNameThe new name for the profile
Returns
Returns true if the rename was successful

◆ retriesDone()

void ProfileManager::retriesDone ( const QString & aProfileName)

call this to indicate that retries have to stop for a certain sync for a profile - either the no. of retry attempts exhausted or one of the retries succeeded

Parameters
aProfileNamename of the profile

◆ saveLog()

bool ProfileManager::saveLog ( const SyncLog & aLog)

Saves the given synchronization log.

Parameters
aLogLog to save.
Returns
True if saving was successful.

◆ saveRemoteTargetId()

void ProfileManager::saveRemoteTargetId ( Profile & aProfile,
const QString & aId )

Sets remote target in profile.

Parameters
aProfileProfile of the remote device
aIdremote device id

◆ saveSyncResults()

bool ProfileManager::saveSyncResults ( QString aProfileName,
const SyncResults & aResults )

Saves the results of a sync session to the log.

This is a convenience function that loads the log associated with the given profile, appends the given results to the log and then saves the log.

Parameters
aProfileNameName of the profile used in the sync session.
aResultsResults.
Returns
True if saving was successful.

◆ setStoragesVisible()

void ProfileManager::setStoragesVisible ( Profile & aProfile,
QMap< QString, bool > & aStorageMap,
bool * aModified = NULL )

Sets storage subprofiles hidden status for the given profile.

Parameters
aProfileProfile of the remote device
aStorageMapMap of storage names (hcalendar, hcontacts) and visibility status. With value true the storage will be set visible (equals profile attribute hidden=false)
aModifiedWhether the profile was updated as a result of this function call, and thus requires writing to disk

◆ setSyncSchedule()

bool ProfileManager::setSyncSchedule ( QString aProfileId,
QString aScheduleAsXml )

Sets/Overwrites the schedule to a profile.

Parameters
aProfileIdProfile Id
aScheduleAsXmlSyncSchedule Object as an xml string

◆ signalProfileChanged

void Buteo::ProfileManager::signalProfileChanged ( QString aProfileName,
int aChangeType,
QString aProfileAsXml )
signal

Notifies about a change in profile.

This signal is sent when the profile data is modified or when a profile is added or deleted in msyncd.

Parameters
aProfileNameName of the changed profile.
aChangeType
See also
ProfileManager::ProfileChangeType
Parameters
aProfileAsXmlUpdated Profile Object is sent as xml

◆ syncProfile()

SyncProfile * ProfileManager::syncProfile ( const QString & aName)

Gets a sync profile.

Loads and merges also all sub-profiles that are referenced from the main profile. Loads the log of finished synchronization sessions with this profile.

Parameters
aNameName of the profile to get.
Returns
The sync profile. NULL if the profile is not found. Caller becomes the owner of the returned object and is responsible of deleting it after use. Changes made to the profile are not saved to the persistent profile storage, unless save function of this class is called.

◆ updateProfile()

QString ProfileManager::updateProfile ( const Profile & aProfile)

Updates the existing profile with the profile given as parameter and emits profileChanged() Signal with appropriate value depening if profile was newly added (0) or updated (1)

NOTE: only Sync Profiles can be updated using ProfileManger

Parameters
aProfile- Profile Object
Returns
profileId - this will be empty if the update Failed.

The documentation for this class was generated from the following files: