\documentclass{article}
\usepackage{ulem}
\pagestyle{headings}
\begin{document}
\part{ Developer Notes on WebDAV\footnote{http://example.com/index.php?page=WebDAV} and CalDAV\footnote{http://example.com/index.php?page=CalDAV}/CardDAV\footnote{http://example.com/index.php?page=CardDAV} Support in Horde}
This page is mostly based on Horde 5 and Horde master as of 12/2018

Horde offers two different DAV endpoint types:

- CalDAV\footnote{http://example.com/index.php?page=CalDAV} and CardDAV\footnote{http://example.com/index.php?page=CardDAV} are tied to the applications implementing the calendar/ and addressbooks/ api's\newline
- Generic WebDAV\footnote{http://example.com/index.php?page=WebDAV} hierarchies may be implemented by any application.

\section{ Horde\_Dav and SabreDAV\footnote{http://example.com/index.php?page=SabreDAV}}
Horde DAV support is implemented based on the SabreDAV\footnote{http://example.com/index.php?page=SabreDAV} library. As of 2018, it's SabreDAV\footnote{http://example.com/index.php?page=SabreDAV} 2.1

SabreDAV\footnote{http://example.com/index.php?page=SabreDAV} is wrapped in Horde\_Dav. Horde\_Dav implements or extends various interfaces and base classes used by SabreDAV\footnote{http://example.com/index.php?page=SabreDAV}.\newline
Horde\_Auth is wrapped into Horde\_Dav\_Auth which extends the abstract SabreDAV\footnote{http://example.com/index.php?page=SabreDAV} auth backend.\newline
Horde\_Dav\_RootCollection implements a top node for a hierarchy of Horde\_Dav\_Collection items (DAV folders)\newline
Horde\_Dav\_Principals exposes users and groups as (principials) to SabreDAV\footnote{http://example.com/index.php?page=SabreDAV}.\newline
Shares/Resources owned by the system use the empty string in the horde shares backend, but use the string -system- in SabreDAV\footnote{http://example.com/index.php?page=SabreDAV} context. This conversion needs to be done by the implementing app, not by Horde\_Dav.\newline
Horde\_Dav\_File implements a leaf node in DAV (a file)

\section{ CalDAV\footnote{http://example.com/index.php?page=CalDAV} and CardDAV\footnote{http://example.com/index.php?page=CardDAV}}
The Horde\_Dav caldav and CardDAV\footnote{http://example.com/index.php?page=CardDAV} backends is accessed through the horde/base app's rpc endpoint /rpc/ or /rpc.php depending on config. This endpoint detects DAV and exposes three hierarchies\newline
rpc/addressbooks/\newline
rpc/calendars/\newline
rpc/principals/

Horde\_Dav\_Storage maps the exposed name of caldav and carddav leaf objects (files) to collections.

TODO: How are resources handled when they exist internally but the mapping is missing for some reasons like admin meddling in DB?

\subsection{ CalDAV\footnote{http://example.com/index.php?page=CalDAV} specifics}
The CalDAV\footnote{http://example.com/index.php?page=CalDAV} calendars backend relies on registry Api calls. Most of the code delegates finding the implementing horde app for a specific resource to the storage implementation's getCollectionInterface() method. However, the constructor explicitly only looks for the apps implementing the calendar api (kronolith) and the tasks api (nag). If another app implements the respective API's, it can substitute any of the two as a backend. However, it's currently not possible to directly expose a third app's resources to caldav. However, there is work to make kronolith expose other applications' timeobjects to caldav as a pass-through, just like in UI.

Currently, Horde\_Dav does not allow adding new collections via CalDAV\footnote{http://example.com/index.php?page=CalDAV}.

\subsection{ CardDAV\footnote{http://example.com/index.php?page=CardDAV} specifics}
The CardDAV\footnote{http://example.com/index.php?page=CardDAV} addressbooks backend relies on registry Api calls to whatever application implements the contacts api. Thus, only one application can interface addressbooks to CardDAV\footnote{http://example.com/index.php?page=CardDAV}. However, that application may or may not implement interfacing resources exposed by other apps. The default app to expose addressbooks is turba.

Flow:

horde/rpc determines it is a webdav call and starts a Horde\_Rpc\_Webdav instance. \newline
This wraps Horde\_Dav\_Server, which is a SabreDAV\footnote{http://example.com/index.php?page=SabreDAV} server with a Horde\_Dav CardDAV\footnote{http://example.com/index.php?page=CardDAV} backend.\newline
This carddav backend is an app which implements the dav* methods in Application.php\newline
SabreDAV\footnote{http://example.com/index.php?page=SabreDAV} will handle the request and provide an answer to horde/rpc, using the Horde app as its storage backend.

\section{ WebDAV\footnote{http://example.com/index.php?page=WebDAV}}
Generic WebDAV\footnote{http://example.com/index.php?page=WebDAV} can be implemented by any app. \newline
It is exposed as rpc/\$appname/ in the tree. Note how it uses the internal app name, not the name of a registry interface.\newline
An app needs to implement the following API methods to expose WebDAV\footnote{http://example.com/index.php?page=WebDAV} folders and files:

\$App\_Api::browse(\$path, \$properties)

returns a list of next level nodes relative to the path (files and collections)

\$App\_Api::put(\$path, \$content, \$contentType)

to support writing files

path\_delete(\$path) to delete either files or collections

The app implementing these methods does not need to deal with any of the Horde\_Dav related objects as Horde\_Rpc\_WebDAV and Horde\_Dav handle these aspects.\newline
However, if the same resources are also exposed via CalDAV\footnote{http://example.com/index.php?page=CalDAV}/CardDAV\footnote{http://example.com/index.php?page=CardDAV} Api, it might create inconsistency if a resource is created or deleted without Horde\_Dav knowing.

\section{ Notes on *dav lingo and principles}
\end{document}
