Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
47c70b523589373493401d61364757a05204a529
[xestiacalendar/.git] / source / libraries / CalendarDataStorage / CalendarDataStorage.h
1 #ifndef __LIBRARIES_CALENDARDATASTORAGE_H__
2 #define __LIBRARIES_CALENDARDATASTORAGE_H__
4 #include <string>
5 #include <iostream>
6 #include <sstream>
7 #include <cctype>
8 #include <algorithm>
10 #include <sqlite3.h>
12 #include "../../objects/calendarevent/CalendarEvent.h"
13 #include "../../common/colour.h"
14 #include "../../common/random.h"
16 /*enum CDSAddEntryResult{
17         CDSADDENTRY_UNITTESTFAIL = -1,
18         CDSADDENTRY_OK
19 }*/
21 enum CDSAccountResult{
22         CDSACCOUNT_UNITTESTFAIL = -1,
23         CDSACCOUNT_OK,
24         CDSACCOUNT_FAILED,
25         CDSACCOUNT_NOACTION,
26         CDSACCOUNT_NOACCOUNT
27 };
29 enum CDSCalendarResult{
30         CDSCALENDAR_UNITTESTFAIL = -1,
31         CDSCALENDAR_OK,
32         CDSCALENDAR_FAILED,
33         CDSCALENDAR_NOACTION,
34         CDSCALENDAR_NOCALENDAR
35 };
37 enum CDSEntryResult{
38         CDSENTRY_UNITTESTFAIL = -1,
39         CDSENTRY_OK,
40         CDSENTRY_FAILED,
41         CDSENTRY_NOACTION,
42         CDSENTRY_NOACCOUNT,
43         CDSENTRY_NOCALENDAR,
44         CDSENTRY_NOENTRY,
45         CDSENTRY_MISSINGFILE,
46         CDSENTRY_CANNOTOPENFILE,
47         CDSENTRY_INVALIDFILE,
48 };
50 struct CDSGetAccountInfo{
51         int accountID = 0;
52         int accountPreferencesID = 0;
53         std::string accountName = "";
54         CDSAccountResult accountInfoResult = CDSACCOUNT_NOACTION;
55 };
57 struct CDSGetCalendarInfo{
58         int accountID = 0;
59         int calendarID = 0;
60         std::string accountName = "";
61         std::string calendarName = "";
62         std::string calendarTextID = "";
63         std::string calendarDescription = "";
64         Colour calendarColour;
65         CDSAccountResult accountInfoResult = CDSACCOUNT_NOACTION;
66         CDSCalendarResult calendarInfoResult = CDSCALENDAR_NOACTION;
67 };
69 struct CDSAddEntryResult{
70         int calendarEntryID = 0;
71         CDSEntryResult addEventResult = CDSENTRY_NOACTION;
72 };
74 struct CDSEditEntryResult{
75         int calendarEntryID = 0;
76         CDSEntryResult editEventResult = CDSENTRY_NOACTION;
77 };
79 struct CDSGetCalendarEntryInfo{
80         int accountID = 0;
81         int calendarID = 0;
82         int calendarEntryID = 0;
83         std::string entryName = "";
84         std::string entryDescription = "";
85         std::string entryFilename = "";
86         int entryStartYear = 0;
87         int entryStartMonth = 0;
88         int entryStartDay = 0;
89         int entryStartHour = 0;
90         int entryStartMinute = 0;
91         int entryStartSecond = 0;
92         int entryEndYear = 0;
93         int entryEndMonth = 0;
94         int entryEndDay = 0;
95         int entryEndHour = 0;
96         int entryEndMinute = 0;
97         int entryEndSecond = 0;
98         int entryDurationWeeks = 0;
99         int entryDurationDays = 0;
100         int entryDurationHours = 0;
101         int entryDurationMinutes = 0;
102         int entryDurationSeconds = 0;
103         CDSEntryResult getEventResult = CDSENTRY_NOACTION;
104 };
106 struct CDSEntryList{
107         std::vector <int> entryList;
108         CDSEntryResult getEventListResult = CDSENTRY_NOACTION;
109 };
111 struct CDSCalendarList{
112         std::vector <int> calendarList;
113         std::vector <std::string> calendarListTextID;
114         CDSCalendarResult getCalendarListResult = CDSCALENDAR_NOACTION;
115 };
117 struct CDSAccountList{
118         std::vector<CDSGetAccountInfo> accountList;
119         CDSAccountResult getAccountListResult = CDSACCOUNT_NOACTION;
120 };
122 enum CDSChecksumResult{
123         CDSCHECKSUM_UNITTESTFAIL = -1,
124         CDSCHECKSUM_OK,
125         CDSCHECKSUM_FAILED,
126         CDSCHECKSUM_NOHASH,
127         CDSCHECKSUM_CHECKSUMALREADYEXISTS,
128         CDSCHECKSUM_NORESULT
129 };
131 struct CDSGetChecksumResult{
132         CDSChecksumResult getChecksumResult = CDSCHECKSUM_NORESULT;
133         std::string checksumValue = "";
134 };
136 enum CDSCleanupResult{
137         CDSCLEANUP_UNITTESTFAIL = -1,
138         CDSCLEANUP_OK,
139         CDSCLEANUP_FAILED
140 };
142 class CalendarDataStorage{
144         private:
145                 sqlite3 *db = nullptr;
146                 void SetupTables();
147                 bool DataStorageInitOK = false;
148         public:
149                 CalendarDataStorage();
150                 ~CalendarDataStorage();
151                 bool DidInitOK();
152         
153                 // Account functions.
154         
155                 CDSAccountResult AddAccount(std::string accountName, int accountPreferencesID);
156                 CDSGetAccountInfo GetAccount(std::string accountName);
157                 CDSAccountResult UpdateAccount(int accountID, std::string accountName);
158                 CDSAccountResult DeleteAccount(int accountID);
159                 CDSAccountList GetAccountList();
160         
161                 // Calendar functions.
162         
163                 CDSCalendarResult AddCalendar(int accountID, std::string calendarName, std::string calendarID, Colour calendarColour, std::string calendarDescription);
164                 CDSGetCalendarInfo GetCalendar(std::string accountName, std::string calendarTextID);
165                 CDSGetCalendarInfo GetCalendar(int calendarID);
166                 CDSCalendarList GetCalendarList(int accountID);
167                 CDSCalendarResult UpdateCalendar(int calendarID, std::string calendarName, Colour calendarColour, std::string calendarDescription);
168                 CDSCalendarResult DeleteCalendar(int calendarID);
169         
170                 // Entry functions
171         
172                 CDSAddEntryResult AddEvent(int calendarID, std::string filename);
173                 CDSGetCalendarEntryInfo GetEvent(int calendarEntryID);
174                 CDSEntryList GetEventList(int calendarID);
175                 CDSEntryList GetEventListByDate(int calendarYear, int calendarMonth, int calendarDay);
176                 CDSEditEntryResult UpdateEvent(int eventID, std::string filename);
177                 CDSEntryResult DeleteEvent(int calendarEntryID);
178                 
179                 // Checksum functions.
180                 
181                 CDSChecksumResult AddChecksum(std::string checksumName, std::string checksumValue);             
182                 CDSGetChecksumResult GetChecksum(std::string checksumName);
183                 CDSChecksumResult UpdateChecksum(std::string checksumName, std::string checksumValue);
184                 
185                 // Cleanup functions.
186                 
187                 CDSCleanupResult Clear();
188          
189 };
191 #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