get calandars and there names
This commit is contained in:
@@ -16,4 +16,10 @@ type PropStat struct {
|
|||||||
|
|
||||||
type Prop struct {
|
type Prop struct {
|
||||||
DisplayName string `xml:"displayname"`
|
DisplayName string `xml:"displayname"`
|
||||||
|
Type ResourceType `xml:"resourcetype"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ResourceType struct {
|
||||||
|
Collection *struct{} `xml:"DAV: collection"`
|
||||||
|
Calendar *struct{} `xml:"urn:ietf:params:xml:ns:caldav calendar"`
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-2
@@ -26,9 +26,13 @@ func init_dav_client() {
|
|||||||
client = &http.Client{}
|
client = &http.Client{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Calandar struct {
|
||||||
|
DisplayName string
|
||||||
|
}
|
||||||
|
|
||||||
type SimpleCalDavData struct {
|
type SimpleCalDavData struct {
|
||||||
DisplayName string
|
DisplayName string
|
||||||
Calandars []string
|
Calandars []Calandar
|
||||||
}
|
}
|
||||||
|
|
||||||
// this makes stalwart assumptions
|
// this makes stalwart assumptions
|
||||||
@@ -60,8 +64,23 @@ func get_caldav_data(username string, password string) SimpleCalDavData {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Print(string(body))
|
||||||
|
|
||||||
|
calandars := []Calandar{}
|
||||||
|
for i := range len(davResp.Responses) {
|
||||||
|
if davResp.Responses[i].PropStat[0].Prop.Type.Calendar == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
var new_cal Calandar = Calandar{
|
||||||
|
DisplayName: davResp.Responses[i].PropStat[0].Prop.DisplayName,
|
||||||
|
}
|
||||||
|
|
||||||
|
calandars = append(calandars, new_cal)
|
||||||
|
}
|
||||||
|
|
||||||
return SimpleCalDavData{
|
return SimpleCalDavData{
|
||||||
DisplayName: davResp.Responses[0].PropStat[0].Prop.DisplayName,
|
DisplayName: davResp.Responses[0].PropStat[0].Prop.DisplayName,
|
||||||
Calandars: []string{},
|
Calandars: calandars,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-1
@@ -6,5 +6,12 @@ func main() {
|
|||||||
read_config()
|
read_config()
|
||||||
init_dav_client()
|
init_dav_client()
|
||||||
calDavData := get_caldav_data(serverConfig.Username, serverConfig.Password)
|
calDavData := get_caldav_data(serverConfig.Username, serverConfig.Password)
|
||||||
fmt.Printf("Users display name: {%s}\n", calDavData.DisplayName)
|
|
||||||
|
fmt.Println()
|
||||||
|
|
||||||
|
fmt.Printf("Users display name: %s\n", calDavData.DisplayName)
|
||||||
|
fmt.Printf("Calandar Count: %d\n", len(calDavData.Calandars))
|
||||||
|
for i := range len(calDavData.Calandars) {
|
||||||
|
fmt.Printf("Cal %d is named %s\n", i, calDavData.Calandars[i].DisplayName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user