X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fobjects%2Fcalendarevent%2FCalendarEvent.cpp;h=720c7bd3fa353cc8289a1fe0c8e56dbbf6dd410c;hb=23ed94d24ff92c7e8e1a253575c02935cb672d19;hp=6d105b81382cc12cbca9fd5753964c923399518b;hpb=1d1766f3741224c2f66b9363f81264f49a8a5da3;p=xestiacalendar%2F.git diff --git a/source/objects/calendarevent/CalendarEvent.cpp b/source/objects/calendarevent/CalendarEvent.cpp index 6d105b8..720c7bd 100644 --- a/source/objects/calendarevent/CalendarEvent.cpp +++ b/source/objects/calendarevent/CalendarEvent.cpp @@ -1,7 +1,216 @@ #include "CalendarEvent.h" +using namespace std; + CalendarObjectValidResult CalendarEventObject::ValidObject(){ - return CALENDAROBJECTVALID_UNITTESTFAIL; - -} + bool ValidBegin = false; + bool ValidEnd = false; + bool ValidDateTimeStamp = false; + bool ValidUniqueID = false; + bool ValidDateTimeStart = false; + int SeekCount = 0; + string PropertyName; + + // Look for BEGIN:VEVENT. + + for (vector::iterator iter = ObjectName.begin(); + iter != ObjectName.end(); iter++){ + + if (ObjectName[SeekCount] == "BEGIN" && + ObjectData[SeekCount] == "VEVENT"){ + + if (ValidBegin == false){ + ValidBegin = true; + } else { + return CALENDAROBJECTVALID_INVALIDFORMAT; + } + + } + + if (ObjectName[SeekCount] == "END" && + ObjectData[SeekCount] == "VEVENT" && + ValidBegin == false){ + + return CALENDAROBJECTVALID_INVALIDFORMAT; + + } + + SeekCount++; + + } + + SeekCount = 0; + + // Look for DTSTAMP. + + 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 == "DTSTAMP"){ + + if (ValidDateTimeStamp == false){ + ValidDateTimeStamp = true; + } else { + return CALENDAROBJECTVALID_INVALIDFORMAT; + } + + } + + SeekCount++; + + } + + SeekCount = 0; + + // Look for UID. + + for (vector::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 DTSTART. + + 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++; + + } + + SeekCount = 0; + + // Look for END:VEVENT. + + for (vector::iterator iter = ObjectName.begin(); + iter != ObjectName.end(); iter++){ + + if (ObjectName[SeekCount] == "END" && + ObjectData[SeekCount] == "VEVENT"){ + + if (ValidEnd == false){ + ValidEnd = true; + } else { + return CALENDAROBJECTVALID_INVALIDFORMAT; + } + + } + + SeekCount++; + + } + + // Check if the VEVENT is valid. + + if (ValidBegin == true && + ValidEnd == true && + ValidDateTimeStamp == true && + ValidDateTimeStart == true && + ValidUniqueID == true){ + + return CALENDAROBJECTVALID_OK; + + } else { + + return CALENDAROBJECTVALID_INVALIDFORMAT; + + } + +} + +void CalendarEventObject::ProcessData(){ + + // Process the data. + + multimap DataReceived; + + // 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 DTSTAMP. + + 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; + + } + +}