Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Initial version of CalDAV::GetCalendars
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 6 Mar 2016 11:10:14 +0000 (11:10 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 6 Mar 2016 11:10:14 +0000 (11:10 +0000)
Doesn't return a list of calendars at present, but prints the list to
std::cout XML formatted (ProcessXMLCalendarAddresses will need to be
created).

source/objects/CalDAV/CalDAV.cpp

index acb5321..a34ca07 100644 (file)
@@ -451,6 +451,78 @@ string CalDAV::GetCalendarHome(string UserPrincipalURI){
 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;
        
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