blob: 82a8c18e45c96fc904b98bcd52828a48c9d31766 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
(define-module (calp webdav resource calendar object)
:use-module (srfi srfi-1)
:use-module (srfi srfi-71)
:use-module (srfi srfi-88)
:use-module (oop goops)
:use-module (calp webdav resource)
:use-module ((vcomponent formats ical) :prefix #{ics:}#)
:use-module ((vcomponent formats xcal) :prefix #{xcs:}#)
:use-module ((vcomponent) :prefix vcs-)
:use-module ((calp namespaces) :select (webdav))
:use-module (calp webdav property)
:use-module (sxml namespaced)
:export (<calendar-object-resource>
calendar-object-resource?
component)
)
;;; content%
(define-class <calendar-object-resource> (<resource>)
(component getter: component
init-keyword: component:))
(define-method (is-collection? (_ <calendar-object-resource>))
#f)
(define-method (children (_ <calendar-object-resource>))
'())
(define (calendar-object-resource? x)
(is-a? x <calendar-object-resource>))
(define-method (content (self <calendar-object-resource>) content-type)
(case content-type
((text/calendar)
(call-with-output-string (lambda (port) (ics:serialize (content% self) port))))
((application/calendar+xml)
(call-with-output-string (lambda (port) (xcs:serialize (content% self) port))))
;; ((text/html))
;; ((application/xhtml+xml))
;; ((application/calendar+json))
(else (content self 'text/calendar))
)
)
(define-method (creationdate (self <calendar-object-resource>))
(propstat 200
`((,(xml webdav 'creationdate)
(-> (content self)
(prop 'CREATED)
;; TODO timezone
(datetime->string "~Y-~m-~dT~H:~M:~SZ"))))))
(define-method (getcontentlength (self <calendar-object-resource>))
;; TODO which representation should be choosen to calculate length?
(propstat 501 `((,(xml webdav 'getcontentlength)))))
(define-method (getcontenttyype (self <calendar-object-resource>))
;; TODO different representations
(propstat 200 `((,(xml webdav 'getcontentlength)
"text/calendar"))))
(define-method (getlastmodified (self <calendar-object-resource>))
(propstat 200
`((,(xml webdav 'getlastmodified)
(string->datetime (prop (content self) 'LAST-MODIFIED)
"~Y~m~dT~H~M~S")))))
|