Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added code to process CLASS in CalendarEventObject.
[xestiacalendar/.git] / source / objects / calendarevent / CalendarEvent.cpp
index 3b063ab..7cc99a4 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,41 @@ CalendarObjectValidResult CalendarEventObject::ValidObject(){
        
        SeekCount = 0;
        
+       // Look for DTSTART if nothing is set for METHOD..
+       
+       if (MethodData.size() == 0){
+       
+               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++;
+                       
+               }
+       
+       } else {
+               ValidDateTimeStart = true;
+       }
+       
+       SeekCount = 0;
+       
        // Look for END:VEVENT.
        
        for (vector<string>::iterator iter = ObjectName.begin();
@@ -107,6 +160,7 @@ CalendarObjectValidResult CalendarEventObject::ValidObject(){
        if (ValidBegin == true && 
                ValidEnd == true && 
                ValidDateTimeStamp == true &&
+               ValidDateTimeStart == true &&
                ValidUniqueID == true){
                
                return CALENDAROBJECTVALID_OK;
@@ -117,4 +171,122 @@ CalendarObjectValidResult CalendarEventObject::ValidObject(){
                
        }
        
-} 
+}
+
+void CalendarEventObject::ProcessData(){
+       
+       // Process the data.
+       
+       multimap<string,string> DataReceived;
+       map<string,string> PropertyData;
+       string *PropertyNameData = nullptr;
+       
+       // Get the Date Time Stamp (DTSTAMP).
+       
+       DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "DTSTAMP");
+       
+       // 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 UID.
+       
+       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;
+               
+       }
+       
+       // Get the Date Time Start value.
+       
+       DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "DTSTART");
+       
+       // Process the data from DTSTART.
+       
+       if (DataReceived.begin() != DataReceived.end()){
+       
+               bool TokenData = false;
+               string PropertyTokens;
+               
+               PropertyNameData = (string*)&DataReceived.begin()->first;
+               
+               PropertyData = SplitValues(*PropertyNameData);
+               
+               for(map<string,string>::iterator iter = PropertyData.begin();
+                       iter != PropertyData.end(); iter++){
+                       
+                       if (iter->first == "VALUE"){
+                               
+                               DateTimeStartDataValue = iter->second;
+                               
+                       } else if (iter->first == "TZID"){
+                               
+                               DateTimeStartDataTimeZoneID = iter->second;
+                               
+                       } else {
+                               
+                               if (TokenData == false){
+                                       TokenData = true;
+                               } else {
+                                       PropertyTokens += ";";
+                               }
+                               
+                               PropertyTokens += iter->first;
+                               PropertyTokens += "=";
+                               PropertyTokens += iter->second;
+                               
+                       }
+                               
+               }
+               
+               if (PropertyTokens.size() > 0){
+                       DateTimeStartDataTokens = PropertyTokens;
+               }
+               
+               DateTimeStartData = DataReceived.begin()->second;
+               
+       }
+       
+       // Get the Class value.
+       
+       DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "CLASS");
+       
+       if (DataReceived.begin() != DataReceived.end()){
+       
+               try {
+                       ClassDataTokens = DataReceived.begin()->first.substr(6);
+               }
+               
+               catch(const out_of_range &oor){
+                       // Do nothing as there is no data.
+               }               
+               
+               ClassData = 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