Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
When processing calendars, attempt to get the sync-token.
[xestiacalendar/.git] / source / objects / CalDAV / CalDAV.h
1 // CalDAV.h - CalDAV Connection Object header.
2 //
3 // (c) 2016 Xestia Software Development.
4 //
5 // This file is part of Xestia Calendar.
6 //
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.
10 //
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.
15 //
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>
25 #include <string>
26 #include <iostream>
27 #include <vector>
28 #include <stdexcept>
29 #include <map>
30 #include "../../common/colour.h"
31 #include "../../common/text.h"
32 #include "../../common/uuid.h"
34 using namespace std;
36 // CalDAVConnectionData: used for
37 // connecting to the server.
39 enum CalDAVQueryResult {
40         CALDAVQUERYRESULT_UNITTESTFAIL = -1,
41         CALDAVQUERYRESULT_OK,
42         CALDAVQUERYRESULT_NOTRUN,
43         CALDAVQUERYRESULT_SERVERERROR
44 };
46 struct CalDAVCalendarList {
48         map<int,string> Name;
49         map<int,string> HREF;
50         map<int,int> Order;
51         map<int,string> Description;
52         map<int,Colour> CalColour;
53         map<int,string> Tag;
54         map<int,string> TagURL;
55         
56 };
57         
58 };
60 struct CalDAVConnectionData{
61         
62         string Hostname = "";
63         int Port = 8008;
64         string Username = "";
65         string Password = "";
66         string Prefix = "";
67         bool UseSSL = true;
68         int Timeout = 60;
69         
70 };
72 // CalDAVStatusData: used for
73 // getting the current server
74 // settings for the CalDAV
75 // object.
77 struct CalDAVStatus{
79         string Hostname;
80         int Port;
81         string Username;
82         string Prefix;
83         bool UseSSL;    
84         int Timeout;
86 };
88 // CalDAVServerSupport: used for
89 // getting what the server supports
90 // from the CalDAV specification.
92 struct CalDAVServerSupport{
93         
94         // Variable name.                          Name in CalDAV header.
95         
96         bool BasicSupport = false;              // calendar-access
97         
98 };
100 // CalDAVServerResult: used for
101 // getting the result of the
102 // request made via the CalDAV
103 // object.
105 struct CalDAVServerResult{
107         CalDAVQueryResult Result = CALDAVQUERYRESULT_NOTRUN;
108         CURLcode Code = CURLE_OK;
109         long HTTPCode = 0;
110         
111 };
113 // CalDAVSendData: used for
114 // sending data to the CaLDAV
115 // server.
117 struct CalDAVSendData{
118         string *readptr;
119         long sizeleft;
120         int seek = 0;
121 };
123 class CalDAV{
125         private:
126                 string ProcessXMLUserPrincipal();
127                 string ProcessXMLCalendarHome();
128                 CalDAVCalendarList ProcessXMLCalendarList();
129                 string ProcessXMLEntryETag();
130                 bool MatchXMLNameTransverse(xmlNodePtr *NodePtr, string NodeName);
131                 bool MatchXMLName(xmlNodePtr *NodePtrOriginal, string NodeName);
132                 string FetchXMLData(xmlNodePtr *NodePtr);
133                 CalDAVServerResult EditCalendarProcess(string *CalendarHREF,
134                         string *CalendarName,
135                         Colour *CalendarColour,
136                         string *CalendarDescription,
137                         int *CalendarOrder);
138         
139                 CalDAVConnectionData ConnectionData;
140                 CalDAVServerResult ConnectionServerResult;
141                 CURL *ConnectionHandle = nullptr;
142                 string ServerData = "";
143                 string ServerHeader = "";
144         
145         public:
146                 CalDAV();
147                 ~CalDAV();
148                 void SetupConnectionData(CalDAVConnectionData *ConnData);
149                 CalDAVStatus GetConnectionData();
150                 CalDAVServerResult Connect();
151                 CalDAVServerResult GetServerResult();
152                 CalDAVServerSupport GetServerSupport();
153                 CalDAVCalendarList GetCalendars();
154         
155                 CalDAVServerResult AddCalendar(string CalendarName);
156         
157                 CalDAVServerResult EditCalendar(string *CalendarHREF,
158                         string *CalendarName,
159                         Colour *CalendarColour,
160                         string *CalendarDescription,
161                         int *CalendarOrder);
162                 CalDAVServerResult EditCalendar(string *CalendarHREF,
163                         Colour *CalendarColour);
164                 CalDAVServerResult EditCalendar(string *CalendarHREF,
165                         string *CalendarName);
166                 CalDAVServerResult EditCalendar(string *CalendarHREF,
167                         int *CalendarOrder);
168                 CalDAVServerResult EditCalendarDescription(string *CalendarHREF,
169                         string *CalendarDescription);
170                 
171                 CalDAVServerResult DeleteCalendar(string *CalendarHREF);
172                 
173                 CalDAVServerResult AddEntry(string *CalendarEntryHREF, string *EntryData);
174                 CalDAVServerResult EditEntry(string *CalendarEntryHREF, string *EntryData, string *EntryETag);
175                 CalDAVServerResult DeleteEntry(string *CalendarEntryHREF);
176         
177                 string GetUserPrincipal();
178                 string GetCalendarHome(string UserPrincipalURI);
179                 
180                 CalDAVServerResult GetEntryETag(string *CalendarEntryHREF, string *ETagValue);
181         
182 };
184 // Subroutines that are used with the 
185 // CalDAVConnectionData struct.
187 bool CalDAVObjectValidSettings(CalDAVConnectionData *ConnData);
188 string BuildServerAddress(CalDAVConnectionData *ConnData, string URIAddress);
190 #endif
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy