+}
+
+size_t CalDAVSend(char *sendBuffer, size_t size, size_t newMemoryBytes, void *dataStruct){
+
+ struct CalDAVSendData *uploadPtr = (struct CalDAVSendData *)dataStruct;
+
+ if (uploadPtr->sizeleft){
+
+ uploadPtr->sizeleft--;
+ char charSend;
+
+ charSend = (*uploadPtr->readptr)[uploadPtr->seek];
+
+ *sendBuffer = charSend;
+
+ uploadPtr->seek++;
+
+ return 1;
+
+ }
+
+ return 0;
+
+}
+
+CalDAV::CalDAV(){
+
+ // Setup the objects within the CalDAV connection
+ // object.
+
+ connectionHandle = curl_easy_init();
+
+}
+
+CalDAV::~CalDAV(){
+
+ // Destory the objects within the CalDAV connection
+ // object.
+
+ curl_easy_cleanup(connectionHandle);
+ connectionHandle = nullptr;
+
+}
+
+void CalDAV::SetupConnectionData(CalDAVConnectionData *connData){
+
+ // Check if ConnData is a nullptr, return if it is.
+
+ if (connData == nullptr){
+ return;
+ }
+
+ // Set the connection settings to the values from ConnData.
+
+ connectionData = (*connData);
+
+}
+
+CalDAVStatus CalDAV::GetConnectionData(){
+
+ // Get the current connection settings for the CalDAV
+ // connection object and return a CalDAVStatus object.
+
+ CalDAVStatus connectionStatus;
+
+ connectionStatus.hostname = connectionData.hostname;
+ connectionStatus.port = connectionData.port;
+ connectionStatus.username = connectionData.username;
+ connectionStatus.prefix = connectionData.prefix;
+ connectionStatus.useSSL = connectionData.useSSL;
+ connectionStatus.timeout = connectionData.timeout;
+
+ return connectionStatus;
+
+}
+
+CalDAVServerResult CalDAV::Connect(){
+
+ CalDAVServerResult serverResult;
+
+ string serverAddress = "";
+ string serverUserPass = "";
+
+ // Setup the server address.
+
+ serverAddress = BuildServerAddress(&connectionData, "/principals/");
+
+ // Setup the server password.
+
+ serverUserPass += connectionData.username;
+ serverUserPass += ":";
+ serverUserPass += connectionData.password;
+
+ curl_easy_setopt(connectionHandle, CURLOPT_URL, serverAddress.c_str());
+ curl_easy_setopt(connectionHandle, CURLOPT_USERPWD, serverUserPass.c_str());
+ curl_easy_setopt(connectionHandle, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
+ curl_easy_setopt(connectionHandle, CURLOPT_FAILONERROR, 1L);
+ curl_easy_setopt(connectionHandle, CURLOPT_TIMEOUT, connectionData.timeout);
+ curl_easy_setopt(connectionHandle, CURLOPT_WRITEFUNCTION, CalDAVReceive);
+ curl_easy_setopt(connectionHandle, CURLOPT_WRITEDATA, &serverData);
+ curl_easy_setopt(connectionHandle, CURLOPT_WRITEHEADER, &serverHeader);
+
+ // Connect to the CalDAV server.
+
+ serverResult.code = curl_easy_perform(connectionHandle);
+
+ // Process the result received from the server.
+
+ if (serverResult.code != CURLE_OK){
+
+ serverResult.result = CALDAVQUERYRESULT_SERVERERROR;
+
+ } else {
+
+ serverResult.result = CALDAVQUERYRESULT_OK;
+
+ }
+
+ // Get the HTTP code.
+
+ curl_easy_getinfo(connectionHandle, CURLINFO_RESPONSE_CODE, &serverResult.httpCode);
+
+ return serverResult;
+
+}
+
+CalDAVServerResult CalDAV::GetServerResult(){
+
+ return connectionServerResult;
+
+}
+
+CalDAVServerSupport CalDAV::GetServerSupport(){
+
+ CalDAVServerSupport serverStatus;
+
+ // Setup the server connection.
+
+ curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, "OPTIONS");
+
+ CURLcode serverResult = curl_easy_perform(connectionHandle);
+
+ // Set the results.
+
+ 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){
+ return serverStatus;
+ }
+
+ // Check that the server header has data in,
+ // otherwise return an "empty" CalDAVServerSupport.
+
+ if (serverHeader.size() == 0){
+ return serverStatus;
+ }
+
+ // Process each line looking for the first DAV header
+ // line.
+
+ bool newlineMode = true;
+
+ string davLine;
+
+ for (int charSeek = 0; charSeek < serverHeader.size(); charSeek++){
+
+ if (newlineMode == true){
+
+ // Check if we have reached the end of the string.
+
+ if (charSeek >= serverHeader.size()){
+
+ break;
+
+ }
+
+ // Check the first four letters to make sure
+ // they are 'DAV:'.
+
+ string davHeaderCheck = "";
+
+ try {
+ davHeaderCheck = serverHeader.substr(charSeek, 4);
+ }
+
+ catch (out_of_range &oor){
+ break;
+ }
+
+ if (davHeaderCheck == "DAV:"){
+
+ charSeek += 5;
+
+ for (; charSeek < serverHeader.size(); charSeek++){
+
+ if (serverHeader[charSeek] == '\n'){
+
+ break;
+
+ }
+
+ davLine.push_back(serverHeader[charSeek]);
+
+ }
+
+ break;
+
+ }
+
+ newlineMode = false;
+
+ }
+
+ if (serverHeader[charSeek] == '\n'){
+
+ newlineMode = true;
+
+ }
+
+ }
+
+ // Process the DAV line.
+
+ vector<string> davLineData;
+ string davSegmentString;
+
+ for (int charSeek = 0; charSeek < davLine.size(); charSeek++){
+
+ if (davLine[charSeek] == ' '){
+ continue;
+ }
+
+ if (davLine[charSeek] == ','){
+
+ davLineData.push_back(davSegmentString);
+ davSegmentString.clear();
+ continue;
+
+ }
+
+ davSegmentString += davLine[charSeek];
+
+ }
+
+ // Process the DAV values and set each value
+ // to true as required.
+
+ for (int davItemSeek = 0;
+ davItemSeek < davLineData.size();
+ davItemSeek++){
+
+ if (davLineData.at(davItemSeek) == "calendar-access"){
+
+ serverStatus.basicSupport = true;
+
+ }
+
+ }
+
+ // Reset the connection status.
+
+ curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, NULL);
+
+ return serverStatus;
+
+}
+
+string CalDAV::GetUserPrincipal(){
+
+ string currentUserPrincipal = "";
+ string userPrincipalRequest = "";
+ CalDAVSendData userPrincipalSendData;
+
+ userPrincipalRequest = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<d:propfind xmlns:d=\"DAV:\">\n"
+ " <d:prop>\n"
+ " <d:current-user-principal />\n"
+ " </d:prop>\n"
+ "</d:propfind>";
+
+ userPrincipalSendData.readptr = &userPrincipalRequest;
+ userPrincipalSendData.sizeleft = userPrincipalRequest.size();
+
+ // Setup the header.
+
+ struct curl_slist *userPrincipalRequestHeader = NULL;
+
+ userPrincipalRequestHeader = curl_slist_append(userPrincipalRequestHeader, "Depth: 0");
+ userPrincipalRequestHeader = curl_slist_append(userPrincipalRequestHeader, "Prefer: return-minimal");
+ userPrincipalRequestHeader = curl_slist_append(userPrincipalRequestHeader, "Content-Type: application/xml; charset=utf-8");
+
+ curl_easy_setopt(connectionHandle, CURLOPT_HTTPHEADER, userPrincipalRequestHeader);
+
+ curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, "PROPFIND");
+ curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 1L);
+ curl_easy_setopt(connectionHandle, CURLOPT_READDATA, &userPrincipalSendData);
+ curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, CalDAVSend);
+
+ // Process the data.
+
+ serverData.clear();
+ serverHeader.clear();
+
+ CURLcode serverResult = curl_easy_perform(connectionHandle);
+
+ // Set the results.
+
+ 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){
+
+ return currentUserPrincipal;
+
+ }
+
+ // Process the User Principal from the ServerData.
+
+ currentUserPrincipal = ProcessXMLUserPrincipal();
+
+ // Reset the changed settings.
+
+ curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 0L);
+ curl_easy_setopt(connectionHandle, CURLOPT_READDATA, NULL);
+ curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, NULL);
+
+ return currentUserPrincipal;
+
+}
+
+string CalDAV::GetCalendarHome(string userPrincipalURI){
+
+ string calendarHomeURI = "";
+
+ // Build the Calendar Home URL address.
+
+ string calendarHomeURL = BuildServerAddress(&connectionData, userPrincipalURI);
+
+ // Setup the header request.
+
+ CalDAVSendData calendarHomeSendData;
+
+ string calendarHomeRequest = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<d:propfind xmlns:d=\"DAV:\" xmlns:c=\"urn:ietf:params:xml:ns:caldav\">\n"
+ " <d:prop>\n"
+ " <c:calendar-home-set />\n"
+ " </d:prop>\n"
+ "</d:propfind>";
+
+ calendarHomeSendData.readptr = &calendarHomeRequest;
+ calendarHomeSendData.sizeleft = calendarHomeRequest.size();
+
+ // Setup the header.
+
+ struct curl_slist *calendarRequestHeader = NULL;
+
+ calendarRequestHeader = curl_slist_append(calendarRequestHeader, "Depth: 0");
+ calendarRequestHeader = curl_slist_append(calendarRequestHeader, "Prefer: return-minimal");
+ calendarRequestHeader = curl_slist_append(calendarRequestHeader, "Content-Type: application/xml; charset=utf-8");
+
+ curl_easy_setopt(connectionHandle, CURLOPT_HTTPHEADER, calendarRequestHeader);
+ curl_easy_setopt(connectionHandle, CURLOPT_URL, calendarHomeURL.c_str());
+ curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, "PROPFIND");
+ curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 1L);
+ curl_easy_setopt(connectionHandle, CURLOPT_READDATA, &calendarHomeSendData);
+ curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, CalDAVSend);
+
+ // Process the data.
+
+ serverData.clear();
+ serverHeader.clear();
+
+ CURLcode serverResult = curl_easy_perform(connectionHandle);
+
+ // Set the results.
+
+ 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){
+
+ return calendarHomeURI;
+
+ }
+
+ // Process the User Principal from the ServerData.
+
+ calendarHomeURI = ProcessXMLCalendarHome();
+
+ // Reset the changed settings.
+
+ string originalServerAddress = BuildServerAddress(&connectionData, "/principals/");
+ curl_easy_setopt(connectionHandle, CURLOPT_URL, originalServerAddress.c_str());
+
+ 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 calendarHomeURI;
+
+}
+
+CalDAVCalendarList CalDAV::GetCalendars(){
+
+ CalDAVCalendarList serverList;
+ CalDAVSendData calendarListSendData;
+
+ // Build the server address.
+
+ string userPrincipalURI = "";
+ userPrincipalURI = GetUserPrincipal();
+
+ if (userPrincipalURI.size() == 0){
+
+ return serverList;
+
+ }
+
+ string calendarHomeURI = "";
+ calendarHomeURI = GetCalendarHome(userPrincipalURI);
+
+ string calendarListURLAddress = BuildServerAddress(&connectionData, calendarHomeURI);
+
+ string calendarListRequest = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<d:propfind xmlns:d=\"DAV:\" xmlns:cs=\"http://calendarserver.org/ns/\""
+ " xmlns:c=\"urn:ietf:params:xml:ns:caldav\" xmlns:x0=\"http://apple.com/ns/ical/\">\n"
+ " <d:prop>\n"
+ " <d:resourcetype />\n"
+ " <d:displayname />\n"
+ " <d:sync-token />\n"
+ " <x0:calendar-color />\n"
+ " <x0:calendar-order />\n"
+ " <cs:getctag />\n"
+ " <c:supported-calendar-component-set />\n"
+ " <c:calendar-description />\n"
+ " </d:prop>\n"
+ "</d:propfind>";
+
+ calendarListSendData.readptr = &calendarListRequest;
+ calendarListSendData.sizeleft = calendarListRequest.size();
+
+ // Setup the header.
+
+ struct curl_slist *calendarListRequestHeader = NULL;
+
+ calendarListRequestHeader = curl_slist_append(calendarListRequestHeader, "Depth: 1");
+ calendarListRequestHeader = curl_slist_append(calendarListRequestHeader, "Prefer: return-minimal");
+ calendarListRequestHeader = curl_slist_append(calendarListRequestHeader, "Content-Type: application/xml; charset=utf-8");
+
+ curl_easy_setopt(connectionHandle, CURLOPT_HTTPHEADER, calendarListRequestHeader);
+ curl_easy_setopt(connectionHandle, CURLOPT_URL, calendarListURLAddress.c_str());
+ curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, "PROPFIND");
+ curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 1L);
+ curl_easy_setopt(connectionHandle, CURLOPT_READDATA, &calendarListSendData);
+ curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, CalDAVSend);
+
+ // Process the data.
+
+ serverData.clear();
+ serverHeader.clear();
+
+ CURLcode serverResult = curl_easy_perform(connectionHandle);
+
+ //ServerList = ProcessXMLCalendarList();
+
+ 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){
+
+ return serverList;
+
+ }
+
+ // 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;
+
+}
+
+CalDAVEntryList CalDAV::GetEntryList(string *calendarHREF){
+
+ CalDAVEntryList entryList;
+ CalDAVSendData entryListSendData;
+
+ if (calendarHREF->size() == 0){
+
+ return entryList;
+
+ }
+
+ string entryListURLAddress = BuildServerAddress(&connectionData, *calendarHREF);
+
+ string entryListRequest = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+
+ /*if (CalendarTag == nullptr){*/
+
+ entryListRequest += "<c:calendar-query xmlns:d=\"DAV:\" xmlns:cs=\"http://calendarserver.org/ns/\""
+ " xmlns:c=\"urn:ietf:params:xml:ns:caldav\" xmlns:x0=\"http://apple.com/ns/ical/\">\n"
+ " <d:prop>\n"
+ " <d:getetag />\n"
+ " <c:calendar-data />\n"
+ " </d:prop>\n"
+ " <c:filter>\n"
+ " <c:comp-filter name=\"VCALENDAR\" />\n"
+ " </c:filter>\n"
+ "</c:calendar-query>";
+
+ /*} else {
+
+ EntryListRequest += "<d:sync-collection xmlns:d=\"DAV:\" xmlns:cs=\"http://calendarserver.org/ns/\""
+ " xmlns:c=\"urn:ietf:params:xml:ns:caldav\" xmlns:x0=\"http://apple.com/ns/ical/\">\n"
+ " <d:sync-token>";
+ EntryListRequest += *CalendarTag;
+ EntryListRequest += "</d:sync-token>\n"
+ " <d:sync-level>1</d:sync-level>\n"
+ " <d:prop>\n"
+ " <d:getetag />\n"
+ " <c:calendar-data />\n"
+ " </d:prop>\n"
+ "</d:sync-collection>";
+
+ }*/
+
+ entryListSendData.readptr = &entryListRequest;
+ entryListSendData.sizeleft = entryListRequest.size();
+
+ struct curl_slist *entryListRequestHeader = NULL;
+
+ entryListRequestHeader = curl_slist_append(entryListRequestHeader, "Content-Type: application/xml; charset=utf-8");
+
+ /*if (CalendarTag != nullptr){
+
+ EntryListRequestHeader = curl_slist_append(EntryListRequestHeader, "Content-Type: application/xml; charset=utf-8");
+ EntryListRequestHeader = curl_slist_append(EntryListRequestHeader, "Content-Type: application/xml; charset=utf-8");
+
+ }*/
+
+ curl_easy_setopt(connectionHandle, CURLOPT_HTTPHEADER, entryListRequestHeader);
+ curl_easy_setopt(connectionHandle, CURLOPT_URL, entryListURLAddress.c_str());
+ curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, "REPORT");
+ curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 1L);
+ curl_easy_setopt(connectionHandle, CURLOPT_READDATA, &entryListSendData);
+ curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, CalDAVSend);
+
+ // Process the data.
+
+ serverData.clear();
+ serverHeader.clear();
+
+ CURLcode serverResult = curl_easy_perform(connectionHandle);
+
+ //ServerList = ProcessXMLCalendarList();
+
+ 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){
+
+ return entryList;
+
+ }
+
+ // Process the received XML data into a list of calendars
+ // and locations.
+
+ entryList = ProcessXMLEntryList();
+
+ // 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 entryList;
+
+}
+
+CalDAVEntryList CalDAV::GetEntryList(string *calendarHREF, string *calendarTag){
+
+ CalDAVEntryList entryList;
+ CalDAVSendData entryListSendData;
+
+ if (calendarHREF->size() == 0){
+
+ return entryList;
+
+ }
+
+ string entryListURLAddress = BuildServerAddress(&connectionData, *calendarHREF);
+
+ // First query: Get the list of contacts that need to be updated.
+
+ string entryListRequest = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+
+ entryListRequest += "<d:sync-collection xmlns:d=\"DAV:\" xmlns:cs=\"http://calendarserver.org/ns/\""
+ " xmlns:c=\"urn:ietf:params:xml:ns:caldav\" xmlns:x0=\"http://apple.com/ns/ical/\">\n"
+ " <d:sync-token>";
+
+ if (calendarTag != nullptr){
+
+ entryListRequest += *calendarTag;
+
+ } else {
+
+ entryListRequest += "";
+
+ }
+
+ entryListRequest += "</d:sync-token>\n"
+ " <d:sync-level>1</d:sync-level>\n"
+ " <d:prop>\n"
+ " <d:getetag />\n"
+ " </d:prop>\n"
+ "</d:sync-collection>";
+
+ entryListSendData.readptr = &entryListRequest;
+ entryListSendData.sizeleft = entryListRequest.size();
+
+ struct curl_slist *entryListRequestHeader = NULL;
+
+ entryListRequestHeader = curl_slist_append(entryListRequestHeader, "Content-Type: application/xml; charset=utf-8");
+
+ curl_easy_setopt(connectionHandle, CURLOPT_HTTPHEADER, entryListRequestHeader);
+ curl_easy_setopt(connectionHandle, CURLOPT_URL, entryListURLAddress.c_str());
+ curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, "REPORT");
+ curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 1L);
+ curl_easy_setopt(connectionHandle, CURLOPT_READDATA, &entryListSendData);
+ curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, CalDAVSend);
+
+ // Process the data.
+
+ serverData.clear();
+ serverHeader.clear();
+
+ CURLcode serverResult = curl_easy_perform(connectionHandle);
+
+ 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){
+
+ return entryList;
+
+ }
+
+ entryList = ProcessXMLSyncTokenList();
+
+ // Check the last entry matches the HREF and if it
+ // does then delete it.
+
+ if (entryList.href.size() > 0) {
+
+ if (entryList.href.rbegin()->second == *calendarHREF){
+
+ entryList.href.erase((entryList.href.size() - 1));
+ entryList.tag.erase((entryList.href.size() - 1));
+ entryList.data.erase((entryList.href.size() - 1));
+
+ }
+
+ }
+
+ // Build the list into a new list for getting the new
+ // calendar data with.
+
+ entryListRequest.clear();
+
+ entryListRequest = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+
+ entryListRequest += "<c:calendar-multiget xmlns:d=\"DAV:\" "
+ " xmlns:c=\"urn:ietf:params:xml:ns:caldav\">\n"
+ " <d:prop>\n"
+ " <d:getetag />\n"
+ " <c:calendar-data />\n"
+ " </d:prop>\n";
+
+ for (std::map<int,string>::iterator hrefIter = entryList.href.begin();
+ hrefIter != entryList.href.end(); hrefIter++){
+
+ string entryListHREFString = hrefIter->second;
+
+ entryListRequest += " <d:href>";
+ entryListRequest += entryListHREFString;
+ entryListRequest += "</d:href>\n";
+
+ }
+
+ entryListRequest += "</c:calendar-multiget>";