X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fobjects%2Fcalendarevent%2FCalendarEvent.cpp;h=6c1887d592a598fd2bcf8ccff2aaa5823d12d3bb;hb=998a20ed92cae6cb809722792fa384e00b5f7828;hp=6d105b81382cc12cbca9fd5753964c923399518b;hpb=1d1766f3741224c2f66b9363f81264f49a8a5da3;p=xestiacalendar%2F.git diff --git a/source/objects/calendarevent/CalendarEvent.cpp b/source/objects/calendarevent/CalendarEvent.cpp index 6d105b8..6c1887d 100644 --- a/source/objects/calendarevent/CalendarEvent.cpp +++ b/source/objects/calendarevent/CalendarEvent.cpp @@ -1,7 +1,140 @@ #include "CalendarEvent.h" +using namespace std; + CalendarObjectValidResult CalendarEventObject::ValidObject(){ - return CALENDAROBJECTVALID_UNITTESTFAIL; - -} + bool ValidBegin = false; + bool ValidEnd = false; + bool ValidDateTimeStamp = false; + bool ValidUniqueID = false; + int SeekCount = 0; + + // 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++){ + + if (ObjectName[SeekCount] == "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++){ + + if (ObjectName[SeekCount] == "UID"){ + + if (ValidUniqueID == false){ + ValidUniqueID = 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 && + 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. + + if (DataReceived.begin() != DataReceived.end()){ + + DateTimeStampData = DataReceived.begin()->second; + + } + +}