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