Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added code to process ATTACH in CalendarTaskObject.
[xestiacalendar/.git] / source / objects / calendartask / CalendarTask.cpp
index 48af315..7d118a8 100644 (file)
@@ -4,8 +4,874 @@ using namespace std;
 
 CalendarObjectValidResult CalendarTaskObject::ValidObject(){
 
+       bool ValidBegin = false;
+       bool ValidEnd = false;
+       bool ValidDateTimeStamp = false;
+       bool ValidUniqueID = false;
+       int SeekCount = 0;
+       string PropertyName;
+       
+       // Look for BEGIN:VTODO.
+       
+       for (vector<string>::iterator iter = ObjectName.begin();
+               iter != ObjectName.end(); iter++){
+       
+               if (ObjectName[SeekCount] == "BEGIN" &&
+                       ObjectData[SeekCount] == "VTODO"){
+                       
+                       if (ValidBegin == false){
+                               ValidBegin = true;
+                       } else {
+                               return CALENDAROBJECTVALID_INVALIDFORMAT;
+                       }
+                               
+               }
+               
+               if (ObjectName[SeekCount] == "END" &&
+                       ObjectData[SeekCount] == "VTODO" &&
+                       ValidBegin == false){
+               
+                       return CALENDAROBJECTVALID_INVALIDFORMAT;
+                               
+               }
+               
+               SeekCount++;
+                       
+       }
+       
+       SeekCount = 0;
+       
+       // Look for DTSTAMP.
+       
+       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 == "DTSTAMP"){
+                       
+                       if (ValidDateTimeStamp == false){
+                               ValidDateTimeStamp = true;
+                       } else {
+                               return CALENDAROBJECTVALID_INVALIDFORMAT;
+                       }
+                               
+               }
+                       
+               SeekCount++;
+
+       }
+       
+       SeekCount = 0;
+       
+       // Look for UID.
+       
+       for (vector<string>::iterator iter = ObjectName.begin();
+               iter != ObjectName.end(); iter++){
+       
+               try{
+                       PropertyName = ObjectName[SeekCount].substr(0,3);
+               }
+               
+               catch(const out_of_range& oor){
+                       continue;
+               }
+                       
+               if (PropertyName == "UID"){
+                       
+                       if (ValidUniqueID == false){
+                               ValidUniqueID = true;
+                       } else {
+                               return CALENDAROBJECTVALID_INVALIDFORMAT;
+                       }
+                               
+               }
+                       
+               SeekCount++;
+                       
+       }
+       
+       SeekCount = 0;
+               
+       // Look for END:VTODO.
+       
+       for (vector<string>::iterator iter = ObjectName.begin();
+               iter != ObjectName.end(); iter++){
+       
+               if (ObjectName[SeekCount] == "END" &&
+                       ObjectData[SeekCount] == "VTODO"){
+                       
+                       if (ValidEnd == false){
+                               ValidEnd = true;
+                       } else {
+                               return CALENDAROBJECTVALID_INVALIDFORMAT;
+                       }
+                               
+               }
+                       
+               SeekCount++;
+                       
+       }
+       
+       // Check if the VTODO is valid.
+       
+       if (ValidBegin == true && 
+               ValidEnd == true && 
+               ValidDateTimeStamp == true &&
+               ValidUniqueID == true){
+                       
+               return CALENDAROBJECTVALID_OK;
+                       
+       } else {
+               
+               return CALENDAROBJECTVALID_INVALIDFORMAT;
+               
+       }
+       
 }
 
 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);
+               
+       }
+       
+       // 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;
+               
+       }
+       
+       // Process the data from GEO.
+       
+       DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "GEO");
+       
+       if (DataReceived.begin() != DataReceived.end()){
+       
+               try {
+                       GeographicTokens = DataReceived.begin()->first.substr(4);
+               }
+               
+               catch(const out_of_range &oor){
+                       // Do nothing as there is no data.
+               }               
+               
+               GeographicData = DataReceived.begin()->second;
+               
+       }
+       
+       // Process the data from LAST-MODIFIED.
+       
+       DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "LAST-MODIFIED");
+       
+       if (DataReceived.begin() != DataReceived.end()){
+       
+               try {
+                       LastModifiedTokens = DataReceived.begin()->first.substr(14);
+               }
+               
+               catch(const out_of_range &oor){
+                       // Do nothing as there is no data.
+               }               
+               
+               LastModifiedData = DataReceived.begin()->second;
+               
+       }
+       
+       // Process the data from LOCATION.
+       
+       DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "LOCATION");
+       
+       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"){
+                               
+                               LocationDataAltRep = iter->second;
+                               
+                       } else if (iter->first == "LANGUAGE"){
+                               
+                               LocationDataLanguage = iter->second;
+                               
+                       } else {
+                               
+                               if (TokenData == false){
+                                       TokenData = true;
+                               } else {
+                                       PropertyTokens += ";";
+                               }
+                               
+                               PropertyTokens += iter->first;
+                               PropertyTokens += "=";
+                               PropertyTokens += iter->second;
+                               
+                       }
+                               
+               }
+               
+               if (PropertyTokens.size() > 0){
+                       
+                       LocationDataTokens = PropertyTokens;
+                       
+               }
+               
+               LocationData = DataReceived.begin()->second;
+               
+       }
+       
+       // Process the data from ORGANIZER.
+       
+       DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "ORGANIZER");
+       
+       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 == "CN"){
+                               
+                               OrganiserDataCommonName = iter->second;
+                               
+                       } else if (iter->first == "DIR"){
+                               
+                               OrganiserDataDirectoryEntry = iter->second;
+                               
+                       } else if (iter->first == "SENT-BY"){
+                               
+                               OrganiserDataSentByParam = iter->second;
+                               
+                       } else if (iter->first == "LANGUAGE"){
+                               
+                               OrganiserDataLanguage = iter->second;
+                               
+                       } else {
+                               
+                               if (TokenData == false){
+                                       TokenData = true;
+                               } else {
+                                       PropertyTokens += ";";
+                               }
+                               
+                               PropertyTokens += iter->first;
+                               PropertyTokens += "=";
+                               PropertyTokens += iter->second;
+                               
+                       }
+                               
+               }
+               
+               if (PropertyTokens.size() > 0){
+                       
+                       OrganiserDataTokens = PropertyTokens;
+                       
+               }
+               
+               OrganiserData = DataReceived.begin()->second;
+               
+       }
+       
+       // Process the data from PERCENT-COMPLETE.
+       
+       DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "PERCENT-COMPLETE");
+       
+       if (DataReceived.begin() != DataReceived.end()){
+       
+               try {
+                       PercentCompleteTokens = DataReceived.begin()->first.substr(17);
+               }
+               
+               catch(const out_of_range &oor){
+                       // Do nothing as there is no data.
+               }
+               
+               PercentCompleteData = DataReceived.begin()->second;
+               
+       }
+       
+       // Process the data from PRIORITY.
+       
+       DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "PRIORITY");
+       
+       if (DataReceived.begin() != DataReceived.end()){
+       
+               try {
+                       PriorityTokens = DataReceived.begin()->first.substr(9);
+               }
+               
+               catch(const out_of_range &oor){
+                       // Do nothing as there is no data.
+               }               
+               
+               try {
+                       PriorityData = stoi(DataReceived.begin()->second);
+               }
+               
+               catch(const invalid_argument &oor){
+                       PriorityTokens.clear();
+               }
+               
+       }
+       
+       // Process the data from RECURRENCE-ID.
+       
+       DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "RECURRENCE-ID");
+       
+       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 == "TZID"){
+                               
+                               RecurranceIDDataTimeZoneParam = iter->second;
+                               
+                       } else if (iter->first == "VALUE"){
+                               
+                               RecurranceIDDataValue = iter->second;
+                               
+                       } else if (iter->first == "RANGE"){
+                               
+                               RecurranceIDDataRangeParam = iter->second;
+                               
+                       } else {
+                               
+                               if (TokenData == false){
+                                       TokenData = true;
+                               } else {
+                                       PropertyTokens += ";";
+                               }
+                               
+                               PropertyTokens += iter->first;
+                               PropertyTokens += "=";
+                               PropertyTokens += iter->second;
+                               
+                       }
+                               
+               }
+               
+               if (PropertyTokens.size() > 0){
+                       
+                       RecurranceIDDataTokens = PropertyTokens;
+                       
+               }
+               
+               RecurranceIDData = DataReceived.begin()->second;
+               
+       }
+       
+       // Process the data from SEQUENCE.
+       
+       DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "SEQUENCE");
+       
+       if (DataReceived.begin() != DataReceived.end()){
+       
+               try {
+                       SequenceTokens = DataReceived.begin()->first.substr(9);
+               }
+               
+               catch(const out_of_range &oor){
+                       // Do nothing as there is no data.
+               }               
+               
+               try {
+                       SequenceData = stoi(DataReceived.begin()->second);
+               }
+               
+               catch(const invalid_argument &oor){
+                       SequenceTokens.clear();
+               }
+               
+       }
+       
+       // Process the data from STATUS.
+       
+       DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "STATUS");
+       
+       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 == "LANGUAGE"){
+                               
+                               StatusLanguage = iter->second;
+                               
+                       } else {
+                               
+                               if (TokenData == false){
+                                       TokenData = true;
+                               } else {
+                                       PropertyTokens += ";";
+                               }
+                               
+                               PropertyTokens += iter->first;
+                               PropertyTokens += "=";
+                               PropertyTokens += iter->second;
+                               
+                       }
+                               
+               }
+               
+               if (PropertyTokens.size() > 0){
+                       
+                       StatusTokens = PropertyTokens;
+                       
+               }
+               
+               StatusData = DataReceived.begin()->second;
+               
+       }
+       
+       // Process the data from SUMMARY.
+       
+       DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "SUMMARY");
+       
+       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"){
+                               
+                               SummaryDataAltRep = iter->second;
+                               
+                       } else if (iter->first == "LANGUAGE"){
+                               
+                               SummaryDataLanguage = iter->second;
+                               
+                       } else {
+                               
+                               if (TokenData == false){
+                                       TokenData = true;
+                               } else {
+                                       PropertyTokens += ";";
+                               }
+                               
+                               PropertyTokens += iter->first;
+                               PropertyTokens += "=";
+                               PropertyTokens += iter->second;
+                               
+                       }
+                               
+               }
+               
+               if (PropertyTokens.size() > 0){
+                       
+                       SummaryDataTokens = PropertyTokens;
+                       
+               }
+               
+               SummaryData = DataReceived.begin()->second;
+               
+       }
+       
+       // Process the data from URL.
+       
+       DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "URL");
+       
+       if (DataReceived.begin() != DataReceived.end()){
+       
+               try {
+                       URLDataTokens = DataReceived.begin()->first.substr(4);
+               }
+               
+               catch(const out_of_range &oor){
+                       // Do nothing as there is no data.
+               }               
+               
+               URLData = DataReceived.begin()->second;
+               
+       }
+       
+       // Process the data from RRULE.
+       
+       DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "RRULE");
+       
+       if (DataReceived.begin() != DataReceived.end()){
+       
+               try {
+                       RecurranceRuleDataTokens = DataReceived.begin()->first.substr(6);
+               }
+               
+               catch(const out_of_range &oor){
+                       // Do nothing as there is no data.
+               }               
+               
+               RecurranceRuleData = DataReceived.begin()->second;
+               
+       }
+       
+       bool DueProcessed = false;
+       
+       // Process the data from DUE.
+       
+       DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "DUE");
+       
+       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 == "TZID"){
+                               
+                               DueDataTimeZoneID = iter->second;
+                               
+                       } else if (iter->first == "VALUE"){
+                               
+                               DueDataValue = iter->second;
+                               
+                       } else {
+                               
+                               if (TokenData == false){
+                                       TokenData = true;
+                               } else {
+                                       PropertyTokens += ";";
+                               }
+                               
+                               PropertyTokens += iter->first;
+                               PropertyTokens += "=";
+                               PropertyTokens += iter->second;
+                               
+                       }
+                               
+               }
+               
+               if (PropertyTokens.size() > 0){
+                       
+                       DueDataTokens = PropertyTokens;
+                       
+               }
+               
+               DueData = DataReceived.begin()->second;
+               DueProcessed = true;
+               
+       }
+       
+       // If there is no DUE, then check for DURATION.
+       
+       if (DueProcessed == false){
+
+               DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "DURATION");
+       
+               if (DataReceived.begin() != DataReceived.end()){
+       
+                       try {
+                               DurationDataTokens = DataReceived.begin()->first.substr(9);
+                       }
+               
+                       catch(const out_of_range &oor){
+                               // Do nothing as there is no data.
+                       }               
+               
+                       DurationData = DataReceived.begin()->second;
+               
+               }
+               
+       }
+
+       // Process the data from ATTACH.
+       
+       DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, true, "ATTACH");
+       
+       for(multimap<string,string>::iterator iter = DataReceived.begin(); 
+               iter != DataReceived.end(); 
+               ++iter){
+               
+               AttachListEncoding.push_back("");
+               AttachListValue.push_back("");
+               AttachListFormatType.push_back("");
+               AttachListTokens.push_back("");
+               AttachList.push_back("");
+                       
+               bool TokenData = false;
+               string PropertyTokens;
+               
+               PropertyNameData = (string*)&iter->first;
+               
+               PropertyData = SplitValues(*PropertyNameData);
+                       
+               for(map<string,string>::iterator dataiter = PropertyData.begin();
+                       dataiter != PropertyData.end(); dataiter++){
+                       
+                       if (dataiter->first == "ENCODING"){
+                               
+                               AttachListEncoding[ObjectSeekCount] = dataiter->second;
+                               
+                       } else if (dataiter->first == "VALUE"){
+                               
+                               AttachListValue[ObjectSeekCount] = dataiter->second;
+                               
+                       } else if (dataiter->first == "FMTTYPE"){
+                               
+                               AttachListFormatType[ObjectSeekCount] = dataiter->second;
+                               
+                       } else {
+                               
+                               if (TokenData == false){
+                                       TokenData = true;
+                               } else {
+                                       PropertyTokens += ";";
+                               }
+                               
+                               PropertyTokens += dataiter->first;
+                               PropertyTokens += "=";
+                               PropertyTokens += dataiter->second;
+                               
+                       }
+                               
+               }
+               
+               if (PropertyTokens.size() > 0){
+                       AttachListTokens[ObjectSeekCount] = PropertyTokens;
+               }
+                       
+               AttachList[ObjectSeekCount] = iter->second;
+               
+               ObjectSeekCount++;
+               
+       }
+       
 }
\ 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