Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Version 0.08 release
[xestiacalendar/.git] / 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         int SeekCount = 0;
12         string PropertyName;
13         
14         // Look for BEGIN:VEVENT.
15         
16         for (vector<string>::iterator iter = ObjectName.begin();
17                 iter != ObjectName.end(); iter++){
18         
19                 if (ObjectName[SeekCount] == "BEGIN" &&
20                         ObjectData[SeekCount] == "VEVENT"){
21                         
22                         if (ValidBegin == false){
23                                 ValidBegin = true;
24                         } else {
25                                 return CALENDAROBJECTVALID_INVALIDFORMAT;
26                         }
27                                 
28                 }
29                 
30                 if (ObjectName[SeekCount] == "END" &&
31                         ObjectData[SeekCount] == "VEVENT" &&
32                         ValidBegin == false){
33                 
34                         return CALENDAROBJECTVALID_INVALIDFORMAT;
35                                 
36                 }
37                 
38                 SeekCount++;
39                         
40         }
41         
42         SeekCount = 0;
43         
44         // Look for DTSTAMP.
45         
46         for (vector<string>::iterator iter = ObjectName.begin();
47                 iter != ObjectName.end(); iter++){
48                         
49                 try{
50                         PropertyName = ObjectName[SeekCount].substr(0,7);
51                 }
52                         
53                 catch(const out_of_range& oor){
54                         continue;
55                 }
56                 
57                 if (PropertyName == "DTSTAMP"){
58                         
59                         if (ValidDateTimeStamp == false){
60                                 ValidDateTimeStamp = true;
61                         } else {
62                                 return CALENDAROBJECTVALID_INVALIDFORMAT;
63                         }
64                                 
65                 }
66                         
67                 SeekCount++;
68                         
69         }
70         
71         SeekCount = 0;
72         
73         // Look for UID.
74         
75         for (vector<string>::iterator iter = ObjectName.begin();
76                 iter != ObjectName.end(); iter++){
77         
78                 try{
79                         PropertyName = ObjectName[SeekCount].substr(0,3);
80                 }
81                 
82                 catch(const out_of_range& oor){
83                         continue;
84                 }
85                         
86                 if (PropertyName == "UID"){
87                         
88                         if (ValidUniqueID == false){
89                                 ValidUniqueID = true;
90                         } else {
91                                 return CALENDAROBJECTVALID_INVALIDFORMAT;
92                         }
93                                 
94                 }
95                         
96                 SeekCount++;
97                         
98         }
99         
100         SeekCount = 0;
101         
102         // Look for END:VEVENT.
103         
104         for (vector<string>::iterator iter = ObjectName.begin();
105                 iter != ObjectName.end(); iter++){
106         
107                 if (ObjectName[SeekCount] == "END" &&
108                         ObjectData[SeekCount] == "VEVENT"){
109                         
110                         if (ValidEnd == false){
111                                 ValidEnd = true;
112                         } else {
113                                 return CALENDAROBJECTVALID_INVALIDFORMAT;
114                         }
115                                 
116                 }
117                         
118                 SeekCount++;
119                         
120         }
121         
122         // Check if the VEVENT is valid.
124         if (ValidBegin == true && 
125                 ValidEnd == true && 
126                 ValidDateTimeStamp == true &&
127                 ValidUniqueID == true){
128                 
129                 return CALENDAROBJECTVALID_OK;
130                         
131         } else {
132                 
133                 return CALENDAROBJECTVALID_INVALIDFORMAT;
134                 
135         }
136         
139 void CalendarEventObject::ProcessData(){
140         
141         // Process the data.
142         
143         multimap<string,string> DataReceived;
144         
145         // Get the Date Time Stamp (DTSTAMP).
146         
147         DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "DTSTAMP");
148         
149         // Process the data.
150         
151         if (DataReceived.begin() != DataReceived.end()){
152         
153                 DateTimeStampData = DataReceived.begin()->second;
154                 
155         }
156         
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