<?php

include_once 'Horde/SyncML/State.php';
include_once 'Horde/SyncML/Command.php';

/**
 * $Horde: framework/SyncML/SyncML/ResultsSender.php,v 1.1.2.1 2005/07/07 14:59:00 chuck Exp $
 *
 * Copyright 2003-2005 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>
 * @since   Horde 3.0
 * @package Horde_SyncML
 */
class Horde_SyncML_ResultsSender  {

    var $_cmdRef;
    var $_type;
    var $_data;
    var $_locSourceURI;

    function output($currentCmdID, &$output)
    {
        $state = &$_SESSION['SyncML.state'];

        $attrs = array();
        $output->startElement($state->getURI(), 'Results', $attrs);

        $output->startElement($state->getURI(), 'CmdID', $attrs);
        $chars = $currentCmdID;
        $output->characters($chars);
        $output->endElement($state->getURI(), 'CmdID');

        $output->startElement($state->getURI(), 'MsgRef', $attrs);
        $chars = $state->getMsgID();
        $output->characters($chars);
        $output->endElement($state->getURI(), 'MsgRef');

        $output->startElement($state->getURI(), 'CmdRef', $attrs);
        $chars = $this->_cmdRef;
        $output->characters($chars);
        $output->endElement($state->getURI(), 'CmdRef');

        $output->startElement($state->getURI(), 'Meta', $attrs);
        $output->startElement($state->getURIMeta(), 'Type', $attrs);
        $output->characters($this->_type);
        $output->endElement($state->getURIMeta(), 'Type');
        $output->endElement($state->getURI(), 'Meta');

        $output->startElement($state->getURI(), 'Item', $attrs);
        $output->startElement($state->getURI(), 'Source', $attrs);
        $output->startElement($state->getURI(), 'LocURI', $attrs);
        $chars = $this->_locSourceURI;
        $output->characters($chars);
        $output->endElement($state->getURI(), 'LocURI');
        $output->endElement($state->getURI(), 'Source');

        $output->startElement($state->getURI(), 'Data', $attrs);

        // Need to send this information as opaque data.
        $output->opaque($this->_data);

        $output->endElement($state->getURI(), 'Data');
        $output->endElement($state->getURI(), 'Item');
        $output->endElement($state->getURI(), 'Results');

        $currentCmdID++;

        return $currentCmdID;
    }

    /**
     * Setter for property cmdRef.
     *
     * @param string $cmdRef  New value of property cmdRef.
     */
    function setCmdRef($cmdRef)
    {
        $this->_cmdRef = $cmdRef;
    }

    /**
     * Setter for property Type.
     *
     * @param string $type  New value of property type.
     */
    function setType($type)
    {
        $this->_type = $type;
    }

    /**
     * Setter for property data.
     *
     * @param string $data  New value of property data.
     */
    function setData($data)
    {
        $this->_data = $data;
    }

    /**
     * Setter for property locSourceURI.
     *
     * @param string $locSourceURI  New value of property locSourceURI.
     */
    function setlocSourceURI($locSourceURI)
    {
        $this->_locSourceURI = $locSourceURI;
    }

}
