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;
57 struct CalDAVConnectionData{
69 // CalDAVStatusData: used for
70 // getting the current server
71 // settings for the CalDAV
85 // CalDAVServerSupport: used for
86 // getting what the server supports
87 // from the CalDAV specification.
89 struct CalDAVServerSupport{
91 // Variable name. Name in CalDAV header.
93 bool BasicSupport = false; // calendar-access
97 // CalDAVServerResult: used for
98 // getting the result of the
99 // request made via the CalDAV
102 struct CalDAVServerResult{
104 CalDAVQueryResult Result = CALDAVQUERYRESULT_NOTRUN;
105 CURLcode Code = CURLE_OK;
110 // CalDAVSendData: used for
111 // sending data to the CaLDAV
114 struct CalDAVSendData{
123 string ProcessXMLUserPrincipal();
124 string ProcessXMLCalendarHome();
125 CalDAVCalendarList ProcessXMLCalendarList();
126 string ProcessXMLEntryETag();
127 bool MatchXMLNameTransverse(xmlNodePtr *NodePtr, string NodeName);
128 bool MatchXMLName(xmlNodePtr *NodePtrOriginal, string NodeName);
129 string FetchXMLData(xmlNodePtr *NodePtr);
130 CalDAVServerResult EditCalendarProcess(string *CalendarHREF,
131 string *CalendarName,
132 Colour *CalendarColour,
133 string *CalendarDescription,
136 CalDAVConnectionData ConnectionData;
137 CalDAVServerResult ConnectionServerResult;
138 CURL *ConnectionHandle = nullptr;
139 string ServerData = "";
140 string ServerHeader = "";
145 void SetupConnectionData(CalDAVConnectionData *ConnData);
146 CalDAVStatus GetConnectionData();
147 CalDAVServerResult Connect();
148 CalDAVServerResult GetServerResult();
149 CalDAVServerSupport GetServerSupport();
151 CalDAVCalendarList GetCalendars();
153 CalDAVServerResult AddCalendar(string CalendarName);
155 CalDAVServerResult EditCalendar(string *CalendarHREF,
156 string *CalendarName,
157 Colour *CalendarColour,
158 string *CalendarDescription,
160 CalDAVServerResult EditCalendar(string *CalendarHREF,
161 Colour *CalendarColour);
162 CalDAVServerResult EditCalendar(string *CalendarHREF,
163 string *CalendarName);
164 CalDAVServerResult EditCalendar(string *CalendarHREF,
166 CalDAVServerResult EditCalendarDescription(string *CalendarHREF,
167 string *CalendarDescription);
169 CalDAVServerResult DeleteCalendar(string *CalendarHREF);
171 CalDAVServerResult AddEntry(string *CalendarEntryHREF, string *EntryData);
172 CalDAVServerResult EditEntry(string *CalendarEntryHREF, string *EntryData, string *EntryETag);
173 CalDAVServerResult DeleteEntry(string *CalendarEntryHREF);
175 string GetUserPrincipal();
176 string GetCalendarHome(string UserPrincipalURI);
178 CalDAVServerResult GetEntryETag(string *CalendarEntryHREF, string *ETagValue);
182 // Subroutines that are used with the
183 // CalDAVConnectionData struct.
185 bool CalDAVObjectValidSettings(CalDAVConnectionData *ConnData);
186 string BuildServerAddress(CalDAVConnectionData *ConnData, string URIAddress);