MFB:
authorJan Schneider <jan@horde.org>
Thu, 4 Nov 2010 16:04:44 +0000 (17:04 +0100)
committerJan Schneider <jan@horde.org>
Thu, 4 Nov 2010 16:04:44 +0000 (17:04 +0100)
[jan] Skip event status synchronization with Outlook, which is broken.
[jan] Don't send SIF data to recent Funambol clients, unless requested.

framework/SyncML/SyncML/Device.php
framework/SyncML/SyncML/Device/Sync4j.php
framework/SyncML/tests/sif.phpt
horde/docs/CHANGES

index 85b4210..1e75021 100644 (file)
 class SyncML_Device {
 
     /**
+     * The original preferred content type of the client, if provided through
+     * DevInf.
+     *
+     * @var string
+     */
+    var $requestedContentType;
+
+    /**
      * Attempts to return a concrete SyncML_Device instance based on $driver.
      *
      * @param string $driver  The type of concrete SyncML_Device subclass to
@@ -112,6 +120,7 @@ class SyncML_Device {
         if (!empty($ds)) {
             $r = $ds->getPreferredRXContentType();
             if (!empty($r)) {
+                $this->requestedContentType = $r;
                 return $r;
             }
         }
index ecc6731..0fe47ce 100644 (file)
@@ -28,30 +28,6 @@ require_once 'Horde/Icalendar.php';
  */
 class SyncML_Device_sync4j extends SyncML_Device {
 
-    function getPreferredContentTypeClient($serverSyncURI, $sourceSyncURI)
-    {
-        $database = strtolower($serverSyncURI); // no string api needed here
-
-        // Code copied from parent function. But we must not use device
-        // mimetype from device information here as this would result in
-        // us asking the horde backend to provide crazy text/x-s4j-sifn
-        // stuff. Instead we ask backend for default type and convert it
-        // internally in this class (in convertServer2Client).
-        if (strpos($database, 'contact') !== false ||
-            strpos($database, 'card') !== false) {
-            return 'text/x-vcard';
-        } elseif (strpos($database, 'note') !== false ||
-                  strpos($database, 'memo') !== false) {
-            return 'text/x-vnote';
-        } elseif (strpos($database, 'task') !== false ||
-                  strpos($database, 'cal') !== false ||
-                  strpos($database, 'event') !== false) {
-            return 'text/calendar';
-        }
-
-        return parent::getPreferredContentTypeClient($serverSyncURI, $sourceSyncURI);
-    }
-
     /**
      * Convert the content.
      */
@@ -84,6 +60,18 @@ class SyncML_Device_sync4j extends SyncML_Device {
             $content = SyncML_Device_sync4j::sif2vtodo($content);
             $contentType = 'text/calendar';
             break;
+
+        case 'text/calendar':
+        case 'text/x-vcalendar':
+            $si = $_SESSION['SyncML.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);
+            }
+            break;
         }
 
         $GLOBALS['backend']->logFile(
@@ -116,6 +104,21 @@ class SyncML_Device_sync4j extends SyncML_Device {
         list($content, $contentType, $encodingType) =
             parent::convertServer2Client($content, $contentType, $database);
 
+        if ($this->requestedContentType == $contentType) {
+            if ($contentType == 'text/calendar' ||
+                $contentType == 'text/x-vcalendar') {
+                $si = $_SESSION['SyncML.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' :
index c5d47d1..7e81ca8 100644 (file)
@@ -75,6 +75,42 @@ EVENT;
 echo $device->vevent2sif($data);
 echo "\n\n";
 
+$data = <<<EVENT
+BEGIN:VCALENDAR
+VERSION:2.0
+X-WR-CALNAME:Agenda de Pruebas
+PRODID:-//The Horde Project//Horde_iCalendar Library\, Horde 3.3.8//EN
+METHOD:PUBLISH
+BEGIN:VEVENT
+DTSTART:20101101T090000Z
+DTEND:20101101T100000Z
+DTSTAMP:20101025T104946Z
+UID:20101025124222.12755wqg94msihvy@example.com
+CREATED:20101025T104222Z
+LAST-MODIFIED:20101025T104846Z
+SUMMARY:Cinco-Lunes
+ORGANIZER;CN=Pruebas:mailto:pruebas@example.com
+CATEGORIES:Trabajo
+LOCATION:Korta
+CLASS:PUBLIC
+STATUS:CONFIRMED
+TRANSP:OPAQUE
+RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO;UNTIL=20101130T225959Z
+EXDATE:20101108T090000Z
+EXDATE:20101122T090000Z
+EXDATE:20101129T090000Z
+EXDATE:20101115T090000Z
+BEGIN:VALARM
+ACTION:DISPLAY
+TRIGGER;VALUE=DURATION:-PT15M
+END:VALARM
+END:VEVENT
+END:VCALENDAR
+EVENT;
+
+echo $device->vevent2sif($data);
+echo "\n\n";
+
 $data = <<<CONTACT
 <?xml version="1.0" encoding="UTF-8"?>
 <contact>
@@ -177,6 +213,8 @@ echo $device->sif2vcard($data);
 
 <?xml version="1.0"?><appointment><ReminderSet>1</ReminderSet><IsRecurring>0</IsRecurring><BusyStatus>2</BusyStatus><AllDayEvent>1</AllDayEvent><Start>2008-06-30</Start><End>2008-06-30</End><Subject>Server02</Subject><Sensitivity>0</Sensitivity><ReminderMinutesBeforeStart>15</ReminderMinutesBeforeStart></appointment>
 
+<?xml version="1.0"?><appointment><ReminderSet>1</ReminderSet><IsRecurring>1</IsRecurring><BusyStatus>2</BusyStatus><AllDayEvent>0</AllDayEvent><Start>20101101T090000Z</Start><End>20101101T100000Z</End><Subject>Cinco-Lunes</Subject><Categories>Trabajo</Categories><Location>Korta</Location><Sensitivity>0</Sensitivity><Interval>1</Interval><RecurrenceType>1</RecurrenceType><DayOfWeekMask>2</DayOfWeekMask><NoEndDate>0</NoEndDate><PatternEndDate>20101130T225959Z</PatternEndDate><ReminderMinutesBeforeStart>15</ReminderMinutesBeforeStart><Duration>60</Duration></appointment>
+
 BEGIN:VCARD
 VERSION:3.0
 FN:Lastname\, Firstname
index db04930..ecab048 100644 (file)
@@ -53,6 +53,8 @@ v4.0-cvs
 v3.3.11-cvs
 -----------
 
+[jan] Skip event status synchronization with Outlook, which is broken.
+[jan] Don't send SIF data to recent Funambol clients, unless requested.
 [jan] Log all queries by the history library.