Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added unit tests for DESCRIPTION in iCalendarTask/ObjectDataTests.
[xestiacalendar/.git] / source / objects / calendartask / CalendarTask.cpp
index eb99179..5d4a59b 100644 (file)
@@ -11,7 +11,7 @@ CalendarObjectValidResult CalendarTaskObject::ValidObject(){
        int SeekCount = 0;
        string PropertyName;
        
-       // Look for BEGIN:VEVENT.
+       // Look for BEGIN:VTODO.
        
        for (vector<string>::iterator iter = ObjectName.begin();
                iter != ObjectName.end(); iter++){
@@ -65,7 +65,7 @@ CalendarObjectValidResult CalendarTaskObject::ValidObject(){
                }
                        
                SeekCount++;
-                       
+
        }
        
        SeekCount = 0;
@@ -99,7 +99,7 @@ CalendarObjectValidResult CalendarTaskObject::ValidObject(){
        
        SeekCount = 0;
                
-       // Look for END:VEVENT.
+       // Look for END:VTODO.
        
        for (vector<string>::iterator iter = ObjectName.begin();
                iter != ObjectName.end(); iter++){
@@ -119,13 +119,13 @@ CalendarObjectValidResult CalendarTaskObject::ValidObject(){
                        
        }
        
-       // Check if the VEVENT is valid.
-
+       // Check if the VTODO is valid.
+       
        if (ValidBegin == true && 
                ValidEnd == true && 
                ValidDateTimeStamp == true &&
                ValidUniqueID == true){
-               
+                       
                return CALENDAROBJECTVALID_OK;
                        
        } else {
@@ -138,4 +138,157 @@ CalendarObjectValidResult CalendarTaskObject::ValidObject(){
 
 void CalendarTaskObject::ProcessData(){
 
+       // Process the data.
+       
+       multimap<string,string> DataReceived;
+       map<string,string> PropertyData;
+       string *PropertyNameData = nullptr;
+       int ObjectSeekCount = 0;
+       
+       // 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;
+               
+       }
+       
+       // Process the data from CLASS.
+       
+       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;
+               
+       }
+       
+       // Process the data from COMPLETED.
+       
+       DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "COMPLETED");
+       
+       if (DataReceived.begin() != DataReceived.end()){
+       
+               try {
+                       CompletedDataTokens = DataReceived.begin()->first.substr(10);
+               }
+               
+               catch(const out_of_range &oor){
+                       // Do nothing as there is no data.
+               }               
+               
+               CompletedData = DataReceived.begin()->second;
+               
+       }
+       
+       // Process the data from CREATED.
+       
+       DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "CREATED");
+       
+       if (DataReceived.begin() != DataReceived.end()){
+       
+               try {
+                       DateTimeCreatedTokens = DataReceived.begin()->first.substr(8);
+               }
+               
+               catch(const out_of_range &oor){
+                       // Do nothing as there is no data.
+               }               
+               
+               DateTimeCreatedData = DataReceived.begin()->second;
+               
+       }
+       
+       // Process the data from DESCRIPTION.
+       
+       DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "DESCRIPTION");
+       
+       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 == "ALTREP"){
+                               
+                               DescriptionListAltRep.clear();
+                               DescriptionListAltRep.push_back(iter->second);
+                               
+                       } else if (iter->first == "LANGUAGE"){
+                               
+                               DescriptionListLanguage.clear();
+                               DescriptionListLanguage.push_back(iter->second);
+                               
+                       } else {
+                               
+                               if (TokenData == false){
+                                       TokenData = true;
+                               } else {
+                                       PropertyTokens += ";";
+                               }
+                               
+                               PropertyTokens += iter->first;
+                               PropertyTokens += "=";
+                               PropertyTokens += iter->second;
+                               
+                       }
+                               
+               }
+               
+               if (PropertyTokens.size() > 0){
+                       DescriptionListTokens.clear();
+                       DescriptionListTokens.push_back(PropertyTokens);
+               }
+               
+               DescriptionList.clear();
+               DescriptionList.push_back(DataReceived.begin()->second);
+               
+       }
+       
 }
\ No newline at end of file
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