diff options
| author | Calvin Morrison <calvin@pobox.com> | 2026-08-22 14:04:17 -0400 |
|---|---|---|
| committer | Calvin Morrison <calvin@pobox.com> | 2026-08-22 14:04:17 -0400 |
| commit | 08155ead7bf80308b4cb67063cc91e3e3679ce16 (patch) | |
| tree | b0c0673b3e7f20d318695ec1992ef1cdf47e284d /pim/rc | |
| parent | 8a3d2c99bff60cb775ebc42516c0c3912d54ba3d (diff) | |
pim: a caldav backend, and a partstat that refuses to lie
caldav/fs is the second backend, and it cost ~330 lines: discovery,
a report for the window, ETags to decide whether anything moved. The
event model, recurrence expansion, the tree, ctl, query, alarm and
changed all came from lib/cal untouched, which is what the split was
for. go-webdav hands back *ical.Calendar from the same library lib/cal
parses with, so FromCalendars takes it straight in.
Two interfaces, both optional. Identity says whose calendar this is,
because in iTIP your identity is the mailto: in your own ATTENDEE line
and nothing else can tell which attendee is you. RSVPer says the
backend can answer an invitation -- meaning both halves of it, updating
your copy and telling the organiser. A backend that can only do one
should not implement it, so partstat is 0444 on a published .ics and
writing to it fails rather than half-working.
Two bugs worth naming. go-webdav resolves paths with path.Join, which
drops a trailing slash: pointed at /dav/ it asks about /dav, and Cyrus
answers 405 for that spelling and 207 for the other, so the first
PROPFIND is done by hand. And an absolute DAV href replaces the
endpoint's path rather than extending it; appending gave
/dav/dav/calendars/..., a 404, and a probe reading 404 as "no" hid
calendar-auto-schedule, which fastmail does in fact offer.
pimup brings mail and the calendars up and mounts them; riostart runs
it before opening any window, since a mount only exists in the
namespace that made it. rio does not run riostart by itself: it is the
argument to -i.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'pim/rc')
| -rwxr-xr-x | pim/rc/pimup | 71 | ||||
| -rwxr-xr-x | pim/rc/riostart | 20 |
2 files changed, 91 insertions, 0 deletions
diff --git a/pim/rc/pimup b/pim/rc/pimup new file mode 100755 index 0000000..1d7b2de --- /dev/null +++ b/pim/rc/pimup @@ -0,0 +1,71 @@ +#!/bin/rc +# pimup -- bring up mail and the calendars, and mount them here. +# +# Safe to run twice: anything already posted in /srv is reused rather +# than started again. Run it from riostart so every window inherits the +# mounts, since a mount only exists in the namespace that made it. +rfork e + +cald=/usr/glenda/lib/cal +log=/tmp/pimup.log +>$log + +# Wait for a server to announce itself and echo the name it posted. +# rc has no return, so this loops on a condition rather than bailing out. +fn waitsrv { + s=() + i=0 + while(~ $#s 0 && test $i -lt 40){ + s=`{sed -n 's|.*serving /srv/||p' $1} + if(~ $#s 0){ + sleep 1 + i=`{echo $i + 1 | bc} + } + } + echo $"s +} + +# ---- mail +if(! test -e /srv/upasfs.$user) + upas/fs -s -f /imaps/imap.fastmail.com/calvin@pobox.com \ + </dev/null >/dev/null >>[2]$log & +sleep 2 +if(test -e /srv/upasfs.$user) + mount /srv/upasfs.$user /mail/fs >>[2]$log + +# ---- mount points for the calendars +if(! test -e /srv/pimroot) + mntgen -s pimroot /mnt/pim </dev/null >/dev/null >[2]/dev/null & +sleep 1 +mount /srv/pimroot /mnt/pim >[2]/dev/null +ls -d /mnt/pim/calendars >/dev/null >[2]/dev/null +if(! test -e /srv/pimcals) + mntgen -s pimcals /mnt/pim/calendars </dev/null >/dev/null >[2]/dev/null & +sleep 1 +mount /srv/pimcals /mnt/pim/calendars >[2]/dev/null + +# ---- calendars. Go's getpid() on plan9 is a thread id, so the name rc +# knows as $apid is not the one in /srv: read it out of the log. +fn cal { + name=$1 + l=$2 + shift + shift + if(! test -f /mnt/pim/calendars/$name/ctl){ + >$l + $* >[2]$l </dev/null >/dev/null & + s=`{waitsrv $l} + if(~ $#s 0) + echo 'pimup: '^$name^' did not start, see '^$l >>$log + if(! ~ $#s 0) + mount /srv/^$"s /mnt/pim/calendars/$name >>[2]$log + } +} + +cal work /tmp/work.log ical/fs -N work -d $cald +cal local /tmp/local.log ical/fs -N local -d /tmp/callocal +if(test -f $cald/fastmail.pw) + cal fastmail /tmp/dav.log caldav/fs -e https://caldav.fastmail.com/dav/ \ + -u calvin@pobox.com -p $cald/fastmail.pw -C Calendar -N fastmail + +exit 0 diff --git a/pim/rc/riostart b/pim/rc/riostart new file mode 100755 index 0000000..7384503 --- /dev/null +++ b/pim/rc/riostart @@ -0,0 +1,20 @@ +#!/bin/rc +# riostart -- what rio brings up. +# +# rio does not run this by itself: it is the argument to -i. +# rio -i riostart +rfork e + +# servers and mounts first, so every window below inherits them +pimup + +window 0,0,161,117 stats -lmisce +window bar + +# a shell on the serial console, when there is one +~ $#console 0 || window -scroll console + +window -r 170 0 900 640 acme +window -r 170 650 1000 1000 cal9 + +window -miny 130 |
