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)) if(!empty($value))
{ {
$value = $GLOBALS['egw']->translation->convert(trim($value), $sysCharSet, 'utf-8'); $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'; $options['ENCODING'] = 'QUOTED-PRINTABLE';
} }
$hasdata++; $hasdata++;
} }
break; break;
@ -358,7 +361,8 @@ class vcaladdressbook extends bocontacts
'URL;WORK' => array('url'), 'URL;WORK' => array('url'),
'URL' => array('url_home'), 'URL' => array('url_home'),
); );
$defaultFields[7] = array(
$defaultFields[7] = array( // SyncEvolution
'N'=> array('n_family','n_given','n_middle','n_prefix','n_suffix'), 'N'=> array('n_family','n_given','n_middle','n_prefix','n_suffix'),
'TITLE' => array('title'), 'TITLE' => array('title'),
'ROLE' => array('role'), 'ROLE' => array('role'),
@ -383,6 +387,11 @@ class vcaladdressbook extends bocontacts
'PHOTO' => array('jpegphoto'), '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"); //error_log("Client: $_productManufacturer $_productName");
switch(strtolower($_productManufacturer)) switch(strtolower($_productManufacturer))
@ -494,6 +503,10 @@ class vcaladdressbook extends bocontacts
$this->supportedFields = $defaultFields[1]; $this->supportedFields = $defaultFields[1];
break; break;
case 'kde': // KDE Addressbook via GroupDAV
$this->supportedFields = $defaultFields[8];
break;
// the fallback for SyncML // the fallback for SyncML
default: default:
error_log("Client not found: '$_productManufacturer' '$_productName'"); error_log("Client not found: '$_productManufacturer' '$_productName'");
@ -627,7 +640,14 @@ class vcaladdressbook extends bocontacts
{ {
if(!empty($fieldName)) if(!empty($fieldName))
{ {
$value = trim($vcardValues[$vcardKey]['values'][$fieldKey]); 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'"); //error_log("$fieldName=$vcardKey[$fieldKey]='$value'");
switch($fieldName) switch($fieldName)
{ {