+ string calendarHomeURL = calendarHomeURI;
+ calendarHomeURL.append(UUIDValue);
+ calendarHomeURL.append("/");
+
+ // Build the calendar list address.
+
+ struct curl_slist *deleteRequestHeader = NULL;
+
+ deleteRequestHeader = curl_slist_append(deleteRequestHeader, "Depth: infinity");
+
+ string calendarDeleteURLAddress = BuildServerAddress(&connectionData, (*calendarHREF));
+
+ curl_easy_setopt(connectionHandle, CURLOPT_HTTPHEADER, deleteRequestHeader);
+ curl_easy_setopt(connectionHandle, CURLOPT_URL, calendarDeleteURLAddress.c_str());
+ curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, "DELETE");
+
+ // Delete the calendar.
+
+ 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::GetEntryETag(string *calendarEntryHREF, string *eTagValue){
+
+ CalDAVServerResult serverResult;
+ CalDAVSendData entryETagGetData;
+
+ // Build the server address.
+
+ string userPrincipalURI = "";
+ userPrincipalURI = GetUserPrincipal();
+
+ if (userPrincipalURI.size() == 0){
+
+ return serverResult;
+
+ }
+
+ string calendarHomeURI = "";
+ calendarHomeURI = GetCalendarHome(userPrincipalURI);
+
+ // Split the path and filename.
+
+ string entryURIPath;
+ string entryFilename;
+
+ SplitPathFilename(calendarEntryHREF, &entryURIPath, &entryFilename);
+
+ // Build the request for the server.
+
+ string entryETagRequest = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<c:calendar-multiget xmlns:d=\"DAV:\" xmlns:c=\"urn:ietf:params:xml:ns:caldav\">\n"
+ " <d:prop>\n"
+ " <d:getetag />\n"
+ " </d:prop>\n"
+ " <d:href>";
+ entryETagRequest += (*calendarEntryHREF);
+ entryETagRequest += "</d:href>\n"
+ "</c:calendar-multiget>";
+
+ entryETagGetData.readptr = &entryETagRequest;
+ entryETagGetData.sizeleft = entryETagRequest.size();
+
+ // Build the calendar list address.
+
+ struct curl_slist *getETagRequestHeader = NULL;
+
+ getETagRequestHeader = curl_slist_append(getETagRequestHeader, "Depth: 1");
+ getETagRequestHeader = curl_slist_append(getETagRequestHeader, "Prefer: return-minimal");
+ getETagRequestHeader = curl_slist_append(getETagRequestHeader, "Content-Type: application/xml; charset=utf-8");
+
+ string getETagURLAddress = BuildServerAddress(&connectionData, entryURIPath);
+
+ curl_easy_setopt(connectionHandle, CURLOPT_HTTPHEADER, getETagRequestHeader);
+ curl_easy_setopt(connectionHandle, CURLOPT_URL, getETagURLAddress.c_str());
+ curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, "REPORT");
+ curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 1L);
+ curl_easy_setopt(connectionHandle, CURLOPT_READDATA, &entryETagGetData);
+ curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, CalDAVSend);
+
+ // Attempt to get the entity tag.
+
+ 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);
+
+ if (serverConnectionResult != CURLE_OK){
+ return serverResult;
+ }
+
+ // Get the entity tag from the result.
+
+ *eTagValue = ProcessXMLEntryETag();
+
+ // 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::AddEntry(string *calendarEntryHREF, string *entryData){
+
+ // Add an entry to the calendar collection.
+
+ CalDAVServerResult serverResult;
+ CalDAVSendData entryAddSendData;