Fix various issues introduced with Funambol adjustments; code cleanup

This commit is contained in:
Jörg Lehrke 2010-01-10 19:02:16 +00:00
parent 70aee0a67d
commit 548f5f8c98
4 changed files with 308 additions and 264 deletions

View File

@ -219,6 +219,12 @@ class addressbook_vcal extends addressbook_bo
{
$size = $this->clientProperties[$vcardField]['Size'];
$noTruncate = $this->clientProperties[$vcardField]['NoTruncate'];
if ($this->log && $size > 0)
{
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
"() $vcardField Size: $size, NoTruncate: " .
($noTruncate ? 'TRUE' : 'FALSE') . "\n",3,$this->logfile);
}
//Horde::logMessage("vCalAddressbook $vcardField Size: $size, NoTruncate: " .
// ($noTruncate ? 'TRUE' : 'FALSE'), __FILE__, __LINE__, PEAR_LOG_DEBUG);
}
@ -292,7 +298,11 @@ class addressbook_vcal extends addressbook_bo
$value = $values[0];
if (strlen($value) > $size)
{
error_log(__FILE__ . __LINE__ . __METHOD__ . " vCalAddressbook $vcardField omitted due to maximum size $size");
if ($this->log)
{
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
"() $vcardField omitted due to maximum size $size\n",3,$this->logfile);
}
// Horde::logMessage("vCalAddressbook $vcardField omitted due to maximum size $size",
// __FILE__, __LINE__, PEAR_LOG_WARNING);
continue;
@ -332,7 +342,11 @@ class addressbook_vcal extends addressbook_bo
{
if ($noTruncate)
{
error_log(__FILE__ . __LINE__ . __METHOD__ . " vCalAddressbook $vcardField omitted due to maximum size $size");
if ($this->log)
{
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
"() $vcardField omitted due to maximum size $size\n",3,$this->logfile);
}
// Horde::logMessage("vCalAddressbook $vcardField omitted due to maximum size $size",
// __FILE__, __LINE__, PEAR_LOG_WARNING);
continue;
@ -348,7 +362,11 @@ class addressbook_vcal extends addressbook_bo
{
$value = '';
}
error_log(__FILE__ . __LINE__ . __METHOD__ . " vCalAddressbook $vcardField truncated to maximum size $size");
if ($this->log)
{
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
"() $vcardField truncated to maximum size $size\n",3,$this->logfile);
}
//Horde::logMessage("vCalAddressbook $vcardField truncated to maximum size $size",
// __FILE__, __LINE__, PEAR_LOG_INFO);
}
@ -371,10 +389,6 @@ class addressbook_vcal extends addressbook_bo
}
elseif ($this->productManufacturer == 'funambol')
{
if ($this->productName == 'mozilla sync client')
{
$valueData = str_replace( "\n", '\\n', $valueData);
}
$options['ENCODING'] = 'FUNAMBOL-QP';
}
elseif (preg_match('/([\000-\012\015\016\020-\037\075])/', $value))
@ -683,8 +697,6 @@ class addressbook_vcal extends addressbook_bo
// E.g. ADR will be either ADR;WORK, if no ADR;WORK is given,
// or else ADR;HOME, if not available elsewhere.
//error_log(print_r($rowNames, true));
$finalRowNames = array();
foreach ($rowNames as $vcardKey => $rowName)
@ -836,9 +848,6 @@ class addressbook_vcal extends addressbook_bo
array2string($finalRowNames)."\n",3,$this->logfile);
}
//error_log(print_r($finalRowNames, true));
$contact = array();
foreach ($finalRowNames as $key => $vcardKey)

View File

@ -583,8 +583,14 @@ class calendar_ical extends calendar_boupdate
{
$size = $this->clientProperties[$icalFieldName]['Size'];
$noTruncate = $this->clientProperties[$icalFieldName]['NoTruncate'];
#Horde::logMessage("vCalendar $icalFieldName Size: $size, NoTruncate: " .
# ($noTruncate ? 'TRUE' : 'FALSE'), __FILE__, __LINE__, PEAR_LOG_DEBUG);
if ($this->log && $size > 0)
{
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
"() $icalFieldName Size: $size, NoTruncate: " .
($noTruncate ? 'TRUE' : 'FALSE') . "\n",3,$this->logfile);
}
//Horde::logMessage("vCalendar $icalFieldName Size: $size, NoTruncate: " .
// ($noTruncate ? 'TRUE' : 'FALSE'), __FILE__, __LINE__, PEAR_LOG_DEBUG);
}
else
{
@ -597,14 +603,24 @@ class calendar_ical extends calendar_boupdate
{
if ($noTruncate)
{
Horde::logMessage("vCalendar $icalFieldName omitted due to maximum size $size",
__FILE__, __LINE__, PEAR_LOG_WARNING);
if ($this->log)
{
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
"() $icalFieldName omitted due to maximum size $size\n",3,$this->logfile);
}
//Horde::logMessage("vCalendar $icalFieldName omitted due to maximum size $size",
// __FILE__, __LINE__, PEAR_LOG_WARNING);
continue; // skip field
}
// truncate the value to size
$value = substr($value, 0, $size - 1);
Horde::logMessage("vCalendar $icalFieldName truncated to maximum size $size",
__FILE__, __LINE__, PEAR_LOG_INFO);
if ($this->log)
{
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
"() $icalFieldName truncated to maximum size $size\n",3,$this->logfile);
}
//Horde::logMessage("vCalendar $icalFieldName truncated to maximum size $size",
// __FILE__, __LINE__, PEAR_LOG_INFO);
}
if (!empty($value) || ($size >= 0 && !$noTruncate))
{
@ -706,12 +722,11 @@ class calendar_ical extends calendar_boupdate
$GLOBALS['egw']->translation->charset(),'UTF-8');
$valuesData = (array) $GLOBALS['egw']->translation->convert($values[$key],
$GLOBALS['egw']->translation->charset(),'UTF-8');
//echo "$key:$valueID: value=$valueData, param=".print_r($paramDate,true)."\n";
// attendees or organizer CN can contain utf-8 content
$paramData['CHARSET'] = 'UTF-8';
if (preg_match('/[^\x20-\x7F]/', $valueData) ||
($paramData['CN'] && preg_match('/[^\x20-\x7F]/', $paramData['CN'])))
{
$paramData['CHARSET'] = 'UTF-8';
switch ($this->productManufacturer)
{
case 'groupdav':
@ -733,13 +748,10 @@ class calendar_ical extends calendar_boupdate
}
break;
case 'funambol':
if ($this->productName == 'mozilla sync client')
{
$valueData = str_replace( "\n", '\\n', $valueData);
}
$paramData['ENCODING'] = 'FUNAMBOL-QP';
}
}
/*
if (preg_match('/([\000-\012])/', $valueData))
{
if ($this->log)
@ -748,6 +760,7 @@ class calendar_ical extends calendar_boupdate
"() Has invalid XML data: $valueData",3,$this->logfile);
}
}
*/
$vevent->setAttribute($key, $valueData, $paramData, true, $valuesData);
}
}
@ -1334,7 +1347,6 @@ class calendar_ical extends calendar_boupdate
'owner' => 'owner',
'category' => 'category',
'non_blocking' => 'non_blocking',
'recurrence' => 'recurrence',
);
$defaultFields['evolution'] = $defaultFields['basic'] + array(

View File

@ -170,8 +170,14 @@ class infolog_ical extends infolog_bo
{
$size = $this->clientProperties[$field]['Size'];
$noTruncate = $this->clientProperties[$field]['NoTruncate'];
#Horde::logMessage("VTODO $field Size: $size, NoTruncate: " .
# ($noTruncate ? 'TRUE' : 'FALSE'), __FILE__, __LINE__, PEAR_LOG_DEBUG);
if ($this->log && $size > 0)
{
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
"() $field Size: $size, NoTruncate: " .
($noTruncate ? 'TRUE' : 'FALSE') . "\n",3,$this->logfile);
}
//Horde::logMessage("VTODO $field Size: $size, NoTruncate: " .
// ($noTruncate ? 'TRUE' : 'FALSE'), __FILE__, __LINE__, PEAR_LOG_DEBUG);
}
else
{
@ -183,30 +189,40 @@ class infolog_ical extends infolog_bo
{
if ($noTruncate)
{
Horde::logMessage("VTODO $field omitted due to maximum size $size",
__FILE__, __LINE__, PEAR_LOG_WARNING);
if ($this->log)
{
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
"() $field omitted due to maximum size $size\n",3,$this->logfile);
}
//Horde::logMessage("VTODO $field omitted due to maximum size $size",
// __FILE__, __LINE__, PEAR_LOG_WARNING);
continue; // skip field
}
// truncate the value to size
$value = substr($value, 0, $size -1);
#Horde::logMessage("VTODO $field truncated to maximum size $size",
# __FILE__, __LINE__, PEAR_LOG_INFO);
if ($this->log)
{
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
"() $field truncated to maximum size $size\n",3,$this->logfile);
}
//Horde::logMessage("VTODO $field truncated to maximum size $size",
// __FILE__, __LINE__, PEAR_LOG_INFO);
}
if (empty($value) && ($size < 0 || $noTruncate)) continue;
if ($field == 'RELATED-TO')
{
$options = array('RELTYPE' => 'PARENT',
'CHARSET' => 'UTF-8');
$options = array('RELTYPE' => 'PARENT');
}
else
{
$options = array('CHARSET' => 'UTF-8');
$options = array();
}
if (preg_match('/[^\x20-\x7F]/', $value))
{
$options['CHARSET'] = 'UTF-8';
switch ($this->productManufacturer)
{
case 'groupdav':
@ -229,10 +245,6 @@ class infolog_ical extends infolog_bo
}
break;
case 'funambol':
if ($this->productName == 'mozilla sync client')
{
$value = str_replace( "\n", '\\n', $value);
}
$options['ENCODING'] = 'FUNAMBOL-QP';
}
}
@ -268,7 +280,7 @@ class infolog_ical extends infolog_bo
}
else
{
$priority = (int) $this->priority_egw2ical2[$taskData['info_priority']];
$priority = (int) $this->priority_egw2ical[$taskData['info_priority']];
}
$vevent->setAttribute('PRIORITY', $priority);
@ -584,9 +596,10 @@ class infolog_ical extends infolog_bo
'CATEGORIES' => $note['info_cat'],
) as $field => $value)
{
$options = array('CHARSET' => 'UTF-8');
$options = array();
if (preg_match('/[^\x20-\x7F]/', $value))
{
$options['CHARSET'] = 'UTF-8';
switch ($this->productManufacturer)
{
case 'groupdav':
@ -609,10 +622,6 @@ class infolog_ical extends infolog_bo
}
break;
case 'funambol':
if ($this->productName == 'mozilla sync client')
{
$value = str_replace( "\n", '\\n', $value);
}
$options['ENCODING'] = 'FUNAMBOL-QP';
}
}

View File

@ -1128,10 +1128,17 @@ class Horde_iCalendar {
}
}
if (!empty($params['ENCODING']) && strlen(trim($value))) {
$encoding = (!empty($params['ENCODING']) && strlen(trim($value)) > 0);
if ($encoding) {
switch($params['ENCODING']) {
case 'Q':
case 'QUOTED-PRINTABLE':
if (!$this->isOldFormat())
{
$enconding = false;
break;
}
$params_str .= ';ENCODING=' . $params['ENCODING'];
$value = str_replace("\r", '', $value);
$result .= $name . $params_str . ':'
@ -1140,9 +1147,14 @@ class Horde_iCalendar {
. $this->_newline;
break;
case 'FUNAMBOL-QP':
// Funambol does not support wrapping and needs some special quoting
$params_str .= ';ENCODING=QUOTED-PRINTABLE';
// Funambol needs some special quoting
$value = str_replace(array('<', "\r"), array('&lt;', ''), $value);
if (!$this->isOldFormat())
{
$encoding = false;
break;
}
$params_str .= ';ENCODING=QUOTED-PRINTABLE';
$result .= $name . $params_str . ':'
. str_replace('=0A', '=0D=0A',
$this->_quotedPrintableEncode($value, false))
@ -1159,7 +1171,9 @@ class Horde_iCalendar {
$result .= $this->_newline; // Append an empty line
}
}
} else {
}
if (!$encoding) {
$value = str_replace(array("\r", "\n"), array('', '\\n'), $value);
$attr_string = $name . $params_str;
if (strlen($value) > 0) {