CalDAVCalendarList CalDAV::GetCalendars(){
CalDAVCalendarList ServerList;
+ CalDAVSendData CalendarListSendData;
+
+ // Build the server address.
+
+ string UserPrincipalURI = "";
+ UserPrincipalURI = GetUserPrincipal();
+
+ if (UserPrincipalURI.size() == 0){
+
+ return ServerList;
+
+ }
+
+ string CalendarHomeURI = "";
+ CalendarHomeURI = GetCalendarHome(UserPrincipalURI);
+
+ cout << ServerData << endl;
+
+ string CalendarListURLAddress = BuildServerAddress(&ConnectionData, CalendarHomeURI);
+
+ cout << CalendarListURLAddress << endl;
+
+ string CalendarListRequest = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<d:propfind xmlns:d=\"DAV:\" xmlns:cs=\"http://calendarserver.org/ns/\""
+ " xmlns:c=\"urn:ietf:params:xml:ns:caldav\" xmlns:x0=\"http://apple.com/ns/ical/\">\n"
+ " <d:prop>\n"
+ " <d:resourcetype />\n"
+ " <d:displayname />\n"
+ " <x0:calendar-color />\n"
+ " <x0:calendar-order />\n"
+ " <cs:getctag />\n"
+ " <c:supported-calendar-component-set />\n"
+ " </d:prop>\n"
+ "</d:propfind>";
+
+ CalendarListSendData.readptr = &CalendarListRequest;
+ CalendarListSendData.sizeleft = CalendarListRequest.size();
+
+ // Setup the header.
+
+ struct curl_slist *CalendarListRequestHeader = NULL;
+
+ CalendarListRequestHeader = curl_slist_append(CalendarListRequestHeader, "Depth: 1");
+ CalendarListRequestHeader = curl_slist_append(CalendarListRequestHeader, "Prefer: return-minimal");
+ CalendarListRequestHeader = curl_slist_append(CalendarListRequestHeader, "Content-Type: application/xml; charset=utf-8");
+
+ curl_easy_setopt(ConnectionHandle, CURLOPT_HTTPHEADER, CalendarListRequestHeader);
+ curl_easy_setopt(ConnectionHandle, CURLOPT_URL, CalendarListURLAddress.c_str());
+ curl_easy_setopt(ConnectionHandle, CURLOPT_CUSTOMREQUEST, "PROPFIND");
+ curl_easy_setopt(ConnectionHandle, CURLOPT_UPLOAD, 1L);
+ curl_easy_setopt(ConnectionHandle, CURLOPT_READDATA, &CalendarListSendData);
+ curl_easy_setopt(ConnectionHandle, CURLOPT_READFUNCTION, CalDAVSend);
+
+ // Process the data.
+
+ ServerData.clear();
+ ServerHeader.clear();
+
+ CURLcode ServerResult = curl_easy_perform(ConnectionHandle);
+
+ cout << ServerData << endl;
+
+ //ServerList = ProcessXMLCalendarList();
+
+ // Restore the original settings.
+
+ string OriginalServerAddress = BuildServerAddress(&ConnectionData, "/principals");
+ curl_easy_setopt(ConnectionHandle, CURLOPT_URL, OriginalServerAddress.c_str());
+ curl_easy_setopt(ConnectionHandle, CURLOPT_CUSTOMREQUEST, NULL);
+ curl_easy_setopt(ConnectionHandle, CURLOPT_UPLOAD, 0L);
+ curl_easy_setopt(ConnectionHandle, CURLOPT_READDATA, NULL);
+ curl_easy_setopt(ConnectionHandle, CURLOPT_READFUNCTION, NULL);
return ServerList;