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 std::string accountName = "";
53 CDSAccountResult accountInfoResult = CDSACCOUNT_NOACTION;
56 struct CDSGetCalendarInfo{
59 std::string accountName = "";
60 std::string calendarName = "";
61 std::string calendarTextID = "";
62 Colour calendarColour;
63 CDSAccountResult accountInfoResult = CDSACCOUNT_NOACTION;
64 CDSCalendarResult calendarInfoResult = CDSCALENDAR_NOACTION;
67 struct CDSAddEntryResult{
68 int calendarEntryID = 0;
69 CDSEntryResult addEventResult = CDSENTRY_NOACTION;
72 struct CDSGetCalendarEntryInfo{
75 int calendarEntryID = 0;
76 std::string entryName = "";
77 std::string entryDescription = "";
78 int entryStartYear = 0;
79 int entryStartMonth = 0;
80 int entryStartDay = 0;
81 int entryStartHour = 0;
82 int entryStartMinute = 0;
83 int entryStartSecond = 0;
85 int entryEndMonth = 0;
88 int entryEndMinute = 0;
89 int entryEndSecond = 0;
90 int entryDurationWeeks = 0;
91 int entryDurationDays = 0;
92 int entryDurationHours = 0;
93 int entryDurationMinutes = 0;
94 int entryDurationSeconds = 0;
95 CDSEntryResult getEventResult = CDSENTRY_NOACTION;
99 std::vector <int> entryList;
100 CDSEntryResult getEventListResult = CDSENTRY_NOACTION;
103 struct CDSCalendarList{
104 std::vector <int> calendarList;
105 std::vector <std::string> calendarListTextID;
106 CDSCalendarResult getCalendarListResult = CDSCALENDAR_NOACTION;
109 struct CDSAccountList{
110 std::vector<CDSGetAccountInfo> accountList;
111 CDSAccountResult getAccountListResult = CDSACCOUNT_NOACTION;
114 enum CDSChecksumResult{
115 CDSCHECKSUM_UNITTESTFAIL = -1,
119 CDSCHECKSUM_CHECKSUMALREADYEXISTS,
123 struct CDSGetChecksumResult{
124 CDSChecksumResult getChecksumResult = CDSCHECKSUM_NORESULT;
125 std::string checksumValue = "";
128 class CalendarDataStorage{
131 sqlite3 *db = nullptr;
133 bool DataStorageInitOK = false;
135 CalendarDataStorage();
136 ~CalendarDataStorage();
139 // Account functions.
141 CDSAccountResult AddAccount(std::string accountName);
142 CDSGetAccountInfo GetAccount(std::string accountName);
143 CDSAccountResult UpdateAccount(int accountID, std::string accountName);
144 CDSAccountResult DeleteAccount(int accountID);
145 CDSAccountList GetAccountList();
147 // Calendar functions.
149 CDSCalendarResult AddCalendar(int accountID, std::string calendarName, std::string calendarID, Colour calendarColour);
150 CDSGetCalendarInfo GetCalendar(std::string accountName, std::string calendarTextID);
151 CDSGetCalendarInfo GetCalendar(int calendarID);
152 CDSCalendarList GetCalendarList(int accountID);
153 CDSCalendarResult UpdateCalendar(int calendarID, std::string calendarName);
154 CDSCalendarResult DeleteCalendar(int calendarID);
158 CDSAddEntryResult AddEvent(int calendarID, std::string filename);
159 CDSGetCalendarEntryInfo GetEvent(int calendarEntryID);
160 CDSEntryList GetEventList(int calendarID);
161 CDSEntryList GetEventListByDate(int calendarYear, int calendarMonth, int calendarDay);
162 CDSEntryResult DeleteEvent(int calendarEntryID);
164 // Checksum functions.
166 CDSChecksumResult AddChecksum(std::string checksumName, std::string checksumValue);
167 CDSGetChecksumResult GetChecksum(std::string checksumName);
168 CDSChecksumResult UpdateChecksum(std::string checksumName, std::string checksumValue);