mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-22 16:24:14 +00:00
carddav: define XML names as globals
This commit is contained in:
parent
bf666bb2fb
commit
402593c5c6
@ -1,8 +1,6 @@
|
|||||||
package carddav
|
package carddav
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/xml"
|
|
||||||
|
|
||||||
"github.com/emersion/go-vcard"
|
"github.com/emersion/go-vcard"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package carddav
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/xml"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/emersion/go-vcard"
|
"github.com/emersion/go-vcard"
|
||||||
@ -34,9 +33,7 @@ func (c *Client) SetBasicAuth(username, password string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) FindAddressBookHomeSet(principal string) (string, error) {
|
func (c *Client) FindAddressBookHomeSet(principal string) (string, error) {
|
||||||
name := xml.Name{namespace, "addressbook-home-set"}
|
propfind := internal.NewPropNamePropfind(addressBookHomeSetName)
|
||||||
propfind := internal.NewPropNamePropfind(name)
|
|
||||||
|
|
||||||
resp, err := c.ic.PropfindFlat(principal, propfind)
|
resp, err := c.ic.PropfindFlat(principal, propfind)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@ -51,10 +48,7 @@ func (c *Client) FindAddressBookHomeSet(principal string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) FindAddressBooks(addressBookHomeSet string) ([]AddressBook, error) {
|
func (c *Client) FindAddressBooks(addressBookHomeSet string) ([]AddressBook, error) {
|
||||||
resTypeName := xml.Name{"DAV:", "resourcetype"}
|
propfind := internal.NewPropNamePropfind(internal.ResourceTypeName, addressBookDescriptionName)
|
||||||
descName := xml.Name{namespace, "addressbook-description"}
|
|
||||||
propfind := internal.NewPropNamePropfind(resTypeName, descName)
|
|
||||||
|
|
||||||
ms, err := c.ic.Propfind(addressBookHomeSet, internal.DepthOne, propfind)
|
ms, err := c.ic.Propfind(addressBookHomeSet, internal.DepthOne, propfind)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -8,7 +8,11 @@ import (
|
|||||||
|
|
||||||
const namespace = "urn:ietf:params:xml:ns:carddav"
|
const namespace = "urn:ietf:params:xml:ns:carddav"
|
||||||
|
|
||||||
var addressBookName = xml.Name{namespace, "addressbook"}
|
var (
|
||||||
|
addressBookName = xml.Name{namespace, "addressbook"}
|
||||||
|
addressBookHomeSetName = xml.Name{namespace, "addressbook-home-set"}
|
||||||
|
addressBookDescriptionName = xml.Name{namespace, "addressbook-description"}
|
||||||
|
)
|
||||||
|
|
||||||
type addressbookHomeSet struct {
|
type addressbookHomeSet struct {
|
||||||
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:carddav addressbook-home-set"`
|
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:carddav addressbook-home-set"`
|
||||||
|
Loading…
Reference in New Issue
Block a user