mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-22 16:24:14 +00:00
carddav: add AddressBook.Info
This commit is contained in:
parent
8d4a1ede86
commit
1152b72a07
@ -13,6 +13,12 @@ var (
|
||||
ErrNotFound = errors.New("carddav: not found")
|
||||
)
|
||||
|
||||
type AddressBookInfo struct {
|
||||
Name string
|
||||
Description string
|
||||
MaxResourceSize int
|
||||
}
|
||||
|
||||
type AddressObject interface {
|
||||
ID() string
|
||||
Card() (vcard.Card, error)
|
||||
@ -20,6 +26,7 @@ type AddressObject interface {
|
||||
}
|
||||
|
||||
type AddressBook interface {
|
||||
Info() (*AddressBookInfo, error)
|
||||
GetAddressObject(id string) (AddressObject, error)
|
||||
ListAddressObjects() ([]AddressObject, error)
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -202,6 +203,11 @@ func (d *dir) Stat() (os.FileInfo, error) {
|
||||
}
|
||||
|
||||
func (d *dir) DeadProps() (map[xml.Name]webdav.Property, error) {
|
||||
info, err := d.fs.ab.Info()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return map[xml.Name]webdav.Property{
|
||||
resourcetype: webdav.Property{
|
||||
XMLName: resourcetype,
|
||||
@ -209,19 +215,20 @@ func (d *dir) DeadProps() (map[xml.Name]webdav.Property, error) {
|
||||
},
|
||||
displayname: webdav.Property{
|
||||
XMLName: displayname,
|
||||
InnerXML: []byte("Test"),
|
||||
InnerXML: []byte(info.Name),
|
||||
},
|
||||
addressBookDescription: webdav.Property{
|
||||
XMLName: addressBookDescription,
|
||||
InnerXML: []byte("C'est juste un test mdr."),
|
||||
InnerXML: []byte(info.Description),
|
||||
},
|
||||
addressBookSupportedAddressData: webdav.Property{
|
||||
XMLName: addressBookSupportedAddressData,
|
||||
InnerXML: []byte(`<address-data-type xmlns="urn:ietf:params:xml:ns:carddav" content-type="text/vcard" version="3.0"/>`),
|
||||
InnerXML: []byte(`<address-data-type xmlns="urn:ietf:params:xml:ns:carddav" content-type="text/vcard" version="3.0"/>` +
|
||||
`<address-data-type xmlns="urn:ietf:params:xml:ns:carddav" content-type="text/vcard" version="4.0"/>`),
|
||||
},
|
||||
addressBookMaxResourceSize: webdav.Property{
|
||||
XMLName: addressBookMaxResourceSize,
|
||||
InnerXML: []byte("102400"),
|
||||
InnerXML: []byte(strconv.Itoa(info.MaxResourceSize)),
|
||||
},
|
||||
addressBookHomeSet: webdav.Property{
|
||||
XMLName: addressBookHomeSet,
|
||||
|
Loading…
Reference in New Issue
Block a user