Buteo::SyncClientInterface Class Reference

SyncInterface Class - Main Entry Point for SyncFW Clients. More...

`#include <SyncClientInterface.h>`

Inheritance diagram for Buteo::SyncClientInterface:

## Signals

void | isValidChanged ()
| Notifies when the synchronisation service is available or not.
void | backupInProgress ()
| Notifies about Backup start.
void | backupDone ()
| Notifies about Backup done.
void | restoreInProgress ()
| Notifies about Restore start.
void | restoreDone ()
| Notifies about Restore Done.
void | profileChanged (QString aProfileId, int aChangeType, QString aChangedProfile)
| Notifies about a change in profile.
void | resultsAvailable (QString aProfileId, Buteo::SyncResults aResults)
| Notifies about the results of a recent sync for a profile.
void | syncStatus (QString aProfileId, int aStatus, QString aMessage, int aStatusDetails)
| Notifies about a change in synchronization status.
void | transferProgress (QString aProfileId, int aTransferDatabase, int aTransferType, QString aMimeType, int aCommittedItems)
| Notifies about progress in transferring items.

## Public Member Functions

| SyncClientInterface ()
| Constructor.
| ~SyncClientInterface ()
| Destructor.
bool | startSync (const QString &aProfileId) const
| Requests to starts synchronizing using a profile Id.
QDBusPendingCallWatcher * | requestSync (const QString &aProfileId, QObject *aParent=nullptr) const
| asynchronous version of startSync()
void | abortSync (const QString &aProfileId) const
| Stops synchronizing the profile with the given Id.
QStringList | getRunningSyncList () const
| Gets the list of profile names of currently running syncs.
QDBusPendingCallWatcher * | requestRunningSyncList (QObject *aParent=nullptr) const
| asynchronous version of getRunningSyncList()
bool | setSyncSchedule (const QString &aProfileId, const SyncSchedule &aSchedule)
| Sets Sync Schedule to the profile.
bool | saveSyncResults (const QString &aProfileId, const Buteo::SyncResults &aSyncResults)
| Save SyncResults to log.xml file.
bool | removeProfile (const QString &aProfileId) const
| This function should be called when sync profile has to be deleted.
bool | updateProfile (const Buteo::SyncProfile &aSyncProfile)
| This function should be called when sync profile information has been changed by the client.
bool | getBackUpRestoreState ()
| This function returns true if backup/restore in progress else false.
bool | isValid () const
| Use this function to understand if the dbus connection to msyncd is working or not.
Buteo::SyncResults | getLastSyncResult (const QString &aProfileId)
| To get lastSyncResult.
QList< QString > | allVisibleSyncProfiles ()
| Gets all visible sync profiles.
QDBusPendingCallWatcher * | requestAllVisibleSyncProfiles (QObject *aParent=nullptr) const
| asynchronous version of allVisibleSyncProfiles()
QString | syncProfile (const QString &aProfileId)
| Gets a sync profile.
QStringList | syncProfilesByKey (const QString &aKey, const QString &aValue)
| Gets a sync profiles which matches the key-value.
QDBusPendingCallWatcher * | requestSyncProfilesByKey (const QString &aKey, const QString &aValue, QObject *aParent=nullptr) const
| asynchronous version of syncProfilesByKey().
QStringList | profilesByType (const QString &aType)
| Gets profiles matching the profile type.
QDBusPendingCallWatcher * | requestProfilesByType (const QString &aProfileId, QObject *aParent=nullptr) const
| asynchronous version of profilesByType()
QStringList | syncProfilesByType (const QString &aType)
| Gets a profiles matching the profile type.

## Static Public Member Functions

static QSharedPointer< SyncClientInterface > | sharedInstance ()
| creates a process singleton

## Detailed Description

SyncInterface Class - Main Entry Point for SyncFW Clients.

This Class Provides Interface API towards SyncFW. This Class has Methods to start and abort a sync , set schedule for a profile and use the fw functionality to automatically schedule it, get a list of running syncs( to display in UI ) and get status of the synchronization. It also has Signals that the clients can connect to know the last sync results , to keep track of profile changes by SyncFw.

## Member Function Documentation

## abortSync()

void SyncClientInterface::abortSync | ( | const QString & | aProfileId | ) | const

Stops synchronizing the profile with the given Id.

If the sync request is still in queue and not yet started, the queue entry is removed.

Parameters

  aProfileId | Id of the profile to stop syncing.

## allVisibleSyncProfiles()

QList< QString > SyncClientInterface::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.

## backupDone

void Buteo::SyncClientInterface::backupDone | ( |  | ) |

signal

Notifies about Backup done.

This signal is sent when the backup framework has completed backing the sync related data.

## backupInProgress

void Buteo::SyncClientInterface::backupInProgress | ( |  | ) |

signal

Notifies about Backup start.

This signal is sent when the backup framework is backing the sync related data

## getLastSyncResult()

Buteo::SyncResults SyncClientInterface::getLastSyncResult | ( | const QString & | aProfileId | ) |

To get lastSyncResult.

Parameters

  aProfileId |

Returns
  SyncResults of syncLastResult.

## getRunningSyncList()

QStringList SyncClientInterface::getRunningSyncList | ( |  | ) | const

Gets the list of profile names of currently running syncs.

Returns
  Profile name list.

## isValid()

bool SyncClientInterface::isValid | ( |  | ) | const

Use this function to understand if the dbus connection to msyncd is working or not.

Returns
  - status of the dbus object created for msyncd

## isValidChanged

void Buteo::SyncClientInterface::isValidChanged | ( |  | ) |

signal

Notifies when the synchronisation service is available or not.

This signal is sent when the synchronisation daemon is rnning or not.

## profileChanged

void Buteo::SyncClientInterface::profileChanged | ( | QString | aProfileId,
|  | int | aChangeType,
|  | QString | aChangedProfile )

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

  aProfileId | Id of the changed profile.
  aChangeType | 0 (ADDITION): Profile was added. 1 (MODIFICATION): Profile was modified. 2 (DELETION): Profile was deleted.
  aChangedProfile | changed sync profie as XMl string.

## profilesByType()

QStringList SyncClientInterface::profilesByType | ( | const QString & | aType | ) |

Gets profiles matching the profile type.

Parameters

  aType | Type of the profile service/storage/sync.

Returns
  The profiles as Xml string list.

## removeProfile()

bool SyncClientInterface::removeProfile | ( | const QString & | aProfileId | ) | const

This function should be called when sync profile has to be deleted.

Parameters

  aProfileId | Id of the profile to be deleted.

Returns
  status of the remove operation

## requestAllVisibleSyncProfiles()

QDBusPendingCallWatcher * SyncClientInterface::requestAllVisibleSyncProfiles | ( | QObject * | aParent = nullptr | ) | const

asynchronous version of allVisibleSyncProfiles()

Parameters

  aParent | set the parent of the returned QDBusPendingCallWatcher.

Returns
  a newly created watcher on a QDBusPendingReply<QStringList>.

## requestProfilesByType()

QDBusPendingCallWatcher * SyncClientInterface::requestProfilesByType | ( | const QString & | aProfileId,
|  | QObject * | aParent = nullptr ) const

asynchronous version of profilesByType()

Parameters

  aType | Type of the profile service/storage/sync.
  aParent | set the parent of the returned QDBusPendingCallWatcher.

Returns
  a newly created watcher on a QDBusPendingReply<QStringList>.

## requestRunningSyncList()

QDBusPendingCallWatcher * SyncClientInterface::requestRunningSyncList | ( | QObject * | aParent = nullptr | ) | const

asynchronous version of getRunningSyncList()

Parameters

  aParent | set the parent of the returned QDBusPendingCallWatcher.

Returns
  a newly created watcher on a QDBusPendingReply<QStringList>.

## requestSync()

QDBusPendingCallWatcher * SyncClientInterface::requestSync | ( | const QString & | aProfileId,
|  | QObject * | aParent = nullptr ) const

asynchronous version of startSync()

Parameters

  aProfileId | Id of the profile to use in sync.
  aParent | set the parent of the returned QDBusPendingCallWatcher.

Returns
  a newly created watcher on a QDBusPendingReply<bool>.

## requestSyncProfilesByKey()

QDBusPendingCallWatcher * SyncClientInterface::requestSyncProfilesByKey | ( | const QString & | aKey,
|  | const QString & | aValue,
|  | QObject * | aParent = nullptr ) const

asynchronous version of syncProfilesByKey().

Parameters

  aKey | Key to match for profile.
  aValue | Value to match for profile.
  aParent | set the parent of the returned QDBusPendingCallWatcher.

Returns
  a newly created watcher on a QDBusPendingReply<QStringList>.

## restoreDone

void Buteo::SyncClientInterface::restoreDone | ( |  | ) |

signal

Notifies about Restore Done.

This signal is sent when the backup framework has restored the sync related data

## restoreInProgress

void Buteo::SyncClientInterface::restoreInProgress | ( |  | ) |

signal

Notifies about Restore start.

This signal is sent when the backup framework is restoring the sync related data

## resultsAvailable

void Buteo::SyncClientInterface::resultsAvailable | ( | QString | aProfileId,
|  | Buteo::SyncResults | aResults )

signal

Notifies about the results of a recent sync for a profile.

This signal is sent after the sync has completed for a profile.

Parameters

  aProfileId | Id of the changed profile.
  aResults | - Results of the sync

## saveSyncResults()

bool SyncClientInterface::saveSyncResults | ( | const QString & | aProfileId,
|  | const Buteo::SyncResults & | aSyncResults )

Save SyncResults to log.xml file.

Parameters

  aProfileId | to save result in corresponding file.
  aSyncResults | to save in the <profileId>.log.xml

Returns
  status of the saveSyncResults

## setSyncSchedule()

bool SyncClientInterface::setSyncSchedule | ( | const QString & | aProfileId,
|  | const SyncSchedule & | aSchedule )

Sets Sync Schedule to the profile.

This function does the following

1. sets the sync type of the profile to schedule
2. Adds the schedule to the profile
3. saves the profile.
4. schedules the synchronization , so that sync automatically starts next time

Returns
  status of the operation

## sharedInstance()

QSharedPointer< SyncClientInterface > SyncClientInterface::sharedInstance | ( |  | ) |

static

creates a process singleton

Use this instance to share a same D-Bus connection to the daemon between several clients in a process.

Returns
  a singleton instance, don't free it.

## startSync()

bool SyncClientInterface::startSync | ( | const QString & | aProfileId | ) | const

Requests to starts synchronizing using a profile Id.

A status change signal (QUEUED, STARTED or ERROR) will be sent by the daemon when the request is processed. If there is a sync already in progress using the same resources that are needed by the given profile, adds the sync request to a sync queue. Otherwise a sync session is started immediately.

Parameters

  aProfileId | Id of the profile to use in sync.

Returns
  True if a profile with the Id was found. Otherwise false and no status change signals will follow from this request.

## syncProfile()

QString SyncClientInterface::syncProfile | ( | const QString & | aProfileId | ) |

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

  aProfileId | Name of the profile to get.

Returns
  The sync profile as Xml string.

## syncProfilesByKey()

QStringList SyncClientInterface::syncProfilesByKey | ( | const QString & | aKey,
|  | const QString & | aValue )

Gets a sync profiles which matches the key-value.

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

  aKey | Key to match for profile.
  aValue | Value to match for profile.

Returns
  The sync profiles as Xml string list.

## syncProfilesByType()

QStringList SyncClientInterface::syncProfilesByType | ( | const QString & | aType | ) |

Gets a profiles matching the profile type.

Parameters

  aType | Type of the profile service/storage/sync.

Returns
  The sync profile ids as string list.

## syncStatus

void Buteo::SyncClientInterface::syncStatus | ( | QString | aProfileId,
|  | int | aStatus,
|  | QString | aMessage,
|  | int | aStatusDetails )

signal

Notifies about a change in synchronization status.

Parameters

  aProfileId | Id of the profile used in the sync session whose status has changed.

  aStatus

  The new status. One of the following: 0 (QUEUED): Sync request has been queued or was already in the queue when sync start was requested. 1 (STARTED): Sync session has been started. 2 (PROGRESS): Sync session is progressing. 3 (ERROR): Sync session has encountered an error and has been stopped, or the session could not be started at all. 4 (DONE): Sync session was successfully completed. 5 (ABORTED): Sync session was aborted. Statuses 3-5 are final, no more status changes will be sent from the same sync session.

  aMessage | A message describing the status change in detail. This can for example be shown to the user or written to a log
  aStatusDetails | When aStatus is ERROR, this parameter contains a specific error code. When aStatus is PROGRESS, this parameter contains more details about the progress

See also
  SyncCommonDefs::SyncProgressDetails

## transferProgress

void Buteo::SyncClientInterface::transferProgress | ( | QString | aProfileId,
|  | int | aTransferDatabase,
|  | int | aTransferType,
|  | QString | aMimeType,
|  | int | aCommittedItems )

signal

Notifies about progress in transferring items.

Parameters

  aProfileId | Id of the profile where progress has occurred
  aTransferDatabase | Database to which transfer was made. One of the following: 0 (LOCAL_DATABASE): Transfer was made from remote database to local database 1 (REMOTE_DATABASE): Transfer was made from local database to remote database
  aTransferType | Type of transfer that was made. One of the following: 0 (ADDITION): Addition was made to database 1 (MODIFICATION): Modification was made to database 2 (DELETION): Deletion was made to database 3 (ERROR): Addition/Modification/Deletion was attempted, but it failed
  aMimeType | Mime type of the processed item
  aCommittedItems | No. of items committed for this operation

## updateProfile()

bool SyncClientInterface::updateProfile | ( | const Buteo::SyncProfile & | aSyncProfile | ) |

This function should be called when sync profile information has been changed by the client.

Parameters

  aSyncProfile | Modified Profile Object.If same profile already exists it will be overwritten with the changes from this object.

Returns
  status of the update operation

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

- SyncClientInterface.h
- SyncClientInterface.cpp