diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-06-25 18:15:32 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-06-25 18:25:33 +0200 |
commit | 7dc9e082426cd6c81310c2f78088b5b613bd0c10 (patch) | |
tree | 4f3f2295eef117bc539677775f63c1c16fc6bacc /module/vcomponent.scm | |
parent | ICS writer now handles types and parameters. (diff) | |
download | calp-7dc9e082426cd6c81310c2f78088b5b613bd0c10.tar.gz calp-7dc9e082426cd6c81310c2f78088b5b613bd0c10.tar.xz |
Add structure for importing events.
Diffstat (limited to '')
-rw-r--r-- | module/vcomponent.scm | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/module/vcomponent.scm b/module/vcomponent.scm index 61168e70..e55b4f9b 100644 --- a/module/vcomponent.scm +++ b/module/vcomponent.scm @@ -69,3 +69,41 @@ (define-method (get-event-by-uid uid) (hash-ref (getf 'uid-map) uid)) + + + + +(use-modules (output ical) + (ice-9 popen) + ((ice-9 rdelim) :select (read-line)) + ((rnrs io ports) :select (call-with-port)) + ) + + +(define (uuidgen) + (call-with-port (open-input-pipe "uuidgen") + read-line)) + +(define (filepath calendar uid) + (string-append (attr calendar 'X-HNH-DIRECTORY) + file-name-separator-string + uid ".ics")) + + +(define-public (calendar-import calendar event) + (case (attr calendar 'X-HNH-SOURCETYPE) + [(file) + (error "Importing into direct calendar files not supported")] + [(vdir) + (aif (attr event 'UID) + (with-output-to-file (filepath calendar it) + (lambda () (print-components-with-fake-parent (list event)))) + (let ((uuid (uuidgen))) + (set! (attr event 'UID) uuid) + ;; TODO this should caputure attributes from the calendar + (with-output-to-file (filepath calendar uuid) + (lambda () + (print-components-with-fake-parent (list event))))))] + [else + (error "Source of calendar unknown, aborting.") + ])) |