Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added the GetCalendarHome function to the CalDAV object.
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 6 Mar 2016 10:51:57 +0000 (10:51 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 6 Mar 2016 10:51:57 +0000 (10:51 +0000)
source/objects/CalDAV/CalDAV.cpp

index ea578a9..acb5321 100644 (file)
@@ -368,6 +368,84 @@ string CalDAV::GetUserPrincipal(){
        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(){
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy