Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Processing of VALARMs now take place in CalendarObject itself.
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 14 Feb 2016 14:18:40 +0000 (14:18 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 14 Feb 2016 14:18:40 +0000 (14:18 +0000)
source/objects/calendarobject/CalendarObject.cpp

index f5fc97e..4ea4984 100644 (file)
@@ -189,9 +189,13 @@ CalendarObjectLoadResult CalendarObject::LoadString(std::string *LoadStringData)
 CalendarObjectValidResult CalendarObject::ValidBaseObject(){
        
        bool ValidBegin = false;
+       bool ValidAlarmBegin = false;
        bool ValidVersion = false;
        bool ValidEnd = false;
        int SeekCount = 0;
+       vector<int> DeleteLines;
+       vector<string> AlarmObjectName;
+       vector<string> AlarmObjectData;
        
        // Check that the first line contains BEGIN:VCALENDAR
        // and it only appears once.
@@ -216,6 +220,58 @@ CalendarObjectValidResult CalendarObject::ValidBaseObject(){
                
                        return CALENDAROBJECTVALID_INVALIDFORMAT;
                                
+               } else if (ObjectName[SeekCount] == "END" &&
+                       ObjectData[SeekCount] == "VALARM" &&
+                       ValidAlarmBegin == false){
+
+                       return CALENDAROBJECTVALID_INVALIDFORMAT;
+                               
+               } else if (ObjectName[SeekCount] == "END" &&
+                       ObjectData[SeekCount] == "VCALENDAR" &&
+                       ValidAlarmBegin == true){
+
+                       return CALENDAROBJECTVALID_INVALIDFORMAT;
+                               
+               }
+               
+               // Look for any VALARM sections.
+               
+               if (ValidAlarmBegin == true){
+                       
+                       AlarmObjectName.push_back(ObjectName[SeekCount]);
+                       AlarmObjectData.push_back(ObjectData[SeekCount]);
+                       DeleteLines.push_back(SeekCount);
+                       
+               }
+               
+               if (ObjectName[SeekCount] == "END" &&
+                       ObjectData[SeekCount] == "VALARM" && 
+                       ValidAlarmBegin == true){
+                               
+                       EventAlarmName.push_back(AlarmObjectName);
+                       EventAlarmData.push_back(AlarmObjectData);
+                       
+                       AlarmObjectName.clear();
+                       AlarmObjectData.clear();
+
+                       ValidAlarmBegin = false;
+                               
+               }
+               
+               if (ObjectName[SeekCount] == "BEGIN" &&
+                       ObjectData[SeekCount] == "VALARM" && 
+                       ValidBegin == true){
+                               
+                       if (ValidAlarmBegin == false){
+                               ValidAlarmBegin = true;
+                       } else {
+                               return CALENDAROBJECTVALID_INVALIDFORMAT;
+                       }
+                       
+                       AlarmObjectName.push_back(ObjectName[SeekCount]);
+                       AlarmObjectData.push_back(ObjectData[SeekCount]);
+                       DeleteLines.push_back(SeekCount);
+                       
                }
                
                SeekCount++;
@@ -268,10 +324,22 @@ CalendarObjectValidResult CalendarObject::ValidBaseObject(){
                        
        }
 
+       // Remove lines that aren't needed as they have
+       // been moved to the EventAlarm section.
+       
+       for (vector<int>::reverse_iterator deliter = DeleteLines.rbegin();
+               deliter != DeleteLines.rend(); deliter++){
+
+               ObjectName.erase(ObjectName.begin()+(*deliter));
+               ObjectData.erase(ObjectData.begin()+(*deliter));
+                       
+       }
+
        if (ValidBegin == true && 
                ValidEnd == true && 
-               ValidVersion == true){
-               
+               ValidVersion == true &&
+               ValidAlarmBegin == false){
+       
                return CALENDAROBJECTVALID_OK;
                        
        } else {
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