ButeoSynchronizationFramework
|
ProfileManager is responsible for storing and retrieving the profiles. More...
#include <ProfileManager.h>
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=DEFAULT_PRIMARY_PROFILE_PATH, const QString &aSecondaryPath=DEFAULT_SECONDARY_PROFILE_PATH) | |
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... | |
Static Public Attributes | |
static const QString | DEFAULT_PRIMARY_PROFILE_PATH |
Primary profile path where profiles will be searched. More... | |
static const QString | DEFAULT_SECONDARY_PROFILE_PATH |
Secondary profile path where profiles will be searched. More... | |
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.
ProfileManager::ProfileManager | ( | const QString & | aPrimaryPath = DEFAULT_PRIMARY_PROFILE_PATH , |
const QString & | aSecondaryPath = DEFAULT_SECONDARY_PROFILE_PATH |
||
) |
Constructor.
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. |
void ProfileManager::addRetriesInfo | ( | const SyncProfile * | aProfile | ) |
checks if a profile has retries info and stores the same
aProfile | sync profile |
QList< SyncProfile * > ProfileManager::allSyncProfiles | ( | ) |
Gets all sync profiles.
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.
SyncProfile * ProfileManager::createTempSyncProfile | ( | const QString & | btAddress, |
bool & | saveNewProfile | ||
) |
Gets a temporary profile (saved if sync is sucessfull).
btAddress | Address of the remote device bt address/usb . |
saveNewProfile | If to save the profile or not (e.g pc suite profile) |
void ProfileManager::enableStorages | ( | Profile & | aProfile, |
QMap< QString, bool > & | aStorageMap, | ||
bool * | aModified = NULL |
||
) |
Enables sync'd storages in profile.
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 |
void ProfileManager::expand | ( | Profile & | aProfile | ) |
Expands the given profile.
Loads and merges all sub-profiles that are referenced from the main profile.
aProfile | Name of the profile to expand. |
QDateTime ProfileManager::getNextRetryInterval | ( | const SyncProfile * | aProfile | ) |
gets the next retry after time for a sync profile
aProfile | sync profile |
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.
aStorageName | Name of the storage |
QList< SyncProfile * > ProfileManager::getSyncProfilesByData | ( | const QString & | aSubProfileName, |
const QString & | aSubProfileType, | ||
const QString & | aKey = "" , |
||
const QString & | aValue = "" |
||
) |
Gets profiles with matching data.
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. |
QList< SyncProfile * > ProfileManager::getSyncProfilesByData | ( | const QList< SearchCriteria > & | aCriteria | ) |
Gets profiles with matching data.
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. |
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.
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. |
Profile * ProfileManager::profile | ( | const QString & | aName, |
const QString & | aType | ||
) |
Gets a profile.
aName | Name of the profile to get. |
aType | Type of the profile to get. |
Profile * ProfileManager::profileFromXml | ( | const QString & | aProfileAsXml | ) |
Gets a profile object from an xml document.
aProfileAsXml | Name of the profile to get. |
QStringList ProfileManager::profileNames | ( | const QString & | aType | ) |
Gets the names of all available profiles with the given type.
aType | Type of the profiles to get. |
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
aProfileId | Profile to be remove. |
bool ProfileManager::rename | ( | const QString & | aName, |
const QString & | aNewName | ||
) |
Renames a profile, and the associated log too.
aName | The old name of the profile |
aNewName | The new name for the profile |
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
aProfileName | name of the profile |
bool ProfileManager::saveLog | ( | const SyncLog & | aLog | ) |
Saves the given synchronization log.
aLog | Log to save. |
void ProfileManager::saveRemoteTargetId | ( | Profile & | aProfile, |
const QString & | aId | ||
) |
Sets remote target in profile.
aProfile | Profile of the remote device |
aId | remote device id |
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.
aProfileName | Name of the profile used in the sync session. |
aResults | Results. |
void ProfileManager::setStoragesVisible | ( | Profile & | aProfile, |
QMap< QString, bool > & | aStorageMap, | ||
bool * | aModified = NULL |
||
) |
Sets storage subprofiles hidden status for the given profile.
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 |
bool ProfileManager::setSyncSchedule | ( | QString | aProfileId, |
QString | aScheduleAsXml | ||
) |
Sets/Overwrites the schedule to a profile.
aProfileId | Profile Id |
aScheduleAsXml | SyncSchedule Object as an xml string |
|
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.
aProfileName | Name of the changed profile. |
aChangeType |
aProfileAsXml | Updated Profile Object is sent as xml |
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.
aName | Name of the profile to get. |
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
aProfile | - Profile Object |
|
static |
Primary profile path where profiles will be searched.
|
static |
Secondary profile path where profiles will be searched.