Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Getting the right amount of characters to check for TZID 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         
111         
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