" <d:prop>\n"
" <d:resourcetype />\n"
" <d:displayname />\n"
+ " <d:sync-token />\n"
" <x0:calendar-color />\n"
" <x0:calendar-order />\n"
" <cs:getctag />\n"
CalDAVServerResult CalDAV::AddCalendar(string CalendarName){
+ CalDAVServerResult ServerResult;
+
+ AddCalendar(&CalendarName, nullptr);
+
+ return ServerResult;
+
+}
+
+CalDAVServerResult CalDAV::AddCalendar(string *CalendarName, string *CalendarShortName){
+
CalDAVServerResult ServerResult;
CalDAVSendData CalendarAddSendData;
// Generate the UUID.
- string UUIDValue = GenerateUUID();
- UUIDValue.erase(UUIDValue.end()-1);
+ string UUIDValue = "";
+
+ if (CalendarShortName == nullptr){
+
+ UUIDValue = GenerateUUID();
+ UUIDValue.erase(UUIDValue.end()-1);
+
+ } else {
+ UUIDValue = *CalendarShortName;
+
+ }
+
string CalendarHomeURL = CalendarHomeURI;
CalendarHomeURL.append(UUIDValue);
CalendarHomeURL.append("/");
" <d:set>\n"
" <d:prop>\n"
" <d:displayname>";
- CalendarAddRequest += CalendarName;
+ CalendarAddRequest += *CalendarName;
CalendarAddRequest += "</d:displayname>\n"
" <c:supported-calendar-component-set>\n"
" <c:comp name=\"VTODO\"/>\n"
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;
+
+}
+
+CalDAVServerResult CalDAV::EditEntry(string *CalendarEntryHREF, string *EntryData, string *EntryETag){
+
+ // Edit an entry in the calendar collection.
+ // 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();
+
+ string IfMatchHeader = "If-Match: \"";
+ IfMatchHeader.append(*EntryETag);
+ IfMatchHeader.append("\"");
+
struct curl_slist *CalendarRequestHeader = NULL;
CalendarRequestHeader = curl_slist_append(CalendarRequestHeader, "Content-Type: text/calendar; charset=utf-8");
+ CalendarRequestHeader = curl_slist_append(CalendarRequestHeader, IfMatchHeader.c_str());
curl_easy_setopt(ConnectionHandle, CURLOPT_HTTPHEADER, CalendarRequestHeader);
curl_easy_setopt(ConnectionHandle, CURLOPT_URL, EntryAddURLAddress.c_str());