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