X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fobjects%2FCalDAV%2FCalDAV.cpp;h=a94640f8949e4a17b74365e873dc66a6bc07bb72;hb=6e26afc98c0656bbd2ffed756b826d986b97c0bf;hp=d103c8119f132e6cfcb620237db91c7010fd862a;hpb=3c82d9b1245400208b2d167683a82a39cdbc2689;p=xestiacalendar%2F.git diff --git a/source/objects/CalDAV/CalDAV.cpp b/source/objects/CalDAV/CalDAV.cpp index d103c81..a94640f 100644 --- a/source/objects/CalDAV/CalDAV.cpp +++ b/source/objects/CalDAV/CalDAV.cpp @@ -1016,10 +1016,71 @@ CalDAVServerResult CalDAV::AddEntry(string *CalendarEntryHREF, string *EntryData 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());