curl_easy_setopt(ConnectionHandle, CURLOPT_READFUNCTION, NULL);
return CurrentUserPrincipal;
+
+}
+
+string CalDAV::GetCalendarHome(string UserPrincipalURI){
+
+ string CalendarHomeURI = "";
+
+ // Build the Calendar Home URL address.
+
+ string CalendarHomeURL = BuildServerAddress(&ConnectionData, UserPrincipalURI);
+
+ // Setup the header request.
+
+ CalDAVSendData CalendarHomeSendData;
+
+ string CalendarHomeRequest = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<d:propfind xmlns:d=\"DAV:\" xmlns:c=\"urn:ietf:params:xml:ns:caldav\">\n"
+ " <d:prop>\n"
+ " <c:calendar-home-set />\n"
+ " </d:prop>\n"
+ "</d:propfind>";
+
+ CalendarHomeSendData.readptr = &CalendarHomeRequest;
+ CalendarHomeSendData.sizeleft = CalendarHomeRequest.size();
+
+ // Setup the header.
+
+ struct curl_slist *CalendarRequestHeader = NULL;
+
+ CalendarRequestHeader = curl_slist_append(CalendarRequestHeader, "Depth: 0");
+ CalendarRequestHeader = curl_slist_append(CalendarRequestHeader, "Prefer: return-minimal");
+ CalendarRequestHeader = curl_slist_append(CalendarRequestHeader, "Content-Type: application/xml; charset=utf-8");
+
+ curl_easy_setopt(ConnectionHandle, CURLOPT_HTTPHEADER, CalendarRequestHeader);
+ curl_easy_setopt(ConnectionHandle, CURLOPT_URL, CalendarHomeURL.c_str());
+ curl_easy_setopt(ConnectionHandle, CURLOPT_CUSTOMREQUEST, "PROPFIND");
+ curl_easy_setopt(ConnectionHandle, CURLOPT_UPLOAD, 1L);
+ curl_easy_setopt(ConnectionHandle, CURLOPT_READDATA, &CalendarHomeSendData);
+ curl_easy_setopt(ConnectionHandle, CURLOPT_READFUNCTION, CalDAVSend);
+
+ // Process the data.
+
+ ServerData.clear();
+ ServerHeader.clear();
+
+ CURLcode ServerResult = curl_easy_perform(ConnectionHandle);
+
+ // Set the results.
+
+ if (ServerResult == CURLE_OK){
+ ConnectionServerResult.Result = CALDAVQUERYRESULT_OK;
+ } else {
+ ConnectionServerResult.Result = CALDAVQUERYRESULT_SERVERERROR;
+ }
+ ConnectionServerResult.Code = ServerResult;
+ curl_easy_getinfo(ConnectionHandle, CURLINFO_RESPONSE_CODE, &ConnectionServerResult.HTTPCode);
+
+ if (ServerResult != CURLE_OK){
+
+ return CalendarHomeURI;
+
+ }
+
+ // Process the User Principal from the ServerData.
+
+ CalendarHomeURI = ProcessXMLCalendarHome();
+
+ // Reset the changed settings.
+
+ string OriginalServerAddress = BuildServerAddress(&ConnectionData, "/principals");
+ curl_easy_setopt(ConnectionHandle, CURLOPT_URL, OriginalServerAddress.c_str());
+
+ curl_easy_setopt(ConnectionHandle, CURLOPT_UPLOAD, 0L);
+ curl_easy_setopt(ConnectionHandle, CURLOPT_READDATA, NULL);
+ curl_easy_setopt(ConnectionHandle, CURLOPT_READFUNCTION, NULL);
+
+ return CalendarHomeURI;
+
}
CalDAVCalendarList CalDAV::GetCalendars(){