Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added CalendarScaleData/CalendarScaleTokens for CALSCALE
[xestiacalendar/.git] / source / objects / calendarevent / CalendarEvent.cpp
index 6c1887d..720c7bd 100644 (file)
@@ -8,7 +8,9 @@ CalendarObjectValidResult CalendarEventObject::ValidObject(){
        bool ValidEnd = false;
        bool ValidDateTimeStamp = false;
        bool ValidUniqueID = false;
+       bool ValidDateTimeStart = false;
        int SeekCount = 0;
+       string PropertyName;
        
        // Look for BEGIN:VEVENT.
        
@@ -44,8 +46,16 @@ CalendarObjectValidResult CalendarEventObject::ValidObject(){
        
        for (vector<string>::iterator iter = ObjectName.begin();
                iter != ObjectName.end(); iter++){
-       
-               if (ObjectName[SeekCount] == "DTSTAMP"){
+                       
+               try{
+                       PropertyName = ObjectName[SeekCount].substr(0,7);
+               }
+                       
+               catch(const out_of_range& oor){
+                       continue;
+               }
+               
+               if (PropertyName == "DTSTAMP"){
                        
                        if (ValidDateTimeStamp == false){
                                ValidDateTimeStamp = true;
@@ -66,7 +76,15 @@ CalendarObjectValidResult CalendarEventObject::ValidObject(){
        for (vector<string>::iterator iter = ObjectName.begin();
                iter != ObjectName.end(); iter++){
        
-               if (ObjectName[SeekCount] == "UID"){
+               try{
+                       PropertyName = ObjectName[SeekCount].substr(0,3);
+               }
+               
+               catch(const out_of_range& oor){
+                       continue;
+               }
+                       
+               if (PropertyName == "UID"){
                        
                        if (ValidUniqueID == false){
                                ValidUniqueID = true;
@@ -82,6 +100,35 @@ CalendarObjectValidResult CalendarEventObject::ValidObject(){
        
        SeekCount = 0;
        
+       // Look for DTSTART.
+       
+       for (vector<string>::iterator iter = ObjectName.begin();
+               iter != ObjectName.end(); iter++){
+                       
+               try{
+                       PropertyName = ObjectName[SeekCount].substr(0,7);
+               }
+                       
+               catch(const out_of_range& oor){
+                       continue;
+               }
+               
+               if (PropertyName == "DTSTART"){
+                       
+                       if (ValidDateTimeStart == false){
+                               ValidDateTimeStart = true;
+                       } else {
+                               return CALENDAROBJECTVALID_INVALIDFORMAT;
+                       }
+                               
+               }
+                       
+               SeekCount++;
+                       
+       }
+       
+       SeekCount = 0;
+       
        // Look for END:VEVENT.
        
        for (vector<string>::iterator iter = ObjectName.begin();
@@ -107,6 +154,7 @@ CalendarObjectValidResult CalendarEventObject::ValidObject(){
        if (ValidBegin == true && 
                ValidEnd == true && 
                ValidDateTimeStamp == true &&
+               ValidDateTimeStart == true &&
                ValidUniqueID == true){
                
                return CALENDAROBJECTVALID_OK;
@@ -129,12 +177,40 @@ void CalendarEventObject::ProcessData(){
        
        DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "DTSTAMP");
        
-       // Process the data.
+       // Process the data from DTSTAMP.
        
        if (DataReceived.begin() != DataReceived.end()){
        
+               try {
+                       DateTimeStampTokens = DataReceived.begin()->first.substr(8);
+               }
+               
+               catch(const out_of_range &oor){
+                       // Do nothing as there is no data.
+               }               
+               
                DateTimeStampData = DataReceived.begin()->second;
                
        }
+
+       // Get the Unique ID (UID).
+       
+       DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "UID");
+       
+       // Process the data from DTSTAMP.
+       
+       if (DataReceived.begin() != DataReceived.end()){
+       
+               try {
+                       UniqueIDTokens = DataReceived.begin()->first.substr(4);
+               }
+               
+               catch(const out_of_range &oor){
+                       // Do nothing as there is no data.
+               }               
+               
+               UniqueID = DataReceived.begin()->second;
+               
+       }
        
 }
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