Back to index

d-push  2.0
Public Member Functions | Protected Member Functions | Protected Attributes
BackendDiff Class Reference
Inheritance diagram for BackendDiff:
Inheritance graph
[legend]
Collaboration diagram for BackendDiff:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Setup ($store, $checkACLonly=false, $folderid=false)
 Setup the backend to work on a specific store or checks ACLs there.
 GetHierarchy ()
 Returns an array of SyncFolder types with the entire folder hierarchy on the server (the array itself is flat, but refers to parents via the 'parent' property.
 GetImporter ($folderid=false)
 Returns the importer to process changes from the mobile If no $folderid is given, hierarchy importer is expected.
 GetExporter ($folderid=false)
 Returns the exporter to send changes to the mobile If no $folderid is given, hierarchy exporter is expected.
 Fetch ($folderid, $id, $contentparameters)
 Returns all available data of a single message.
 MeetingResponse ($requestid, $folderid, $response)
 Processes a response to a meeting request.
 GetFolderList ()
 
Abstract DiffBackend methods
 GetFolder ($id)
 Returns an actual SyncFolder object with all the properties set.
 StatFolder ($id)
 Returns folder stats.
 ChangeFolder ($folderid, $oldid, $displayname, $type)
 Creates or modifies a folder.
 DeleteFolder ($id, $parentid)
 Deletes a folder.
 GetMessageList ($folderid, $cutoffdate)
 Returns a list (array) of messages, each entry being an associative array with the same entries as StatMessage().
 GetMessage ($folderid, $id, $contentparameters)
 Returns the actual SyncXXX object type.
 StatMessage ($folderid, $id)
 Returns message stats, analogous to the folder stats from StatFolder().
 ChangeMessage ($folderid, $id, $message)
 Called when a message has been changed on the mobile.
 SetReadFlag ($folderid, $id, $flags)
 Changes the 'read' flag of a message on disk.
 DeleteMessage ($folderid, $id)
 Called when the user has requested to delete (really delete) a message.
 MoveMessage ($folderid, $id, $newfolderid)
 Called when the user moves an item on the PDA from one folder to another.
 Backend ()
 Constructor.
 GetStateMachine ()
 Returns a IStateMachine implementation used to save states The default StateMachine should be used here, so, false is fine.
 GetSearchProvider ()
 Returns a ISearchProvider implementation used for searches the SearchProvider is just a stub.
 GetSupportedASVersion ()
 Indicates which AS version is supported by the backend.
 EmptyFolder ($folderid, $includeSubfolders=true)
 Deletes all contents of the specified folder.
 HasChangesSink ()
 Indicates if the backend has a ChangesSink.
 ChangesSinkInitialize ($folderid)
 The folder should be considered by the sink.
 ChangesSink ($timeout=30)
 The actual ChangesSink.
 Settings ($settings)
 Applies settings to and gets informations from the device.
 Logon ($username, $domain, $password)
 Authenticates the user.
 Logoff ()
 Logs off non critical operations closing the session should be done here.
 SendMail ($sm)
 Sends an e-mail This messages needs to be saved into the 'sent items' folder.
 GetWasteBasket ()
 Returns the waste basket.
 GetAttachmentData ($attname)
 Returns the content of the named attachment as stream.

Protected Member Functions

 InitializePermanentStorage ()
 
Protected methods for BackendStorage
 InitializeStateStorage ()
 Loads the state related storage data of the user and device All data not necessary for the next state should be removed.
 SaveStorages ()
 Saves the permanent and state related storage data of the user and device if they were loaded previousily If the backend storage is used this should be called.

Protected Attributes

 $store
 $permanentStorage
 $stateStorage

Detailed Description

Definition at line 63 of file diffbackend.php.


Member Function Documentation

Backend::Backend ( ) [inherited]

Constructor.

public

Definition at line 67 of file backend.php.

                              {
    }

Here is the caller graph for this function:

BackendDiff::ChangeFolder ( folderid,
oldid,
displayname,
type 
) [abstract]

Creates or modifies a folder.

Parameters:
string$folderidid of the parent folder
string$oldidif empty -> new folder created, else folder is to be renamed
string$displaynamenew folder name (to be created, or to be renamed to)
int$typefolder type

public

Returns:
boolean status
Exceptions:
StatusExceptioncould throw specific SYNC_FSSTATUS_* exceptions

Reimplemented in BackendKolab, BackendIMAP, BackendMaildir, and BackendVCardDir.

BackendDiff::ChangeMessage ( folderid,
id,
message 
) [abstract]

Called when a message has been changed on the mobile.

The new message must be saved to disk. The return value must be whatever would be returned from StatMessage() after the message has been saved. This way, the 'flags' and the 'mod' properties of the StatMessage() item may change via ChangeMessage(). This method will never be called on E-mail items as it's not 'possible' to change e-mail items. It's only possible to set them as 'read' or 'unread'.

Parameters:
string$folderidid of the folder
string$idid of the message
SyncXXX$messagethe SyncObject containing a message

public

Returns:
array same return value as StatMessage()
Exceptions:
StatusExceptioncould throw specific SYNC_STATUS_* exceptions

Reimplemented in BackendKolab, BackendIMAP, BackendVCardDir, and BackendMaildir.

Backend::ChangesSink ( timeout = 30) [inherited]

The actual ChangesSink.

For max. the $timeout value this method should block and if no changes are available return an empty array. If changes are available a list of folderids is expected.

Parameters:
int$timeoutmax. amount of seconds to block

public

Returns:
array

Implements IBackend.

Reimplemented in BackendIMAP.

Definition at line 173 of file backend.php.

                                               {
        return array();
    }
Backend::ChangesSinkInitialize ( folderid) [inherited]

The folder should be considered by the sink.

Folders which were not initialized should not result in a notification of IBacken->ChangesSink().

Parameters:
string$folderidpublic
Returns:
boolean false if there is any problem with that folder

Implements IBackend.

Reimplemented in BackendIMAP.

Definition at line 158 of file backend.php.

                                                      {
         return false;
     }
BackendDiff::DeleteFolder ( id,
parentid 
) [abstract]

Deletes a folder.

Parameters:
string$id
string$parentis normally false

public

Returns:
boolean status - false if e.g. does not exist
Exceptions:
StatusExceptioncould throw specific SYNC_FSSTATUS_* exceptions

Reimplemented in BackendIMAP, BackendMaildir, and BackendVCardDir.

BackendDiff::DeleteMessage ( folderid,
id 
) [abstract]

Called when the user has requested to delete (really delete) a message.

Usually this means just unlinking the file its in or somesuch. After this call has succeeded, a call to GetMessageList() should no longer list the message. If it does, the message will be re-sent to the mobile as it will be seen as a 'new' item. This means that if this method is not implemented, it's possible to delete messages on the PDA, but as soon as a sync is done, the item will be resynched to the mobile

Parameters:
string$folderidid of the folder
string$idid of the message

public

Returns:
boolean status of the operation
Exceptions:
StatusExceptioncould throw specific SYNC_STATUS_* exceptions

Reimplemented in BackendKolab, BackendIMAP, BackendVCardDir, and BackendMaildir.

Backend::EmptyFolder ( folderid,
includeSubfolders = true 
) [inherited]

Deletes all contents of the specified folder.

This is generally used to empty the trash (wastebasked), but could also be used on any other folder.

Parameters:
string$folderid
boolean$includeSubfolders(opt) also delete sub folders, default true

public

Returns:
boolean
Exceptions:
StatusException

Implements IBackend.

Definition at line 133 of file backend.php.

                                                                      {
        return false;
    }
BackendDiff::Fetch ( folderid,
id,
contentparameters 
)

Returns all available data of a single message.

Parameters:
string$folderid
string$id
ContentParameters$contentparametersflag

public

Returns:
object(SyncObject)
Exceptions:
StatusException

Implements IBackend.

Definition at line 150 of file diffbackend.php.

                                                              {
        // override truncation
        $contentparameters->SetTruncation(SYNC_TRUNCATION_ALL);
        $msg = $this->GetMessage($folderid, $id, $contentparameters);
        if ($msg === false)
            throw new StatusException("BackendDiff->Fetch('%s','%s'): Error, unable retrieve message from backend", SYNC_STATUS_OBJECTNOTFOUND);
        return $msg;
    }

Here is the call graph for this function:

IBackend::GetAttachmentData ( attname) [inherited]

Returns the content of the named attachment as stream.

The passed attachment identifier is the exact string that is returned in the 'AttName' property of an SyncAttachment. Any information necessary to locate the attachment must be encoded in that 'attname' property. Data is written directly - 'print $data;'

Parameters:
string$attnamepublic
Returns:
SyncItemOperationsAttachment
Exceptions:
StatusException

Implemented in BackendKolab, BackendZarafa, BackendIMAP, BackendCombined, BackendMaildir, and BackendVCardDir.

BackendDiff::GetExporter ( folderid = false)

Returns the exporter to send changes to the mobile If no $folderid is given, hierarchy exporter is expected.

Parameters:
string$folderid(opt)

public

Returns:
object(ExportChanges)
Exceptions:
StatusException

Implements IBackend.

Definition at line 135 of file diffbackend.php.

                                                   {
        return new ExportChangesDiff($this, $folderid);
    }
BackendDiff::GetFolder ( id) [abstract]

Returns an actual SyncFolder object with all the properties set.

Folders are pretty simple, having only a type, a name, a parent and a server ID.

Parameters:
string$idid of the folder

public

Returns:
object SyncFolder with information

Reimplemented in BackendKolab, BackendIMAP, BackendMaildir, and BackendVCardDir.

Here is the caller graph for this function:


Abstract DiffBackend methods

Need to be implemented in the actual diff backend Returns a list (array) of folders, each entry being an associative array with the same entries as StatFolder(). This method should return stable information; ie if nothing has changed, the items in the array must be exactly the same. The order of the items within the array is not important though.

protected

Returns:
array/boolean false if the list could not be retrieved

Reimplemented in BackendKolab, BackendIMAP, BackendMaildir, and BackendVCardDir.

Here is the caller graph for this function:

Returns an array of SyncFolder types with the entire folder hierarchy on the server (the array itself is flat, but refers to parents via the 'parent' property.

provides AS 1.0 compatibility

public

Returns:
array SYNC_FOLDER

Implements IBackend.

Definition at line 100 of file diffbackend.php.

                            {
        $folders = array();

        $fl = $this->GetFolderList();
        if (is_array($fl))
            foreach($fl as $f)
                $folders[] = $this->GetFolder($f['id']);

        return $folders;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

BackendDiff::GetImporter ( folderid = false)

Returns the importer to process changes from the mobile If no $folderid is given, hierarchy importer is expected.

Parameters:
string$folderid(opt)

public

Returns:
object(ImportChanges)
Exceptions:
StatusException

Implements IBackend.

Definition at line 121 of file diffbackend.php.

                                                   {
        return new ImportChangesDiff($this, $folderid);
    }
BackendDiff::GetMessage ( folderid,
id,
contentparameters 
) [abstract]

Returns the actual SyncXXX object type.

The '$folderid' of parent folder can be used. Mixing item types returned is illegal and will be blocked by the engine; ie returning an Email object in a Tasks folder will not do anything. The SyncXXX objects should be filled with as much information as possible, but at least the subject, body, to, from, etc.

Parameters:
string$folderidid of the parent folder
string$idid of the message
ContentParameters$contentparametersparameters of the requested message (truncation, mimesupport etc)

public

Returns:
object/false false if the message could not be retrieved

Reimplemented in BackendKolab, BackendIMAP, and BackendVCardDir.

Here is the caller graph for this function:

BackendDiff::GetMessageList ( folderid,
cutoffdate 
) [abstract]

Returns a list (array) of messages, each entry being an associative array with the same entries as StatMessage().

This method should return stable information; ie if nothing has changed, the items in the array must be exactly the same. The order of the items within the array is not important though.

The $cutoffdate is a date in the past, representing the date since which items should be shown. This cutoffdate is determined by the user's setting of getting 'Last 3 days' of e-mail, etc. If the cutoffdate is ignored, the user will not be able to select their own cutoffdate, but all will work OK apart from that.

Parameters:
string$folderidid of the parent folder
long$cutoffdatetimestamp in the past from which on messages should be returned

public

Returns:
array/false array with messages or false if folder is not available

Reimplemented in BackendIMAP, BackendKolab, BackendMaildir, and BackendVCardDir.

Backend::GetSearchProvider ( ) [inherited]

Returns a ISearchProvider implementation used for searches the SearchProvider is just a stub.

public

Returns:
object Implementation of ISearchProvider

Implements IBackend.

Definition at line 88 of file backend.php.

                                        {
        return new SearchProvider();
    }
Backend::GetStateMachine ( ) [inherited]

Returns a IStateMachine implementation used to save states The default StateMachine should be used here, so, false is fine.

public

Returns:
boolean/object

Implements IBackend.

Definition at line 77 of file backend.php.

                                      {
        return false;
    }

Indicates which AS version is supported by the backend.

By default AS version 2.5 (ASV_25) is returned (Z-Push 1 standard). Subclasses can overwrite this method to set another AS version

public

Returns:
string AS version constant

Implements IBackend.

Definition at line 100 of file backend.php.

                                            {
        return ZPush::ASV_25;
    }
IBackend::GetWasteBasket ( ) [inherited]

Returns the waste basket.

The waste basked is used when deleting items; if this function returns a valid folder ID, then all deletes are handled as moves and are sent to the backend as a move. If it returns FALSE, then deletes are handled as real deletes

public

Returns:
string

Implemented in BackendZarafa, BackendIMAP, BackendKolab, BackendCombined, BackendMaildir, and BackendVCardDir.

Backend::HasChangesSink ( ) [inherited]

Indicates if the backend has a ChangesSink.

A sink is an active notification mechanism which does not need polling.

public

Returns:
boolean

Implements IBackend.

Reimplemented in BackendIMAP.

Definition at line 144 of file backend.php.

                                     {
        return false;
    }
Backend::InitializePermanentStorage ( ) [protected, inherited]


Protected methods for BackendStorage

Backends can use a permanent and a state related storage to save additional data used during the synchronization.

While permament storage is bound to the device and user, state related data works linked to the regular states (and its counters).

Both consist of a StateObject, while the backend can decide what to save in it.

Before using $this->permanentStorage and $this->stateStorage the initilize methods have to be called from the backend.

Backend->LogOff() must call $this->SaveStorages() so the data is written to disk!

These methods are an abstraction layer for StateManager->Get/SetBackendStorage() which can also be used independently. Loads the permanent storage data of the user and device

protected

Returns:

Definition at line 218 of file backend.php.

                                                    {
        if (!isset($this->permanentStorage)) {
            try {
                $this->permanentStorage = ZPush::GetDeviceManager()->GetStateManager()->GetBackendStorage(StateManager::BACKENDSTORAGE_PERMANENT);
            }
            catch (StateNotYetAvailableException $snyae) {
                $this->permanentStorage = new StateObject();
            }
            catch(StateNotFoundException $snfe) {
                $this->permanentStorage = new StateObject();
            }
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Backend::InitializeStateStorage ( ) [protected, inherited]

Loads the state related storage data of the user and device All data not necessary for the next state should be removed.

protected

Returns:

Definition at line 239 of file backend.php.

                                                {
        if (!isset($this->stateStorage)) {
            try {
                $this->stateStorage = ZPush::GetDeviceManager()->GetStateManager()->GetBackendStorage(StateManager::BACKENDSTORAGE_STATE);
            }
            catch (StateNotYetAvailableException $snyae) {
                $this->stateStorage = new StateObject();
            }
            catch(StateNotFoundException $snfe) {
                $this->stateStorage = new StateObject();
            }
        }
    }

Here is the call graph for this function:

IBackend::Logoff ( ) [inherited]

Logs off non critical operations closing the session should be done here.

public

Returns:
boolean

Implemented in BackendZarafa, BackendCombined, BackendIMAP, BackendKolab, BackendMaildir, and BackendVCardDir.

IBackend::Logon ( username,
domain,
password 
) [inherited]

Authenticates the user.

Parameters:
string$username
string$domain
string$passwordpublic
Returns:
boolean
Exceptions:
FatalExceptione.g. some required libraries are unavailable

Implemented in BackendZarafa, BackendCombined, BackendIMAP, BackendMaildir, BackendVCardDir, and BackendKolab.

BackendDiff::MeetingResponse ( requestid,
folderid,
response 
)

Processes a response to a meeting request.

CalendarID is a reference and has to be set if a new calendar item is created

Parameters:
string$requestidid of the object containing the request
string$folderidid of the parent folder of $requestid
string$responsepublic
Returns:
string id of the created/updated calendar obj
Exceptions:
StatusException

Implements IBackend.

Definition at line 171 of file diffbackend.php.

                                                                      {
        throw new StatusException(sprintf("BackendDiff->MeetingResponse('%s','%s','%s'): Error, this functionality is not supported by the diff backend", $requestid, $folderid, $response), SYNC_MEETRESPSTATUS_MAILBOXERROR);
    }
BackendDiff::MoveMessage ( folderid,
id,
newfolderid 
) [abstract]

Called when the user moves an item on the PDA from one folder to another.

Whatever is needed to move the message on disk has to be done here. After this call, StatMessage() and GetMessageList() should show the items to have a new parent. This means that it will disappear from GetMessageList() of the sourcefolder and the destination folder will show the new message

Parameters:
string$folderidid of the source folder
string$idid of the message
string$newfolderidid of the destination folder

public

Returns:
boolean status of the operation
Exceptions:
StatusExceptioncould throw specific SYNC_MOVEITEMSSTATUS_* exceptions

Reimplemented in BackendKolab, BackendIMAP, BackendVCardDir, and BackendMaildir.

Backend::SaveStorages ( ) [protected, inherited]

Saves the permanent and state related storage data of the user and device if they were loaded previousily If the backend storage is used this should be called.

protected

Returns:

Definition at line 261 of file backend.php.

                                      {
        if (isset($this->permanentStorage)) {
            try {
                ZPush::GetDeviceManager()->GetStateManager()->SetBackendStorage($this->permanentStorage, StateManager::BACKENDSTORAGE_PERMANENT);
            }
            catch (StateNotYetAvailableException $snyae) { }
            catch(StateNotFoundException $snfe) { }
        }
        if (isset($this->stateStorage)) {
            try {
                $this->storage_state = ZPush::GetDeviceManager()->GetStateManager()->SetBackendStorage($this->stateStorage, StateManager::BACKENDSTORAGE_STATE);
            }
            catch (StateNotYetAvailableException $snyae) { }
            catch(StateNotFoundException $snfe) { }
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

IBackend::SendMail ( sm) [inherited]

Sends an e-mail This messages needs to be saved into the 'sent items' folder.

Basically two things can be done 1) Send the message to an SMTP server as-is 2) Parse the message, and send it some other way

Parameters:
SyncSendMail$smSyncSendMail object

public

Returns:
boolean
Exceptions:
StatusException

Implemented in BackendZarafa, BackendCombined, BackendIMAP, BackendMaildir, and BackendVCardDir.

BackendDiff::SetReadFlag ( folderid,
id,
flags 
) [abstract]

Changes the 'read' flag of a message on disk.

The $flags parameter can only be '1' (read) or '0' (unread). After a call to SetReadFlag(), GetMessageList() should return the message with the new 'flags' but should not modify the 'mod' parameter. If you do change 'mod', simply setting the message to 'read' on the mobile will trigger a full resync of the item from the server.

Parameters:
string$folderidid of the folder
string$idid of the message
int$flagsread flag of the message

public

Returns:
boolean status of the operation
Exceptions:
StatusExceptioncould throw specific SYNC_STATUS_* exceptions

Reimplemented in BackendKolab, BackendIMAP, BackendVCardDir, and BackendMaildir.

Backend::Settings ( settings) [inherited]

Applies settings to and gets informations from the device.

Parameters:
SyncObject$settings(SyncOOF or SyncUserInformation possible)

public

Returns:
SyncObject $settings

Implements IBackend.

Definition at line 185 of file backend.php.

                                        {
        if ($settings instanceof SyncOOF || $settings instanceof SyncUserInformation)
            $settings->Status = SYNC_SETTINGSSTATUS_SUCCESS;
        return $settings;
    }
BackendDiff::Setup ( store,
checkACLonly = false,
folderid = false 
)

Setup the backend to work on a specific store or checks ACLs there.

If only the $store is submitted, all Import/Export/Fetch/Etc operations should be performed on this store (switch operations store). If the ACL check is enabled, this operation should just indicate the ACL status on the submitted store, without changing the store for operations. For the ACL status, the currently logged on user MUST have access rights on

  • the entire store - admin access if no folderid is sent, or
  • on a specific folderid in the store (secretary/full access rights)

The ACLcheck MUST fail if a folder of the authenticated user is checked!

Parameters:
string$storetarget store, could contain a "domain\user" value
boolean$checkACLonlyif set to true, Setup() should just check ACLs
string$folderidif set, only ACLs on this folderid are relevant

public

Returns:
boolean

Implements IBackend.

Reimplemented in BackendKolab.

Definition at line 85 of file diffbackend.php.

                                                                            {
        $this->store = $store;

        return true;
    }
BackendDiff::StatFolder ( id) [abstract]

Returns folder stats.

An associative array with properties is expected.

Parameters:
string$idid of the folder

public

Returns:
array Associative array( string "id" The server ID that will be used to identify the folder. It must be unique, and not too long How long exactly is not known, but try keeping it under 20 chars or so. It must be a string. string "parent" The server ID of the parent of the folder. Same restrictions as 'id' apply. long "mod" This is the modification signature. It is any arbitrary string which is constant as long as the folder has not changed. In practice this means that 'mod' can be equal to the folder name as this is the only thing that ever changes in folders. (the type is normally constant) )

Reimplemented in BackendKolab, BackendIMAP, BackendMaildir, and BackendVCardDir.

BackendDiff::StatMessage ( folderid,
id 
) [abstract]

Returns message stats, analogous to the folder stats from StatFolder().

Parameters:
string$folderidid of the folder
string$idid of the message

public

Returns:
array or boolean if fails Associative array( string "id" Server unique identifier for the message. Again, try to keep this short (under 20 chars) int "flags" simply '0' for unread, '1' for read long "mod" This is the modification signature. It is any arbitrary string which is constant as long as the message has not changed. As soon as this signature changes, the item is assumed to be completely changed, and will be sent to the PDA as a whole. Normally you can use something like the modification time for this field, which will change as soon as the contents have changed. )

Reimplemented in BackendKolab, BackendIMAP, BackendVCardDir, and BackendMaildir.


Member Data Documentation

Backend::$permanentStorage [protected, inherited]

Definition at line 59 of file backend.php.

Backend::$stateStorage [protected, inherited]

Definition at line 60 of file backend.php.

BackendDiff::$store [protected]

Definition at line 64 of file diffbackend.php.


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