Back to index

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

List of all members.

Public Member Functions

 Logon ($username, $domain, $password)
 
default backend methods
 Logoff ()
 Logs off.
 SendMail ($sm)
 Sends an e-mail Not implemented here.
 GetWasteBasket ()
 Returns the waste basket.
 GetAttachmentData ($attname)
 Returns the content of the named attachment as stream.
 GetFolderList ()
 
implemented DiffBackend methods
 GetFolder ($id)
 Returns an actual SyncFolder object.
 StatFolder ($id)
 Returns folder stats.
 ChangeFolder ($folderid, $oldid, $displayname, $type)
 Creates or modifies a folder not implemented.
 DeleteFolder ($id, $parentid)
 Deletes a folder.
 GetMessageList ($folderid, $cutoffdate)
 Returns a list (array) of messages.
 GetMessage ($folderid, $id, $truncsize, $mimesupport=0)
 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 not implemented.
 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.
 GetMessage ($folderid, $id, $contentparameters)
 Returns the actual SyncXXX object type.
 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.

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

Private Member Functions

 findMessage ($id)
 
private maildir-specific internals
 getBody ($message)
 Parses the message and return only the plaintext body.
 getBodyRecursive ($message, $subtype, &$body)
 Get all parts in the message with specified type and concatenate them together, unless the Content-Disposition is 'attachment', in which case the text is apparently an attachment.
 parseReceivedDate ($received)
 Parses the received date.
 moveNewToCur ()
 Moves everything in Maildir/new/* to Maildir/cur/.
 getPath ()
 The path we're working on.

Detailed Description

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

BackendMaildir::ChangeFolder ( folderid,
oldid,
displayname,
type 
)

Creates or modifies a folder not implemented.

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 from BackendDiff.

Definition at line 247 of file maildir.php.

                                                                        {
        return false;
    }
BackendMaildir::ChangeMessage ( folderid,
id,
message 
)

Called when a message has been changed on the mobile.

This functionality is not available for emails.

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 from BackendDiff.

Definition at line 485 of file maildir.php.

                                                            {
        return false;
    }
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;
     }
BackendMaildir::DeleteFolder ( id,
parentid 
)

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 from BackendDiff.

Definition at line 262 of file maildir.php.

                                                {
        return false;
    }
BackendMaildir::DeleteMessage ( folderid,
id 
)

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

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 from BackendDiff.

Definition at line 538 of file maildir.php.

                                                  {
        if($folderid != 'root')
            return false;

        $fn = $this->findMessage($id);

        if(!$fn)
            return true; // success because message has been deleted already

        if(!unlink($this->getPath() . "/$fn")) {
            return true; // success - message may have been deleted in the mean time (since findMessage)
        }

        return true;
    }

Here is the call graph for this function:

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 
) [inherited]

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:

BackendMaildir::findMessage ( id) [private]


private maildir-specific internals

Searches for the message

Parameters:
string$idid of the message

private

Returns:
string

Definition at line 583 of file maildir.php.

                                      {
        // We could use 'this->folderid' for path info but we currently
        // only support a single INBOX. We also have to use a glob '*'
        // because we don't know the flags of the message we're looking for.

        $dirname = $this->getPath();
        $dir = opendir($dirname);

        while($entry = readdir($dir)) {
            if(strpos($entry,$id) === 0)
                return $entry;
        }
        return false; // not found
    }

Here is the call graph for this function:

Here is the caller graph for this function:

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 find the attachment must be encoded in that 'attname' property. Data is written directly (with print $data;)

Parameters:
string$attnamepublic
Returns:
SyncItemOperationsAttachment
Exceptions:
StatusException

Implements IBackend.

Definition at line 128 of file maildir.php.

                                                {
        list($id, $part) = explode(":", $attname);

        $fn = $this->findMessage($id);
        if ($fn == false)
            throw new StatusException(sprintf("BackendMaildir->GetAttachmentData('%s'): Error, requested message/attachment can not be found", $attname), SYNC_ITEMOPERATIONSSTATUS_INVALIDATT);

        // Parse e-mail
        $rfc822 = file_get_contents($this->getPath() . "/$fn");

        $message = Mail_mimeDecode::decode(array('decode_headers' => true, 'decode_bodies' => true, 'include_bodies' => true, 'input' => $rfc822, 'crlf' => "\n", 'charset' => 'utf-8'));

        include_once('include/stringstreamwrapper.php');
        $attachment = new SyncItemOperationsAttachment();
        $attachment->data = StringStreamWrapper::Open($message->parts[$part]->body);
        if (isset($message->parts[$part]->ctype_primary) && isset($message->parts[$part]->ctype_secondary))
            $attachment->contenttype = $message->parts[$part]->ctype_primary .'/'.$message->parts[$part]->ctype_secondary;

        return $attachment;
    }

Here is the call graph for this function:

BackendMaildir::getBody ( message) [private]

Parses the message and return only the plaintext body.

Parameters:
string$messagehtml message

private

Returns:
string plaintext message

Definition at line 606 of file maildir.php.

                                       {
        $body = "";
        $htmlbody = "";

        $this->getBodyRecursive($message, "plain", $body);

        if(!isset($body) || $body === "") {
            $this->getBodyRecursive($message, "html", $body);
            // remove css-style tags
            $body = preg_replace("/<style.*?<\/style>/is", "", $body);
            // remove all other html
            $body = strip_tags($body);
        }

        return $body;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

BackendMaildir::getBodyRecursive ( message,
subtype,
&$  body 
) [private]

Get all parts in the message with specified type and concatenate them together, unless the Content-Disposition is 'attachment', in which case the text is apparently an attachment.

Parameters:
string$messagemimedecode message(part)
string$messagemessage subtype
string&$bodybody reference

private

Returns:

Definition at line 634 of file maildir.php.

                                                                  {
        if(!isset($message->ctype_primary)) return;
        if(strcasecmp($message->ctype_primary,"text")==0 && strcasecmp($message->ctype_secondary,$subtype)==0 && isset($message->body))
            $body .= $message->body;

        if(strcasecmp($message->ctype_primary,"multipart")==0 && isset($message->parts) && is_array($message->parts)) {
            foreach($message->parts as $part) {
                if(!isset($part->disposition) || strcasecmp($part->disposition,"attachment"))  {
                    $this->getBodyRecursive($part, $subtype, $body);
                }
            }
        }
    }

Here is the caller graph for this function:

BackendDiff::GetExporter ( folderid = false) [inherited]

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

Returns an actual SyncFolder object.

Parameters:
string$idid of the folder

public

Returns:
object SyncFolder with information

Reimplemented from BackendDiff.

Definition at line 189 of file maildir.php.

                                   {
        if($id == "root") {
            $inbox = new SyncFolder();

            $inbox->serverid = $id;
            $inbox->parentid = "0"; // Root
            $inbox->displayname = "Inbox";
            $inbox->type = SYNC_FOLDER_TYPE_INBOX;

            return $inbox;
        } else if($id == "sub") {
            $inbox = new SyncFolder();
            $inbox->serverid = $id;
            $inbox->parentid = "root";
            $inbox->displayname = "Sub";
            $inbox->type = SYNC_FOLDER_TYPE_OTHER;

            return $inbox;
        } else {
            return false;
        }
    }

Here is the caller graph for this function:


implemented DiffBackend methods

Returns a list (array) of folders. In simple implementations like this one, probably just one folder is returned.

public

Returns:
array

Reimplemented from BackendDiff.

Definition at line 161 of file maildir.php.

                                    {
        $folders = array();

        $inbox = array();
        $inbox["id"] = "root";
        $inbox["parent"] = "0";
        $inbox["mod"] = "Inbox";

        $folders[]=$inbox;

        $sub = array();
        $sub["id"] = "sub";
        $sub["parent"] = "root";
        $sub["mod"] = "Sub";

//        $folders[]=$sub;

        return $folders;
    }
BackendDiff::GetHierarchy ( ) [inherited]

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) [inherited]

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, inherited]

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:

BackendMaildir::GetMessage ( folderid,
id,
truncsize,
mimesupport = 0 
)

Returns the actual SyncXXX object type.

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

Definition at line 344 of file maildir.php.

                                                                             {
        if($folderid != 'root')
            return false;

        $fn = $this->findMessage($id);

        // Get flags, etc
        $stat = $this->StatMessage($folderid, $id);

        // Parse e-mail
        $rfc822 = file_get_contents($this->getPath() . "/" . $fn);

        $message = Mail_mimeDecode::decode(array('decode_headers' => true, 'decode_bodies' => true, 'include_bodies' => true, 'input' => $rfc822, 'crlf' => "\n", 'charset' => 'utf-8'));

        $output = new SyncMail();

        $output->body = str_replace("\n", "\r\n", $this->getBody($message));
        $output->bodysize = strlen($output->body);
        $output->bodytruncated = 0; // We don't implement truncation in this backend
        $output->datereceived = $this->parseReceivedDate($message->headers["received"][0]);
        $output->messageclass = "IPM.Note";
        $output->subject = $message->headers["subject"];
        $output->read = $stat["flags"];
        $output->from = $message->headers["from"];

        $Mail_RFC822 = new Mail_RFC822();
        $toaddr = $ccaddr = $replytoaddr = array();
        if(isset($message->headers["to"]))
            $toaddr = $Mail_RFC822->parseAddressList($message->headers["to"]);
        if(isset($message->headers["cc"]))
            $ccaddr = $Mail_RFC822->parseAddressList($message->headers["cc"]);
        if(isset($message->headers["reply_to"]))
            $replytoaddr = $Mail_RFC822->parseAddressList($message->headers["reply_to"]);

        $output->to = array();
        $output->cc = array();
        $output->reply_to = array();
        foreach(array("to" => $toaddr, "cc" => $ccaddr, "reply_to" => $replytoaddr) as $type => $addrlist) {
            foreach($addrlist as $addr) {
                $address = $addr->mailbox . "@" . $addr->host;
                $name = $addr->personal;

                if (!isset($output->displayto) && $name != "")
                    $output->displayto = $name;

                if($name == "" || $name == $address)
                    $fulladdr = w2u($address);
                else {
                    if (substr($name, 0, 1) != '"' && substr($name, -1) != '"') {
                        $fulladdr = "\"" . w2u($name) ."\" <" . w2u($address) . ">";
                    }
                    else {
                        $fulladdr = w2u($name) ." <" . w2u($address) . ">";
                    }
                }

                array_push($output->$type, $fulladdr);
            }
        }

        // convert mime-importance to AS-importance
        if (isset($message->headers["x-priority"])) {
            $mimeImportance =  preg_replace("/\D+/", "", $message->headers["x-priority"]);
            if ($mimeImportance > 3)
                $output->importance = 0;
            if ($mimeImportance == 3)
                $output->importance = 1;
            if ($mimeImportance < 3)
                $output->importance = 2;
        }

        // Attachments are only searched in the top-level part
        $n = 0;
        if(isset($message->parts)) {
            foreach($message->parts as $part) {
                if($part->ctype_primary == "application") {
                    $attachment = new SyncAttachment();
                    $attachment->attsize = strlen($part->body);

                    if(isset($part->d_parameters['filename']))
                        $attname = $part->d_parameters['filename'];
                    else if(isset($part->ctype_parameters['name']))
                        $attname = $part->ctype_parameters['name'];
                    else if(isset($part->headers['content-description']))
                        $attname = $part->headers['content-description'];
                    else $attname = "unknown attachment";

                    $attachment->displayname = $attname;
                    $attachment->attname = $id . ":" . $n;
                    $attachment->attmethod = 1;
                    $attachment->attoid = isset($part->headers['content-id']) ? $part->headers['content-id'] : "";

                    array_push($output->attachments, $attachment);
                }
                $n++;
            }
        }

        return $output;
    }

Here is the call graph for this function:

BackendMaildir::GetMessageList ( folderid,
cutoffdate 
)

Returns a list (array) of messages.

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 from BackendDiff.

Definition at line 275 of file maildir.php.

                                                           {
        $this->moveNewToCur();

        if($folderid != "root")
            return false;

        // return stats of all messages in a dir. We can do this faster than
        // just calling statMessage() on each message; We still need fstat()
        // information though, so listing 10000 messages is going to be
        // rather slow (depending on filesystem, etc)

        // we also have to filter by the specified cutoffdate so only the
        // last X days are retrieved. Normally, this would mean that we'd
        // have to open each message, get the Received: header, and check
        // whether that is in the filter range. Because this is much too slow, we
        // are depending on the creation date of the message instead, which should
        // normally be just about the same, unless you just did some kind of import.

        $messages = array();
        $dirname = $this->getPath();

        $dir = opendir($dirname);

        if(!$dir)
            return false;

        while($entry = readdir($dir)) {
            if($entry{0} == ".")
                continue;

            $message = array();

            $stat = stat("$dirname/$entry");

            if($stat["mtime"] < $cutoffdate) {
                // message is out of range for curoffdate, ignore it
                continue;
            }

            $message["mod"] = $stat["mtime"];

            $matches = array();

            // Flags according to http://cr.yp.to/proto/maildir.html (pretty authoritative - qmail author's website)
            if(!preg_match("/([^:]+):2,([PRSTDF]*)/",$entry,$matches))
                continue;
            $message["id"] = $matches[1];
            $message["flags"] = 0;

            if(strpos($matches[2],"S") !== false) {
                $message["flags"] |= 1; // 'seen' aka 'read' is the only flag we want to know about
            }

            array_push($messages, $message);
        }

        return $messages;
    }

Here is the call graph for this function:

BackendMaildir::getPath ( ) [private]

The path we're working on.

private

Returns:
string

Definition at line 694 of file maildir.php.

                               {
        return MAILDIR_BASE . "/" . $this->store . "/" . MAILDIR_SUBDIR . "/cur";
    }

Here is the caller 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.

public

Returns:
string

Implements IBackend.

Definition at line 112 of file maildir.php.

                                     {
        return false;
    }
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.

public

Returns:
boolean

Implements IBackend.

Definition at line 88 of file maildir.php.

                             {
        return true;
    }
BackendMaildir::Logon ( username,
domain,
password 
)


default backend methods

Authenticates the user - NOT EFFECTIVELY IMPLEMENTED Normally some kind of password check would be done here. Alternatively, the password could be ignored and an Apache authentication via mod_auth_* could be done

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

Implements IBackend.

Definition at line 78 of file maildir.php.

                                                         {
        return true;
    }
BackendDiff::MeetingResponse ( requestid,
folderid,
response 
) [inherited]

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);
    }
BackendMaildir::MoveMessage ( folderid,
id,
newfolderid 
)

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

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 from BackendDiff.

Definition at line 566 of file maildir.php.

                                                              {
        return false;
    }

Moves everything in Maildir/new/* to Maildir/cur/.

private

Returns:

Definition at line 673 of file maildir.php.

                                    {
        $newdirname = MAILDIR_BASE . "/" . $this->store . "/" . MAILDIR_SUBDIR . "/new";

        $newdir = opendir($newdirname);

        while($newentry = readdir($newdir)) {
            if($newentry{0} == ".")
                continue;

            // link/unlink == move. This is the way to move the message according to cr.yp.to
            link($newdirname . "/" . $newentry, $this->getPath() . "/" . $newentry . ":2,");
            unlink($newdirname . "/" . $newentry);
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

BackendMaildir::parseReceivedDate ( received) [private]

Parses the received date.

Parameters:
string$receivedreceived date string

private

Returns:
long

Definition at line 656 of file maildir.php.

                                                  {
        $pos = strpos($received, ";");
        if(!$pos)
            return false;

        $datestr = substr($received, $pos+1);
        $datestr = ltrim($datestr);

        return strtotime($datestr);
    }

Here is the caller 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 Not implemented here.

Parameters:
SyncSendMail$smSyncSendMail object

public

Returns:
boolean
Exceptions:
StatusException

Implements IBackend.

Definition at line 102 of file maildir.php.

                                  {
        return false;
    }
BackendMaildir::SetReadFlag ( folderid,
id,
flags 
)

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

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 from BackendDiff.

Definition at line 500 of file maildir.php.

                                                        {
        if($folderid != 'root')
            return false;

        $fn = $this->findMessage($id);

        if(!$fn)
            return true; // message may have been deleted

        if(!preg_match("/([^:]+):2,([PRSTDF]*)/",$fn,$matches))
            return false;

        // remove 'seen' (S) flag
        if(!$flags) {
            $newflags = str_replace("S","",$matches[2]);
        } else {
            // make sure we don't double add the 'S' flag
            $newflags = str_replace("S","",$matches[2]) . "S";
        }

        $newfn = $matches[1] . ":2," . $newflags;
        // rename if required
        if($fn != $newfn)
            rename($this->getPath() ."/$fn", $this->getPath() . "/$newfn");

        return true;
    }

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;
    }
BackendDiff::Setup ( store,
checkACLonly = false,
folderid = false 
) [inherited]

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

Returns folder stats.

An associative array with properties is expected.

Parameters:
string$idid of the folder

public

Returns:
array

Reimplemented from BackendDiff.

Definition at line 221 of file maildir.php.

                                    {
        $folder = $this->GetFolder($id);

        $stat = array();
        $stat["id"] = $id;
        $stat["parent"] = $folder->parentid;
        $stat["mod"] = $folder->displayname;

        return $stat;
    }

Here is the call graph for this function:

BackendMaildir::StatMessage ( folderid,
id 
)

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

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

public

Returns:
array

Reimplemented from BackendDiff.

Definition at line 454 of file maildir.php.

                                                {
        $dirname = $this->getPath();
        $fn = $this->findMessage($id);
        if(!$fn)
            return false;

        $stat = stat("$dirname/$fn");

        $entry = array();
        $entry["id"] = $id;
        $entry["flags"] = 0;

        if(strpos($fn,"S"))
            $entry["flags"] |= 1;
        $entry["mod"] = $stat["mtime"];

        return $entry;
    }

Here is the call graph for this function:

Here is the caller graph for this function:


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, inherited]

Definition at line 64 of file diffbackend.php.


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