"Patch from Phillip Herbert from Knauber to support Nokia e51, e90, 9300 and funambol iphone"

This commit is contained in:
Ralf Becker 2008-09-03 17:09:17 +00:00
parent 15c0b07903
commit e3b9117d4f

View File

@ -419,16 +419,96 @@ class addressbook_vcal extends addressbook_bo
'PHOTO' => array('jpegphoto'), 'PHOTO' => array('jpegphoto'),
)); ));
$defaultFields[9] = array( // nokia e90
'ADR;WORK' => array('','','adr_one_street','adr_one_locality','adr_one_region',
'adr_one_postalcode','adr_one_countryname'),
'ADR;HOME' => array('','','adr_two_street','adr_two_locality','adr_two_region',
'adr_two_postalcode','adr_two_countryname'),
'BDAY' => array('bday'),
'X-CLASS' => array('private'),
'EMAIL;INTERNET;WORK' => array('email'),
'EMAIL;INTERNET;HOME' => array('email_home'),
'N' => array('n_family','n_given','n_middle','n_prefix','n_suffix'),
'FN' => array('n_fn'),
'NOTE' => array('note'),
'ORG' => array('org_name','org_unit'),
'TEL;CELL;WORK' => array('tel_cell'),
'TEL;CELL;HOME' => array('tel_cell_private'),
'TEL;FAX;WORK' => array('tel_fax'),
'TEL;FAX;HOME' => array('tel_fax_home'),
'TEL;CAR' => array('tel_car'),
'TEL;PAGER;WORK' => array('tel_pager'),
'TEL;VOICE;WORK' => array('tel_work'),
'TEL;VOICE;HOME' => array('tel_home'),
'TITLE' => array('contact_role'),
'URL;WORK' => array('url'),
'URL;HOME' => array('url_home'),
'X-ASSISTANT' => array('assistent'),
'X-ASSISTANT-TEL' => array('tel_assistent'),
'PHOTO' => array('jpegphoto'),
);
$defaultFields[10] = array( // nokia 9300
'ADR;WORK' => array('','','adr_one_street','adr_one_locality','adr_one_region',
'adr_one_postalcode','adr_one_countryname'),
'ADR;HOME' => array('','','adr_two_street','adr_two_locality','adr_two_region',
'adr_two_postalcode','adr_two_countryname'),
'BDAY' => array('bday'),
'EMAIL;INTERNET' => array('email'),
'N' => array('n_family','n_given','n_middle','n_prefix','n_suffix'),
'FN' => array('n_fn'),
'NOTE' => array('note'),
'ORG' => array('org_name','org_unit'),
'TEL;CELL' => array('tel_cell'),
'TEL;WORK;FAX' => array('tel_fax'),
'TEL;FAX' => array('tel_fax_home'),
'TEL;PAGER' => array('tel_pager'),
'TEL;WORK;VOICE' => array('tel_work'),
'TEL;HOME;VOICE' => array('tel_home'),
'TITLE' => array('contact_role'),
'URL' => array('url'),
);
$defaultFields[11] = array( // funambol: iphone
'ADR;WORK' => array('','','adr_one_street','adr_one_locality','adr_one_region',
'adr_one_postalcode','adr_one_countryname'),
'ADR;HOME' => array('','','adr_two_street','adr_two_locality','adr_two_region',
'adr_two_postalcode','adr_two_countryname'),
'EMAIL;INTERNET;WORK' => array('email'),
'EMAIL;INTERNET;HOME' => array('email_home'),
'N' => array('n_family','n_given','n_middle','n_prefix','n_suffix'),
'FN' => array('n_fn'),
'NOTE' => array('note'),
'ORG' => array('org_name','org_unit'),
'TEL;CELL' => array('tel_cell'),
'TEL;HOME;FAX' => array('tel_fax_home'),
'TEL;WORK;FAX' => array('tel_fax'),
'TEL;VOICE;HOME' => array('tel_home'),
'TEL;VOICE;WORK' => array('tel_work'),
'TEL;PAGER' => array('tel_pager'),
'TEL;CAR' => array('tel_car'),
'TITLE' => array('title'),
'URL;WORK' => array('url'),
'URL;HOME' => array('url_home'),
'PHOTO' => array('jpegphoto'),
);
//error_log("Client: $_productManufacturer $_productName"); //error_log("Client: $_productManufacturer $_productName");
switch($this->productManufacturer) switch($this->productManufacturer)
{ {
case 'funambol': case 'funambol':
case 'funambol inc.':
switch ($this->productName) switch ($this->productName)
{ {
case 'thunderbird': case 'thunderbird':
$this->supportedFields = $defaultFields[6]; $this->supportedFields = $defaultFields[6];
break; break;
case 'iphone':
$this->supportedFields = $defaultFields[11];
break;
default: default:
error_log("Funambol product '$_productName', assuming same as thunderbird"); error_log("Funambol product '$_productName', assuming same as thunderbird");
$this->supportedFields = $defaultFields[6]; $this->supportedFields = $defaultFields[6];
@ -456,6 +536,13 @@ class addressbook_vcal extends addressbook_bo
case 'e61': case 'e61':
$this->supportedFields = $defaultFields[5]; $this->supportedFields = $defaultFields[5];
break; break;
case 'e51':
case 'e90':
$this->supportedFields = $defaultFields[9];
break;
case '9300':
$this->supportedFields = $defaultFields[10];
break;
case '6600': case '6600':
$this->supportedFields = $defaultFields[4]; $this->supportedFields = $defaultFields[4];
break; break;
@ -545,7 +632,8 @@ class addressbook_vcal extends addressbook_bo
{ {
// the horde class does the charset conversion. DO NOT CONVERT HERE. // the horde class does the charset conversion. DO NOT CONVERT HERE.
if(!is_array($this->supportedFields)) { if(!is_array($this->supportedFields))
{
$this->setSupportedFields(); $this->setSupportedFields();
} }
@ -556,7 +644,8 @@ class addressbook_vcal extends addressbook_bo
// Unfold any folded lines. // Unfold any folded lines.
$vCardUnfolded = preg_replace ('/(\r|\n)+ /', ' ', $_vcard); $vCardUnfolded = preg_replace ('/(\r|\n)+ /', ' ', $_vcard);
if(!$vCard->parsevCalendar($vCardUnfolded, 'VCARD')) { if(!$vCard->parsevCalendar($vCardUnfolded, 'VCARD'))
{
return False; return False;
} }
$vcardValues = $vCard->getAllAttributes(); $vcardValues = $vCard->getAllAttributes();
@ -569,44 +658,26 @@ class addressbook_vcal extends addressbook_bo
{ {
$rowName = $vcardRow['name']; $rowName = $vcardRow['name'];
if(isset($vcardRow['params']['INTERNET'])) $vcardElementCount = count($vcardRow['params'],COUNT_RECURSIVE);
{
$rowName .= ";INTERNET";
}
$type = strtoupper($vcardRow['params']['TYPE']); // vCard3 sets TYPE={work|home|cell|fax}!
if(isset($vcardRow['params']['CELL']) || $type == 'CELL') if( $vcardElementCount > 0 )
{ {
$rowName .= ';CELL'; foreach($vcardRow['params'] as $VKey => $vcardParam)
} {
if(isset($vcardRow['params']['FAX']) || $type == 'FAX') if( ! strlen($vcardParam) )
{ {
$rowName .= ';FAX'; $rowName .= ';'.$VKey;
} }
if(isset($vcardRow['params']['PAGER']) || $type == 'PAGER') if( $VKey == 'TYPE' && in_array(strtoupper($vcardParam),array('CELL','FAX','PAGER','WORK','HOME','VOICE','CAR')))
{ {
$rowName .= ';PAGER'; $rowName .= ';'.strtoupper($vcardParam);
} }
if(isset($vcardRow['params']['WORK']) || $type == 'WORK') }
{ }
$rowName .= ';WORK';
}
if(isset($vcardRow['params']['HOME']) || $type == 'HOME')
{
$rowName .= ';HOME';
}
if(isset($vcardRow['params']['VOICE']) || $type == 'VOICE')
{
$rowName .= ';VOICE';
}
if(isset($vcardRow['params']['CAR']) || $type == 'CAR')
{
$rowName .= ';CAR';
}
//error_log("key: $key --> $rowName: name=$vcardRow[name], params=".print_r($vcardRow['params'],true));
$rowNames[$rowName] = $key; $rowNames[$rowName] = $key;
} }
#error_log(print_r($rowNames, true)); #error_log(print_r($rowNames, true));
// now we have all rowNames the vcard provides // now we have all rowNames the vcard provides
@ -616,6 +687,7 @@ class addressbook_vcal extends addressbook_bo
foreach($rowNames as $rowName => $vcardKey) foreach($rowNames as $rowName => $vcardKey)
{ {
switch($rowName) switch($rowName)
{ {
case 'ADR': case 'ADR':
@ -624,10 +696,35 @@ class addressbook_vcal extends addressbook_bo
case 'TEL;FAX': case 'TEL;FAX':
case 'TEL;CELL': case 'TEL;CELL':
case 'TEL;PAGER': case 'TEL;PAGER':
if(!isset($rowNames[$rowName. ';WORK'])) case 'TEL;VOICE':
if(!isset($rowNames[$rowName. ';WORK']) && array_key_exists($rowName. ';WORK', $this->supportedFields) )
{ {
$finalRowNames[$rowName. ';WORK'] = $vcardKey; $finalRowNames[$rowName. ';WORK'] = $vcardKey;
} }
else
{
$InvolvedValues = explode(';',$rowName.';WORK');
foreach($this->supportedFields as $suppFields => $suppFieldsValue )
{
$InvolvedHits = 0;
foreach($InvolvedValues as $hlparr => $hlparrKey )
{
if( ! stristr( $suppFields,$hlparrKey ) === FALSE )
{
$InvolvedHits++;
}
}
if( count($InvolvedValues) == $InvolvedHits && !isset($finalRowNames[$suppFields]) )
{
$finalRowNames[$suppFields] = $vcardKey;
break; // if a combination of all words in $InvolvedValues were found
}
}
if( count($InvolvedValues) != $InvolvedHits && ! isset($finalRowNames[$rowName]) && array_key_exists($rowName, $this->supportedFields) )
{
$finalRowNames[$rowName] = $vcardKey;
}
}
break; break;
case 'EMAIL': case 'EMAIL':
case 'EMAIL;WORK': case 'EMAIL;WORK':
@ -652,7 +749,6 @@ class addressbook_vcal extends addressbook_bo
break; break;
} }
} }
#error_log(print_r($finalRowNames, true)); #error_log(print_r($finalRowNames, true));
$contact = array(); $contact = array();
@ -674,7 +770,7 @@ class addressbook_vcal extends addressbook_bo
{ {
$value = trim($vcardValues[$vcardKey]['values'][$fieldKey]); $value = trim($vcardValues[$vcardKey]['values'][$fieldKey]);
} }
//error_log("$fieldName=$vcardKey[$fieldKey]='$value'");
switch($fieldName) switch($fieldName)
{ {
case 'bday': case 'bday':
@ -684,7 +780,7 @@ class addressbook_vcal extends addressbook_bo
break; break;
case 'private': case 'private':
$contact[$fieldName] = (int) ( strtoupper($value) == 'PRIVATE'); $contact[$fieldName] = (int) ( strtoupper($value) == 'PRIVATE');
break; break;
case 'cat_id': case 'cat_id':