Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added initial version of the CalendarFreeBusyObject.
[xestiacalendar/.git] / source / objects / calendarfreebusy / CalendarFreeBusy.cpp
1 #include "CalendarFreeBusy.h"
3 using namespace std;
5 CalendarObjectValidResult CalendarFreeBusyObject::ValidObject(){
6  
7         bool ValidBegin = false;
8         bool ValidEnd = false;
9         bool ValidDateTimeStamp = false;
10         bool ValidUniqueID = false;
11         bool ValidDateTimeStart = false;
12         int SeekCount = 0;
13         string PropertyName;
14         
15         // Look for BEGIN:VFREEBUSY.
16         
17         for (vector<string>::iterator iter = ObjectName.begin();
18                 iter != ObjectName.end(); iter++){
19         
20                 if (ObjectName[SeekCount] == "BEGIN" &&
21                         ObjectData[SeekCount] == "VFREEBUSY"){
22                         
23                         if (ValidBegin == false){
24                                 ValidBegin = true;
25                         } else {
26                                 return CALENDAROBJECTVALID_INVALIDFORMAT;
27                         }
28                                 
29                 }
30                 
31                 if (ObjectName[SeekCount] == "END" &&
32                         ObjectData[SeekCount] == "VFREEBUSY" &&
33                         ValidBegin == false){
34                 
35                         return CALENDAROBJECTVALID_INVALIDFORMAT;
36                                 
37                 }
38                 
39                 SeekCount++;
40                         
41         }
42         
43         SeekCount = 0;
44         
45         // Look for DTSTAMP.
46         
47         for (vector<string>::iterator iter = ObjectName.begin();
48                 iter != ObjectName.end(); iter++){
49                         
50                 try{
51                         PropertyName = ObjectName[SeekCount].substr(0,7);
52                 }
53                         
54                 catch(const out_of_range& oor){
55                         continue;
56                 }
57                 
58                 if (PropertyName == "DTSTAMP"){
59                         
60                         if (ValidDateTimeStamp == false){
61                                 ValidDateTimeStamp = true;
62                         } else {
63                                 return CALENDAROBJECTVALID_INVALIDFORMAT;
64                         }
65                                 
66                 }
67                         
68                 SeekCount++;
69                         
70         }
71         
72         SeekCount = 0;
73         
74         // Look for UID.
75         
76         for (vector<string>::iterator iter = ObjectName.begin();
77                 iter != ObjectName.end(); iter++){
78         
79                 try{
80                         PropertyName = ObjectName[SeekCount].substr(0,3);
81                 }
82                 
83                 catch(const out_of_range& oor){
84                         continue;
85                 }
86                         
87                 if (PropertyName == "UID"){
88                         
89                         if (ValidUniqueID == false){
90                                 ValidUniqueID = true;
91                         } else {
92                                 return CALENDAROBJECTVALID_INVALIDFORMAT;
93                         }
94                                 
95                 }
96                         
97                 SeekCount++;
98                         
99         }
100         
101         SeekCount = 0;
102         
103         // Look for END:VFREEBUSY.
104         
105         for (vector<string>::iterator iter = ObjectName.begin();
106                 iter != ObjectName.end(); iter++){
107         
108                 if (ObjectName[SeekCount] == "END" &&
109                         ObjectData[SeekCount] == "VFREEBUSY"){
110                         
111                         if (ValidEnd == false){
112                                 ValidEnd = true;
113                         } else {
114                                 return CALENDAROBJECTVALID_INVALIDFORMAT;
115                         }
116                                 
117                 }
118                         
119                 SeekCount++;
120                         
121         }
122         
123         // Check if the VEVENT is valid.
125         if (ValidBegin == true && 
126                 ValidEnd == true && 
127                 ValidDateTimeStamp == true &&
128                 ValidUniqueID == true){
129                 
130                 return CALENDAROBJECTVALID_OK;
131                         
132         } else {
133                 
134                 return CALENDAROBJECTVALID_INVALIDFORMAT;
135                 
136         }
137         
140 void CalendarFreeBusyObject::ProcessData(){
141         
142         // Process the data.
143         
144         multimap<string,string> DataReceived;
145         map<string,string> PropertyData;
146         string *PropertyNameData = nullptr;
147         int ObjectSeekCount = 0;
148         
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