X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fobjects%2Fcalendarevent%2FCalendarEvent.cpp;h=5331fb34f07f9aa1a87dadf9e9db7b1458f4d6a9;hb=0b0f3e646240d19797c0d480d2419a058b1c8574;hp=ee003f93f1e72e7558b05449bb88505452f7429c;hpb=ad94c9c170df05dbdb00af6773052227327dd3c1;p=xestiacalendar%2F.git diff --git a/source/objects/calendarevent/CalendarEvent.cpp b/source/objects/calendarevent/CalendarEvent.cpp index ee003f9..5331fb3 100644 --- a/source/objects/calendarevent/CalendarEvent.cpp +++ b/source/objects/calendarevent/CalendarEvent.cpp @@ -8,6 +8,7 @@ CalendarObjectValidResult CalendarEventObject::ValidObject(){ bool ValidEnd = false; bool ValidDateTimeStamp = false; bool ValidUniqueID = false; + bool ValidDateTimeStart = false; int SeekCount = 0; string PropertyName; @@ -99,6 +100,41 @@ CalendarObjectValidResult CalendarEventObject::ValidObject(){ SeekCount = 0; + // Look for DTSTART if nothing is set for METHOD.. + + if (MethodData.size() == 0){ + + for (vector::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::iterator iter = ObjectName.begin(); @@ -124,6 +160,7 @@ CalendarObjectValidResult CalendarEventObject::ValidObject(){ if (ValidBegin == true && ValidEnd == true && ValidDateTimeStamp == true && + ValidDateTimeStart == true && ValidUniqueID == true){ return CALENDAROBJECTVALID_OK; @@ -141,6 +178,8 @@ void CalendarEventObject::ProcessData(){ // Process the data. multimap DataReceived; + map PropertyData; + string *PropertyNameData = nullptr; // Get the Date Time Stamp (DTSTAMP). @@ -166,7 +205,7 @@ void CalendarEventObject::ProcessData(){ DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "UID"); - // Process the data from DTSTAMP. + // Process the data from UID. if (DataReceived.begin() != DataReceived.end()){ @@ -182,4 +221,228 @@ void CalendarEventObject::ProcessData(){ } + // 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::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 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 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::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); + + } + + // 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::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; + + } + }