Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added code and unit tests for AddEntry in the CalDAV object.
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 24 Apr 2016 20:52:58 +0000 (21:52 +0100)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 24 Apr 2016 20:52:58 +0000 (21:52 +0100)
source/objects/CalDAV/CalDAV.cpp
source/objects/CalDAV/CalDAV.h

index a2bb856..467f3e1 100644 (file)
@@ -908,6 +908,59 @@ CalDAVServerResult CalDAV::DeleteCalendar(string *CalendarHREF){
        
 }
 
+CalDAVServerResult CalDAV::AddEntry(string *CalendarEntryHREF, string *EntryData){
+       
+       // Add an entry to the calendar collection.
+       
+       CalDAVServerResult ServerResult;
+       CalDAVSendData EntryAddSendData;
+       
+       // Build the calendar list address.
+       
+       string EntryAddURLAddress = BuildServerAddress(&ConnectionData, (*CalendarEntryHREF));
+       
+       EntryAddSendData.readptr = EntryData;
+       EntryAddSendData.sizeleft = EntryData->size();
+
+       struct curl_slist *CalendarRequestHeader = NULL;
+       
+       CalendarRequestHeader = curl_slist_append(CalendarRequestHeader, "Content-Type: text/calendar; charset=utf-8");
+       
+       curl_easy_setopt(ConnectionHandle, CURLOPT_HTTPHEADER, CalendarRequestHeader);
+       curl_easy_setopt(ConnectionHandle, CURLOPT_URL, EntryAddURLAddress.c_str());
+       curl_easy_setopt(ConnectionHandle, CURLOPT_CUSTOMREQUEST, "PUT");
+       curl_easy_setopt(ConnectionHandle, CURLOPT_UPLOAD, 1L);
+       curl_easy_setopt(ConnectionHandle, CURLOPT_READDATA, &EntryAddSendData);
+       curl_easy_setopt(ConnectionHandle, CURLOPT_READFUNCTION, CalDAVSend);
+       
+       // Process the data.
+       
+       ServerData.clear();
+       ServerHeader.clear();
+       
+       CURLcode ServerConnectionResult = curl_easy_perform(ConnectionHandle);
+       
+       if (ServerConnectionResult == CURLE_OK){
+               ServerResult.Result = CALDAVQUERYRESULT_OK;
+       } else {
+               ServerResult.Result = CALDAVQUERYRESULT_SERVERERROR;            
+       }
+       ServerResult.Code = ServerConnectionResult;
+       curl_easy_getinfo(ConnectionHandle, CURLINFO_RESPONSE_CODE, &ServerResult.HTTPCode);
+       
+       // 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);
+       curl_easy_setopt(ConnectionHandle, CURLOPT_HTTPHEADER, NULL);
+       
+       return ServerResult;
+       
+}
 bool CalDAVObjectValidSettings(CalDAVConnectionData *ConnData){
 
        // Check if the passed CalDAV Connection Data is has
index 208d11b..0774cc0 100644 (file)
@@ -146,7 +146,9 @@ class CalDAV{
                CalDAVServerResult Connect();
                CalDAVServerResult GetServerResult();
                CalDAVServerSupport GetServerSupport();
+       
                CalDAVCalendarList GetCalendars();
+       
                CalDAVServerResult AddCalendar(string CalendarName);
        
                CalDAVServerResult EditCalendar(string *CalendarHREF,
@@ -162,7 +164,10 @@ class CalDAV{
                        int *CalendarOrder);
                CalDAVServerResult EditCalendarDescription(string *CalendarHREF,
                        string *CalendarDescription);
+               
                CalDAVServerResult DeleteCalendar(string *CalendarHREF);
+               
+               CalDAVServerResult AddEntry(string *CalendarEntryHREF, string *EntryData);
        
                string GetUserPrincipal();
                string GetCalendarHome(string UserPrincipalURI);
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