Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Corrected comment lines with accurate information.
[xestiacalendar/.git] / source / objects / calendarevent / CalendarEvent.cpp
1 #include "CalendarEvent.h"
3 using namespace std;
5 CalendarObjectValidResult CalendarEventObject::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:VEVENT.
16         
17         for (vector<string>::iterator iter = ObjectName.begin();
18                 iter != ObjectName.end(); iter++){
19         
20                 if (ObjectName[SeekCount] == "BEGIN" &&
21                         ObjectData[SeekCount] == "VEVENT"){
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] == "VEVENT" &&
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 DTSTART if nothing is set for METHOD..
104         
105         if (MethodData.size() == 0){
106         
107                 for (vector<string>::iterator iter = ObjectName.begin();
108                         iter != ObjectName.end(); iter++){
109                         
110                         try{
111                                 PropertyName = ObjectName[SeekCount].substr(0,7);
112                         }
113                         
114                         catch(const out_of_range& oor){
115                                 continue;
116                         }
117                 
118                         if (PropertyName == "DTSTART"){
119                         
120                                 if (ValidDateTimeStart == false){
121                                         ValidDateTimeStart = true;
122                                 } else {
123                                         return CALENDAROBJECTVALID_INVALIDFORMAT;
124                                 }
125                                 
126                         }
127                         
128                         SeekCount++;
129                         
130                 }
131         
132         } else {
133                 ValidDateTimeStart = true;
134         }
135         
136         SeekCount = 0;
137         
138         // Look for END:VEVENT.
139         
140         for (vector<string>::iterator iter = ObjectName.begin();
141                 iter != ObjectName.end(); iter++){
142         
143                 if (ObjectName[SeekCount] == "END" &&
144                         ObjectData[SeekCount] == "VEVENT"){
145                         
146                         if (ValidEnd == false){
147                                 ValidEnd = true;
148                         } else {
149                                 return CALENDAROBJECTVALID_INVALIDFORMAT;
150                         }
151                                 
152                 }
153                         
154                 SeekCount++;
155                         
156         }
157         
158         // Check if the VEVENT is valid.
160         if (ValidBegin == true && 
161                 ValidEnd == true && 
162                 ValidDateTimeStamp == true &&
163                 ValidDateTimeStart == true &&
164                 ValidUniqueID == true){
165                 
166                 return CALENDAROBJECTVALID_OK;
167                         
168         } else {
169                 
170                 return CALENDAROBJECTVALID_INVALIDFORMAT;
171                 
172         }
173         
176 void CalendarEventObject::ProcessData(){
177         
178         // Process the data.
179         
180         multimap<string,string> DataReceived;
181         
182         // Get the Date Time Stamp (DTSTAMP).
183         
184         DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "DTSTAMP");
185         
186         // Process the data from DTSTAMP.
187         
188         if (DataReceived.begin() != DataReceived.end()){
189         
190                 try {
191                         DateTimeStampTokens = DataReceived.begin()->first.substr(8);
192                 }
193                 
194                 catch(const out_of_range &oor){
195                         // Do nothing as there is no data.
196                 }               
197                 
198                 DateTimeStampData = DataReceived.begin()->second;
199                 
200         }
202         // Get the Unique ID (UID).
203         
204         DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "UID");
205         
206         // Process the data from UID.
207         
208         if (DataReceived.begin() != DataReceived.end()){
209         
210                 try {
211                         UniqueIDTokens = DataReceived.begin()->first.substr(4);
212                 }
213                 
214                 catch(const out_of_range &oor){
215                         // Do nothing as there is no data.
216                 }               
217                 
218                 UniqueID = DataReceived.begin()->second;
219                 
220         }
221         
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