2005-06-19 21:00:58 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
include_once 'Horde/SyncML/State.php';
|
|
|
|
include_once 'Horde/SyncML/Command.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* $Horde: framework/SyncML/SyncML/Command/Results.php,v 1.11 2004/07/02 19:24:44 chuck Exp $
|
|
|
|
*
|
|
|
|
* Copyright 2003-2004 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$
|
|
|
|
* @since Horde 3.0
|
|
|
|
* @package Horde_SyncML
|
|
|
|
*/
|
|
|
|
class Horde_SyncML_Command_Results extends Horde_SyncML_Command {
|
|
|
|
|
2006-08-15 16:42:13 +02:00
|
|
|
var $_cmdRef;
|
|
|
|
var $_type;
|
|
|
|
var $_data;
|
|
|
|
var $_locSourceURI;
|
|
|
|
var $_deviceInfo;
|
|
|
|
|
|
|
|
function endElement($uri, $element) {
|
2007-06-25 01:52:41 +02:00
|
|
|
#Horde::logMessage('SyncML: put endelement ' . $element . ' chars ' . $this->_chars, __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
2006-08-15 16:42:13 +02:00
|
|
|
|
|
|
|
switch ($this->_xmlStack) {
|
|
|
|
case 5:
|
|
|
|
switch($element) {
|
|
|
|
case 'DataStore':
|
|
|
|
$this->_deviceInfo['dataStore'][$this->_sourceReference] = array (
|
|
|
|
'maxGUIDSize' => $this->_maxGUIDSize,
|
|
|
|
'rxPreference' => $this->_rxPreference,
|
|
|
|
'txPreference' => $this->_txPreference,
|
|
|
|
'syncCapabilities' => $this->_syncCapabilities,
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'DevID':
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
$devid = trim($this->_chars);
|
|
|
|
$this->_deviceInfo['deviceID'] = $devid;
|
|
|
|
switch ($devid)
|
|
|
|
{
|
2007-06-25 01:52:41 +02:00
|
|
|
case 'fmz-thunderbird-plugin':
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
if (empty($this->_devinceInfo['manufacturer']))
|
|
|
|
$this->_deviceInfo['manufacturer'] = 'funambol';
|
|
|
|
if (empty($this->_devinceInfo['model']))
|
|
|
|
$this->_deviceInfo['model'] = 'thunderbird';
|
|
|
|
if (empty($this->_devinceInfo['softwareVersion']))
|
|
|
|
$this->_deviceInfo['softwareVersion'] = '0.3';
|
2007-06-25 01:52:41 +02:00
|
|
|
break;
|
|
|
|
}
|
2006-08-15 16:42:13 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'DevTyp':
|
|
|
|
$this->_deviceInfo['deviceType'] = trim($this->_chars);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'FwV':
|
|
|
|
$this->_deviceInfo['firmwareVersion'] = trim($this->_chars);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'HwV':
|
|
|
|
$this->_deviceInfo['hardwareVersion'] = trim($this->_chars);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Man':
|
|
|
|
$this->_deviceInfo['manufacturer'] = trim($this->_chars);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Mod':
|
|
|
|
$this->_deviceInfo['model'] = trim($this->_chars);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'OEM':
|
|
|
|
$this->_deviceInfo['oem'] = trim($this->_chars);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'SwV':
|
|
|
|
$this->_deviceInfo['softwareVersion'] = trim($this->_chars);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'SupportLargeObjs':
|
|
|
|
$this->_deviceInfo['supportLargeObjs'] = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'SupportNumberOfChanges':
|
|
|
|
$this->_deviceInfo['supportNumberOfChanges'] = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'UTC':
|
|
|
|
$this->_deviceInfo['UTC'] = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'VerDTD':
|
|
|
|
$this->_deviceInfo['DTDVersion'] = trim($this->_chars);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2005-06-19 21:00:58 +02:00
|
|
|
|
2006-08-15 16:42:13 +02:00
|
|
|
case 6:
|
|
|
|
switch($element) {
|
|
|
|
case 'MaxGUIDSize':
|
|
|
|
$this->_maxGUIDSize = trim($this->_chars);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Rx-Pref':
|
|
|
|
$this->_rxPreference = array (
|
|
|
|
'contentType' => $this->_contentType,
|
|
|
|
'contentVersion' => $this->_contentVersion,
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'SourceRef':
|
|
|
|
$this->_sourceReference = trim($this->_chars);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Tx-Pref':
|
|
|
|
$this->_txPreference = array(
|
|
|
|
'contentType' => $this->_contentType,
|
|
|
|
'contentVersion' => $this->_contentVersion,
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 7:
|
|
|
|
switch($element) {
|
|
|
|
case 'CTType':
|
|
|
|
$this->_contentType = trim($this->_chars);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'SyncType':
|
|
|
|
$this->_syncCapabilities[] = trim($this->_chars);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'VerCT':
|
|
|
|
$this->_contentVersion = trim($this->_chars);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2005-06-19 21:00:58 +02:00
|
|
|
|
2006-08-15 16:42:13 +02:00
|
|
|
parent::endElement($uri, $element);
|
|
|
|
}
|
|
|
|
|
|
|
|
function output($currentCmdID, &$output) {
|
|
|
|
if(!isset($this->_locSourceURI)) {
|
|
|
|
#Horde::logMessage('SyncML: BIG TODO!!!!!!!!!!!!!!!!!! parse reply', __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
|
|
|
$state = &$_SESSION['SyncML.state'];
|
|
|
|
|
|
|
|
$status = &new Horde_SyncML_Command_Status((($state->isAuthorized()) ? RESPONSE_OK : RESPONSE_INVALID_CREDENTIALS), 'Results');
|
|
|
|
$status->setCmdRef($this->_cmdID);
|
|
|
|
|
|
|
|
$ref = ($state->getVersion() == 0) ? './devinf10' : './devinf11';
|
|
|
|
|
|
|
|
$status->setSourceRef($ref);
|
|
|
|
|
|
|
|
if($state->isAuthorized()) {
|
|
|
|
if(count((array)$this->_deviceInfo) > 0) {
|
|
|
|
$state->setClientDeviceInfo($this->_deviceInfo);
|
|
|
|
$state->writeClientDeviceInfo();
|
|
|
|
}
|
2005-06-19 21:00:58 +02:00
|
|
|
}
|
2006-08-15 16:42:13 +02:00
|
|
|
|
|
|
|
return $status->output($currentCmdID, $output);
|
|
|
|
} else {
|
|
|
|
#Horde::logMessage('SyncML: BIG TODO!!!!!!!!!!!!!!!!!! generate reponse', __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
|
|
|
$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 so the WBXML
|
|
|
|
// will understand it.
|
|
|
|
$output->opaque($this->_data);
|
|
|
|
|
|
|
|
$output->endElement($state->getURI(), 'Data');
|
|
|
|
$output->endElement($state->getURI(), 'Item');
|
|
|
|
|
|
|
|
$output->endElement($state->getURI(), 'Results');
|
|
|
|
|
|
|
|
$currentCmdID++;
|
|
|
|
|
|
|
|
return $currentCmdID;
|
2005-06-19 21:00:58 +02:00
|
|
|
}
|
|
|
|
}
|
2006-08-15 16:42:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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;
|
2005-06-19 21:00:58 +02:00
|
|
|
}
|
|
|
|
}
|