mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-23 00:34:23 +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")
|
ErrNotFound = errors.New("carddav: not found")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type AddressBookInfo struct {
|
||||||
|
Name string
|
||||||
|
Description string
|
||||||
|
MaxResourceSize int
|
||||||
|
}
|
||||||
|
|
||||||
type AddressObject interface {
|
type AddressObject interface {
|
||||||
ID() string
|
ID() string
|
||||||
Card() (vcard.Card, error)
|
Card() (vcard.Card, error)
|
||||||
@ -20,6 +26,7 @@ type AddressObject interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type AddressBook interface {
|
type AddressBook interface {
|
||||||
|
Info() (*AddressBookInfo, error)
|
||||||
GetAddressObject(id string) (AddressObject, error)
|
GetAddressObject(id string) (AddressObject, error)
|
||||||
ListAddressObjects() ([]AddressObject, error)
|
ListAddressObjects() ([]AddressObject, error)
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -202,6 +203,11 @@ func (d *dir) Stat() (os.FileInfo, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *dir) DeadProps() (map[xml.Name]webdav.Property, 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{
|
return map[xml.Name]webdav.Property{
|
||||||
resourcetype: webdav.Property{
|
resourcetype: webdav.Property{
|
||||||
XMLName: resourcetype,
|
XMLName: resourcetype,
|
||||||
@ -209,19 +215,20 @@ func (d *dir) DeadProps() (map[xml.Name]webdav.Property, error) {
|
|||||||
},
|
},
|
||||||
displayname: webdav.Property{
|
displayname: webdav.Property{
|
||||||
XMLName: displayname,
|
XMLName: displayname,
|
||||||
InnerXML: []byte("Test"),
|
InnerXML: []byte(info.Name),
|
||||||
},
|
},
|
||||||
addressBookDescription: webdav.Property{
|
addressBookDescription: webdav.Property{
|
||||||
XMLName: addressBookDescription,
|
XMLName: addressBookDescription,
|
||||||
InnerXML: []byte("C'est juste un test mdr."),
|
InnerXML: []byte(info.Description),
|
||||||
},
|
},
|
||||||
addressBookSupportedAddressData: webdav.Property{
|
addressBookSupportedAddressData: webdav.Property{
|
||||||
XMLName: addressBookSupportedAddressData,
|
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{
|
addressBookMaxResourceSize: webdav.Property{
|
||||||
XMLName: addressBookMaxResourceSize,
|
XMLName: addressBookMaxResourceSize,
|
||||||
InnerXML: []byte("102400"),
|
InnerXML: []byte(strconv.Itoa(info.MaxResourceSize)),
|
||||||
},
|
},
|
||||||
addressBookHomeSet: webdav.Property{
|
addressBookHomeSet: webdav.Property{
|
||||||
XMLName: addressBookHomeSet,
|
XMLName: addressBookHomeSet,
|
||||||
|
Loading…
Reference in New Issue
Block a user