If a sync client needs any kind of special conversion of the data sent to it or received from it, this is done here. There are two sources of information to identify an device: The first (and better) one is the DevInf device info sent by the device during a request. If DevInf is not supported or sent by the client, the Source/LocURI of the device request might be sufficent to identify it. Copyright 2005-2016 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
저자: Karsten Fourmont (karsten@horde.org)
예제 #1
0
파일: Nokia.php 프로젝트: raz0rsdge/horde
 /**
  * Converts the content from the backend to a format suitable for the
  * client device.
  *
  * Strips the UID (primary key) information as client and server might use
  * different ones.
  *
  * Charset conversions might be added here too.
  *
  * @param string $content      The content to convert
  * @param string $contentType  The content type of content as returned
  *                             from the backend
  * @param string $database     The server database URI.
  *
  * @return array  Three-element array with the converted content, the
  *                (possibly changed) new content type, and encoding type
  *                (like b64 as used by Funambol).
  */
 public function convertServer2Client($content, $contentType, $database)
 {
     $database = $GLOBALS['backend']->normalize($database);
     list($content, $contentType, $encodingType) = parent::convertServer2Client($content, $contentType, $database);
     $content = preg_replace('/(\\r\\n|\\r|\\n)PHOTO;ENCODING=b[^:]*:(.+?)(\\r\\n|\\r|\\n)/', '\\1PHOTO;ENCODING=BASE64:\\1\\2\\1\\1', $content, 1);
     $GLOBALS['backend']->logFile(Horde_SyncMl_Backend::LOGFILE_DATA, "\nOutput converted for client ({$contentType}):\n{$content}\n");
     return array($content, $contentType, null);
 }
예제 #2
0
파일: Synthesis.php 프로젝트: horde/horde
 /**
  * Convert the content.
  *
  * @param string $content       The content to convert.
  * @param string $contentType   The contentType of the content.
  * @return array                array($newcontent, $newcontentType):
  *                              the converted content and the
  *                              (possibly changed) new ContentType.
  */
 public function convertClient2Server($content, $contentType)
 {
     list($content, $contentType) = parent::convertClient2Server($content, $contentType);
     $di = $GLOBALS['backend']->state->deviceInfo;
     if (stristr($di->Mod, 'palm') === false) {
         // Some special priority handling is required. Synthesis uses 1
         // (high), 2 (medium), 3(low), at least for my windows mobile
         // device.  convert these to valid priority settings:
         $content = preg_replace('/(\\r\\n|\\r|\\n)PRIORITY:3(\\r\\n|\\r|\\n)/', '\\1PRIORITY:5\\2', $content, 1);
         $content = preg_replace('/(\\r\\n|\\r|\\n)PRIORITY:2(\\r\\n|\\r|\\n)/', '\\1PRIORITY:3\\2', $content, 1);
     }
     $GLOBALS['backend']->logFile(Horde_SyncMl_Backend::LOGFILE_DATA, "\ninput converted for server ({$contentType}):\n{$content}\n");
     return array($content, $contentType);
 }
예제 #3
0
파일: Sync4j.php 프로젝트: jubinpatel/horde
 /**
  * Converts the content from the backend to a format suitable for the
  * client device.
  *
  * Strips the uid (primary key) information as client and server might use
  * different ones.
  *
  * @param string $content      The content to convert
  * @param string $contentType  The content type of content as returned
  *                             from the backend
  * @param string $database     The server database URI.
  *
  * @return array  Three-element array with the converted content, the
  *                (possibly changed) new content type, and encoding type
  *                (like b64 as used by Funambol).
  */
 public function convertServer2Client($content, $contentType, $database)
 {
     $database = $GLOBALS['backend']->normalize($database);
     list($content, $contentType, $encodingType) = parent::convertServer2Client($content, $contentType, $database);
     if ($this->requestedContentType == $contentType) {
         if ($contentType == 'text/calendar' || $contentType == 'text/x-vcalendar') {
             $si = $GLOBALS['backend']->state->sourceURI;
             if (stristr($si, 'fol-') !== false) {
                 // The Funambol Outlook connector uses invalid STATUS
                 // values. Actually it maps MeetingStatus values of the
                 // Outlook event to the STATUS property, which is
                 // completely useless. So drop the STATUS altogether.
                 $content = preg_replace('/^STATUS:.*\\r?\\n/im', '', $content);
             }
         }
         return array($content, $contentType, $encodingType);
     }
     switch ($contentType) {
         case 'text/calendar':
         case 'text/x-vcalendar':
             switch ($database) {
                 case 'calendar':
                     $content = Horde_SyncMl_Device_sync4j::vevent2sif($content);
                     $content = base64_encode($content);
                     $contentType = 'text/x-s4j-sife';
                     break 2;
                 case 'tasks':
                     $content = Horde_SyncMl_Device_sync4j::vtodo2sif($content);
                     $content = base64_encode($content);
                     $contentType = 'text/x-s4j-sift';
                     break 2;
             }
             break;
         case 'text/x-vcard':
             $content = Horde_SyncMl_Device_sync4j::vcard2sif($content);
             $content = base64_encode($content);
             $contentType = 'text/x-s4j-sifc';
             break;
         case 'text/x-vnote':
         case 'text/plain':
             $content = Horde_SyncMl_Device_sync4j::vnote2sif($content);
             $content = base64_encode($content);
             $contentType = 'text/x-s4j-sifn';
             break;
     }
     $l = "\nOutput converted for client ({$contentType}):\n" . base64_decode($content) . "\n";
     $GLOBALS['backend']->logFile(Horde_SyncMl_Backend::LOGFILE_DATA, $l);
     return array($content, $contentType, 'b64');
 }
예제 #4
0
 /**
  * Converts the content from the backend to a format suitable for the
  * client device.
  *
  * Strips the uid (primary key) information as client and server might use
  * different ones.
  *
  * @param string $content      The content to convert
  * @param string $contentType  The content type of content as returned
  *                             from the backend
  * @param string $database     The server database URI.
  *
  * @return array  Three-element array with the converted content, the
  *                (possibly changed) new content type, and encoding type
  *                (like b64 as used by Funambol).
  */
 public function convertServer2Client($content, $contentType, $database)
 {
     list($content, $contentType, $encodingType) = parent::convertServer2Client($content, $contentType, $database);
     /* The plugin does currently not handle lines that are both folded
      * and QUOTED-PRINTABLE encoded. Like this one with a note "abc":
      * NOTE;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:=
      * a=
      * bc
      */
     if (preg_match_all('/\\r\\n[^:]*ENCODING=QUOTED-PRINTABLE[^:]*:.*?=\\r\\n.*?[^=](?=\\r\\n)/mis', $content, $m)) {
         foreach ($m[0] as $v) {
             /* Remove line folding */
             $content = str_replace($v, str_replace("=\r\n", '', $v), $content);
         }
     }
     $l = "\noutput converted for client ({$contentType}):\n" . $content . "\n";
     $GLOBALS['backend']->logFile(Horde_SyncMl_Backend::LOGFILE_DATA, $l);
     return array($content, $contentType, $encodingType);
 }
예제 #5
0
파일: State.php 프로젝트: horde/horde
 /**
  * Returns a Horde_SyncMl_Device instance for the device used in this session.
  *
  * @return Horde_SyncMl_Device  A Horde_SyncMl_Device instance.
  */
 public function getDevice()
 {
     if (empty($this->_deviceDriver)) {
         $si = $this->sourceURI;
         $di = $this->deviceInfo;
         if (stristr($si, 'sync4j') !== false || stristr($si, 'sc-pim') !== false || stristr($si, 'fol-') !== false || stristr($si, 'fwm-') !== false || stristr($si, 'fbb-') !== false) {
             $this->_deviceDriver = 'Sync4j';
         } elseif (!empty($di->Man) && (stristr($di->Man, 'Sony Ericsson') !== false || stristr($di->Mod, 'A1000') !== false)) {
             /* The Morola A1000 has a similar (UIQ) firmware as the
              * P800: */
             $this->_deviceDriver = 'P800';
         } elseif (!empty($di->Man) && stristr($di->Man, 'nokia') !== false) {
             $this->_deviceDriver = 'Nokia';
         } elseif (stristr($si, 'fmz-') !== false) {
             $this->_deviceDriver = 'Sync4JMozilla';
         } else {
             $this->_deviceDriver = 'default';
         }
     }
     return Horde_SyncMl_Device::factory($this->_deviceDriver);
 }
예제 #6
0
파일: P800.php 프로젝트: jubinpatel/horde
 /**
  * Some devices like the Sony Ericsson P800/P900/P910 handle vtodos (tasks)
  * and vevents in the same "calendar" sync.
  * This requires special actions on our side as we store this in different
  * databases (nag and kronolith).
  * This public function could directly return true but tries to be a bit more
  * generic so it might work for other phones as well.
  */
 public function handleTasksInCalendar()
 {
     $di = $GLOBALS['backend']->state->deviceInfo;
     if (isset($di->CTCaps['text/x-vcalendar']) && !empty($di->CTCaps['text/x-vcalendar']['BEGIN']->ValEnum['VEVENT']) && !empty($di->CTCaps['text/x-vcalendar']['BEGIN']->ValEnum['VTODO'])) {
         return true;
     }
     return parent::handleTasksInCalendar();
 }