1 #ifndef __LIBRARIES_CALENDARDATASTORAGE_H__
2 #define __LIBRARIES_CALENDARDATASTORAGE_H__
12 #include "../../objects/calendarevent/CalendarEvent.h"
13 #include "../../common/colour.h"
14 #include "../../common/random.h"
16 /*enum CDSAddEntryResult{
17 CDSADDENTRY_UNITTESTFAIL = -1,
21 enum CDSAccountResult{
22 CDSACCOUNT_UNITTESTFAIL = -1,
29 enum CDSCalendarResult{
30 CDSCALENDAR_UNITTESTFAIL = -1,
34 CDSCALENDAR_NOCALENDAR
38 CDSENTRY_UNITTESTFAIL = -1,
46 CDSENTRY_CANNOTOPENFILE,
50 struct CDSGetAccountInfo{
52 int accountPreferencesID = 0;
53 std::string accountName = "";
54 CDSAccountResult accountInfoResult = CDSACCOUNT_NOACTION;
57 struct CDSGetCalendarInfo{
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;
69 struct CDSAddEntryResult{
70 int calendarEntryID = 0;
71 CDSEntryResult addEventResult = CDSENTRY_NOACTION;
74 struct CDSEditEntryResult{
75 int calendarEntryID = 0;
76 CDSEntryResult editEventResult = CDSENTRY_NOACTION;
79 struct CDSGetCalendarEntryInfo{
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;
93 int entryEndMonth = 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;
107 std::vector <int> entryList;
108 CDSEntryResult getEventListResult = CDSENTRY_NOACTION;
111 struct CDSCalendarList{
112 std::vector <int> calendarList;
113 std::vector <std::string> calendarListTextID;
114 CDSCalendarResult getCalendarListResult = CDSCALENDAR_NOACTION;
117 struct CDSAccountList{
118 std::vector<CDSGetAccountInfo> accountList;
119 CDSAccountResult getAccountListResult = CDSACCOUNT_NOACTION;
122 enum CDSChecksumResult{
123 CDSCHECKSUM_UNITTESTFAIL = -1,
127 CDSCHECKSUM_CHECKSUMALREADYEXISTS,
131 struct CDSGetChecksumResult{
132 CDSChecksumResult getChecksumResult = CDSCHECKSUM_NORESULT;
133 std::string checksumValue = "";
136 enum CDSCleanupResult{
137 CDSCLEANUP_UNITTESTFAIL = -1,
142 class CalendarDataStorage{
145 sqlite3 *db = nullptr;
147 bool DataStorageInitOK = false;
149 CalendarDataStorage();
150 ~CalendarDataStorage();
153 // Account functions.
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();
161 // Calendar functions.
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);
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);
179 // Checksum functions.
181 CDSChecksumResult AddChecksum(std::string checksumName, std::string checksumValue);
182 CDSGetChecksumResult GetChecksum(std::string checksumName);
183 CDSChecksumResult UpdateChecksum(std::string checksumName, std::string checksumValue);
185 // Cleanup functions.
187 CDSCleanupResult Clear();