xref: /plugin/davcal/vendor/sabre/dav/lib/CardDAV/Backend/SyncSupport.php (revision a1a3b6794e0e143a4a8b51d3185ce2d339be61ab)
1*a1a3b679SAndreas Boehler<?php
2*a1a3b679SAndreas Boehler
3*a1a3b679SAndreas Boehlernamespace Sabre\CardDAV\Backend;
4*a1a3b679SAndreas Boehler
5*a1a3b679SAndreas Boehler/**
6*a1a3b679SAndreas Boehler * WebDAV-sync support for CardDAV backends.
7*a1a3b679SAndreas Boehler *
8*a1a3b679SAndreas Boehler * In order for backends to advertise support for WebDAV-sync, this interface
9*a1a3b679SAndreas Boehler * must be implemented.
10*a1a3b679SAndreas Boehler *
11*a1a3b679SAndreas Boehler * Implementing this can result in a significant reduction of bandwidth and CPU
12*a1a3b679SAndreas Boehler * time.
13*a1a3b679SAndreas Boehler *
14*a1a3b679SAndreas Boehler * For this to work, you _must_ return a {http://sabredav.org/ns}sync-token
15*a1a3b679SAndreas Boehler * property from getAddressBooksForUser.
16*a1a3b679SAndreas Boehler *
17*a1a3b679SAndreas Boehler * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
18*a1a3b679SAndreas Boehler * @author Evert Pot (http://evertpot.com/)
19*a1a3b679SAndreas Boehler * @license http://sabre.io/license/ Modified BSD License
20*a1a3b679SAndreas Boehler */
21*a1a3b679SAndreas Boehlerinterface SyncSupport extends BackendInterface {
22*a1a3b679SAndreas Boehler
23*a1a3b679SAndreas Boehler    /**
24*a1a3b679SAndreas Boehler     * The getChanges method returns all the changes that have happened, since
25*a1a3b679SAndreas Boehler     * the specified syncToken in the specified address book.
26*a1a3b679SAndreas Boehler     *
27*a1a3b679SAndreas Boehler     * This function should return an array, such as the following:
28*a1a3b679SAndreas Boehler     *
29*a1a3b679SAndreas Boehler     * [
30*a1a3b679SAndreas Boehler     *   'syncToken' => 'The current synctoken',
31*a1a3b679SAndreas Boehler     *   'added'   => [
32*a1a3b679SAndreas Boehler     *      'new.txt',
33*a1a3b679SAndreas Boehler     *   ],
34*a1a3b679SAndreas Boehler     *   'modified'   => [
35*a1a3b679SAndreas Boehler     *      'modified.txt',
36*a1a3b679SAndreas Boehler     *   ],
37*a1a3b679SAndreas Boehler     *   'deleted' => [
38*a1a3b679SAndreas Boehler     *      'foo.php.bak',
39*a1a3b679SAndreas Boehler     *      'old.txt'
40*a1a3b679SAndreas Boehler     *   ]
41*a1a3b679SAndreas Boehler     * ];
42*a1a3b679SAndreas Boehler     *
43*a1a3b679SAndreas Boehler     * The returned syncToken property should reflect the *current* syncToken
44*a1a3b679SAndreas Boehler     * of the calendar, as reported in the {http://sabredav.org/ns}sync-token
45*a1a3b679SAndreas Boehler     * property. This is needed here too, to ensure the operation is atomic.
46*a1a3b679SAndreas Boehler     *
47*a1a3b679SAndreas Boehler     * If the $syncToken argument is specified as null, this is an initial
48*a1a3b679SAndreas Boehler     * sync, and all members should be reported.
49*a1a3b679SAndreas Boehler     *
50*a1a3b679SAndreas Boehler     * The modified property is an array of nodenames that have changed since
51*a1a3b679SAndreas Boehler     * the last token.
52*a1a3b679SAndreas Boehler     *
53*a1a3b679SAndreas Boehler     * The deleted property is an array with nodenames, that have been deleted
54*a1a3b679SAndreas Boehler     * from collection.
55*a1a3b679SAndreas Boehler     *
56*a1a3b679SAndreas Boehler     * The $syncLevel argument is basically the 'depth' of the report. If it's
57*a1a3b679SAndreas Boehler     * 1, you only have to report changes that happened only directly in
58*a1a3b679SAndreas Boehler     * immediate descendants. If it's 2, it should also include changes from
59*a1a3b679SAndreas Boehler     * the nodes below the child collections. (grandchildren)
60*a1a3b679SAndreas Boehler     *
61*a1a3b679SAndreas Boehler     * The $limit argument allows a client to specify how many results should
62*a1a3b679SAndreas Boehler     * be returned at most. If the limit is not specified, it should be treated
63*a1a3b679SAndreas Boehler     * as infinite.
64*a1a3b679SAndreas Boehler     *
65*a1a3b679SAndreas Boehler     * If the limit (infinite or not) is higher than you're willing to return,
66*a1a3b679SAndreas Boehler     * you should throw a Sabre\DAV\Exception\TooMuchMatches() exception.
67*a1a3b679SAndreas Boehler     *
68*a1a3b679SAndreas Boehler     * If the syncToken is expired (due to data cleanup) or unknown, you must
69*a1a3b679SAndreas Boehler     * return null.
70*a1a3b679SAndreas Boehler     *
71*a1a3b679SAndreas Boehler     * The limit is 'suggestive'. You are free to ignore it.
72*a1a3b679SAndreas Boehler     *
73*a1a3b679SAndreas Boehler     * @param string $addressBookId
74*a1a3b679SAndreas Boehler     * @param string $syncToken
75*a1a3b679SAndreas Boehler     * @param int $syncLevel
76*a1a3b679SAndreas Boehler     * @param int $limit
77*a1a3b679SAndreas Boehler     * @return array
78*a1a3b679SAndreas Boehler     */
79*a1a3b679SAndreas Boehler    function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $limit = null);
80*a1a3b679SAndreas Boehler
81*a1a3b679SAndreas Boehler}
82