\Horde_ActiveSync_Collections

Horde_ActiveSync_Collections:: Responsible for all functionality related to collections and managing the sync cache.

Summary

Methods
Properties
Constants
__construct()
loadCollectionsFromCache()
__call()
__get()
__set()
getNewCollection()
ensureOptions()
addCollection()
getBackendIdForFolderUid()
getFolderUidForBackendId()
collectionCount()
cachedCollectionCount()
setGetChangesFlag()
getChangesFlag()
setDefaultWindowSize()
getDefaultWindowSize()
validateFromCache()
updateCollectionsFromCache()
getCollectionClass()
getCollectionType()
haveSyncableCollections()
setHeartbeat()
getHeartbeat()
canDoLoopingSync()
checkStaleRequest()
haveHierarchy()
initHierarchySync()
updateFolderinHierarchy()
deleteFolderFromHierarchy()
getHierarchyChanges()
validateHierarchyChanges()
updateHierarchyKey()
initFullSync()
initEmptySync()
initPartialSync()
canSendEmptyResponse()
checkFilterType()
updateCache()
save()
initCollectionState()
pollForChanges()
havePingableCollections()
updatePingableFlag()
resetPingCache()
getCollectionChanges()
getCollectionChangeCount()
getIterator()
No public properties found
COLLECTION_ERR_FOLDERSYNC_REQUIRED
COLLECTION_ERR_SERVER
COLLECTION_ERR_STALE
COLLECTION_ERR_SYNC_REQUIRED
COLLECTION_ERR_PING_NEED_FULL
COLLECTION_ERR_AUTHENTICATION
_checkConfirmedKeys()
_haveNoChangesInPartialSync()
_getMissingCollectionsFromCache()
_sleep()
$_collections
$_tempSyncCache
$_cache
$_logger
$_unchangedCount
$_synckeyCount
$_globalWindowSize
$_windowsizeOverride
$_importedChanges
$_shortSyncRequest
$_changedCollections
$_as
$_procid
$_changes
$_hangingSync
N/A
No private methods found
No private properties found
N/A

Constants

COLLECTION_ERR_FOLDERSYNC_REQUIRED

COLLECTION_ERR_FOLDERSYNC_REQUIRED

COLLECTION_ERR_SERVER

COLLECTION_ERR_SERVER

COLLECTION_ERR_STALE

COLLECTION_ERR_STALE

COLLECTION_ERR_SYNC_REQUIRED

COLLECTION_ERR_SYNC_REQUIRED

COLLECTION_ERR_PING_NEED_FULL

COLLECTION_ERR_PING_NEED_FULL

COLLECTION_ERR_AUTHENTICATION

COLLECTION_ERR_AUTHENTICATION

Properties

$_collections

$_collections : array

The collection data

Type

array

$_logger

$_logger : \Horde_Log_Logger

The logger

Type

\Horde_Log_Logger

$_unchangedCount

$_unchangedCount : integer

Count of unchanged collections calculated for PARTIAL sync.

Type

integer

$_synckeyCount

$_synckeyCount : integer

Count of available synckeys

Type

integer

$_globalWindowSize

$_globalWindowSize : integer

Global WINDOWSIZE Defaults to 100 (MS-ASCMD 2.2.3.188)

Type

integer

$_windowsizeOverride

$_windowsizeOverride : boolean

Flag to indicate we have overridden the globalWindowSize

Type

boolean

$_importedChanges

$_importedChanges : boolean

Imported changes flag.

Type

boolean

$_shortSyncRequest

$_shortSyncRequest : boolean

Short sync request flag.

Type

boolean

$_changedCollections

$_changedCollections : array

Cache of collections that have had changes detected.

Type

array

$_procid

$_procid : integer

Cache the process id for logging.

Type

integer

$_changes

$_changes : array

Cache of changes.

Type

array

$_hangingSync

$_hangingSync : boolean

Flag to indicate the client is requesting a hanging SYNC.

Type

boolean

Methods

loadCollectionsFromCache()

loadCollectionsFromCache() 

Load all the collections we know about from the cache.

__call()

__call(  $method,   $parameters) 

Magic.

..

Parameters

$method
$parameters

__get()

__get(  $property) 

Property getter

Parameters

$property

__set()

__set(  $property,   $value) 

Property setter.

Parameters

$property
$value

getNewCollection()

getNewCollection() : array

Get a new collection array, populated with default values.

Returns

array

ensureOptions()

ensureOptions() 

Ensure default OPTIONS values are populated, while not overwriting any existing values.

addCollection()

addCollection(array  $collection, boolean  $requireSyncKey = false) 

Add a new populated collection array to the sync cache.

Parameters

array $collection

The collection array.

boolean $requireSyncKey

Attempt to read missing synckey from cache if true. If not found, set to 0.

Throws

\Horde_ActiveSync_Exception_StateGone

Thrown when no synckey is provided when one is specified as required, indicating the state on the client is possibly corrupt or when the serverid can not be found by the backend.

getBackendIdForFolderUid()

getBackendIdForFolderUid(  $folderid) : string

Translate an EAS folder uid into a backend serverid.

Parameters

$folderid

Throws

\Horde_ActiveSync_Exception_FolderGone

Returns

string —

The backend server id.

getFolderUidForBackendId()

getFolderUidForBackendId(string  $folderid) : string

Translate a backend id E.g., INBOX into an EAS folder uid.

Parameters

string $folderid

The backend id.

Returns

string —

The EAS uid.

collectionCount()

collectionCount() : integer

Return the count of available collections.

Returns

integer

cachedCollectionCount()

cachedCollectionCount() : integer

Return the count of collections in the cache only.

Returns

integer

setGetChangesFlag()

setGetChangesFlag(string  $collection_id) 

Set the getchanges flag on the specified collection.

Parameters

string $collection_id

The collection id.

Throws

\Horde_ActiveSync_Exception

getChangesFlag()

getChangesFlag(string  $collection_id) : boolean

Get the getchanges flag on the specified collection.

Parameters

string $collection_id

The collection id.

Throws

\Horde_ActiveSync_Exception

Returns

boolean

setDefaultWindowSize()

setDefaultWindowSize(integer  $window, boolean  $override = false) 

Sets the default WINDOWSIZE.

Note that this is really a ceiling on the number of TOTAL responses that can be sent (including all collections). This method should be renamed for 3.0

Parameters

integer $window

The windowsize

boolean $override

If true, this value will override any client supplied value.

getDefaultWindowSize()

getDefaultWindowSize() 

validateFromCache()

validateFromCache() 

Validates the collection data from the syncCache, filling in missing values from the folder cache.

updateCollectionsFromCache()

updateCollectionsFromCache() 

Updates data from the cache for collectons that are already loaded. Used to ensure looping SYNC and PING requests are operating on the most recent syncKey.

getCollectionClass()

getCollectionClass(string  $id) : string|boolean

Return a collection class given the collection id.

Parameters

string $id

The collection id.

Returns

string|boolean —

The collection class or false if not found.

getCollectionType()

getCollectionType(  $id) 

Parameters

$id

haveSyncableCollections()

haveSyncableCollections(\long  $version) : boolean

Determine if we have any syncable collections either locally or in the sync cache.

Parameters

\long $version

The EAS version

Returns

boolean

setHeartbeat()

setHeartbeat(array  $hb) 

Set the looping sync heartbeat values.

Parameters

array $hb

An array containing one or both of: hbinterval, wait.

getHeartbeat()

getHeartbeat() : integer|boolean

Return the heartbeat interval. Always returned as the heartbeat (seconds) not wait interval (minutes).

Returns

integer|boolean —

The number of seconds in a heartbeat, or false if no heartbeat set.

canDoLoopingSync()

canDoLoopingSync() : boolean

Return whether or not we want a looping sync. We can do a looping sync if we have no imported changes AND we have either a hbinterval, wait, or a shortSync.

Returns

boolean —

True if we want a looping sync, false otherwise.

checkStaleRequest()

checkStaleRequest() : boolean

Return if the current looping sync is stale. A stale looping sync is one which has begun earlier than the most recently running sync reported by the syncCache.

Returns

boolean —

True if the current looping sync is stale. False otherwise.

haveHierarchy()

haveHierarchy() : boolean

Return if we have a current folder hierarchy.

Returns

boolean

initHierarchySync()

initHierarchySync(string  $synckey) : array

Prepare for a hierarchy sync.

Parameters

string $synckey

The current synckey from the client.

Returns

array —

An array of known folders.

updateFolderinHierarchy()

updateFolderinHierarchy(\Horde_ActiveSync_Message_Folder  $folder, boolean  $update = false) 

Update/Add a folder in the hierarchy cache.

Parameters

\Horde_ActiveSync_Message_Folder $folder

The folder object.

boolean $update

Update the state objects? @since 2.4.0

deleteFolderFromHierarchy()

deleteFolderFromHierarchy(  $uid) 

Delete a folder from the hierarchy cache.

Parameters

$uid

getHierarchyChanges()

getHierarchyChanges() : array

Return all know hierarchy changes.

Returns

array —

An array of changes.

validateHierarchyChanges()

validateHierarchyChanges(\Horde_ActiveSync_Connector_Exporter_FolderSync  $exporter, array  $seenFolders) 

Validate and perform some sanity checks on the hierarchy changes before being sent to the client.

Parameters

\Horde_ActiveSync_Connector_Exporter_FolderSync $exporter

The exporter.

array $seenFolders

An array of folders.

updateHierarchyKey()

updateHierarchyKey(string  $key) 

Update the hierarchy synckey in the cache.

Parameters

string $key

The new/existing synckey.

initFullSync()

initFullSync() 

Prepares the syncCache for a full sync request.

initEmptySync()

initEmptySync() : boolean

Prepare the syncCache for an EMPTY sync request.

Returns

boolean —

False if EMPTY request cannot be performed, otherwise true.

initPartialSync()

initPartialSync() : boolean

Prepares the syncCache for a partial sync request and checks that it is allowed.

MS-ASCMD 2.2.3.124

Returns

boolean —

True if parital sync is possible, false otherwise.

canSendEmptyResponse()

canSendEmptyResponse() : boolean

Return if we can do an empty response

Returns

boolean

checkFilterType()

checkFilterType(string  $id, string  $filter) : boolean

Check for an update FILTERTYPE

Parameters

string $id

The collection id to check

string $filter

The new filter value.

Returns

boolean —

True if filtertype passed, false if it has changed.

updateCache()

updateCache() 

Update the syncCache with current collection data.

save()

save(boolean  $preserve_folders = false) 

Save the syncCache to storage.

Parameters

boolean $preserve_folders

If true, ensure the folder cache is not overwritten. @since 2.18.0

initCollectionState()

initCollectionState(array  $collection, boolean  $requireSyncKey = false) 

Attempt to initialize the sync state.

Parameters

array $collection

The collection array.

boolean $requireSyncKey

Require collection to have a synckey and throw exception if it's not present.

Throws

\Horde_ActiveSync_Exception_InvalidRequest
\Horde_ActiveSync_Exception_FolderGone

pollForChanges()

pollForChanges(integer  $heartbeat, integer  $interval, array  $options = array()) : boolean|integer

Poll the backend for changes.

Parameters

integer $heartbeat

The heartbeat lifetime to wait for changes.

integer $interval

The wait interval between poll iterations.

array $options

An options array containing any of:

  • pingable: (boolean) Only poll collections with the pingable flag set. DEFAULT: false

Returns

boolean|integer —

True if changes were detected in any of the collections, false if no changes detected or a status code if failed.

havePingableCollections()

havePingableCollections() : boolean

Check if we have any pingable collections.

Returns

boolean —

True if we have collections marked as pingable.

updatePingableFlag()

updatePingableFlag() 

Marks all loaded collections with a synckey as pingable.

resetPingCache()

resetPingCache() 

Force reset all collection's PINGABLE flag. Used to force client to issue a non-empty PING request.

getCollectionChanges()

getCollectionChanges(boolean  $ping = false, array  $ensure = array()) : array

Return any changes for the current collection.

Parameters

boolean $ping

True if this is a PING request, false otherwise. If true, we only detect that a change has occured, not the data on all of the changes.

array $ensure

An array of UIDs that should be sent in the current response if possible, and not put off because of a MOREAVAILABLE situation. @deprecated and no longer used.

Returns

array —

The changes array.

getCollectionChangeCount()

getCollectionChangeCount(boolean  $ping = false) : integer

Return the count of the current collection's chagnes.

Parameters

boolean $ping

Only ping the collection if true.

Returns

integer —

The change count.

getIterator()

getIterator() 

Iterator

_checkConfirmedKeys()

_checkConfirmedKeys() 

_haveNoChangesInPartialSync()

_haveNoChangesInPartialSync() : boolean

Return if we have no changes to collection options, but have requested a partial sync. A partial sync must have either a wait, hbinterval, or some subset of collections to be valid.

Returns

boolean

_getMissingCollectionsFromCache()

_getMissingCollectionsFromCache() 

Populate the collections data with missing data from the syncCache during a PARTIAL SYNC.

_sleep()

_sleep(integer  $interval) 

Wait for specified interval, and close any backend connections while we wait.

Parameters

integer $interval

The number of seconds to sleep.