CardDAV Client Library

SyncHandler

Interface for application-level synchronization handler.

During an addressbook synchronization, the corresponding methods of this interface are invoked for events such as changed or deleted address objects, to be handled in an application-specific manner.

Table of Contents

addressObjectChanged()  : void
This method is called for each changed address object, including new address objects.
addressObjectDeleted()  : void
This method is called for each deleted address object.
finalizeSync()  : void
Called upon completion of the synchronization process to enable the handler to perform final actions if needed.
getExistingVCardETags()  : array<string, string>
Provides the URIs and ETags of all VCards existing locally.

Methods

addressObjectChanged()

This method is called for each changed address object, including new address objects.

public addressObjectChanged(string $uri, string $etag, VCard|null $card) : void

In case an error occurs attempting to retrieve or to parse the address data for an URI that the server reported as changed, this method is invoked with a null $card parameter. This allows the client to know that there was a change that is missing from the sync, and to handle or ignore it as it sees fit.

Parameters
$uri : string

URI of the changed or added address object.

$etag : string

ETag of the retrieved version of the address object.

$card : VCard|null

A (partial) VCard containing (at least, if available)the requested VCard properties. Null in case an error occurred retrieving or parsing the VCard retrieved from the server.

Tags
see
Sync
Return values
void

addressObjectDeleted()

This method is called for each deleted address object.

public addressObjectDeleted(string $uri) : void
Parameters
$uri : string

URI of the deleted address object.

Tags
see
Sync
Return values
void

finalizeSync()

Called upon completion of the synchronization process to enable the handler to perform final actions if needed.

public finalizeSync() : void
Tags
see
Sync
Return values
void

getExistingVCardETags()

Provides the URIs and ETags of all VCards existing locally.

public getExistingVCardETags() : array<string, string>

During synchronization, it may be required to identify the version of locally existing address objects to determine whether the server-side version is newer than the local version. This is the case if the server does not support the sync-collection report, or if the sync-token has expired on the server and thus the server is not able to report the changes against the local state.

For the first sync, returns an empty array. The Sync service will consider cards as:

  • new: URI not contained in the returned aray
  • changed: URI contained, assigned local ETag differs from server-side ETag
  • unchanged: URI contained, assigned local ETag equals server-side ETag
  • deleted: URI contained in array, but not reported by server as content of the addressbook

Note: This array is only requested by the Sync service if needed, which is only the case if the sync-collection REPORT cannot be used. Therefore, if it is expensive to construct this array, make sure construction is done on demand in this method, which will not be called if the data is not needed.

Tags
see
Sync
Return values
array<string, string>

Associative array with URIs (URL path component without server) as keys, ETags as values.

Search results