[prev in list] [next in list] [prev in thread] [next in thread] 

List:       horde-sync
Subject:    [sync] last syncml command class
From:       Anthony Mills <amills () gascard ! net>
Date:       2003-12-20 11:16:12
Message-ID: 20031220051612.qyfscokw8kkkg4ks () online ! gascard ! net
[Download RAW message or body]

This message is in MIME format.


I put these files in this directory horde/framework/RPC/RPC/syncml_command.
Feel free to move them around.  The factory can be rewritten to use file names
instead of a switch statement.  The elements are case sensitive.

Anthony


["sync.txt" (text/plain)]

<?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@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@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 extends Horde_RPC_syncml_command {
    
    
    var $_isInSource;
    
    
    var $_targetURI;
    
    
    var $_sourceURI;

    
    var $_currentSyncElement;
    
    
    var $_syncElements;
    
    
    function outputStatus($currentCmdID, $output)
    {
        $status = &new Horde_RPC_syncml_command_Status(RESPONSE_OK, 'Sync');
        $status->setVersion(version);
        $status->setCmdRef(cmdID);
        $status->setMsgID(msgID);
        
        if ($this->_targetURI != null)
            $status->setTargetRef($this->_targetURI);
        
        if ($this->_sourceURI != null)
            $status->setSourceRef($this->_sourceURI);
        
        return $status->output($currentCmdID, $output);
    }
        
    function output($currentCmdID, $output)
    {
        attrs = array();
        
        $output->startElement(uri, 'Sync', $attrs);

        $output->startElement(uri, 'CmdID', $attrs);
        $chars = (new String(currentCmdID + '')).toCharArray();
        $output->characters(chars, 0, chars.length);
        $output->endElement(uri, 'CmdID');

        $output->startElement(uri, 'Target', $attrs);
        $output->startElement(uri, 'LocURI', $attrs);
        $chars = (new String(sourceURI + '')).toCharArray();
        $output->characters(chars, 0, chars.length);
        $output->endElement(uri, 'LocURI');
        $output->endElement(uri, 'Target');
        
        $output->startElement(uri, 'Source', $attrs);
        $output->startElement(uri, 'LocURI', $attrs);
        $chars = (new String(targetURI + '')).toCharArray();
        $output->characters(chars, 0, chars.length);
        $output->endElement(uri, 'LocURI');
        $output->endElement(uri, 'Source');
   
        $output->startElement(uri, 'NumberOfChanged', $attrs);
        $chars = (new String(syncElements.size() + '')).toCharArray();
        $output->characters(chars, 0, chars.length);
        $output->endElement(uri, 'NumberOfChanged');
   
        $output->endElement(uri, 'Sync');
        
        $currentCmdID++;
        
        return $currentCmdID;
    }

/*    
    function startSync(int currentCmdID, ContentHandler contentHandler, ErrorHandler \
errorHandler) throws SAXException {  return currentCmdID;
    }
    
    function endSync(int currentCmdID, ContentHandler contentHandler, ErrorHandler \
errorHandler) throws SAXException {  return currentCmdID;
    }
    
    public Iterator getSyncElements() {
        return syncElements.iterator();
    }
*/
    
    function getTargetURI() {
        return $this->_targetURI;
    }
    
    function startElement($uri, $element, $attrs)
    {            
        parent::startElement($uri, $element, $attrs);
        
        if ($this->_currentSyncElement != null)
            $this->_currentSyncElement.startElement($uri, $element, $attrs);
        
        switch ($this->_currentElementLevel) {
            case 2:                
                if ($element = 'Replace' || $element = 'Add' || $element = 'Atomic'
                    || $element = 'Copy' || $element = 'Delete' || $element = \
                'Sequence') {
                    $this->_currentSyncElement = \
                SyncElementFactory::newInstance($this->_element);
                    $this->_currentSyncElement.setVersion($this->_version);
                    $this->_currentSyncElement.setCmdRef($this->_cmdID);
                    $this->_currentSyncElement.setMsgID($this->_msgID);
                    
                } else if ($element == 'Target') {
                    $this->_isInSource = false;
                } else {
                    $this->_isInSource = true;
                }
                break;
        }                
    }

    function endElement($uri, $element)
    {        
        switch ($this->_currentElementLevel) {
            case 2:
                if ($element = 'Replace' || $element = 'Add' || $element = 'Atomic'
                    || $element = 'Copy' || $element = 'Delete' || $element = \
'Sequence') {  //syncElements.add(currentSyncElement);
                    
                }
                break;                
            case 3:
                if ($element = 'LocURI') {
                    if ($this->_isInSource)
                        $this->_sourceURI = trim($this->_chars);
                    else
                        $this->_targetURI = trim($this->_chars);
                }
                break;
        }

        if ($this->_currentSyncElement != null)
            $this->_currentSyncElement->endElement($uri, $element);

        parent::endElement($uri, $element);
    }  
    
    
    function characters($str)
    {
        if ($this->_currentSyncElement != null) {
            $this->_currentSyncElement->characters($str);
        } else {
            if (isset($this->_chars)) {
                $this->_chars = $this->_chars . $str;
            }
        }
    }

}
?>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic