]>
Commit | Line | Data |
---|---|---|
b1364d61 MR |
1 | http://sabre.io/dav/building-a-caldav-client/ |
2 | 0. Discovery | |
3 | PROPFIND / HTTP/1.1 | |
4 | Depth: 0 | |
5 | Prefer: return-minimal | |
6 | Content-Type: application/xml; charset=utf-8 | |
7 | ||
8 | <d:propfind xmlns:d="DAV:"> | |
9 | <d:prop> | |
10 | <d:current-user-principal /> | |
11 | </d:prop> | |
12 | </d:propfind> | |
13 | ||
14 | Success: | |
15 | HTTP/1.1 207 Multi-status | |
16 | Content-Type: application/xml; charset=utf-8 | |
17 | ||
18 | <d:multistatus xmlns:d="DAV:" xmlns:cs="http://calendarserver.org/ns/"> | |
19 | <d:response> | |
20 | <d:href>/</d:href> | |
21 | <d:propstat> | |
22 | <d:prop> | |
23 | <d:current-user-principal> | |
24 | <d:href>/principals/users/johndoe/</d:href> | |
25 | </d:current-user-principal> | |
26 | </d:prop> | |
27 | <d:status>HTTP/1.1 200 OK</d:status> | |
28 | </d:propstat> | |
29 | </d:response> | |
30 | </d:multistatus> | |
31 | ||
32 | Get calendar home: | |
33 | PROPFIND /principals/users/johndoe/ HTTP/1.1 | |
34 | Depth: 0 | |
35 | Prefer: return-minimal | |
36 | Content-Type: application/xml; charset=utf-8 | |
37 | ||
38 | <d:propfind xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav"> | |
39 | <d:prop> | |
40 | <c:calendar-home-set /> | |
41 | </d:prop> | |
42 | </d:propfind> | |
43 | ||
44 | Success: | |
45 | HTTP/1.1 207 Multi-status | |
46 | Content-Type: application/xml; charset=utf-8 | |
47 | ||
48 | <d:multistatus xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav"> | |
49 | <d:response> | |
50 | <d:href>/principals/users/johndoe/</d:href> | |
51 | <d:propstat> | |
52 | <d:prop> | |
53 | <c:calendar-home-set> | |
54 | <d:href>/calendars/johndoe/</d:href> | |
55 | </c:calendar-home-set> | |
56 | </d:prop> | |
57 | <d:status>HTTP/1.1 200 OK</d:status> | |
58 | </d:propstat> | |
59 | </d:response> | |
60 | </d:multistatus> | |
61 | ||
62 | Get all calendars: | |
63 | PROPFIND /calendars/johndoe/ HTTP/1.1 | |
64 | Depth: 1 | |
65 | Prefer: return-minimal | |
66 | Content-Type: application/xml; charset=utf-8 | |
67 | ||
68 | <d:propfind xmlns:d="DAV:" xmlns:cs="http://calendarserver.org/ns/" xmlns:c="urn:ietf:params:xml:ns:caldav"> | |
69 | <d:prop> | |
70 | <d:resourcetype /> | |
71 | <d:displayname /> | |
72 | <cs:getctag /> | |
73 | <c:supported-calendar-component-set /> | |
74 | </d:prop> | |
75 | </d:propfind> | |
76 | ||
77 | Success: | |
78 | HTTP/1.1 207 Multi-status | |
79 | Content-Type: application/xml; charset=utf-8 | |
80 | ||
81 | <d:multistatus xmlns:d="DAV:" xmlns:cs="http://calendarserver.org/ns/" xmlns:c="urn:ietf:params:xml:ns:caldav"> | |
82 | <d:response> | |
83 | <d:href>/calendars/johndoe/</d:href> | |
84 | <d:propstat> | |
85 | <d:prop> | |
86 | <d:resourcetype> | |
87 | <d:collection/> | |
88 | </d:resourcetype> | |
89 | </d:prop> | |
90 | <d:status>HTTP/1.1 200 OK</d:status> | |
91 | </d:propstat> | |
92 | </d:response> | |
93 | <d:response> | |
94 | <d:href>/calendars/johndoe/home/</d:href> | |
95 | <d:propstat> | |
96 | <d:prop> | |
97 | <d:resourcetype> | |
98 | <d:collection/> | |
99 | <c:calendar/> | |
100 | </d:resourcetype> | |
101 | <d:displayname>Home calendar</d:displayname> | |
102 | <cs:getctag>3145</cs:getctag> | |
103 | <c:supported-calendar-component-set> | |
104 | <c:comp name="VEVENT" /> | |
105 | </c:supported-calendar-component-set> | |
106 | </d:prop> | |
107 | <d:status>HTTP/1.1 200 OK</d:status> | |
108 | </d:propstat> | |
109 | </d:response> | |
110 | <d:response> | |
111 | <d:href>/calendars/johndoe/tasks/</d:href> | |
112 | <d:propstat> | |
113 | <d:prop> | |
114 | <d:resourcetype> | |
115 | <d:collection/> | |
116 | <c:calendar/> | |
117 | </d:resourcetype> | |
118 | <d:displayname>My TODO list</d:displayname> | |
119 | <cs:getctag>3345</cs:getctag> | |
120 | <c:supported-calendar-component-set> | |
121 | <c:comp name="VTODO" /> | |
122 | </c:supported-calendar-component-set> | |
123 | </d:prop> | |
124 | <d:status>HTTP/1.1 200 OK</d:status> | |
125 | </d:propstat> | |
126 | </d:response> | |
127 | </d:multistatus> | |
128 | ||
129 | 1. Get display name and ctag | |
130 | PROPFIND /calendars/johndoe/home/ HTTP/1.1 | |
131 | Depth: 0 | |
132 | Prefer: return-minimal | |
133 | Content-Type: application/xml; charset=utf-8 | |
134 | ||
135 | <d:propfind xmlns:d="DAV:" xmlns:cs="http://calendarserver.org/ns/"> | |
136 | <d:prop> | |
137 | <d:displayname /> | |
138 | <cs:getctag /> | |
139 | </d:prop> | |
140 | </d:propfind> | |
141 | ||
142 | Success: | |
143 | HTTP/1.1 207 Multi-status | |
144 | Content-Type: application/xml; charset=utf-8 | |
145 | ||
146 | <d:multistatus xmlns:d="DAV:" xmlns:cs="http://calendarserver.org/ns/"> | |
147 | <d:response> | |
148 | <d:href>/calendars/johndoe/home/</d:href> | |
149 | <d:propstat> | |
150 | <d:prop> | |
151 | <d:displayname>Home calendar</d:displayname> | |
152 | <cs:getctag>3145</cs:getctag> | |
153 | </d:prop> | |
154 | <d:status>HTTP/1.1 200 OK</d:status> | |
155 | </d:propstat> | |
156 | </d:response> | |
157 | </d:multistatus> | |
158 | ||
159 | Failure: | |
160 | HTTP/1.1 207 Multi-status | |
161 | Content-Type: application/xml; charset=utf-8 | |
162 | ||
163 | <d:multistatus xmlns:d="DAV:" xmlns:cs="http://calendarserver.org/ns/"> | |
164 | <d:response> | |
165 | <d:href>/calendars/johndoe/home/</d:href> | |
166 | <d:propstat> | |
167 | <d:prop> | |
168 | <d:displayname /> | |
169 | <cs:getctag /> | |
170 | </d:prop> | |
171 | <d:status>HTTP/1.1 403 Forbidden</d:status> | |
172 | </d:propstat> | |
173 | </d:response> | |
174 | </d:multistatus> | |
175 | ||
176 | 2. Save display name and ctag (if ctag changes the calendar has changes) | |
177 | ||
178 | 3. Download objects | |
179 | REPORT /calendars/johndoe/home/ HTTP/1.1 | |
180 | Depth: 1 | |
181 | Prefer: return-minimal | |
182 | Content-Type: application/xml; charset=utf-8 | |
183 | ||
184 | <c:calendar-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav"> | |
185 | <d:prop> | |
186 | <d:getetag /> | |
187 | <c:calendar-data /> | |
188 | </d:prop> | |
189 | <c:filter> | |
190 | <c:comp-filter name="VCALENDAR" /> | |
191 | </c:filter> | |
192 | </c:calendar-query> | |
193 | ||
194 | Success: | |
195 | HTTP/1.1 207 Multi-status | |
196 | Content-Type: application/xml; charset=utf-8 | |
197 | ||
198 | <d:multistatus xmlns:d="DAV:" xmlns:cs="http://calendarserver.org/ns/"> | |
199 | <d:response> | |
200 | <d:href>/calendars/johndoe/home/132456762153245.ics</d:href> | |
201 | <d:propstat> | |
202 | <d:prop> | |
203 | <d:getetag>"2134-314"</d:getetag> | |
204 | <c:calendar-data>BEGIN:VCALENDAR | |
205 | VERSION:2.0 | |
206 | CALSCALE:GREGORIAN | |
207 | BEGIN:VTODO | |
208 | UID:132456762153245 | |
209 | SUMMARY:Do the dishes | |
210 | DUE:20121028T115600Z | |
211 | END:VTODO | |
212 | END:VCALENDAR | |
213 | </c:calendar-data> | |
214 | </d:prop> | |
215 | <d:status>HTTP/1.1 200 OK</d:status> | |
216 | </d:propstat> | |
217 | </d:response> | |
218 | <d:response> | |
219 | <d:href>/calendars/johndoe/home/132456-34365.ics</d:href> | |
220 | <d:propstat> | |
221 | <d:prop> | |
222 | <d:getetag>"5467-323"</d:getetag> | |
223 | <c:calendar-data>BEGIN:VCALENDAR | |
224 | VERSION:2.0 | |
225 | CALSCALE:GREGORIAN | |
226 | BEGIN:VEVENT | |
227 | UID:132456-34365 | |
228 | SUMMARY:Weekly meeting | |
229 | DTSTART:20120101T120000 | |
230 | DURATION:PT1H | |
231 | RRULE:FREQ=WEEKLY | |
232 | END:VEVENT | |
233 | END:VCALENDAR | |
234 | </c:calendar-data> | |
235 | </d:prop> | |
236 | <d:status>HTTP/1.1 200 OK</d:status> | |
237 | </d:propstat> | |
238 | </d:response> | |
239 | </d:multistatus> | |
240 | ||
241 | For each object get: | |
242 | - Calendar data | |
243 | - url | |
244 | - etag | |
245 | ||
246 | 4. Check for changes | |
247 | - Fetch ctag -> see 1. | |
248 | - If ctag is changes fetch all etags | |
249 | REPORT /calendars/johndoe/home/ HTTP/1.1 | |
250 | Depth: 1 | |
251 | Prefer: return-minimal | |
252 | Content-Type: application/xml; charset=utf-8 | |
253 | ||
254 | <c:calendar-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav"> | |
255 | <d:prop> | |
256 | <d:getetag /> | |
257 | </d:prop> | |
258 | <c:filter> | |
259 | <c:comp-filter name="VCALENDAR" /> | |
260 | </c:filter> | |
261 | </c:calendar-query> | |
262 | ||
263 | Success: | |
264 | HTTP/1.1 207 Multi-status | |
265 | Content-Type: application/xml; charset=utf-8 | |
266 | ||
267 | <d:multistatus xmlns:d="DAV:" xmlns:cs="http://calendarserver.org/ns/"> | |
268 | <d:response> | |
269 | <d:href>/calendars/johndoe/home/132456762153245.ics</d:href> | |
270 | <d:propstat> | |
271 | <d:prop> | |
272 | <d:getetag>"xxxx-xxx"</d:getetag> | |
273 | </d:prop> | |
274 | <d:status>HTTP/1.1 200 OK</d:status> | |
275 | </d:propstat> | |
276 | </d:response> | |
277 | <d:response> | |
278 | <d:href>/calendars/johndoe/home/fancy-caldav-client-1234253678.ics</d:href> | |
279 | <d:propstat> | |
280 | <d:prop> | |
281 | <d:getetag>"5-12"</d:getetag> | |
282 | </d:prop> | |
283 | <d:status>HTTP/1.1 200 OK</d:status> | |
284 | </d:propstat> | |
285 | </d:response> | |
286 | </d:multistatus> | |
287 | ||
288 | Compare local url's to request: | |
289 | if match compare etag. if etag compares continue else update. | |
290 | delete each local url not found | |
291 | fetch every url not found local | |
292 | ||
293 | update/fetch: | |
294 | REPORT /calendars/johndoe/home/ HTTP/1.1 | |
295 | Depth: 1 | |
296 | Prefer: return-minimal | |
297 | Content-Type: application/xml; charset=utf-8 | |
298 | ||
299 | <c:calendar-multiget xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav"> | |
300 | <d:prop> | |
301 | <d:getetag /> | |
302 | <c:calendar-data /> | |
303 | </d:prop> | |
304 | <d:href>/calendars/johndoe/home/132456762153245.ics</d:href> | |
305 | <d:href>/calendars/johndoe/home/fancy-caldav-client-1234253678.ics</d:href> | |
306 | </c:calendar-multiget> | |
307 | ||
308 | 5. Updating objects | |
309 | If-Match contains etag to update and You must not change the UID of the original object | |
310 | PUT /calendars/johndoe/home/132456762153245.ics HTTP/1.1 | |
311 | Content-Type: text/calendar; charset=utf-8 | |
312 | If-Match: "2134-314" | |
313 | ||
314 | BEGIN:VCALENDAR | |
315 | .... | |
316 | END:VCALENDAR | |
317 | ||
318 | Success: | |
319 | HTTP/1.1 204 No Content | |
320 | ETag: "2134-315" | |
321 | ||
322 | If no etag is returned make an immediate GET to get etag | |
323 | ||
324 | 6. Create an object | |
325 | PUT /calendars/johndoe/home/somerandomstring.ics HTTP/1.1 | |
326 | Content-Type: text/calendar; charset=utf-8 | |
327 | ||
328 | BEGIN:VCALENDAR | |
329 | .... | |
330 | END:VCALENDAR | |
331 | ||
332 | Success: | |
333 | HTTP/1.1 201 Created | |
334 | ETag: "21345-324" | |
335 | ||
336 | 7. Deleting an object | |
337 | DELETE /calendars/johndoe/home/132456762153245.ics HTTP/1.1 | |
338 | If-Match: "2134-314" | |
339 |