Back to index

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

List of all members.

Public Member Functions

 BackendCombined ()
 Constructor of the combined backend.
 Logon ($username, $domain, $password)
 Authenticates the user on each backend.
 Setup ($store, $checkACLonly=false, $folderid=false)
 Setup the backend to work on a specific store or checks ACLs there.
 Logoff ()
 Logs off each backend.
 GetHierarchy ()
 Returns an array of SyncFolder types with the entire folder hierarchy from all backends combined.
 GetImporter ($folderid=false)
 Returns the importer to process changes from the mobile.
 GetExporter ($folderid=false)
 Returns the exporter to send changes to the mobile the exporter from right backend for contents exporter and our own exporter for hierarchy exporter.
 SendMail ($sm)
 Sends an e-mail This messages needs to be saved into the 'sent items' folder.
 Fetch ($folderid, $id, $contentparameters)
 Returns all available data of a single message.
 GetWasteBasket ()
 Returns the waste basket If the wastebasket is set to one backend, return the wastebasket of that backend else return the first waste basket we can find.
 GetAttachmentData ($attname)
 Returns the content of the named attachment as stream.
 MeetingResponse ($requestid, $folderid, $error)
 Processes a response to a meeting request.
 GetBackend ($folderid)
 Finds the correct backend for a folder.
 GetBackendFolder ($folderid)
 Returns an understandable folderid for the backend.
 GetBackendId ($folderid)
 Returns backend id for a folder.
 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.

Public Attributes

 $config
 $backends

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

 $permanentStorage
 $stateStorage

Private Attributes

 $activeBackend

Detailed Description

Definition at line 60 of file combined.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:

Constructor of the combined backend.

public

Definition at line 70 of file combined.php.

                                      {
        parent::Backend();
        $this->config = BackendCombinedConfig::GetBackendCombinedConfig();

        foreach ($this->config['backends'] as $i => $b){
            // load and instatiate backend
            ZPush::IncludeBackend($b['name']);
            $this->backends[$i] = new $b['name']($b['config']);
        }
        ZLog::Write(LOGLEVEL_INFO, sprintf("Combined %d backends loaded.", count($this->backends)));
    }

Here is the call graph for this function:

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;
     }
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;
    }
BackendCombined::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 295 of file combined.php.

                                                              {
        ZLog::Write(LOGLEVEL_DEBUG, sprintf("Combined->Fetch('%s', '%s', CPO)", $folderid, $id));
        $backend = $this->GetBackend($folderid);
        if($backend == false)
            return false;
        return $backend->Fetch($this->GetBackendFolder($folderid), $id, $contentparameters);
    }

Here is the call graph for this function:

Returns the content of the named attachment as stream.

There is no way to tell which backend the attachment is from, so we try them all

Parameters:
string$attnamepublic
Returns:
SyncItemOperationsAttachment
Exceptions:
StatusException

Implements IBackend.

Definition at line 329 of file combined.php.

                                                {
        ZLog::Write(LOGLEVEL_DEBUG, sprintf("Combined->GetAttachmentData('%s')", $attname));
        foreach ($this->backends as $i => $b) {
            try {
                $attachment = $this->backends[$i]->GetAttachmentData($attname);
                if ($attachment instanceof SyncItemOperationsAttachment)
                    return $attachment;
            }
            catch (StatusException $s) {
                // backends might throw StatusExceptions if it's not their attachment
            }
        }
        throw new StatusException("Combined->GetAttachmentData(): no backend found", SYNC_ITEMOPERATIONSSTATUS_INVALIDATT);
    }

Here is the call graph for this function:

BackendCombined::GetBackend ( folderid)

Finds the correct backend for a folder.

Parameters:
string$folderidcombinedid of the folder

public

Returns:
object

Definition at line 370 of file combined.php.

                                         {
        $pos = strpos($folderid, $this->config['delimiter']);
        if($pos === false)
            return false;
        $id = substr($folderid, 0, $pos);
        if(!isset($this->backends[$id]))
            return false;

        $this->activeBackend = $this->backends[$id];
        return $this->backends[$id];
    }

Here is the caller graph for this function:

Returns an understandable folderid for the backend.

Parameters:
string$folderidcombinedid of the folder

public

Returns:
string

Definition at line 390 of file combined.php.

                                               {
        $pos = strpos($folderid, $this->config['delimiter']);
        if($pos === false)
            return false;
        return substr($folderid,$pos + strlen($this->config['delimiter']));
    }

Here is the caller graph for this function:

Returns backend id for a folder.

Parameters:
string$folderidcombinedid of the folder

public

Returns:
object

Definition at line 405 of file combined.php.

                                           {
        $pos = strpos($folderid, $this->config['delimiter']);
        if($pos === false)
            return false;
        return substr($folderid,0,$pos);
    }
BackendCombined::GetExporter ( folderid = false)

Returns the exporter to send changes to the mobile the exporter from right backend for contents exporter and our own exporter for hierarchy exporter.

Parameters:
string$folderid(opt)

public

Returns:
object(ExportChanges)

Implements IBackend.

Definition at line 253 of file combined.php.

                                                  {
        ZLog::Write(LOGLEVEL_DEBUG, sprintf("Combined->GetExporter('%s')", $folderid));
        if($folderid){
            $backend = $this->GetBackend($folderid);
            if($backend == false)
                return false;
            return $backend->GetExporter($this->GetBackendFolder($folderid));
        }
        return new ExportChangesCombined($this);
    }

Here is the call graph for this function:

Returns an array of SyncFolder types with the entire folder hierarchy from all backends combined.

provides AS 1.0 compatibility

public

Returns:
array SYNC_FOLDER

Implements IBackend.

Definition at line 184 of file combined.php.

                                  {
        ZLog::Write(LOGLEVEL_DEBUG, "Combined->GetHierarchy()");
        $ha = array();
        foreach ($this->backends as $i => $b){
            if(!empty($this->config['backends'][$i]['subfolder'])){
                $f = new SyncFolder();
                $f->serverid = $i.$this->config['delimiter'].'0';
                $f->parentid = '0';
                $f->displayname = $this->config['backends'][$i]['subfolder'];
                $f->type = SYNC_FOLDER_TYPE_OTHER;
                $ha[] = $f;
            }
            $h = $this->backends[$i]->GetHierarchy();
            if(is_array($h)){
                foreach($h as $j => $f){
                    $h[$j]->serverid = $i.$this->config['delimiter'].$h[$j]->serverid;
                    if($h[$j]->parentid != '0' || !empty($this->config['backends'][$i]['subfolder'])){
                        $h[$j]->parentid = $i.$this->config['delimiter'].$h[$j]->parentid;
                    }
                    if(isset($this->config['folderbackend'][$h[$j]->type]) && $this->config['folderbackend'][$h[$j]->type] != $i){
                        $h[$j]->type = SYNC_FOLDER_TYPE_OTHER;
                    }
                }
                $ha = array_merge($ha, $h);
            }
        }
        ZLog::Write(LOGLEVEL_DEBUG, "Combined->GetHierarchy() success");
        return $ha;
    }

Here is the call graph for this function:

BackendCombined::GetImporter ( folderid = false)

Returns the importer to process changes from the mobile.

Parameters:
string$folderid(opt)

public

Returns:
object(ImportChanges)

Implements IBackend.

Definition at line 222 of file combined.php.

                                                   {
        if($folderid !== false) {
            ZLog::Write(LOGLEVEL_DEBUG, sprintf("Combined->GetImporter() Content: ImportChangesCombined:('%s')", $folderid));

            // get the contents importer from the folder in a backend
            // the importer is wrapped to check foldernames in the ImportMessageMove function
            $backend = $this->GetBackend($folderid);
            if($backend === false)
                return false;
            $importer = $backend->GetImporter($this->GetBackendFolder($folderid));
            if($importer){
                return new ImportChangesCombined($this, $folderid, $importer);
            }
            return false;
        }
        else {
            ZLog::Write(LOGLEVEL_DEBUG, "Combined->GetImporter() -> Hierarchy: ImportChangesCombined()");
            //return our own hierarchy importer which send each change to the right backend
            return new ImportChangesCombined($this);
        }
    }

Here is the call graph for this function:

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;
    }

Returns the waste basket If the wastebasket is set to one backend, return the wastebasket of that backend else return the first waste basket we can find.

public

Returns:
string

Implements IBackend.

Definition at line 311 of file combined.php.

                             {
        ZLog::Write(LOGLEVEL_DEBUG, "Combined->GetWasteBasket()");
        if (isset($this->activeBackend))
            return $this->activeBackend->GetWasteBasket();

        return false;
    }

Here is the call graph for this function:

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:

Logs off each backend.

public

Returns:
boolean

Implements IBackend.

Definition at line 166 of file combined.php.

                             {
        ZLog::Write(LOGLEVEL_DEBUG, "Combined->Logoff()");
        foreach ($this->backends as $i => $b){
            $this->backends[$i]->Logoff();
        }
        ZLog::Write(LOGLEVEL_DEBUG, "Combined->Logoff() success");
        return true;
    }

Here is the call graph for this function:

BackendCombined::Logon ( username,
domain,
password 
)

Authenticates the user on each backend.

Parameters:
string$username
string$domain
string$passwordpublic
Returns:
boolean

Implements IBackend.

Definition at line 92 of file combined.php.

                                                         {
        ZLog::Write(LOGLEVEL_DEBUG, sprintf("Combined->Logon('%s', '%s',***))", $username, $domain));
        if(!is_array($this->backends)){
            return false;
        }
        foreach ($this->backends as $i => $b){
            $u = $username;
            $d = $domain;
            $p = $password;
            if(isset($this->config['backends'][$i]['users'])){
                if(!isset($this->config['backends'][$i]['users'][$username])){
                    unset($this->backends[$i]);
                    continue;
                }
                if(isset($this->config['backends'][$i]['users'][$username]['username']))
                    $u = $this->config['backends'][$i]['users'][$username]['username'];
                if(isset($this->config['backends'][$i]['users'][$username]['password']))
                    $p = $this->config['backends'][$i]['users'][$username]['password'];
                if(isset($this->config['backends'][$i]['users'][$username]['domain']))
                    $d = $this->config['backends'][$i]['users'][$username]['domain'];
            }
            if($this->backends[$i]->Logon($u, $d, $p) == false){
                ZLog::Write(LOGLEVEL_DEBUG, sprintf("Combined->Logon() failed on %s ", $this->config['backends'][$i]['name']));
                return false;
            }
        }
        ZLog::Write(LOGLEVEL_INFO, "Combined->Logon() success");
        return true;
    }

Here is the call graph for this function:

BackendCombined::MeetingResponse ( requestid,
folderid,
error 
)

Processes a response to a meeting request.

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 355 of file combined.php.

                                                                   {
        $backend = $this->GetBackend($folderid);
        if($backend === false)
            return false;
        return $backend->MeetingResponse($requestid, $this->GetBackendFolder($folderid), $error);
    }

Here is the call graph for this function:

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:

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

Parameters:
SyncSendMail$smSyncSendMail object

public

Returns:
boolean
Exceptions:
StatusException

Implements IBackend.

Definition at line 274 of file combined.php.

                                  {
        ZLog::Write(LOGLEVEL_DEBUG, "Combined->SendMail()");
        foreach ($this->backends as $i => $b){
            if($this->backends[$i]->SendMail($sm) == true){
                return true;
            }
        }
        return false;
    }

Here is the call graph for this function:

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;
    }
BackendCombined::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.

Definition at line 141 of file combined.php.

                                                                            {
        ZLog::Write(LOGLEVEL_DEBUG, sprintf("Combined->Setup('%s', '%s', '%s')", $store, Utils::PrintAsString($checkACLonly), $folderid));
        if(!is_array($this->backends)){
            return false;
        }
        foreach ($this->backends as $i => $b){
            $u = $store;
            if(isset($this->config['backends'][$i]['users']) && isset($this->config['backends'][$i]['users'][$store]['username'])){
                $u = $this->config['backends'][$i]['users'][$store]['username'];
            }
            if($this->backends[$i]->Setup($u, $checkACLonly, $folderid) == false){
                ZLog::Write(LOGLEVEL_WARN, "Combined->Setup() failed");
                return false;
            }
        }
        ZLog::Write(LOGLEVEL_INFO, "Combined->Setup() success");
        return true;
    }

Here is the call graph for this function:


Member Data Documentation

Definition at line 63 of file combined.php.

Definition at line 62 of file combined.php.

Definition at line 61 of file combined.php.

Backend::$permanentStorage [protected, inherited]

Definition at line 59 of file backend.php.

Backend::$stateStorage [protected, inherited]

Definition at line 60 of file backend.php.


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