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"
35 // CalDAVConnectionData: used for
36 // connecting to the server.
38 enum CalDAVQueryResult {
39 CALDAVQUERYRESULT_UNITTESTFAIL = -1,
41 CALDAVQUERYRESULT_NOTRUN,
42 CALDAVQUERYRESULT_SERVERERROR
45 struct CalDAVCalendarList {
50 map<int,string> Description;
51 map<int,Colour> CalColour;
56 struct CalDAVConnectionData{
68 // CalDAVStatusData: used for
69 // getting the current server
70 // settings for the CalDAV
84 // CalDAVServerSupport: used for
85 // getting what the server supports
86 // from the CalDAV specification.
88 struct CalDAVServerSupport{
90 // Variable name. Name in CalDAV header.
92 bool BasicSupport = false; // calendar-access
96 // CalDAVServerResult: used for
97 // getting the result of the
98 // request made via the CalDAV
101 struct CalDAVServerResult{
103 CalDAVQueryResult Result = CALDAVQUERYRESULT_NOTRUN;
104 CURLcode Code = CURLE_OK;
109 // CalDAVSendData: used for
110 // sending data to the CaLDAV
113 struct CalDAVSendData{
122 string ProcessXMLUserPrincipal();
123 string ProcessXMLCalendarHome();
124 CalDAVCalendarList ProcessXMLCalendarList();
125 bool MatchXMLNameTransverse(xmlNodePtr *NodePtr, string NodeName);
126 bool MatchXMLName(xmlNodePtr *NodePtrOriginal, string NodeName);
127 string FetchXMLData(xmlNodePtr *NodePtr);
129 CalDAVConnectionData ConnectionData;
130 CalDAVServerResult ConnectionServerResult;
131 CURL *ConnectionHandle = nullptr;
132 string ServerData = "";
133 string ServerHeader = "";
138 void SetupConnectionData(CalDAVConnectionData *ConnData);
139 CalDAVStatus GetConnectionData();
140 CalDAVServerResult Connect();
141 CalDAVServerResult GetServerResult();
142 CalDAVServerSupport GetServerSupport();
143 CalDAVCalendarList GetCalendars();
145 string GetUserPrincipal();
146 string GetCalendarHome(string UserPrincipalURI);
150 // Subroutines that are used with the
151 // CalDAVConnectionData struct.
153 bool CalDAVObjectValidSettings(CalDAVConnectionData *ConnData);
154 string BuildServerAddress(CalDAVConnectionData *ConnData, string URIAddress);