Back to index

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

List of all members.

Public Member Functions

 ImportChangesStream (&$encoder, $class)
 Constructor of the StreamImporter.
 Config ($state, $flags=0)
 Implement interface - never used.
 GetState ()
 Reads and returns the current state.
 LoadConflicts ($contentparameters, $state)
 
Methods for to import contents
 ImportMessageChange ($id, $message)
 Imports a single message.
 ImportMessageDeletion ($id)
 Imports a deletion.
 ImportMessageReadFlag ($id, $flags)
 Imports a change in 'read' flag Can only be applied to SyncMail (Email) requests.
 ImportMessageMove ($id, $newfolder)
 ImportMessageMove is not implemented, as this operation can not be streamed to a WBXMLEncoder.
 ImportFolderChange ($folder)
 Imports a change on a folder.
 ImportFolderDeletion ($id, $parent=false)
 Imports a folder deletion.
 GetImportedMessages ()
 Returns the number of messages which were changed, deleted and had changed read status.

Private Attributes

 $encoder
 $objclass
 $seenObjects
 $importedMsgs

Detailed Description

Definition at line 44 of file streamimporter.php.


Member Function Documentation

ImportChangesStream::Config ( state,
flags = 0 
)

Implement interface - never used.

Implements IChanges.

Definition at line 69 of file streamimporter.php.

{ return true; }

Returns the number of messages which were changed, deleted and had changed read status.

public

Returns:
int

Definition at line 232 of file streamimporter.php.

                                          {
        return $this->importedMsgs;
    }

Reads and returns the current state.

public

Returns:
string

Implements IChanges.

Definition at line 70 of file streamimporter.php.

{ return false;}
ImportChangesStream::ImportChangesStream ( &$  encoder,
class 
)

Constructor of the StreamImporter.

Parameters:
WBXMLEncoder$encoderObjects are streamed to this encoder
SyncObject$classSyncObject class (only these are accepted when streaming content messages)

public

Definition at line 58 of file streamimporter.php.

                                                           {
        $this->encoder = &$encoder;
        $this->objclass = $class;
        $this->classAsString = (is_object($class))?get_class($class):'';
        $this->seenObjects = array();
        $this->importedMsgs = 0;
    }

Imports a change on a folder.

Parameters:
object$folderSyncFolder

public

Returns:
string id of the folder

Implements IImportChanges.

Definition at line 188 of file streamimporter.php.

                                                {
        // checks if the next message may cause a loop or is broken
        if (ZPush::GetDeviceManager(false) && ZPush::GetDeviceManager()->DoNotStreamMessage($folder->serverid, $folder)) {
            ZLog::Write(LOGLEVEL_DEBUG, sprintf("ImportChangesStream->ImportFolderChange('%s'): folder ignored as requested by DeviceManager.", $folder->serverid));
            return true;
        }

        // send a modify flag if the folder is already known on the device
        if (isset($folder->flags) && $folder->flags === SYNC_NEWMESSAGE)
            $this->encoder->startTag(SYNC_FOLDERHIERARCHY_ADD);
        else
            $this->encoder->startTag(SYNC_FOLDERHIERARCHY_UPDATE);

        $folder->Encode($this->encoder);
        $this->encoder->endTag();

        return true;
    }

Here is the call graph for this function:

ImportChangesStream::ImportFolderDeletion ( id,
parent = false 
)

Imports a folder deletion.

Parameters:
string$id
string$parentid

public

Returns:
boolean

Implements IImportChanges.

Definition at line 216 of file streamimporter.php.

                                                               {
        $this->encoder->startTag(SYNC_FOLDERHIERARCHY_REMOVE);
            $this->encoder->startTag(SYNC_FOLDERHIERARCHY_SERVERENTRYID);
                $this->encoder->content($id);
            $this->encoder->endTag();
        $this->encoder->endTag();

        return true;
    }
ImportChangesStream::ImportMessageChange ( id,
message 
)

Imports a single message.

Parameters:
string$id
SyncObject$messagepublic
Returns:
boolean

Implements IImportChanges.

Definition at line 82 of file streamimporter.php.

                                                       {
        // ignore other SyncObjects
        if(!($message instanceof $this->classAsString))
            return false;

        // prevent sending the same object twice in one request
        if (in_array($id, $this->seenObjects)) {
            ZLog::Write(LOGLEVEL_DEBUG, sprintf("Object '%s' discarded! Object already sent in this request.", $id));
            return true;
        }

        $this->importedMsgs++;
        $this->seenObjects[] = $id;

        // checks if the next message may cause a loop or is broken
        if (ZPush::GetDeviceManager(false) && ZPush::GetDeviceManager()->DoNotStreamMessage($id, $message)) {
            ZLog::Write(LOGLEVEL_DEBUG, sprintf("ImportChangesStream->ImportMessageChange('%s'): message ignored and requested to be removed from mobile", $id));
            return $this->ImportMessageDeletion($id);
        }

        if ($message->flags === false || $message->flags === SYNC_NEWMESSAGE)
            $this->encoder->startTag(SYNC_ADD);
        else
            $this->encoder->startTag(SYNC_MODIFY);

            $this->encoder->startTag(SYNC_SERVERENTRYID);
                $this->encoder->content($id);
            $this->encoder->endTag();
            $this->encoder->startTag(SYNC_DATA);
                $message->Encode($this->encoder);
            $this->encoder->endTag();
        $this->encoder->endTag();

        return true;
    }

Here is the call graph for this function:

Imports a deletion.

Parameters:
string$idpublic
Returns:
boolean

Implements IImportChanges.

Definition at line 126 of file streamimporter.php.

                                               {
        $this->importedMsgs++;
        $this->encoder->startTag(SYNC_REMOVE);
            $this->encoder->startTag(SYNC_SERVERENTRYID);
                $this->encoder->content($id);
            $this->encoder->endTag();
        $this->encoder->endTag();

        return true;
    }

Here is the caller graph for this function:

ImportChangesStream::ImportMessageMove ( id,
newfolder 
)

ImportMessageMove is not implemented, as this operation can not be streamed to a WBXMLEncoder.

Parameters:
string$id
int$flagsread/unread

public

Returns:
boolean

Implements IImportChanges.

Definition at line 176 of file streamimporter.php.

                                                       {
        return true;
    }

Imports a change in 'read' flag Can only be applied to SyncMail (Email) requests.

Parameters:
string$id
int$flags- read/unread

public

Returns:
boolean

Implements IImportChanges.

Definition at line 147 of file streamimporter.php.

                                                       {
        if(!($this->objclass instanceof SyncMail))
            return false;

        $this->importedMsgs++;

        $this->encoder->startTag(SYNC_MODIFY);
            $this->encoder->startTag(SYNC_SERVERENTRYID);
                $this->encoder->content($id);
            $this->encoder->endTag();
            $this->encoder->startTag(SYNC_DATA);
                $this->encoder->startTag(SYNC_POOMMAIL_READ);
                    $this->encoder->content($flags);
                $this->encoder->endTag();
            $this->encoder->endTag();
        $this->encoder->endTag();

        return true;
    }
ImportChangesStream::LoadConflicts ( contentparameters,
state 
)


Methods for to import contents

Loads objects which are expected to be exported with the state Before importing/saving the actual message from the mobile, a conflict detection should be done

Parameters:
ContentParameters$contentparameters
string$statepublic
Returns:
boolean
Exceptions:
StatusException

Implements IImportChanges.

Definition at line 71 of file streamimporter.php.

{ return true; }

Member Data Documentation

Definition at line 45 of file streamimporter.php.

Definition at line 48 of file streamimporter.php.

Definition at line 46 of file streamimporter.php.

Definition at line 47 of file streamimporter.php.


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