X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fobjects%2FCalDAV%2FCalDAV.cpp;h=a34ca071cf655e557637d6177f1449543aceba64;hb=c9138ee3356f67e30b75dd6fb4b9ce8d020423cc;hp=acb5321cbb92ac15057aac5cf303fcc372ad8d59;hpb=2dfb7189efe8e02d37af274b2ec193b5ae058d85;p=xestiacalendar%2F.git diff --git a/source/objects/CalDAV/CalDAV.cpp b/source/objects/CalDAV/CalDAV.cpp index acb5321..a34ca07 100644 --- a/source/objects/CalDAV/CalDAV.cpp +++ b/source/objects/CalDAV/CalDAV.cpp @@ -451,6 +451,78 @@ string CalDAV::GetCalendarHome(string UserPrincipalURI){ 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); + + cout << ServerData << endl; + + string CalendarListURLAddress = BuildServerAddress(&ConnectionData, CalendarHomeURI); + + cout << CalendarListURLAddress << endl; + + string CalendarListRequest = "\n" + "\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + ""; + + 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); + + cout << ServerData << endl; + + //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;