Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
camelCase: Converted code in CalDAV directory
[xestiacalendar/.git] / source / objects / CalDAV / CalDAV.h
index 8a9c06c..148f2d0 100644 (file)
@@ -1,8 +1,35 @@
+// CalDAV.h - CalDAV Connection Object header.
+//
+// (c) 2016-2017 Xestia Software Development.
+//
+// This file is part of Xestia Calendar.
+//
+// Xestia Calendar is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by the
+// Free Software Foundation, version 3 of the license.
+//
+// Xestia Calendar is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with Xestia Calendar. If not, see <http://www.gnu.org/licenses/>
+
 #ifndef __OBJECTS_CALDAV_CALDAV_H__
 #define __OBJECTS_CALDAV_CALDAV_H__
 
 #include <curl/curl.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
 #include <string>
+#include <iostream>
+#include <vector>
+#include <stdexcept>
+#include <map>
+#include "../../common/colour.h"
+#include "../../common/text.h"
+#include "../../common/uuid.h"
 
 using namespace std;
 
@@ -11,17 +38,40 @@ using namespace std;
 
 enum CalDAVQueryResult {
        CALDAVQUERYRESULT_UNITTESTFAIL = -1,
-       CALDAVQUERYRESULT_OK
+       CALDAVQUERYRESULT_OK,
+       CALDAVQUERYRESULT_NOTRUN,
+       CALDAVQUERYRESULT_SERVERERROR
+};
+
+struct CalDAVCalendarList {
+
+       map<int,string> name;
+       map<int,string> href;
+       map<int,int> order;
+       map<int,string> description;
+       map<int,Colour> calColour;
+       map<int,string> tag;
+       map<int,string> tagURL;
+       
+};
+
+struct CalDAVEntryList {
+       
+       map<int,string> href;
+       map<int,string> data;
+       map<int,string> tag;
+       
 };
 
 struct CalDAVConnectionData{
        
-       string Hostname;
-       int Port;
-       string Username;
-       string Password;
-       string Prefix;
-       bool UseSSL;
+       string hostname = "";
+       int port = 8008;
+       string username = "";
+       string password = "";
+       string prefix = "";
+       bool useSSL = true;
+       int timeout = 60;
        
 };
 
@@ -32,14 +82,27 @@ struct CalDAVConnectionData{
 
 struct CalDAVStatus{
 
-       string Hostname;
-       int Port;
-       string Username;
-       string Prefix;
-       bool UseSSL;    
+       string hostname;
+       int port;
+       string username;
+       string prefix;
+       bool useSSL;    
+       int timeout;
 
 };
 
+// CalDAVServerSupport: used for
+// getting what the server supports
+// from the CalDAV specification.
+
+struct CalDAVServerSupport{
+       
+       // Variable name.                          Name in CalDAV header.
+       
+       bool basicSupport = false;              // calendar-access
+       
+};
+
 // CalDAVServerResult: used for
 // getting the result of the
 // request made via the CalDAV
@@ -47,19 +110,92 @@ struct CalDAVStatus{
 
 struct CalDAVServerResult{
 
+       CalDAVQueryResult result = CALDAVQUERYRESULT_NOTRUN;
+       CURLcode code = CURLE_OK;
+       long httpCode = 0;
        
+};
 
+// CalDAVSendData: used for
+// sending data to the CaLDAV
+// server.
+
+struct CalDAVSendData{
+       string *readptr;
+       long sizeleft;
+       int seek = 0;
 };
 
 class CalDAV{
 
+       private:
+               string ProcessXMLUserPrincipal();
+               string ProcessXMLCalendarHome();
+               CalDAVCalendarList ProcessXMLCalendarList();
+               CalDAVEntryList ProcessXMLEntryList();
+               CalDAVEntryList ProcessXMLSyncTokenList();
+               string ProcessXMLEntryETag();
+               bool MatchXMLNameTransverse(xmlNodePtr *nodePtr, string nodeName);
+               bool MatchXMLName(xmlNodePtr *nodePtrOriginal, string nodeName);
+               string FetchXMLData(xmlNodePtr *nodePtr);
+               CalDAVServerResult EditCalendarProcess(string *calendarHREF,
+                       string *calendarName,
+                       Colour *calendarColour,
+                       string *calendarDescription,
+                       int *calendarOrder);
+       
+               CalDAVConnectionData connectionData;
+               CalDAVServerResult connectionServerResult;
+               CURL *connectionHandle = nullptr;
+               string serverData = "";
+               string serverHeader = "";
+       
+       public:
+               CalDAV();
+               ~CalDAV();
+               void SetupConnectionData(CalDAVConnectionData *connData);
+               CalDAVStatus GetConnectionData();
+               CalDAVServerResult Connect();
+               CalDAVServerResult GetServerResult();
+               CalDAVServerSupport GetServerSupport();
+               CalDAVCalendarList GetCalendars();
+               CalDAVEntryList GetEntryList(string *calendarHREF);
+               CalDAVEntryList GetEntryList(string *calendarHREF, string *calendarTag);
+       
+               CalDAVServerResult AddCalendar(string calendarName);
+               CalDAVServerResult AddCalendar(string *calendarName, string *calendarShortName);
+       
+               CalDAVServerResult EditCalendar(string *calendarHREF,
+                       string *calendarName,
+                       Colour *calendarColour,
+                       string *calendarDescription,
+                       int *calendarOrder);
+               CalDAVServerResult EditCalendar(string *calendarHREF,
+                       Colour *calendarColour);
+               CalDAVServerResult EditCalendar(string *calendarHREF,
+                       string *calendarName);
+               CalDAVServerResult EditCalendar(string *calendarHREF,
+                       int *calendarOrder);
+               CalDAVServerResult EditCalendarDescription(string *calendarHREF,
+                       string *calendarDescription);
+               
+               CalDAVServerResult DeleteCalendar(string *calendarHREF);
+               
+               CalDAVServerResult AddEntry(string *calendarEntryHREF, string *entryData);
+               CalDAVServerResult EditEntry(string *calendarEntryHREF, string *entryData, string *entryETag);
+               CalDAVServerResult DeleteEntry(string *calendarEntryHREF);
        
+               string GetUserPrincipal();
+               string GetCalendarHome(string userPrincipalURI);
+               
+               CalDAVServerResult GetEntryETag(string *calendarEntryHREF, string *eTagValue);
        
 };
 
 // Subroutines that are used with the 
 // CalDAVConnectionData struct.
 
-bool CalDAVObjectValidSettings(CalDAVConnectionData *ConnData);
+bool CalDAVObjectValidSettings(CalDAVConnectionData *connData);
+string BuildServerAddress(CalDAVConnectionData *connData, string uriAddress);
 
 #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