[sync] Sync, Funambol and HTC Touch

Christian Bomhardt bomhardt at bomhardt.de
Thu Dec 18 21:19:43 UTC 2008


Hi,

I sync my HTC Touch with Horde Webmail with the now outdated 1.2 
edition. As it took me rather long to adjust everything to my needs, I 
didn't update yet even though I read that especially  in the area of 
Sync, many things were improved.

Please find attached my adjustments made to 
/horde/lib/Device/Sync4j.php. If you think it helps, feel free to use it 
- for me it totaly works fine now and I am absolutly happy.


Important remark: I only do "sync" from horde to the mobile



     function vcard2sif($vcard)
     {
         $iCal = &new Horde_iCalendar();
         if (!$iCal->parsevCalendar($vcard)) {
             // @TODO: NEVER use die() in a library.
             die("There was an error importing the data.");
         }

<
	....
 >
//First thing: replace / into - as my mobile phone doesn't like / in 
phone numbers
//Adjust the mapping such that private and business phone, fax and cell
//phone are supported
             case 'TEL':
                 $item['value']=str_replace('/','-',$item['value']);
                 if (isset($item['params']['FAX']))
                    {
                    if (isset($item['params']['WORK']))
                       {
                       $hash['BusinessFaxNumber'] = $item['value'];
                       }
                    elseif (isset($item['params']['HOME']))
                       {
                       $hash['HomeFaxNumber'] = $item['value'];
                       }
                    else
                       {
                       $hash['OtherFaxNumber'] = $item['value'];
                       }
                     }
                  elseif (isset($item['params']['TYPE']))
                     {
                     if (!is_array($item['params']['TYPE']))
                         {
                         $item['params']['TYPE'] = 
array($item['params']['TYPE']);
                         }
                     // For vCard 3.0., never happens for mydata
                     foreach ($item['params']['TYPE'] as $tel)
                           {
                           if (String::upper($tel) == 'WORK')
                             {
                             $hash['BusinessTelephoneNumber'] = 
$item['value'];
                             }
                           elseif (String::upper($tel) == 'HOME')
                             {
                             $hash['HomeTelephoneNumber'] = $item['value'];
                             }
                           elseif (String::upper($tel) == 'CELL')
                             {
                             $hash['MobileTelephoneNumber'] = 
$item['value'];
                             }
                           elseif (String::upper($tel) == 'FAX')
                             {
                             $hash['BusinessFaxNumber'] = $item['value'];
                             }
                           }
                      }
                 else
                     {
                     if (isset($item['params']['CELL']))
                         {
                         if (isset($item['params']['WORK']))
                           {
                           $hash['CarTelephoneNumber'] = $item['value'];
                           }
                         else
 
$hash['MobileTelephoneNumber']=$item['value'];
                         }
                     else
                     {
                     if (isset($item['params']['HOME']))
                         {
                         $hash['HomeTelephoneNumber'] = $item['value'];
                         }
                     elseif (isset($item['params']['WORK']))
                         {
                         $hash['BusinessTelephoneNumber'] = $item['value'];
                         }
                     elseif (isset($item['params']['CELL']))
                         {
                         $hash['MobileTelephoneNumber'] = $item['value'];
                         }
                     elseif (!isset($hash['HomeTelephoneNumber']))
                         {
                         $hash['HomeTelephoneNumber'] = $item['value'];
                         }
                     }
                     }
                 break;
//Adjust to support 2 email adresses
             case 'EMAIL':
                                  /*if (isset($item['params']['PREF']))
                                      {
                                      $hash['Email1Address'] = 
Horde_iCalendar_vcard::getBareEmail($item['value']);
                                      $hash['Email1AddressType'] = 'SMTP';
                                      }
                                  else*/
                                  if (isset($item['params']['WORK']))
                                      {
                                      $hash['Email2Address'] = 
Horde_iCalendar_vcard::getBareEmail($item['value']);
                                      $hash['Email2AddressType'] = 'SMTP';
                                      }
                                  elseif (isset($item['params']['HOME']))
                                      {
                                      $hash['Email3Address'] = 
Horde_iCalendar_vcard::getBareEmail($item['value']);
                                      $hash['Email3AddressType'] = 'SMTP';
                                      }
                                      /* elseif 
(isset($item['params']['TYPE'])) {
                                      if 
(!is_array($item['params']['TYPE'])) {
                                          $item['params']['TYPE'] = 
array($item['params']['TYPE']);
                                    }
                                      if (in_array('WORK', 
$item['params']['TYPE'])) {
                                        $hash['Email2Address'] = 
Horde_iCalendar_vcard::getBareEmail($item['value']);
                                          $hash['Email2AddressType'] = 
'SMTP';
                                      } elseif (in_array('HOME', 
$item['params']['TYPE'])) {
                                          $hash['Email3Address'] = 
Horde_iCalendar_vcard::getBareEmail($item['value']);
                                          $hash['Email3AddressType'] = 
'SMTP';
                                      } else {
                                          $hash['Email1Address'] = 
Horde_iCalendar_vcard::getBareEmail($item['value']);
                                          $hash['Email1AddressType'] = 
'SMTP';
                                      }
                                  } else {
                                       $hash['Email1Address'] = 
Horde_iCalendar_vcard::getBareEmail($item['value']);
 
$hash['Email1AddressType'] = 'SMTP';
 
      }
                                      */ 

             /*
                 if (isset($item['params']['PREF']) || 
!isset($hash['email'])) {
                     $hash['Email1Address'] = 
Horde_iCalendar_vcard::getBareEmail($item['value']);
                     $hash['Email1AddressType'] = 'SMTP';
                 }
                 */
                 break;

//continue with the default coding
             case 'TITLE':
<...>
         return SyncML_Device_sync4j::array2sif(
             $hash,
             '<?xml version="1.0"?><contact>',
             '</contact>');
     }


More information about the sync mailing list