PHP Class Horde_SyncMl_Sync, horde

See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Author: Anthony Mills ([email protected])
Exibir arquivo Open project: horde/horde Class Usage Examples

Protected Properties

Property Type Description
$_clientAnchorNext integer Sync Anchors determine the interval from which changes are retrieved.
$_client_add_count integer Number of objects that have been sent to the server for adding.
$_client_addreplaces integer Add due to client replace request when map entry is not found. Happens during SlowSync.
$_client_delete_count integer Number of objects that have been sent to the server for deletion.
$_client_replace_count integer Number of objects that have been sent to the server for replacement.
$_errors integer Number of failed actions, for logging purposes only.
$_expectingMapData boolean Map data is expected whenever an add is sent to the client.
$_serverAnchorLast
$_serverAnchorNext
$_server_add_count integer Number of objects that have been sent to the client for adding.
$_server_adds array List of object UIDs (in the keys) that have been added on the server since the last synchronization and are supposed to be sent to the client.
$_server_delete_count integer Number of objects that have been sent to the client for deletion.
$_server_deletes array List of object UIDs (in the keys) that have been deleted on the server since the last synchronization and are supposed to be sent to the client.
$_server_largeobj array Array holding the remaining content when splitting a large object into multiple messages. Keys are numeric, values are: command, chunkContent, clientContentType, clientEncodingType, cuid, suid
$_server_replace_count integer Number of objects that have been sent to the client for replacement.
$_server_replaces array List of object UIDs (in the keys) that have been changed on the server since the last synchronization and are supposed to be sent to the client.
$_server_task_adds array This is only used for clients handling tasks and events in one database. We need to seperately store the server tasks adds, so when we get a Map command from the client, we know whether to put this in tasks or calendar.
$_sourceLocURI string Source (server) URI (database).
$_state constant A sync starts in Horde_SyncMl_Sync::STATE_INIT and moves on to the next state with every received from the client: Horde_SyncMl_Sync::STATE_INIT, Horde_SyncMl_Sync::STATE_SYNC, Horde_SyncMl_Sync::STATE_MAP, Horde_SyncMl_Sync::STATE_COMPLETED. Horde_SyncMl_Sync::STATE_MAP doesn't occur for _FROM_CLIENT syncs.
$_syncType integer The synchronization method, one of the Horde_SyncMl::ALERT_* constants.
$_syncsReceived integer Counts the s received by the server. Currently unused.
$_syncsSent integer Counts the s sent by the server.
$_targetLocURI string Target (client) URI (database).

Public Methods

Method Description
__construct ( string $syncType, string $serverURI, string $clientURI, integer $serverAnchorLast, integer $serverAnchorNext, string $clientAnchorNext )
addSyncReceived ( )
closeSync ( ) Completes a sync once everything is done: store the sync anchors so the next sync can be a delta sync and produce some debug info.
createSyncOutput ( &$output ) Creates a output containing the server changes.
createUidMap ( $databaseURI, $cuid, $suid )
getClientAnchorNext ( )
getClientLocURI ( )
getServerAnchorLast ( )
getServerAnchorNext ( )
getServerChange ( string $change, string $id ) : string Returns the client ID of server change identified by the change type and server ID.
getServerLocURI ( )
getSyncsReceived ( ) * Currently unused
handleClientSyncItem ( &$output, Horde_SyncMl_SyncElement &$item ) Here's where the actual processing of a client-sent Sync Item takes place. Entries are added, deleted or replaced from the server database by using backend API calls.
handleFinal ( &$output, $debug = false ) Notifies the sync that a final has been received by the client.
hasPendingElements ( ) Returns true if there are still outstanding server sync items to be sent to the client.
isComplete ( )
setServerChange ( string $change, string $sid, string $cid ) Sets the client ID of server change identified by the change type and server ID.
unsetServerChange ( string $change, string $id ) Unsets the server-client-map of server change identified by the change type and server ID.

Protected Methods

Method Description
_getServerLargeObjChunk ( integer $chunkLength ) : string Get the next chunk from the cached large object with maximum length of chunkLength or return false.
_retrieveChanges ( string $syncDB, array &$adds, array &$replaces, array &$deletes ) Retrieves and condenses the changes on the server side since the last synchronization.
_taskToCalendar ( $databaseURI ) Converts a calendar databaseURI to a tasks databaseURI for devices with handleTasksInCalendar.

Method Details

__construct() public method

public __construct ( string $syncType, string $serverURI, string $clientURI, integer $serverAnchorLast, integer $serverAnchorNext, string $clientAnchorNext )
$syncType string
$serverURI string
$clientURI string
$serverAnchorLast integer
$serverAnchorNext integer
$clientAnchorNext string

_getServerLargeObjChunk() protected method

Get the next chunk from the cached large object with maximum length of chunkLength or return false.
protected _getServerLargeObjChunk ( integer $chunkLength ) : string
$chunkLength integer The maximum length of the chunk.
return string The next chunk of the cached large object.

_retrieveChanges() protected method

Retrieves and condenses the changes on the server side since the last synchronization.
protected _retrieveChanges ( string $syncDB, array &$adds, array &$replaces, array &$deletes )
$syncDB string The database being synchronized.
$adds array Will be set with the server-client-uid mappings of added objects.
$replaces array Will be set with the server-client-uid mappings of changed objects.
$deletes array Will be set with the server-client-uid mappings of deleted objects.

_taskToCalendar() protected method

Converts a calendar databaseURI to a tasks databaseURI for devices with handleTasksInCalendar.
protected _taskToCalendar ( $databaseURI )

addSyncReceived() public method

public addSyncReceived ( )

closeSync() public method

Completes a sync once everything is done: store the sync anchors so the next sync can be a delta sync and produce some debug info.
public closeSync ( )

createSyncOutput() public method

Creates a output containing the server changes.
public createSyncOutput ( &$output )

createUidMap() public method

public createUidMap ( $databaseURI, $cuid, $suid )

getClientAnchorNext() public method

public getClientAnchorNext ( )

getClientLocURI() public method

public getClientLocURI ( )

getServerAnchorLast() public method

public getServerAnchorLast ( )

getServerAnchorNext() public method

public getServerAnchorNext ( )

getServerChange() public method

Returns the client ID of server change identified by the change type and server ID.
public getServerChange ( string $change, string $id ) : string
$change string The change type (add, replace, delete).
$id string The object's server UID.
return string The matching client ID or null if none found.

getServerLocURI() public method

public getServerLocURI ( )

getSyncsReceived() public method

* Currently unused
public getSyncsReceived ( )

handleClientSyncItem() public method

Here's where the actual processing of a client-sent Sync Item takes place. Entries are added, deleted or replaced from the server database by using backend API calls.
public handleClientSyncItem ( &$output, Horde_SyncMl_SyncElement &$item )
$output
$item Horde_SyncMl_SyncElement

handleFinal() public method

Depending on the current state of the sync this can mean various things: a) Init phase (Alerts) done. Next package contaings actual syncs. b) Sync sending from client done. Next package are maps (or finish or finish if ONE_WAY_FROM_CLIENT sync c) Maps finished, completly done.
public handleFinal ( &$output, $debug = false )

hasPendingElements() public method

This is the case if the MaxMsgSize has been reached and the pending elements are to be sent in another message.
public hasPendingElements ( )

isComplete() public method

public isComplete ( )

setServerChange() public method

Sets the client ID of server change identified by the change type and server ID.
public setServerChange ( string $change, string $sid, string $cid )
$change string The change type (add, replace, delete).
$sid string The object's server UID.
$cid string The object's client UID.

unsetServerChange() public method

Unsets the server-client-map of server change identified by the change type and server ID.
public unsetServerChange ( string $change, string $id )
$change string The change type (add, replace, delete).
$id string The object's server UID.

Property Details

$_clientAnchorNext protected_oe property

Sync Anchors determine the interval from which changes are retrieved.
protected int $_clientAnchorNext
return integer

$_client_add_count protected_oe property

Number of objects that have been sent to the server for adding.
protected int $_client_add_count
return integer

$_client_addreplaces protected_oe property

Add due to client replace request when map entry is not found. Happens during SlowSync.
protected int $_client_addreplaces
return integer

$_client_delete_count protected_oe property

Number of objects that have been sent to the server for deletion.
protected int $_client_delete_count
return integer

$_client_replace_count protected_oe property

Number of objects that have been sent to the server for replacement.
protected int $_client_replace_count
return integer

$_errors protected_oe property

Number of failed actions, for logging purposes only.
protected int $_errors
return integer

$_expectingMapData protected_oe property

Map data is expected whenever an add is sent to the client.
protected bool $_expectingMapData
return boolean

$_serverAnchorLast protected_oe property

protected $_serverAnchorLast

$_serverAnchorNext protected_oe property

protected $_serverAnchorNext

$_server_add_count protected_oe property

Number of objects that have been sent to the client for adding.
protected int $_server_add_count
return integer

$_server_adds protected_oe property

List of object UIDs (in the keys) that have been added on the server since the last synchronization and are supposed to be sent to the client.
protected array $_server_adds
return array

$_server_delete_count protected_oe property

Number of objects that have been sent to the client for deletion.
protected int $_server_delete_count
return integer

$_server_deletes protected_oe property

List of object UIDs (in the keys) that have been deleted on the server since the last synchronization and are supposed to be sent to the client.
protected array $_server_deletes
return array

$_server_largeobj protected_oe property

Array holding the remaining content when splitting a large object into multiple messages. Keys are numeric, values are: command, chunkContent, clientContentType, clientEncodingType, cuid, suid
protected array $_server_largeobj
return array

$_server_replace_count protected_oe property

Number of objects that have been sent to the client for replacement.
protected int $_server_replace_count
return integer

$_server_replaces protected_oe property

List of object UIDs (in the keys) that have been changed on the server since the last synchronization and are supposed to be sent to the client.
protected array $_server_replaces
return array

$_server_task_adds protected_oe property

This is only used for clients handling tasks and events in one database. We need to seperately store the server tasks adds, so when we get a Map command from the client, we know whether to put this in tasks or calendar.
protected array $_server_task_adds
return array

$_sourceLocURI protected_oe property

Source (server) URI (database).
protected string $_sourceLocURI
return string

$_state protected_oe property

A sync starts in Horde_SyncMl_Sync::STATE_INIT and moves on to the next state with every received from the client: Horde_SyncMl_Sync::STATE_INIT, Horde_SyncMl_Sync::STATE_SYNC, Horde_SyncMl_Sync::STATE_MAP, Horde_SyncMl_Sync::STATE_COMPLETED. Horde_SyncMl_Sync::STATE_MAP doesn't occur for _FROM_CLIENT syncs.
protected constant $_state
return constant

$_syncType protected_oe property

The synchronization method, one of the Horde_SyncMl::ALERT_* constants.
protected int $_syncType
return integer

$_syncsReceived protected_oe property

Counts the s received by the server. Currently unused.
protected int $_syncsReceived
return integer

$_syncsSent protected_oe property

Counts the s sent by the server.
protected int $_syncsSent
return integer

$_targetLocURI protected_oe property

Target (client) URI (database).
protected string $_targetLocURI
return string