[Pkg-owncloud-commits] [php-sabredav] 164/275: Support for carddav:supported-collation-set and max-resource-size.

David Prévot taffit at moszumanska.debian.org
Thu Sep 25 14:56:04 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository php-sabredav.

commit 8f30f2b18dfae93e160b84fe1fb5257c8b6edf68
Author: Evert Pot <me at evertpot.com>
Date:   Tue Aug 19 11:03:15 2014 -0400

    Support for carddav:supported-collation-set and max-resource-size.
    
    Also moved supported-address-data to the carddav plugin.
---
 ChangeLog.md                                    |  7 ++++
 lib/CardDAV/Backend/PDO.php                     |  2 --
 lib/CardDAV/Plugin.php                          | 20 +++++++++++
 lib/CardDAV/Property/SupportedCollationSet.php  | 45 +++++++++++++++++++++++++
 tests/Sabre/CardDAV/Backend/AbstractPDOTest.php |  6 ----
 5 files changed, 72 insertions(+), 8 deletions(-)

diff --git a/ChangeLog.md b/ChangeLog.md
index 63c9781..bfa2b2c 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -42,6 +42,13 @@ ChangeLog
 * Changed: CalDAV plugin is now responsible for reporting
   `CALDAV:supported-collation-set` and `CALDAV:supported-calendar-data`
   properties.
+* Added: Now reporting `CARDDAV:max-resource-size`, but we're not actively
+  restricting it yet.
+* Added: Support for `CARDDAV:supported-collation-set`.
+* Changed: CardDAV plugin is now responsible for reporting
+  `CARDDAV:supported-address-data`. This functionality has been removed from
+  the CardDAV PDO backend.
+
 
 2.0.4 (????-??-??)
 ------------------
diff --git a/lib/CardDAV/Backend/PDO.php b/lib/CardDAV/Backend/PDO.php
index 3a03077..ddba0e0 100644
--- a/lib/CardDAV/Backend/PDO.php
+++ b/lib/CardDAV/Backend/PDO.php
@@ -78,8 +78,6 @@ class PDO extends AbstractBackend implements SyncSupport {
                 '{DAV:}displayname' => $row['displayname'],
                 '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
                 '{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
-                '{' . CardDAV\Plugin::NS_CARDDAV . '}supported-address-data' =>
-                    new CardDAV\Property\SupportedAddressData(),
                 '{DAV:}sync-token' => $row['synctoken']?$row['synctoken']:'0',
             );
 
diff --git a/lib/CardDAV/Plugin.php b/lib/CardDAV/Plugin.php
index 4070205..c8aec51 100644
--- a/lib/CardDAV/Plugin.php
+++ b/lib/CardDAV/Plugin.php
@@ -43,6 +43,13 @@ class Plugin extends DAV\ServerPlugin {
     protected $server;
 
     /**
+     * The default PDO storage uses a MySQL MEDIUMBLOB for iCalendar data,
+     * which can hold up to 2^24 = 16777216 bytes. This is plenty. We're
+     * capping it to 10M here.
+     */
+    protected $maxResourceSize = 10000000;
+
+    /**
      * Initializes the plugin
      *
      * @param DAV\Server $server
@@ -125,6 +132,19 @@ class Plugin extends DAV\ServerPlugin {
      */
     public function propFindEarly(DAV\PropFind $propFind, DAV\INode $node) {
 
+        $ns = '{' . self::NS_CARDDAV . '}';
+
+        if ($node instanceof IAddressBook) {
+
+            $propFind->handle($ns . 'max-resource-size', $this->maxResourceSize);
+            $propFind->handle($ns . 'supported-address-data', function() {
+                return new Property\SupportedAddressData();
+            });
+            $propFind->handle($ns . 'supported-collation-set', function() {
+                return new Property\SupportedCollationSet();
+            });
+
+        }
         if ($node instanceof DAVACL\IPrincipal) {
 
             $path = $propFind->getPath();
diff --git a/lib/CardDAV/Property/SupportedCollationSet.php b/lib/CardDAV/Property/SupportedCollationSet.php
new file mode 100644
index 0000000..ea64227
--- /dev/null
+++ b/lib/CardDAV/Property/SupportedCollationSet.php
@@ -0,0 +1,45 @@
+<?php
+
+namespace Sabre\CardDAV\Property;
+use Sabre\DAV;
+
+/**
+ * supported-collation-set property
+ *
+ * This property is a representation of the supported-collation-set property
+ * in the CardDAV namespace.
+ *
+ * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/).
+ * @author Evert Pot (http://evertpot.com/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+class SupportedCollationSet extends DAV\Property {
+
+    /**
+     * Serializes the property in a DOM document
+     *
+     * @param DAV\Server $server
+     * @param \DOMElement $node
+     * @return void
+     */
+    public function serialize(DAV\Server $server,\DOMElement $node) {
+
+        $doc = $node->ownerDocument;
+
+        $prefix = $node->lookupPrefix('urn:ietf:params:xml:ns:carddav');
+        if (!$prefix) $prefix = 'card';
+
+        $node->appendChild(
+            $doc->createElement($prefix . ':supported-collation','i;ascii-casemap')
+        );
+        $node->appendChild(
+            $doc->createElement($prefix . ':supported-collation','i;octet')
+        );
+        $node->appendChild(
+            $doc->createElement($prefix . ':supported-collation','i;unicode-casemap')
+        );
+
+
+    }
+
+}
diff --git a/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php b/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php
index ffa086e..a026351 100644
--- a/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php
+++ b/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php
@@ -39,7 +39,6 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
                 '{DAV:}displayname' => 'book1',
                 '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 1',
                 '{http://calendarserver.org/ns/}getctag' => 1,
-                '{' . CardDAV\Plugin::NS_CARDDAV . '}supported-address-data' => new CardDAV\Property\SupportedAddressData(),
                 '{DAV:}sync-token' => 1
             )
         );
@@ -71,7 +70,6 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
                 '{DAV:}displayname' => 'book1',
                 '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 1',
                 '{http://calendarserver.org/ns/}getctag' => 1,
-                '{' . CardDAV\Plugin::NS_CARDDAV . '}supported-address-data' => new CardDAV\Property\SupportedAddressData(),
                 '{DAV:}sync-token' => 1
             )
         );
@@ -99,7 +97,6 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
                 '{DAV:}displayname' => 'book1',
                 '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 1',
                 '{http://calendarserver.org/ns/}getctag' => 1,
-                '{' . CardDAV\Plugin::NS_CARDDAV . '}supported-address-data' => new CardDAV\Property\SupportedAddressData(),
                 '{DAV:}sync-token' => 1
             )
         );
@@ -131,7 +128,6 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
                 '{DAV:}displayname' => 'updated',
                 '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'updated',
                 '{http://calendarserver.org/ns/}getctag' => 2,
-                '{' . CardDAV\Plugin::NS_CARDDAV . '}supported-address-data' => new CardDAV\Property\SupportedAddressData(),
                 '{DAV:}sync-token' => 2
             )
         );
@@ -175,7 +171,6 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
                 '{DAV:}displayname' => 'book1',
                 '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 1',
                 '{http://calendarserver.org/ns/}getctag' => 1,
-                '{' . CardDAV\Plugin::NS_CARDDAV . '}supported-address-data' => new CardDAV\Property\SupportedAddressData(),
                 '{DAV:}sync-token' => 1,
             ),
             array(
@@ -185,7 +180,6 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
                 '{DAV:}displayname' => 'book2',
                 '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 2',
                 '{http://calendarserver.org/ns/}getctag' => 1,
-                '{' . CardDAV\Plugin::NS_CARDDAV . '}supported-address-data' => new CardDAV\Property\SupportedAddressData(),
                 '{DAV:}sync-token' => 1,
             )
         );

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git



More information about the Pkg-owncloud-commits mailing list