[sync] More Syncml Sync Subcommands

Anthony Mills amills at gascard.net
Sat Dec 20 11:47:27 PST 2003


Here are the classes for the Sync sub commands.  These files I put in
framework/RPC/RPC/syncml_command/sync.

Anthony
-------------- next part --------------
<?php

include_once 'Horde/RPC/syncml_state.php';

/**
 * The Horde_RPC_syncml_command class provides a SyncML implementation of the
 * Horde RPC system.
 *
 * $Horde: framework/RPC/RPC/syncml.php,v 1.6 2003/12/17 16:02:44 chuck Exp $
 *
 * Copyright 2003 Anthony Mills <amills at pyramid6.com>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 *
 * @author  Anthony Mills <amills at pyramid6.com>
 * @version $Revision: 1.6 $
 * @since   Horde 3.0
 * @package Horde_RPC
 */
 
 /**
  * All variables are from the client standpoint.
  *
  *
  */
class Horde_RPC_syncml_command_sync_Copy extends Horde_RPC_syncml_command_sync_Sync {
    
}

?>
-------------- next part --------------
<?php

include_once 'Horde/RPC/syncml_state.php';

/**
 * The Horde_RPC_syncml_command class provides a SyncML implementation of the
 * Horde RPC system.
 *
 * $Horde: framework/RPC/RPC/syncml.php,v 1.6 2003/12/17 16:02:44 chuck Exp $
 *
 * Copyright 2003 Anthony Mills <amills at pyramid6.com>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 *
 * @author  Anthony Mills <amills at pyramid6.com>
 * @version $Revision: 1.6 $
 * @since   Horde 3.0
 * @package Horde_RPC
 */
 
 /**
  * All variables are from the client standpoint.
  *
  *
  */
class Horde_RPC_syncml_command_sync_Delete extends Horde_RPC_syncml_command_sync_SyncElement {
    
}

?>
-------------- next part --------------
<?php

include_once 'Horde/RPC/syncml_state.php';

/**
 * The Horde_RPC_syncml_command class provides a SyncML implementation of the
 * Horde RPC system.
 *
 * $Horde: framework/RPC/RPC/syncml.php,v 1.6 2003/12/17 16:02:44 chuck Exp $
 *
 * Copyright 2003 Anthony Mills <amills at pyramid6.com>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 *
 * @author  Anthony Mills <amills at pyramid6.com>
 * @version $Revision: 1.6 $
 * @since   Horde 3.0
 * @package Horde_RPC
 */
 
 /**
  * All variables are from the client standpoint.
  *
  *
  */
class Horde_RPC_syncml_command_sync_Replace extends Horde_RPC_syncml_command_sync_Sync {
    function endElement($uri, $element)
    {        
        switch ($this->_xmlStack) {
            case 2:
                if ($element == 'Type') {
                    //$this->_content = ContentFactory::newInstance($this->_chars);
                } else if ($element == 'Data') {
                    $str = trim($this->_chars);
                    if ($str !== '') {
                        $this->_content->setBytes($str);
                    }
                }
                    
                break;
            case 3:
                if ($element == 'LocURI') {
                    $this->_content->setProperty('SyncML.Source', trim($this->_chars));
                }
                break;
        }
        
        $super->endElement($uri, $element);
    }   
    
    function output($currentCmdID, $output)
    {
        $status = &new Horde_RPC_syncml_command_Status(RESPONSE_ITEM_ADDED, 'Replace');
        $status->setVersion($this->_version);
        $status->setCmdRef($this->_cmdID);
        $status->setMsgID($this->_msgID);
        
        if ($this->_luid != null)
            $status->setSourceRef($this->_luid);
                
        return $status->output($currentCmdID, $output);
    }        

/*    
    public void opaque(byte[] bytes) throws org.xml.sax.SAXException {
        System.err.println('Replace.opaque: content.setBytes(): ' + content);
        if (content != null) {
            try {
                content.setBytes(bytes);
            } catch (ContentException ce) {
                throw new org.xml.sax.SAXException(ce.toString());
            }
        }
        //does nothing
    }
*/
}
-------------- next part --------------
<?php

include_once 'Horde/RPC/syncml_state.php';

/**
 * The Horde_RPC_syncml_command class provides a SyncML implementation of the
 * Horde RPC system.
 *
 * $Horde: framework/RPC/RPC/syncml.php,v 1.6 2003/12/17 16:02:44 chuck Exp $
 *
 * Copyright 2003 Anthony Mills <amills at pyramid6.com>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 *
 * @author  Anthony Mills <amills at pyramid6.com>
 * @version $Revision: 1.6 $
 * @since   Horde 3.0
 * @package Horde_RPC
 */
 
 /**
  * All variables are from the client standpoint.
  *
  *
  */
class Horde_RPC_syncml_command_sync_Sequence extends Horde_RPC_syncml_command_sync_SyncElement {
    
}

?>
-------------- next part --------------
<?php

include_once 'Horde/RPC/syncml_state.php';

/**
 * The Horde_RPC_syncml_command class provides a SyncML implementation of the
 * Horde RPC system.
 *
 * $Horde: framework/RPC/RPC/syncml.php,v 1.6 2003/12/17 16:02:44 chuck Exp $
 *
 * Copyright 2003 Anthony Mills <amills at pyramid6.com>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 *
 * @author  Anthony Mills <amills at pyramid6.com>
 * @version $Revision: 1.6 $
 * @since   Horde 3.0
 * @package Horde_RPC
 */
 
 /**
  * All variables are from the client standpoint.
  *
  *
  */
class Horde_RPC_syncml_command_sync_Sync extends Horde_RPC_syncml_command_sync_SyncElement {
    var $_content;
    
    var $_charset;
    
    function getCharset()
    {
        return $_charset;
    }
    
    function setCharset($charset)
    {
        $this->_charset = $charset;
    }
    
    function getContent() {
        return $content;
    }
    
    function setContent($content) {
        $this->_content = $content;
    }
    
}
-------------- next part --------------
<?php

include_once 'Horde/RPC/syncml_state.php';

/**
 * The Horde_RPC_syncml_command class provides a SyncML implementation of the
 * Horde RPC system.
 *
 * $Horde: framework/RPC/RPC/syncml.php,v 1.6 2003/12/17 16:02:44 chuck Exp $
 *
 * Copyright 2003 Anthony Mills <amills at pyramid6.com>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 *
 * @author  Anthony Mills <amills at pyramid6.com>
 * @version $Revision: 1.6 $
 * @since   Horde 3.0
 * @package Horde_RPC
 */
 
 /**
  * All variables are from the client standpoint.
  *
  *
  */
class Horde_RPC_syncml_command_sync_SyncElement {
    
    var $_cmlStack;
    
    var $_chars;
    
    var $_luid;
    
    var $_guid;
    
    var $_isSource;
    
    var $_cmdID;
    
    var $_msgID;
    
    var $_version;
    
    function startElement($uri, $element, $attrs)
    {            
        $this->xmlStack++;
        
        switch($this->_xmlStack) {
            case 2:
                if ($element = 'Source') {
                    $this->_isSource = true;
                }
                break;
        }
    }

    function endElement($uri, $element)
    {
        switch($this->_xmlStack) {
            case 2:
                if ($element = 'Source') {
                    $this->_isSource = false;
                }
                break;
            case 3:
                if ($element = 'LocURI') && $this->_isSource) {
                    $this->_luid = trim($this->_chars);
                }
                break;
        }
         
        
        if (isset($this->_chars))
            unset($this->_chars);
        
        $this->_xmlStack--;
    }        
    
    //from ContentHandler
    function characters($chars)
    {
        if (!isset($this->_chars))
            $this->_chars = '';
        
        $this->_chars . = $str;
    }

    
    function output($currentCmdID, $output) 
    {
        return $currentCmdID;
    }
    
    function getLUID() {
        return $this->_luid;
    }
    
    function getGUID() {
        return $this->_guid;
    }
    
    function setLUID($luid) {
        $this->_luid = $luid;
    }
    
    function setGUID($guid) {
        $this->_guid = $guid;
    }
    
    /** Getter for property cmdID.
     * @return Value of property cmdID.
     *
     */
    function getCmdRef() {
        return $this->_cmdID;
    }    
    
    /** Setter for property cmdID.
     * @param cmdID New value of property cmdID.
     *
     */
    function setCmdRef($cmdID) {
        $this->_cmdID = $cmdID;
    }
    
    /** Getter for property msgID.
     * @return Value of property msgID.
     *
     */
    function getMsgID() {
        return $msgID;
    }
    
    /** Setter for property msgID.
     * @param msgID New value of property msgID.
     *
     */
    function setMsgID($msgID) {
        $this->_msgID = $msgID;
    }
    
    /** Getter for property version.
     * @return Value of property version.
     *
     */
    function getVersion() {
        return $version;
    }
    
    /** Setter for property version.
     * @param version New value of property version.
     *
     */
    function setVersion($version) {
        $this->_version = $version;
    }
    
}

?>
-------------- next part --------------
/*
 * CommandFactory.java
 *
 * Creat<?php

include_once 'Horde/RPC/syncml_state.php';

/**
 * The Horde_RPC_syncml_command class provides a SyncML implementation of the
 * Horde RPC system.
 *
 * $Horde: framework/RPC/RPC/syncml.php,v 1.6 2003/12/17 16:02:44 chuck Exp $
 *
 * Copyright 2003 Anthony Mills <amills at pyramid6.com>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 *
 * @author  Anthony Mills <amills at pyramid6.com>
 * @version $Revision: 1.6 $
 * @since   Horde 3.0
 * @package Horde_RPC
 */
 
 /**
  * All variables are from the client standpoint.
  *
  *
  */

class Horde_RPC_syncml_command_sync_SyncElementFactory {
    
    function newInstance($cmd) {
        if ($cmd == 'Add') {
            return &new Horde_RPC_syncml_command_sync_Add();
        } else if ($cmd == 'Atomic') {
            return &new Horde_RPC_syncml_command_sync_Atomic();
        } else if ($cmd == 'Copy') {
            return &new Horde_RPC_syncml_command_sync_Copy();
        } else if ($cmd == 'Delete') {
            return &new Horde_RPC_syncml_command_sync_Delete();
        } else if ($cmd == 'Sequence') {
            return &new Horde_RPC_syncml_command_sync_Sequence();
        } else if ($cmd == 'Replace') {
            return &new Horde_RPC_syncml_command_sync_Replace();
        } else {
            return null;
        }
    }
    
}

?>


More information about the sync mailing list