Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Win32: implement further UTF8 support
[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 #if defined(WIN32)
35 #include <Windows.h>
36 #endif
38 enum CDSAccountResult{
39         CDSACCOUNT_UNITTESTFAIL = -1,
40         CDSACCOUNT_OK,
41         CDSACCOUNT_FAILED,
42         CDSACCOUNT_NOACTION,
43         CDSACCOUNT_NOACCOUNT,
44         CDSACCOUNT_NONAME
45 };
47 enum CDSCalendarResult{
48         CDSCALENDAR_UNITTESTFAIL = -1,
49         CDSCALENDAR_OK,
50         CDSCALENDAR_FAILED,
51         CDSCALENDAR_NOACTION,
52         CDSCALENDAR_NOACCOUNT,
53         CDSCALENDAR_NOCALENDAR
54 };
56 enum CDSEntryResult{
57         CDSENTRY_UNITTESTFAIL = -1,
58         CDSENTRY_OK,
59         CDSENTRY_FAILED,
60         CDSENTRY_NOACTION,
61         CDSENTRY_NOACCOUNT,
62         CDSENTRY_NOCALENDAR,
63         CDSENTRY_NOENTRY,
64         CDSENTRY_MISSINGFILE,
65         CDSENTRY_CANNOTOPENFILE,
66         CDSENTRY_INVALIDFILE,
67 };
69 struct CDSGetAccountInfo{
70         int accountID = 0;
71         int accountPreferencesID = 0;
72         std::string accountName = "";
73         CDSAccountResult accountInfoResult = CDSACCOUNT_NOACTION;
74 };
76 struct CDSGetCalendarInfo{
77         int accountID = 0;
78         int calendarID = 0;
79         std::string accountName = "";
80         std::string calendarName = "";
81         std::string calendarTextID = "";
82         std::string calendarDescription = "";
83         Colour calendarColour;
84         CDSAccountResult accountInfoResult = CDSACCOUNT_NOACTION;
85         CDSCalendarResult calendarInfoResult = CDSCALENDAR_NOACTION;
86 };
88 struct CDSAddEntryResult{
89         int calendarEntryID = 0;
90         CDSEntryResult addEventResult = CDSENTRY_NOACTION;
91 };
93 struct CDSEditEntryResult{
94         int calendarEntryID = 0;
95         CDSEntryResult editEventResult = CDSENTRY_NOACTION;
96 };
98 struct CDSGetCalendarEntryInfo{
99         int accountID = 0;
100         int calendarID = 0;
101         int calendarEntryID = 0;
102         std::string entryName = "";
103         std::string entryDescription = "";
104         std::string entryFilename = "";
105         int entryStartYear = 0;
106         int entryStartMonth = 0;
107         int entryStartDay = 0;
108         int entryStartHour = 0;
109         int entryStartMinute = 0;
110         int entryStartSecond = 0;
111         int entryEndYear = 0;
112         int entryEndMonth = 0;
113         int entryEndDay = 0;
114         int entryEndHour = 0;
115         int entryEndMinute = 0;
116         int entryEndSecond = 0;
117         int entryDurationWeeks = 0;
118         int entryDurationDays = 0;
119         int entryDurationHours = 0;
120         int entryDurationMinutes = 0;
121         int entryDurationSeconds = 0;
122         CDSEntryResult getEventResult = CDSENTRY_NOACTION;
123 };
125 struct CDSEntryList{
126         std::vector <int> entryList;
127         CDSEntryResult getEventListResult = CDSENTRY_NOACTION;
128 };
130 struct CDSCalendarList{
131         std::vector <int> calendarList;
132         std::vector <std::string> calendarListTextID;
133         CDSCalendarResult getCalendarListResult = CDSCALENDAR_NOACTION;
134 };
136 struct CDSAccountList{
137         std::vector<CDSGetAccountInfo> accountList;
138         CDSAccountResult getAccountListResult = CDSACCOUNT_NOACTION;
139 };
141 enum CDSChecksumResult{
142         CDSCHECKSUM_UNITTESTFAIL = -1,
143         CDSCHECKSUM_OK,
144         CDSCHECKSUM_FAILED,
145         CDSCHECKSUM_NOHASH,
146         CDSCHECKSUM_CHECKSUMALREADYEXISTS,
147         CDSCHECKSUM_NORESULT
148 };
150 struct CDSGetChecksumResult{
151         CDSChecksumResult getChecksumResult = CDSCHECKSUM_NORESULT;
152         std::string checksumValue = "";
153 };
155 enum CDSCleanupResult{
156         CDSCLEANUP_UNITTESTFAIL = -1,
157         CDSCLEANUP_OK,
158         CDSCLEANUP_FAILED
159 };
161 class CalendarDataStorage{
163         private:
164                 sqlite3 *db = nullptr;
165                 void SetupTables();
166                 bool DataStorageInitOK = false;
167         public:
168                 CalendarDataStorage();
169                 ~CalendarDataStorage();
170                 bool DidInitOK();
171         
172                 // Account functions.
173         
174                 CDSAccountResult AddAccount(std::string accountName, int accountPreferencesID);
175                 CDSGetAccountInfo GetAccount(std::string accountName);
176                 CDSAccountResult UpdateAccount(int accountID, std::string accountName);
177                 CDSAccountResult DeleteAccount(int accountID);
178                 CDSAccountList GetAccountList();
179         
180                 // Calendar functions.
181         
182                 CDSCalendarResult AddCalendar(int accountID, std::string calendarName, std::string calendarID, Colour calendarColour, std::string calendarDescription);
183                 CDSGetCalendarInfo GetCalendar(std::string accountName, std::string calendarTextID);
184                 CDSGetCalendarInfo GetCalendar(int calendarID);
185                 CDSCalendarList GetCalendarList(int accountID);
186                 CDSCalendarResult UpdateCalendar(int calendarID, std::string calendarName, Colour calendarColour, std::string calendarDescription);
187                 CDSCalendarResult DeleteCalendar(int calendarID);
188         
189                 // Entry functions
190         
191                 CDSAddEntryResult AddEvent(int calendarID, std::string filename);
192                 CDSGetCalendarEntryInfo GetEvent(int calendarEntryID);
193                 CDSEntryList GetEventList(int calendarID);
194                 CDSEntryList GetEventListByDate(int calendarYear, int calendarMonth, int calendarDay);
195                 CDSEditEntryResult UpdateEvent(int eventID, std::string filename);
196                 CDSEntryResult DeleteEvent(int calendarEntryID);
197                 
198                 // Checksum functions.
199                 
200                 CDSChecksumResult AddChecksum(std::string checksumName, std::string checksumValue);             
201                 CDSGetChecksumResult GetChecksum(std::string checksumName);
202                 CDSChecksumResult UpdateChecksum(std::string checksumName, std::string checksumValue);
203                 
204                 // Cleanup functions.
205                 
206                 CDSCleanupResult Clear();
207          
208 };
210 #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