Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
7387194c8c55d315d268f58183c10236f3626e8d
[xestiacalendar/.git] / source / libraries / CalendarDataStorage / CalendarDataStorage.h
1 #include <string>
2 #include <iostream>
3 #include <sstream>
4 #include <cctype>
5 #include <algorithm>
7 #include <sqlite3.h>
9 #include "../../objects/calendarevent/CalendarEvent.h"
10 #include "../../common/colour.h"
12 #ifndef __LIBRARIES_CALENDARDATASTORAGE_H__
13 #define __LIBRARIES_CALENDARDATASTORAGE_H__
15 /*enum CDSAddEntryResult{
16         CDSADDENTRY_UNITTESTFAIL = -1,
17         CDSADDENTRY_OK
18 }*/
20 enum CDSAccountResult{
21         CDSACCOUNT_UNITTESTFAIL = -1,
22         CDSACCOUNT_OK,
23         CDSACCOUNT_FAILED,
24         CDSACCOUNT_NOACTION,
25         CDSACCOUNT_NOACCOUNT
26 };
28 enum CDSCalendarResult{
29         CDSCALENDAR_UNITTESTFAIL = -1,
30         CDSCALENDAR_OK,
31         CDSCALENDAR_FAILED,
32         CDSCALENDAR_NOACTION,
33         CDSCALENDAR_NOCALENDAR
34 };
36 enum CDSEntryResult{
37         CDSENTRY_UNITTESTFAIL = -1,
38         CDSENTRY_OK,
39         CDSENTRY_FAILED,
40         CDSENTRY_NOACTION,
41         CDSENTRY_NOACCOUNT,
42         CDSENTRY_NOCALENDAR,
43         CDSENTRY_NOENTRY,
44         CDSENTRY_MISSINGFILE,
45         CDSENTRY_CANNOTOPENFILE,
46         CDSENTRY_INVALIDFILE,
47 };
49 struct CDSGetAccountInfo{
50         int accountID = 0;
51         std::string accountName = "";
52         CDSAccountResult accountInfoResult = CDSACCOUNT_NOACTION;
53 };
55 struct CDSGetCalendarInfo{
56         int accountID = 0;
57         int calendarID = 0;
58         std::string accountName = "";
59         std::string calendarName = "";
60         std::string calendarTextID = "";
61         Colour calendarColour;
62         CDSAccountResult accountInfoResult = CDSACCOUNT_NOACTION;
63         CDSCalendarResult calendarInfoResult = CDSCALENDAR_NOACTION;
64 };
66 struct CDSAddEntryResult{
67         int calendarEntryID = 0;
68         CDSEntryResult addEventResult = CDSENTRY_NOACTION;
69 };
71 struct CDSGetCalendarEntryInfo{
72         int accountID = 0;
73         int calendarID = 0;
74         int calendarEntryID = 0;
75         std::string entryName = "";
76         std::string entryDescription = "";
77         int entryStartYear = 0;
78         int entryStartMonth = 0;
79         int entryStartDay = 0;
80         int entryStartHour = 0;
81         int entryStartMinute = 0;
82         int entryStartSecond = 0;
83         int entryEndYear = 0;
84         int entryEndMonth = 0;
85         int entryEndDay = 0;
86         int entryEndHour = 0;
87         int entryEndMinute = 0;
88         int entryEndSecond = 0;
89         int entryDurationWeeks = 0;
90         int entryDurationDays = 0;
91         int entryDurationHours = 0;
92         int entryDurationMinutes = 0;
93         int entryDurationSeconds = 0;
94         CDSEntryResult getEventResult = CDSENTRY_NOACTION;
95 };
97 struct CDSEntryList{
98         std::vector <int> entryList;
99         CDSEntryResult getEventListResult = CDSENTRY_NOACTION;
100 };
102 struct CDSCalendarList{
103         std::vector <int> calendarList;
104         std::vector <std::string> calendarListTextID;
105         CDSCalendarResult getCalendarListResult = CDSCALENDAR_NOACTION;
106 };
108 struct CDSAccountList{
109         std::vector<CDSGetAccountInfo> accountList;
110         CDSAccountResult getAccountListResult = CDSACCOUNT_NOACTION;
111 };
113 class CalendarDataStorage{
115         private:
116                 sqlite3 *db = nullptr;
117                 void SetupTables();
118                 bool DataStorageInitOK = false;
119         public:
120                 CalendarDataStorage();
121                 ~CalendarDataStorage();
122                 bool DidInitOK();
123         
124                 // Account functions.
125         
126                 CDSAccountResult AddAccount(std::string accountName);
127                 CDSGetAccountInfo GetAccount(std::string accountName);
128                 CDSAccountResult UpdateAccount(int accountID, std::string accountName);
129                 CDSAccountResult DeleteAccount(int accountID);
130                 CDSAccountList GetAccountList();
131         
132                 // Calendar functions.
133         
134                 CDSCalendarResult AddCalendar(int accountID, std::string calendarName, std::string calendarID, Colour calendarColour);
135                 CDSGetCalendarInfo GetCalendar(std::string accountName, std::string calendarTextID);
136                 CDSCalendarList GetCalendarList(int accountID);
137                 CDSCalendarResult UpdateCalendar(int calendarID, std::string calendarName);
138                 CDSCalendarResult DeleteCalendar(int calendarID);
139         
140                 // Entry functions
141         
142                 CDSAddEntryResult AddEvent(int calendarID, std::string filename);
143                 CDSGetCalendarEntryInfo GetEvent(int calendarEntryID);
144                 CDSEntryList GetEventList(int calendarID);
145                 CDSEntryResult DeleteEvent(int calendarEntryID);
146          
147 };
149 #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