mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 14:41:29 +01:00
* Generate well-formed XML for Funambol and SyncEvolution clients (community bug#2975)
This commit is contained in:
parent
816cae2dfa
commit
79fa226d83
@ -32,21 +32,13 @@ class Horde_SyncML_Command_Sync_ContentSyncElement extends Horde_SyncML_Command_
|
||||
}
|
||||
|
||||
$attrs = array();
|
||||
$strict_xml = strtolower($this->_contentFormat) == 'strictxml';
|
||||
$output->startElement($state->getURI(), $command, $attrs);
|
||||
|
||||
$output->startElement($state->getURI(), 'CmdID', $attrs);
|
||||
$output->characters($currentCmdID);
|
||||
$output->endElement($state->getURI(), 'CmdID');
|
||||
|
||||
/*
|
||||
if (isset($this->_contentType)) {
|
||||
$output->startElement($state->getURI(), 'Meta', $attrs);
|
||||
$output->startElement($state->getURIMeta(), 'Type', $attrs);
|
||||
$output->characters($this->_contentType);
|
||||
$output->endElement($state->getURIMeta(), 'Type');
|
||||
$output->endElement($state->getURI(), 'Meta');
|
||||
}
|
||||
*/
|
||||
if (isset($this->_content) && !$this->_moreData) {
|
||||
//$this->_content = trim($this->_content);
|
||||
$this->_contentSize = strlen($this->_content);
|
||||
@ -58,14 +50,15 @@ class Horde_SyncML_Command_Sync_ContentSyncElement extends Horde_SyncML_Command_
|
||||
}
|
||||
|
||||
// <command><Meta>
|
||||
if ($this->_contentSize || isset($this->_contentType) || isset($this->_contentFormat)) {
|
||||
if ($this->_contentSize || isset($this->_contentType) ||
|
||||
(!$strict_xml && isset($this->_contentFormat))) {
|
||||
$output->startElement($state->getURI(), 'Meta', $attrs);
|
||||
if (isset($this->_contentType)) {
|
||||
$output->startElement($state->getURIMeta(), 'Type', $attrs);
|
||||
$output->characters($this->_contentType);
|
||||
$output->endElement($state->getURIMeta(), 'Type');
|
||||
}
|
||||
if (isset($this->_contentFormat)) {
|
||||
if (!$strict_xml && isset($this->_contentFormat)) {
|
||||
$output->startElement($state->getURIMeta(), 'Format', $attrs);
|
||||
$output->characters($this->_contentFormat);
|
||||
$output->endElement($state->getURIMeta(), 'Format');
|
||||
@ -105,16 +98,15 @@ class Horde_SyncML_Command_Sync_ContentSyncElement extends Horde_SyncML_Command_
|
||||
// <command><Item><Data>
|
||||
if (isset($this->_content)) {
|
||||
$output->startElement($state->getURI(), 'Data', $attrs);
|
||||
#$chars = '<![CDATA['.$this->_content.']]>';
|
||||
$currentSize = $output->getOutputSize();
|
||||
Horde::logMessage("SyncML: $command: current = $currentSize, max = $maxMsgSize", __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
if (!$maxMsgSize ||
|
||||
(($currentSize + MIN_MSG_LEFT + $this->_contentSize) <= $maxMsgSize)) {
|
||||
(($currentSize + MIN_MSG_LEFT + $this->_contentSize + 12) <= $maxMsgSize)) {
|
||||
$chars = $this->_content;
|
||||
unset($this->_content);
|
||||
$this->_moreData = false;
|
||||
} else {
|
||||
$sizeLeft = $maxMsgSize - $currentSize - MIN_MSG_LEFT;
|
||||
$sizeLeft = $maxMsgSize - $currentSize - MIN_MSG_LEFT - 12;
|
||||
if ($sizeLeft < 0) {
|
||||
Horde::logMessage("SyncML: $command: split with $currentSize for $maxMsgSize, increase MIN_MSG_LEFT!", __FILE__, __LINE__, PEAR_LOG_WARNING);
|
||||
$sizeLeft = 0;
|
||||
@ -132,6 +124,9 @@ class Horde_SyncML_Command_Sync_ContentSyncElement extends Horde_SyncML_Command_
|
||||
. $chars, __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
||||
$this->_moreData = true;
|
||||
}
|
||||
if ($strict_xml) {
|
||||
$chars = '<![CDATA['. $chars. ']]>';
|
||||
}
|
||||
$output->characters($chars);
|
||||
$output->endElement($state->getURI(), 'Data');
|
||||
|
||||
@ -150,5 +145,4 @@ class Horde_SyncML_Command_Sync_ContentSyncElement extends Horde_SyncML_Command_
|
||||
|
||||
return $currentCmdID;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -838,6 +838,8 @@ class Horde_SyncML_State {
|
||||
$manufacturer = isset($deviceInfo['manufacturer']) ? strtolower($deviceInfo['manufacturer']) : 'unknown';
|
||||
switch ($manufacturer) {
|
||||
case 'funambol':
|
||||
// Funambol requires well-formed XML
|
||||
$res['ContentFormat'] = 'strictxml';
|
||||
switch (strtolower($deviceInfo['model'])) {
|
||||
case 'thunderbird':
|
||||
case 'mozilla plugin':
|
||||
@ -853,6 +855,9 @@ class Horde_SyncML_State {
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'patrick ohly':
|
||||
// SyncEvolution requires well-formed XML, too
|
||||
$res['ContentFormat'] = 'strictxml';
|
||||
default:
|
||||
$res['mayFragment'] = 1;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user