Buteo Synchronization Framework: Buteo::ProfileManager Class Reference

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. More...

## Public Member Functions
| ProfileManager (const QString &aPrimaryPath=QString(), const QString &aSecondaryPath=QString())
| Constructor. More...
| ~ProfileManager ()
| Destructor.
QStringList | profileNames (const QString &aType)
| Gets the names of all available profiles with the given type. More...
SyncProfile * | syncProfile (const QString &aName)
| Gets a sync profile. More...
QList< SyncProfile * > | allSyncProfiles ()
| Gets all sync profiles. More...
QList< SyncProfile * > | allVisibleSyncProfiles ()
| Gets all visible sync profiles. More...
QList< SyncProfile * > | getSyncProfilesByData (const QString &aSubProfileName, const QString &aSubProfileType, const QString &aKey="", const QString &aValue="")
| Gets profiles with matching data. More...
QList< SyncProfile * > | getSyncProfilesByData (const QList< SearchCriteria > &aCriteria)
| Gets profiles with matching data. More...
QList< SyncProfile * > | getSyncProfilesByStorage (const QString &aStorageName, bool aStorageMustBeEnabled=false)
| Gets profiles based on supported storages. More...
QList< SyncProfile * > | getSOCProfilesForStorage (const QString &aStorageName)
| Gets profiles interested in sync on change for a storage. More...
void | expand (Profile &aProfile)
| Expands the given profile. More...
bool | saveLog (const SyncLog &aLog)
| Saves the given synchronization log. More...
bool | saveSyncResults (QString aProfileName, const SyncResults &aResults)
| Saves the results of a sync session to the log. More...
Profile * | profile (const QString &aName, const QString &aType)
| Gets a profile. More...
Profile * | profileFromXml (const QString &aProfileAsXml)
| Gets a profile object from an xml document. More...
SyncProfile * | createTempSyncProfile (const QString &btAddress, bool &saveNewProfile)
| Gets a temporary profile (saved if sync is sucessfull). More...
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) More...
bool | removeProfile (const QString &aProfileId)
| Deletes a profile from the persistent storage. More...
bool | rename (const QString &aName, const QString &aNewName)
| Renames a profile, and the associated log too. More...
void | enableStorages (Profile &aProfile, QMap< QString, bool > &aStorageMap, bool *aModified=NULL)
| Enables sync'd storages in profile. More...
void | setStoragesVisible (Profile &aProfile, QMap< QString, bool > &aStorageMap, bool *aModified=NULL)
| Sets storage subprofiles hidden status for the given profile. More...
void | saveRemoteTargetId (Profile &aProfile, const QString &aId)
| Sets remote target in profile. More...
bool | setSyncSchedule (QString aProfileId, QString aScheduleAsXml)
| Sets/Overwrites the schedule to a profile. More...
void | addRetriesInfo (const SyncProfile *aProfile)
| checks if a profile has retries info and stores the same More...
QDateTime | getNextRetryInterval (const SyncProfile *aProfile)
| gets the next retry after time for a sync profile More...
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 More...

## 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 Buteo::ProfileManager::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.

## Constructor & Destructor Documentation

## ◆ ProfileManager()

ProfileManager::ProfileManager | ( | const QString & | aPrimaryPath = `QString()`,
|  | const QString & | aSecondaryPath = `QString()`
| ) |  |

Constructor.

Parameters

  aPrimaryPath | Path where profiles are searched first. Save operations will write to this location.
  aSecondaryPath | Path where a profile is searched for if it is not found from the primary path. Useful for having default read-only profiles.

## Member Function Documentation

## ◆ addRetriesInfo()

void ProfileManager::addRetriesInfo | ( | const SyncProfile * | aProfile | ) |

checks if a profile has retries info and stores the same

Parameters

  aProfile | sync 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

  btAddress | Address of the remote device bt address/usb .
  saveNewProfile | If 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

  aProfile | Profile of the remote device
  aStorageMap | Map of storage names(hcalendar, hcontacts) and if sync enabled value true/false
  aModified | Whether 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

  aProfile | Name of the profile to expand.

## ◆ getNextRetryInterval()

QDateTime ProfileManager::getNextRetryInterval | ( | const SyncProfile * | aProfile | ) |

gets the next retry after time for a sync profile

Parameters

  aProfile | sync 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

  aStorageName | Name 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

  aCriteria | List 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

  aSubProfileName | Name 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.
  aSubProfileType | Type 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.
  aKey | Name of a required key. If this is empty, key comparison is not made and existance of the sub-profile is enough.
  aValue | Value 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

  aStorageName | Name of the storage that must be supported.
  aStorageMustBeEnabled | True 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

  aName | Name of the profile to get.
  aType | Type 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

  aProfileAsXml | Name 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

  aType | Type 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

  aProfileId | Profile 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

  aName | The old name of the profile
  aNewName | The 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

  aProfileName | name of the profile

## ◆ saveLog()

bool ProfileManager::saveLog | ( | const SyncLog & | aLog | ) |

Saves the given synchronization log.

Parameters

  aLog | Log to save.

Returns
  True if saving was successful.

## ◆ saveRemoteTargetId()

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

Sets remote target in profile.

Parameters

  aProfile | Profile of the remote device
  aId | remote 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

  aProfileName | Name of the profile used in the sync session.
  aResults | Results.

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

  aProfile | Profile of the remote device
  aStorageMap | Map of storage names (hcalendar, hcontacts) and visibility status. With value true the storage will be set visible (equals profile attribute hidden=false)
  aModified | Whether 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

  aProfileId | Profile Id
  aScheduleAsXml | SyncSchedule 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

  aProfileName | Name of the changed profile.
  aChangeType |

See also
  ProfileManager::ProfileChangeType

Parameters

  aProfileAsXml | Updated 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

  aName | Name 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:

- ProfileManager.h
- moc_ProfileManager.cpp
- ProfileManager.cpp