Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmMain: Implemented code to hide/show calendar entries
[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         std::string accountName = "";
53         CDSAccountResult accountInfoResult = CDSACCOUNT_NOACTION;
54 };
56 struct CDSGetCalendarInfo{
57         int accountID = 0;
58         int calendarID = 0;
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;
65 };
67 struct CDSAddEntryResult{
68         int calendarEntryID = 0;
69         CDSEntryResult addEventResult = CDSENTRY_NOACTION;
70 };
72 struct CDSGetCalendarEntryInfo{
73         int accountID = 0;
74         int calendarID = 0;
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;
84         int entryEndYear = 0;
85         int entryEndMonth = 0;
86         int entryEndDay = 0;
87         int entryEndHour = 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;
96 };
98 struct CDSEntryList{
99         std::vector <int> entryList;
100         CDSEntryResult getEventListResult = CDSENTRY_NOACTION;
101 };
103 struct CDSCalendarList{
104         std::vector <int> calendarList;
105         std::vector <std::string> calendarListTextID;
106         CDSCalendarResult getCalendarListResult = CDSCALENDAR_NOACTION;
107 };
109 struct CDSAccountList{
110         std::vector<CDSGetAccountInfo> accountList;
111         CDSAccountResult getAccountListResult = CDSACCOUNT_NOACTION;
112 };
114 enum CDSChecksumResult{
115         CDSCHECKSUM_UNITTESTFAIL = -1,
116         CDSCHECKSUM_OK,
117         CDSCHECKSUM_FAILED,
118         CDSCHECKSUM_NOHASH,
119         CDSCHECKSUM_CHECKSUMALREADYEXISTS,
120         CDSCHECKSUM_NORESULT
121 };
123 struct CDSGetChecksumResult{
124         CDSChecksumResult getChecksumResult = CDSCHECKSUM_NORESULT;
125         std::string checksumValue = "";
126 };
128 class CalendarDataStorage{
130         private:
131                 sqlite3 *db = nullptr;
132                 void SetupTables();
133                 bool DataStorageInitOK = false;
134         public:
135                 CalendarDataStorage();
136                 ~CalendarDataStorage();
137                 bool DidInitOK();
138         
139                 // Account functions.
140         
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();
146         
147                 // Calendar functions.
148         
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);
155         
156                 // Entry functions
157         
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);
163                 
164                 // Checksum functions.
165                 
166                 CDSChecksumResult AddChecksum(std::string checksumName, std::string checksumValue);             
167                 CDSGetChecksumResult GetChecksum(std::string checksumName);
168                 CDSChecksumResult UpdateChecksum(std::string checksumName, std::string checksumValue);
169          
170 };
172 #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