1 // CalDAV.h - CalDAV Connection Object header.
3 // (c) 2016 Xestia Software Development.
5 // This file is part of Xestia Calendar.
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Calendar. If not, see <http://www.gnu.org/licenses/>
19 #ifndef __OBJECTS_CALDAV_CALDAV_H__
20 #define __OBJECTS_CALDAV_CALDAV_H__
22 #include <curl/curl.h>
23 #include <libxml/parser.h>
24 #include <libxml/tree.h>
30 #include "../../common/colour.h"
31 #include "../../common/text.h"
32 #include "../../common/uuid.h"
36 // CalDAVConnectionData: used for
37 // connecting to the server.
39 enum CalDAVQueryResult {
40 CALDAVQUERYRESULT_UNITTESTFAIL = -1,
42 CALDAVQUERYRESULT_NOTRUN,
43 CALDAVQUERYRESULT_SERVERERROR
46 struct CalDAVCalendarList {
51 map<int,string> Description;
52 map<int,Colour> CalColour;
54 map<int,string> TagURL;
58 struct CalDAVEntryList {
66 struct CalDAVConnectionData{
78 // CalDAVStatusData: used for
79 // getting the current server
80 // settings for the CalDAV
94 // CalDAVServerSupport: used for
95 // getting what the server supports
96 // from the CalDAV specification.
98 struct CalDAVServerSupport{
100 // Variable name. Name in CalDAV header.
102 bool BasicSupport = false; // calendar-access
106 // CalDAVServerResult: used for
107 // getting the result of the
108 // request made via the CalDAV
111 struct CalDAVServerResult{
113 CalDAVQueryResult Result = CALDAVQUERYRESULT_NOTRUN;
114 CURLcode Code = CURLE_OK;
119 // CalDAVSendData: used for
120 // sending data to the CaLDAV
123 struct CalDAVSendData{
132 string ProcessXMLUserPrincipal();
133 string ProcessXMLCalendarHome();
134 CalDAVCalendarList ProcessXMLCalendarList();
135 CalDAVEntryList ProcessXMLEntryList();
136 string ProcessXMLEntryETag();
137 bool MatchXMLNameTransverse(xmlNodePtr *NodePtr, string NodeName);
138 bool MatchXMLName(xmlNodePtr *NodePtrOriginal, string NodeName);
139 string FetchXMLData(xmlNodePtr *NodePtr);
140 CalDAVServerResult EditCalendarProcess(string *CalendarHREF,
141 string *CalendarName,
142 Colour *CalendarColour,
143 string *CalendarDescription,
146 CalDAVConnectionData ConnectionData;
147 CalDAVServerResult ConnectionServerResult;
148 CURL *ConnectionHandle = nullptr;
149 string ServerData = "";
150 string ServerHeader = "";
155 void SetupConnectionData(CalDAVConnectionData *ConnData);
156 CalDAVStatus GetConnectionData();
157 CalDAVServerResult Connect();
158 CalDAVServerResult GetServerResult();
159 CalDAVServerSupport GetServerSupport();
160 CalDAVCalendarList GetCalendars();
161 CalDAVEntryList GetEntryList(string *CalendarHREF);
162 CalDAVEntryList GetEntryList(string *CalendarHREF, string *CalendarTag);
164 CalDAVServerResult AddCalendar(string CalendarName);
165 CalDAVServerResult AddCalendar(string *CalendarName, string *CalendarShortName);
167 CalDAVServerResult EditCalendar(string *CalendarHREF,
168 string *CalendarName,
169 Colour *CalendarColour,
170 string *CalendarDescription,
172 CalDAVServerResult EditCalendar(string *CalendarHREF,
173 Colour *CalendarColour);
174 CalDAVServerResult EditCalendar(string *CalendarHREF,
175 string *CalendarName);
176 CalDAVServerResult EditCalendar(string *CalendarHREF,
178 CalDAVServerResult EditCalendarDescription(string *CalendarHREF,
179 string *CalendarDescription);
181 CalDAVServerResult DeleteCalendar(string *CalendarHREF);
183 CalDAVServerResult AddEntry(string *CalendarEntryHREF, string *EntryData);
184 CalDAVServerResult EditEntry(string *CalendarEntryHREF, string *EntryData, string *EntryETag);
185 CalDAVServerResult DeleteEntry(string *CalendarEntryHREF);
187 string GetUserPrincipal();
188 string GetCalendarHome(string UserPrincipalURI);
190 CalDAVServerResult GetEntryETag(string *CalendarEntryHREF, string *ETagValue);
194 // Subroutines that are used with the
195 // CalDAVConnectionData struct.
197 bool CalDAVObjectValidSettings(CalDAVConnectionData *ConnData);
198 string BuildServerAddress(CalDAVConnectionData *ConnData, string URIAddress);