1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
|
<?php
require_once 'SyncML/Command.php';
require_once 'SyncML/Constants.php';
/**
* $Horde: framework/SyncML/SyncML/Command/Status.php,v 1.15.10.6 2006/01/31 17:55:19 jan Exp $
*
* Copyright 2003-2006 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 SyncML
*/
class SyncML_Command_Status extends SyncML_Command {
var $_response;
var $_cmdRef;
/**
* Must be present.
*/
var $_cmd;
var $_sourceRef;
var $_targetRef;
var $_chalMetaFormat;
var $_chalMetaType;
var $_chalMetaNextNonce;
var $_itemDataAnchorNext;
var $_itemDataAnchorLast;
function SyncML_Command_Status($response = null, $cmd = null)
{
if ($response != null) {
$this->_response = $response;
}
if ($cmd != null) {
$this->_cmd = $cmd;
}
}
function output($currentCmdID, &$output)
{
$attrs = array();
$state = &$_SESSION['SyncML.state'];
if ($this->_cmd != null) {
$attrs = array();
$output->startElement($state->getURI(), 'Status', $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(), 'Cmd', $attrs);
$chars = $this->_cmd;
$output->characters($chars);
$output->endElement($state->getURI(), 'Cmd');
if (isset($this->_targetRef)) {
$output->startElement($state->getURI(), 'TargetRef', $attrs);
$chars = $this->_targetRef;
$output->characters($chars);
$output->endElement($state->getURI(), 'TargetRef');
}
if (isset($this->_sourceRef)) {
$output->startElement($state->getURI(), 'SourceRef', $attrs);
$chars = $this->_sourceRef;
$output->characters($chars);
$output->endElement($state->getURI(), 'SourceRef');
}
// If we are responding to the SyncHdr and we are not
// authorized then request basic authorization.
//
// FIXME: Right now we always send this, ignoring the
// isAuthorized() test. Is that correct?
if ($this->_cmd == 'SyncHdr' && !$state->isAuthorized()) {
$this->_chalMetaFormat = 'b64';
$this->_chalMetaType = 'syncml:auth-basic';
$this->_response = RESPONSE_CREDENTIALS_MISSING;
}
if (isset($this->_chalMetaFormat) && isset($this->_chalMetaType)) {
$output->startElement($state->getURI(), 'Chal', $attrs);
$output->startElement($state->getURI(), 'Meta', $attrs);
$metainfuri = $state->getURIMeta();
$output->startElement($metainfuri, 'Type', $attrs);
$chars = $this->_chalMetaType;
$output->characters($chars);
$output->endElement($metainfuri, 'Type');
$output->startElement($metainfuri, 'Format', $attrs);
$chars = $this->_chalMetaFormat;
$output->characters($chars);
$output->endElement($metainfuri, 'Format');
$output->endElement($state->getURI(), 'Meta');
$output->endElement($state->getURI(), 'Chal');
}
$output->startElement($state->getURI(), 'Data', $attrs);
$chars = $this->_response;
$output->characters($chars);
$output->endElement($state->getURI(), 'Data');
if (isset($this->_itemDataAnchorNext) || isset($this->_itemDataAnchorLast)) {
$output->startElement($state->getURI(), 'Item', $attrs);
$output->startElement($state->getURI(), 'Data', $attrs);
$metainfuri = $state->getURIMeta();
$output->startElement($metainfuri, 'Anchor', $attrs);
if (isset($this->_itemDataAnchorLast)) {
$output->startElement($metainfuri, 'Last', $attrs);
$chars = $this->_itemDataAnchorLast;
$output->characters($chars);
$output->endElement($metainfuri, 'Last');
}
if (isset($this->_itemDataAnchorNext)) {
$output->startElement($metainfuri, 'Next', $attrs);
$chars = $this->_itemDataAnchorNext;
$output->characters($chars);
$output->endElement($metainfuri, 'Next');
}
$output->endElement($metainfuri, 'Anchor');
$output->endElement($state->getURI(), 'Data');
$output->endElement($state->getURI(), 'Item');
}
$output->endElement($state->getURI(), 'Status');
$currentCmdID++;
}
return $currentCmdID;
}
/**
* Setter for property response.
*
* @param string $response New value of property response.
*/
function setResponse($response)
{
$this->_response = $response;
}
/**
* Setter for property cmd.
*
* @param string $cmd New value of property cmd.
*/
function setCmd($cmd)
{
$this->_cmd = $cmd;
}
/**
* Setter for property cmdRef.
*
* @param string $cmdRef New value of property cmdRef.
*/
function setCmdRef($cmdRef)
{
$this->_cmdRef = $cmdRef;
}
/**
* Setter for property sourceRef.
*
* @param string $sourceRef New value of property sourceRef.
*/
function setSourceRef($sourceRef)
{
$this->_sourceRef = $sourceRef;
}
/**
* Setter for property targetRef.
*
* @param string $targetRef New value of property targetRef.
*/
function setTargetRef($targetRef)
{
$this->_targetRef = $targetRef;
}
/**
* Setter for property itemDataAnchorNext.
*
* @param string $itemDataAnchorNext New value of property itemDataAnchorNext.
*/
function setItemDataAnchorNext($itemDataAnchorNext)
{
$this->_itemDataAnchorNext = $itemDataAnchorNext;
}
/**
* Setter for property itemDataAnchorLast.
*
* @param string $itemDataAnchorLast New value of property itemDataAnchorLast.
*/
function setItemDataAnchorLast($itemDataAnchorLast)
{
$this->_itemDataAnchorLast = $itemDataAnchorLast;
}
}
|