fixed GroupDAV "charset prob" (non-ascii did show up wrong in KAddressbook) and handling of jpeg photo

I hope that works well for SyncML too
This commit is contained in:
Ralf Becker 2008-04-16 16:05:48 +00:00
parent f3181308c5
commit da4a19b7dc

View File

@ -110,13 +110,16 @@ class vcaladdressbook extends bocontacts
if(!empty($value))
{
$value = $GLOBALS['egw']->translation->convert(trim($value), $sysCharSet, 'utf-8');
$options['CHARSET'] = 'UTF-8';
if(preg_match('/([\000-\012\015\016\020-\037\075])/',$value))
if(preg_match('/([\177-\377])/',$valueData))
{
$options['CHARSET'] = 'UTF-8';
$options['ENCODING'] = 'QUOTED-PRINTABLE';
}
elseif(preg_match('/([\000-\012\015\016\020-\037\075])/',$value))
{
$options['ENCODING'] = 'QUOTED-PRINTABLE';
}
$hasdata++;
}
break;
@ -358,7 +361,8 @@ class vcaladdressbook extends bocontacts
'URL;WORK' => array('url'),
'URL' => array('url_home'),
);
$defaultFields[7] = array(
$defaultFields[7] = array( // SyncEvolution
'N'=> array('n_family','n_given','n_middle','n_prefix','n_suffix'),
'TITLE' => array('title'),
'ROLE' => array('role'),
@ -383,6 +387,11 @@ class vcaladdressbook extends bocontacts
'PHOTO' => array('jpegphoto'),
);
$defaultFields[8] = array_merge($defaultFields[1],array( // KDE Addressbook, only changes from all=1
'ORG' => array('org_name'),
'X-KADDRESSBOOK-X-Department' => array('org_unit'),
'PHOTO' => array('jpegphoto'),
));
//error_log("Client: $_productManufacturer $_productName");
switch(strtolower($_productManufacturer))
@ -494,6 +503,10 @@ class vcaladdressbook extends bocontacts
$this->supportedFields = $defaultFields[1];
break;
case 'kde': // KDE Addressbook via GroupDAV
$this->supportedFields = $defaultFields[8];
break;
// the fallback for SyncML
default:
error_log("Client not found: '$_productManufacturer' '$_productName'");
@ -626,8 +639,15 @@ class vcaladdressbook extends bocontacts
foreach($fieldNames as $fieldKey => $fieldName)
{
if(!empty($fieldName))
{
if ($fieldName == 'jpegphoto' || $vcardValues[$vcardKey]['params']['ENCODING'] == 'b')
{
$value = base64_decode($vcardValues[$vcardKey]['values'][$fieldKey]);
}
else
{
$value = trim($vcardValues[$vcardKey]['values'][$fieldKey]);
}
//error_log("$fieldName=$vcardKey[$fieldKey]='$value'");
switch($fieldName)
{