X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fobjects%2FCalDAV%2FCalDAV.cpp;h=467f3e18d2b872892c137a53ada0bcc9a6a19b62;hb=3511800e4e2c6630a24a4a4945f252f976da75c8;hp=3d2e5de42ecbb48517872b186f5339120aca4c67;hpb=91fbe7fbe1eb9b7dd98faccb64102c7b0e7beeeb;p=xestiacalendar%2F.git diff --git a/source/objects/CalDAV/CalDAV.cpp b/source/objects/CalDAV/CalDAV.cpp index 3d2e5de..467f3e1 100644 --- a/source/objects/CalDAV/CalDAV.cpp +++ b/source/objects/CalDAV/CalDAV.cpp @@ -511,17 +511,13 @@ CalDAVCalendarList CalDAV::GetCalendars(){ //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); - - // Process the received XML data into a list of calendars - // and locations. + 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){ @@ -529,8 +525,21 @@ CalDAVCalendarList CalDAV::GetCalendars(){ } + // Process the received XML data into a list of calendars + // and locations. + 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; } @@ -899,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