diff --git a/main/dav_server.go b/main/dav_server.go
new file mode 100644
index 0000000..91a83ab
--- /dev/null
+++ b/main/dav_server.go
@@ -0,0 +1,60 @@
+package main
+
+import (
+ "fmt"
+ "io"
+ "log"
+ "net/http"
+ "strings"
+)
+
+// simple test XML
+const xml string = `
+
+
+
+
+
+
+
+ `
+
+var client *http.Client
+
+func init_dav_client() {
+ client = &http.Client{}
+}
+
+type SimpleCalDavData struct {
+ DisplayName string
+ Calandars []string
+}
+
+// this makes stalwart assumptions
+func get_caldav_data(username string, password string) SimpleCalDavData {
+ req, _ := http.NewRequest(
+ "PROPFIND",
+ serverConfig.URL+"/dav/cal/"+convert_username_into_url(username),
+ strings.NewReader(xml),
+ )
+
+ req.SetBasicAuth(username, password)
+ req.Header.Set("Depth", "1")
+ req.Header.Set("Content-Type", "application/xml")
+
+ resp, err := client.Do(req)
+ if err != nil {
+ fmt.Print(err.Error())
+ }
+ defer resp.Body.Close()
+
+ _, err = io.ReadAll(resp.Body)
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ return SimpleCalDavData{
+ DisplayName: "N/A",
+ Calandars: []string{},
+ }
+}
diff --git a/main/main.go b/main/main.go
index eb8b733..8d4891a 100644
--- a/main/main.go
+++ b/main/main.go
@@ -1,50 +1,7 @@
package main
-import (
- "fmt"
- "io"
- "log"
- "net/http"
- "strings"
-)
-
func main() {
read_config()
-
- client := &http.Client{}
-
- xml := `
-
-
-
-
-
-
-
- `
-
- body := strings.NewReader(xml)
-
- req, _ := http.NewRequest(
- "PROPFIND",
- serverConfig.URL+"/dav/cal/"+convert_username_into_url(serverConfig.Username),
- body,
- )
-
- req.SetBasicAuth(serverConfig.Username, serverConfig.Password)
- req.Header.Set("Depth", "1")
- req.Header.Set("Content-Type", "application/xml")
-
- resp, err := client.Do(req)
- if err != nil {
- fmt.Print(err.Error())
- }
- defer resp.Body.Close()
-
- body2, err := io.ReadAll(resp.Body)
- if err != nil {
- log.Fatal(err)
- }
-
- fmt.Println(string(body2))
+ init_dav_client()
+ get_caldav_data(serverConfig.Username, serverConfig.Password)
}