2020-01-21 20:01:18 +00:00
|
|
|
// Package carddav provides a client and server CardDAV implementation.
|
|
|
|
//
|
|
|
|
// CardDAV is defined in RFC 6352.
|
2020-01-14 21:19:54 +00:00
|
|
|
package carddav
|
|
|
|
|
2020-01-14 22:13:23 +00:00
|
|
|
import (
|
2020-01-22 14:35:36 +00:00
|
|
|
"time"
|
|
|
|
|
2020-01-14 22:44:21 +00:00
|
|
|
"github.com/emersion/go-vcard"
|
2022-03-21 08:16:50 +00:00
|
|
|
"github.com/emersion/go-webdav"
|
|
|
|
"github.com/emersion/go-webdav/internal"
|
2020-01-14 22:13:23 +00:00
|
|
|
)
|
|
|
|
|
2022-03-21 08:16:50 +00:00
|
|
|
func NewAddressBookHomeSet(path string) webdav.BackendSuppliedHomeSet {
|
|
|
|
return &addressbookHomeSet{Href: internal.Href{Path: path}}
|
|
|
|
}
|
|
|
|
|
2020-02-27 11:36:14 +00:00
|
|
|
type AddressDataType struct {
|
|
|
|
ContentType string
|
|
|
|
Version string
|
|
|
|
}
|
|
|
|
|
2020-01-14 22:13:23 +00:00
|
|
|
type AddressBook struct {
|
2020-02-27 11:36:14 +00:00
|
|
|
Path string
|
|
|
|
Name string
|
|
|
|
Description string
|
|
|
|
MaxResourceSize int64
|
|
|
|
SupportedAddressData []AddressDataType
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ab *AddressBook) SupportsAddressData(contentType, version string) bool {
|
|
|
|
if len(ab.SupportedAddressData) == 0 {
|
|
|
|
return contentType == "text/vcard" && version == "3.0"
|
|
|
|
}
|
|
|
|
for _, t := range ab.SupportedAddressData {
|
|
|
|
if t.ContentType == contentType && t.Version == version {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
2020-01-14 22:13:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type AddressBookQuery struct {
|
2020-01-27 09:30:19 +00:00
|
|
|
DataRequest AddressDataRequest
|
2020-01-23 09:35:06 +00:00
|
|
|
|
2020-01-24 10:25:58 +00:00
|
|
|
PropFilters []PropFilter
|
|
|
|
FilterTest FilterTest // defaults to FilterAnyOf
|
|
|
|
|
2020-01-23 09:35:06 +00:00
|
|
|
Limit int // <= 0 means unlimited
|
2020-01-14 22:44:21 +00:00
|
|
|
}
|
|
|
|
|
2020-01-27 09:30:19 +00:00
|
|
|
type AddressDataRequest struct {
|
|
|
|
Props []string
|
|
|
|
AllProp bool
|
|
|
|
}
|
|
|
|
|
2020-01-24 10:25:58 +00:00
|
|
|
type PropFilter struct {
|
|
|
|
Name string
|
2020-01-24 11:24:35 +00:00
|
|
|
Test FilterTest // defaults to FilterAnyOf
|
2020-01-24 10:25:58 +00:00
|
|
|
|
|
|
|
// if IsNotDefined is set, TextMatches and Params need to be unset
|
|
|
|
IsNotDefined bool
|
|
|
|
TextMatches []TextMatch
|
|
|
|
Params []ParamFilter
|
|
|
|
}
|
|
|
|
|
|
|
|
type ParamFilter struct {
|
|
|
|
Name string
|
|
|
|
|
|
|
|
// if IsNotDefined is set, TextMatch needs to be unset
|
|
|
|
IsNotDefined bool
|
|
|
|
TextMatch *TextMatch
|
|
|
|
}
|
|
|
|
|
|
|
|
type TextMatch struct {
|
|
|
|
Text string
|
|
|
|
NegateCondition bool
|
|
|
|
MatchType MatchType // defaults to MatchContains
|
|
|
|
}
|
|
|
|
|
|
|
|
type FilterTest string
|
|
|
|
|
|
|
|
const (
|
|
|
|
FilterAnyOf FilterTest = "anyof"
|
|
|
|
FilterAllOf FilterTest = "allof"
|
|
|
|
)
|
|
|
|
|
|
|
|
type MatchType string
|
|
|
|
|
|
|
|
const (
|
|
|
|
MatchEquals MatchType = "equals"
|
|
|
|
MatchContains MatchType = "contains"
|
|
|
|
MatchStartsWith MatchType = "starts-with"
|
|
|
|
MatchEndsWith MatchType = "ends-with"
|
|
|
|
)
|
|
|
|
|
2020-01-15 11:09:42 +00:00
|
|
|
type AddressBookMultiGet struct {
|
2020-01-30 12:18:05 +00:00
|
|
|
Paths []string
|
2020-01-27 09:30:19 +00:00
|
|
|
DataRequest AddressDataRequest
|
2020-01-15 11:09:42 +00:00
|
|
|
}
|
|
|
|
|
2020-01-17 15:20:05 +00:00
|
|
|
type AddressObject struct {
|
2022-05-17 14:12:12 +01:00
|
|
|
Path string
|
|
|
|
ModTime time.Time
|
|
|
|
ContentLength int64
|
|
|
|
ETag string
|
|
|
|
Card vcard.Card
|
2020-01-14 22:13:23 +00:00
|
|
|
}
|
2020-03-29 13:08:48 +01:00
|
|
|
|
2022-08-31 12:42:38 +01:00
|
|
|
// SyncQuery is the query struct represents a sync-collection request
|
2020-03-29 13:08:48 +01:00
|
|
|
type SyncQuery struct {
|
|
|
|
DataRequest AddressDataRequest
|
|
|
|
SyncToken string
|
|
|
|
Limit int // <= 0 means unlimited
|
|
|
|
}
|
|
|
|
|
2022-08-31 12:42:38 +01:00
|
|
|
// SyncResponse contains the returned sync-token for next time
|
2020-03-29 13:08:48 +01:00
|
|
|
type SyncResponse struct {
|
|
|
|
SyncToken string
|
|
|
|
Updated []AddressObject
|
|
|
|
Deleted []string
|
|
|
|
}
|