package carddav

import "github.com/emersion/go-webdav/carddav"

Package carddav provides a client and server CardDAV implementation.

CardDAV is defined in RFC 6352.

Index

Package Files

carddav.go client.go elements.go server.go

func Discover

func Discover(domain string) (string, error)

Discover performs a DNS-based CardDAV service discovery as described in RFC 6352 section 11. It returns the URL to the CardDAV server.

type AddressBook

type AddressBook struct {
    Path                 string
    Name                 string
    Description          string
    MaxResourceSize      int64
    SupportedAddressData []AddressDataType
}

func (*AddressBook) SupportsAddressData

func (ab *AddressBook) SupportsAddressData(contentType, version string) bool

type AddressBookMultiGet

type AddressBookMultiGet struct {
    Paths       []string
    DataRequest AddressDataRequest
}

type AddressBookQuery

type AddressBookQuery struct {
    DataRequest AddressDataRequest

    PropFilters []PropFilter
    FilterTest  FilterTest // defaults to FilterAnyOf

    Limit int // <= 0 means unlimited
}

type AddressDataRequest

type AddressDataRequest struct {
    Props   []string
    AllProp bool
}

type AddressDataType

type AddressDataType struct {
    ContentType string
    Version     string
}

type AddressObject

type AddressObject struct {
    Path    string
    ModTime time.Time
    ETag    string
    Card    vcard.Card
}

type Backend

type Backend interface {
    AddressBook() (*AddressBook, error)
    GetAddressObject(path string, req *AddressDataRequest) (*AddressObject, error)
    ListAddressObjects(req *AddressDataRequest) ([]AddressObject, error)
    QueryAddressObjects(query *AddressBookQuery) ([]AddressObject, error)
    PutAddressObject(path string, card vcard.Card) (loc string, err error)
    DeleteAddressObject(path string) error
}

Backend is a CardDAV server backend.

type Client

type Client struct {
    *webdav.Client
    // contains filtered or unexported fields
}

Client provides access to a remote CardDAV server.

func NewClient

func NewClient(c webdav.HTTPClient, endpoint string) (*Client, error)

func (*Client) FindAddressBookHomeSet

func (c *Client) FindAddressBookHomeSet(principal string) (string, error)

func (*Client) FindAddressBooks

func (c *Client) FindAddressBooks(addressBookHomeSet string) ([]AddressBook, error)

func (*Client) GetAddressObject

func (c *Client) GetAddressObject(path string) (*AddressObject, error)

func (*Client) HasSupport

func (c *Client) HasSupport() error

func (*Client) MultiGetAddressBook

func (c *Client) MultiGetAddressBook(path string, multiGet *AddressBookMultiGet) ([]AddressObject, error)

func (*Client) PutAddressObject

func (c *Client) PutAddressObject(path string, card vcard.Card) (*AddressObject, error)

func (*Client) QueryAddressBook

func (c *Client) QueryAddressBook(addressBook string, query *AddressBookQuery) ([]AddressObject, error)

func (*Client) SyncCollection

func (c *Client) SyncCollection(path string, query *SyncQuery) (*SyncResponse, error)

SyncCollection do a sync-collection operation on resource(path), it returns a SyncResponse

type FilterTest

type FilterTest string
const (
    FilterAnyOf FilterTest = "anyof"
    FilterAllOf FilterTest = "allof"
)

type Handler

type Handler struct {
    Backend Backend
}

Handler handles CardDAV HTTP requests. It can be used to create a CardDAV server.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler.

type MatchType

type MatchType string
const (
    MatchEquals     MatchType = "equals"
    MatchContains   MatchType = "contains"
    MatchStartsWith MatchType = "starts-with"
    MatchEndsWith   MatchType = "ends-with"
)

type ParamFilter

type ParamFilter struct {
    Name string

    // if IsNotDefined is set, TextMatch needs to be unset
    IsNotDefined bool
    TextMatch    *TextMatch
}

type PropFilter

type PropFilter struct {
    Name string
    Test FilterTest // defaults to FilterAnyOf

    // if IsNotDefined is set, TextMatches and Params need to be unset
    IsNotDefined bool
    TextMatches  []TextMatch
    Params       []ParamFilter
}

type SyncQuery

type SyncQuery struct {
    DataRequest AddressDataRequest
    SyncToken   string
    Limit       int // <= 0 means unlimited
}

SyncQuery is the query struct represents a sync-collection request

type SyncResponse

type SyncResponse struct {
    SyncToken string
    Updated   []AddressObject
    Deleted   []string
}

SyncResponse contains the returned sync-token for next time

type TextMatch

type TextMatch struct {
    Text            string
    NegateCondition bool
    MatchType       MatchType // defaults to MatchContains
}
Version
v0.3.1 (latest)
Published
Aug 11, 2021
Platform
linux/amd64
Imports
13 packages (graph)
Last checked
3 weeks ago

Tools for package owners.