Back to index

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

List of all members.

Public Member Functions

 SyncParameters ()
 SyncParameters constructor.
 GetSyncKey ()
 SyncKey methods.
 SetSyncKey ($synckey)
 Sets the the current synckey.
 HasSyncKey ()
 Indicates if this folder has a synckey.
 SetNewSyncKey ($synckey)
 Sets the the next synckey.
 GetNewSyncKey ()
 Returns the next synckey.
 HasNewSyncKey ()
 Indicates if the folder has a next synckey.
 GetLatestSyncKey ()
 Return the latest synckey.
 RemoveSyncKey ()
 Removes the saved SyncKey of this folder.
 GetCPO ($options=self::DEFAULTOPTIONS)
 CPO methods.
 UseCPO ($options=self::DEFAULTOPTIONS)
 Use the submitted CPO type for next setters/getters.
 __call ($name, $arguments)
 PHP magic to implement any getter, setter, has and delete operations on an instance variable.
 GetID ()
 Returns the unique id of that data object.
 GetDataArray ()
 Returns the internal array which contains all data of this object.
 SetDataArray ($data, $markAsChanged=false)
 Sets the internal array which contains all data of this object.
 IsDataChanged ()
 Indicates if the data contained in this object was modified.
 __set ($name, $value)
 PHP magic to set an instance variable.
 __get ($name)
 PHP magic to get an instance variable if the variable was not set previousely, the value of the Unsetdata array is returned.
 __isset ($name)
 PHP magic to check if an instance variable is set.
 __unset ($name)
 PHP magic to remove an instance variable.
 serialize ()
 Method to serialize a StateObject.
 unserialize ($data)
 Method to unserialize a StateObject.

Static Public Member Functions

static ThrowStateInvalidException ()
 Callback function for failed unserialize.

Public Attributes

const DEFAULTOPTIONS = "DEFAULT"
const SMSOPTIONS = "SMS"

Protected Member Functions

 preSerialize ()
 un/serialization methods
 postUnserialize ()
 Called after the StateObject was unserialized.

Protected Attributes

 $unsetdata
 $data = array()
 $changed = false

Private Member Functions

 checkCPO ($options=self::DEFAULTOPTIONS)
 Checks if a CPO is correctly inicialized and inicializes it if necessary.

Private Attributes

 $synckeyChanged = false
 $currentCPO = self::DEFAULTOPTIONS

Detailed Description

Definition at line 46 of file syncparameters.php.


Member Function Documentation

SyncParameters::__call ( name,
arguments 
)

PHP magic to implement any getter, setter, has and delete operations on an instance variable.

NOTICE: All magic getters and setters of this object which are not defined in the unsetdata array are passed to the current CPO.

Methods like e.g. "SetVariableName($x)" and "GetVariableName()" are supported

public

Returns:
mixed

Reimplemented from StateObject.

Definition at line 291 of file syncparameters.php.

                                              {
        $lowname = strtolower($name);
        $operator = substr($lowname, 0,3);
        $var = substr($lowname,3);

        if (array_key_exists($var, $this->unsetdata)) {
            return parent::__call($name, $arguments);
        }

        return $this->contentParameters[$this->currentCPO]->__call($name, $arguments);
    }
StateObject::__get ( name) [inherited]

PHP magic to get an instance variable if the variable was not set previousely, the value of the Unsetdata array is returned.

public

Returns:

Definition at line 120 of file stateobject.php.

                                 {
        $lname = strtolower($name);

        if (array_key_exists($lname, $this->data))
            return $this->data[$lname];

        if (isset($this->unsetdata) && is_array($this->unsetdata) && array_key_exists($lname, $this->unsetdata))
            return $this->unsetdata[$lname];

        return null;
    }
StateObject::__isset ( name) [inherited]

PHP magic to check if an instance variable is set.

public

Returns:

Definition at line 138 of file stateobject.php.

                                   {
        return isset($this->data[strtolower($name)]);
    }
StateObject::__set ( name,
value 
) [inherited]

PHP magic to set an instance variable.

public

Returns:

Definition at line 103 of file stateobject.php.

                                         {
        $lname = strtolower($name);
        if (isset($this->data[$lname]) && is_scalar($value) && !is_array($value) && $this->data[$lname] === $value)
            return false;

        $this->data[$lname] = $value;
        $this->changed = true;
    }
StateObject::__unset ( name) [inherited]

PHP magic to remove an instance variable.

public

Returns:

Definition at line 148 of file stateobject.php.

                                   {
        if (isset($this->$name)) {
            unset($this->data[strtolower($name)]);
            $this->changed = true;
        }
    }
SyncParameters::checkCPO ( options = self::DEFAULTOPTIONS) [private]

Checks if a CPO is correctly inicialized and inicializes it if necessary.

Parameters:
string$options(opt) If not specified, the default Options (CPO) will be used Valid option SyncParameters::SMSOPTIONS (string "SMS")

private

Returns:
boolean

Definition at line 270 of file syncparameters.php.

                                                             {
        if (!isset($this->contentParameters[$options])) {
            $a = $this->contentParameters;
            $a[$options] = new ContentParameters();
            $this->contentParameters = $a;
        }

        return true;
    }

Here is the caller graph for this function:

SyncParameters::GetCPO ( options = self::DEFAULTOPTIONS)

CPO methods.

A sync request can have several options blocks. Each block is saved into an own CPO object Returns the a specified CPO

Parameters:
string$options(opt) If not specified, the default Options (CPO) will be used Valid option SyncParameters::SMSOPTIONS (string "SMS")

public

Returns:
ContentParameters object

Definition at line 230 of file syncparameters.php.

                                                          {
        if ($options !== self::DEFAULTOPTIONS && $options !== self::SMSOPTIONS)
            throw new FatalNotImplementedException(sprintf("SyncParameters->GetCPO('%s') ContentParameters is invalid. Such type is not available.", $options));

        $this->checkCPO($options);

        // copy contentclass and conversationmode to the CPO
        $this->contentParameters[$options]->SetContentClass($this->contentclass);
        $this->contentParameters[$options]->SetConversationMode($this->conversationmode);

        return $this->contentParameters[$options];
    }

Here is the call graph for this function:

StateObject::GetDataArray ( ) [inherited]

Returns the internal array which contains all data of this object.

public

Returns:
array

Definition at line 69 of file stateobject.php.

                                   {
        return $this->data;
    }
StateObject::GetID ( ) [inherited]

Returns the unique id of that data object.

public

Returns:
array

Definition at line 56 of file stateobject.php.

                            {
        if (!isset($this->SO_internalid))
            $this->SO_internalid = sprintf('%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));

        return $this->SO_internalid;
    }

Here is the caller graph for this function:

Return the latest synckey.

When this is called the new key becomes the current key (if a new key is available). The current key is then returned.

public

Returns:
string

Definition at line 182 of file syncparameters.php.

                                       {
        // New becomes old
        if ($this->HasUuidNewCounter()) {
            $this->uuidCounter = $this->uuidNewCounter;
            unset($this->uuidNewCounter);
        }

        ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncParameters->GetLastestSyncKey(): '%s'", $this->GetSyncKey()));
        return $this->GetSyncKey();
    }

Here is the call graph for this function:

Returns the next synckey.

public

Returns:
string/boolean returns false if uuid or counter are not available

Definition at line 157 of file syncparameters.php.

                                    {
        if (isset($this->uuid) && isset($this->uuidNewCounter))
            return StateManager::BuildStateKey($this->uuid, $this->uuidNewCounter);

        return false;
    }

Here is the call graph for this function:

SyncKey methods.

The current and next synckey is saved as uuid and counter so partial and ping can access the latest states. Returns the latest SyncKey of this folder

public

Returns:
string/boolean false if no uuid/counter available

Definition at line 91 of file syncparameters.php.

                                 {
        if (isset($this->uuid) && isset($this->uuidCounter))
            return StateManager::BuildStateKey($this->uuid, $this->uuidCounter);

        return false;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Indicates if the folder has a next synckey.

public

Returns:
boolean

Definition at line 170 of file syncparameters.php.

                                    {
        return (isset($this->uuid) && isset($this->uuidNewCounter));
    }

Indicates if this folder has a synckey.

public

Returns:
booleans

Definition at line 123 of file syncparameters.php.

                                 {
        return (isset($this->uuid) && isset($this->uuidCounter));
    }

Here is the caller graph for this function:

StateObject::IsDataChanged ( ) [inherited]

Indicates if the data contained in this object was modified.

public

Returns:
array

Definition at line 93 of file stateobject.php.

                                    {
        return $this->changed;
    }

Called after the StateObject was unserialized.

protected

Returns:
boolean

Reimplemented from StateObject.

Definition at line 329 of file syncparameters.php.

                                         {
        // init with default options
        $this->UseCPO();

        return true;
    }

Here is the call graph for this function:

un/serialization methods

Called before the StateObject is serialized

protected

Returns:
boolean

Reimplemented from StateObject.

Definition at line 314 of file syncparameters.php.

                                      {
        parent::preSerialize();

        if ($this->changed === true && $this->synckeyChanged)
            $this->lastsynctime = time();

        return true;
    }

Removes the saved SyncKey of this folder.

public

Returns:
boolean

Definition at line 199 of file syncparameters.php.

                                    {
        if (isset($this->uuid))
            unset($this->uuid);

        if (isset($this->uuidCounter))
            unset($this->uuidCounter);

        if (isset($this->uuidNewCounter))
            unset($this->uuidNewCounter);

        ZLog::Write(LOGLEVEL_DEBUG, "SyncParameters->RemoveSyncKey(): saved sync key removed");
        return true;
    }

Here is the call graph for this function:

StateObject::serialize ( ) [inherited]

Method to serialize a StateObject.

public

Returns:
array

Definition at line 209 of file stateobject.php.

                                {
        // perform tasks just before serialization
        $this->preSerialize();

        return serialize(array($this->SO_internalid,$this->data));
    }

Here is the call graph for this function:

Here is the caller graph for this function:

StateObject::SetDataArray ( data,
markAsChanged = false 
) [inherited]

Sets the internal array which contains all data of this object.

Parameters:
array$datathe data to be written
boolean$markAsChanged(opt) indicates if the object should be marked as "changed", default false

public

Returns:
array

Definition at line 82 of file stateobject.php.

                                                                {
        $this->data = $data;
        $this->changed = $markAsChanged;
    }

Here is the caller graph for this function:

Sets the the next synckey.

This is done by parsing it and saving uuid and next counter. if the folder has no synckey until now (new sync), the next counter becomes current asl well.

Parameters:
string$synckeypublic
Exceptions:
FatalExceptionif the uuids of current and next do not match
Returns:
boolean

Definition at line 138 of file syncparameters.php.

                                            {
        list($uuid, $uuidNewCounter) = StateManager::ParseStateKey($synckey);
        if (!$this->HasSyncKey()) {
            $this->uuid = $uuid;
            $this->uuidCounter = $uuidNewCounter;
        }
        else if ($uuid !== $this->uuid)
            throw new FatalException("SyncParameters->SetNewSyncKey(): new SyncKey must have the same UUID as current SyncKey");

        $this->uuidNewCounter = $uuidNewCounter;
        $this->synckeyChanged = true;
    }

Here is the call graph for this function:

Sets the the current synckey.

This is done by parsing it and saving uuid and counter. By setting the current key, the "next" key is obsolete

Parameters:
string$synckeypublic
Returns:
boolean

Definition at line 108 of file syncparameters.php.

                                         {
        list($this->uuid, $this->uuidCounter) = StateManager::ParseStateKey($synckey);

        // remove newSyncKey
        unset($this->uuidNewCounter);

        return true;
    }

Here is the call graph for this function:

SyncParameters constructor.

Definition at line 72 of file syncparameters.php.

                                     {
        // initialize ContentParameters for the current option
        $this->checkCPO();
    }

Here is the call graph for this function:

static StateObject::ThrowStateInvalidException ( ) [static, inherited]

Callback function for failed unserialize.

public

Exceptions:
StateInvalidException

Definition at line 263 of file stateobject.php.

                                                        {
        throw new StateInvalidException("Unserialization failed as class was not found or not compatible");
    }
StateObject::unserialize ( data) [inherited]

Method to unserialize a StateObject.

public

Returns:
array
Exceptions:
StateInvalidException

Definition at line 223 of file stateobject.php.

                                       {
        // throw a StateInvalidException if unserialize fails
        ini_set('unserialize_callback_func', 'StateObject::ThrowStateInvalidException');

        list($this->SO_internalid, $this->data) = unserialize($data);

        // perform tasks just after unserialization
        $this->postUnserialize();
        return true;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

SyncParameters::UseCPO ( options = self::DEFAULTOPTIONS)

Use the submitted CPO type for next setters/getters.

Parameters:
string$options(opt) If not specified, the default Options (CPO) will be used Valid option SyncParameters::SMSOPTIONS (string "SMS")

public

Returns:

Definition at line 252 of file syncparameters.php.

                                                          {
        if ($options !== self::DEFAULTOPTIONS && $options !== self::SMSOPTIONS)
            throw new FatalNotImplementedException(sprintf("SyncParameters->UseCPO('%s') ContentParameters is invalid. Such type is not available.", $options));

        ZLOG::Write(LOGLEVEL_DEBUG, sprintf("SyncParameters->UseCPO('%s')", $options));
        $this->currentCPO = $options;
        $this->checkCPO($this->currentCPO);
    }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

StateObject::$changed = false [protected, inherited]

Definition at line 48 of file stateobject.php.

SyncParameters::$currentCPO = self::DEFAULTOPTIONS [private]

Definition at line 51 of file syncparameters.php.

StateObject::$data = array() [protected, inherited]

Definition at line 46 of file stateobject.php.

Definition at line 50 of file syncparameters.php.

Initial value:
 array(
                                    'uuid' => false,
                                    'uuidcounter' => false,
                                    'uuidnewcounter' => false,
                                    'folderid' => false,
                                    'referencelifetime' => 10,
                                    'lastsynctime' => false,
                                    'referencepolicykey' => true,
                                    'pingableflag' => false,
                                    'contentclass' => false,
                                    'deletesasmoves' => false,
                                    'conversationmode' => false,
                                    'windowsize' => 5,
                                    'contentparameters' => array()
                                )

Reimplemented from StateObject.

Definition at line 53 of file syncparameters.php.

const SyncParameters::DEFAULTOPTIONS = "DEFAULT"

Definition at line 47 of file syncparameters.php.

Definition at line 48 of file syncparameters.php.


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