get event URLs
This commit is contained in:
@@ -23,3 +23,6 @@ type ResourceType struct {
|
||||
Collection *struct{} `xml:"DAV: collection"`
|
||||
Calendar *struct{} `xml:"urn:ietf:params:xml:ns:caldav calendar"`
|
||||
}
|
||||
|
||||
type CalandarData struct {
|
||||
}
|
||||
|
||||
+26
-7
@@ -26,9 +26,14 @@ func init_dav_client() {
|
||||
client = &http.Client{}
|
||||
}
|
||||
|
||||
type Event struct {
|
||||
Link string
|
||||
}
|
||||
|
||||
type Calandar struct {
|
||||
DisplayName string
|
||||
Link string
|
||||
Events []Event
|
||||
}
|
||||
|
||||
type SimpleCalDavData struct {
|
||||
@@ -90,16 +95,19 @@ const XML_cal string = `
|
||||
xmlns:C="urn:ietf:params:xml:ns:caldav">
|
||||
<D:prop>
|
||||
<D:getetag/>
|
||||
<C:calendar-data/>
|
||||
</D:prop>
|
||||
<C:filter>
|
||||
<C:comp-filter name="VCALENDAR">
|
||||
<C:comp-filter name="VEVENT"/>
|
||||
</C:comp-filter>
|
||||
</C:filter>
|
||||
|
||||
</C:calendar-query>
|
||||
`
|
||||
|
||||
// <C:calendar-data/>
|
||||
|
||||
// <C:filter>
|
||||
// <C:comp-filter name="VCALENDAR">
|
||||
// <C:comp-filter name="VEVENT"/>
|
||||
// </C:comp-filter>
|
||||
// </C:filter>
|
||||
|
||||
func get_calandar_data(cal Calandar, username string, password string) Calandar {
|
||||
req, _ := http.NewRequest(
|
||||
"REPORT",
|
||||
@@ -122,7 +130,18 @@ func get_calandar_data(cal Calandar, username string, password string) Calandar
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Println(string(body))
|
||||
var davResp MultiStatus
|
||||
err = xml.Unmarshal(body, &davResp)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
for i := range len(davResp.Responses) {
|
||||
newEvent := Event{
|
||||
Link: serverConfig.URL + davResp.Responses[i].Href,
|
||||
}
|
||||
cal.Events = append(cal.Events, newEvent)
|
||||
}
|
||||
|
||||
return cal
|
||||
}
|
||||
|
||||
+3
-1
@@ -12,8 +12,10 @@ func main() {
|
||||
fmt.Printf("Users display name: %s\n", calDavData.DisplayName)
|
||||
fmt.Printf("Calandar Count: %d\n", len(calDavData.Calandars))
|
||||
for i := range len(calDavData.Calandars) {
|
||||
calDavData.Calandars[i] = get_calandar_data(calDavData.Calandars[i], serverConfig.Username, serverConfig.Password)
|
||||
|
||||
fmt.Printf("Cal %d is named %s\n", i, calDavData.Calandars[i].DisplayName)
|
||||
fmt.Printf("\tLink to cal: %s\n", calDavData.Calandars[i].Link)
|
||||
calDavData.Calandars[i] = get_calandar_data(calDavData.Calandars[i], serverConfig.Username, serverConfig.Password)
|
||||
fmt.Printf("\tEvent count: %d\n", len(calDavData.Calandars[i].Events))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user