From: Steve Brokenshire Date: Sun, 31 Jan 2016 17:23:12 +0000 (+0000) Subject: Added initial version of the CalendarFreeBusyObject. X-Git-Tag: release-0.02~434 X-Git-Url: http://Server1/repobrowser/?a=commitdiff_plain;h=4d93310894136ede7733c0b4ba22321d85452784;p=xestiacalendar%2F.git Added initial version of the CalendarFreeBusyObject. --- diff --git a/source/objects/calendarfreebusy/CalendarFreeBusy.cpp b/source/objects/calendarfreebusy/CalendarFreeBusy.cpp new file mode 100644 index 0000000..5e729bc --- /dev/null +++ b/source/objects/calendarfreebusy/CalendarFreeBusy.cpp @@ -0,0 +1,149 @@ +#include "CalendarFreeBusy.h" + +using namespace std; + +CalendarObjectValidResult CalendarFreeBusyObject::ValidObject(){ + + bool ValidBegin = false; + bool ValidEnd = false; + bool ValidDateTimeStamp = false; + bool ValidUniqueID = false; + bool ValidDateTimeStart = false; + int SeekCount = 0; + string PropertyName; + + // Look for BEGIN:VFREEBUSY. + + for (vector::iterator iter = ObjectName.begin(); + iter != ObjectName.end(); iter++){ + + if (ObjectName[SeekCount] == "BEGIN" && + ObjectData[SeekCount] == "VFREEBUSY"){ + + if (ValidBegin == false){ + ValidBegin = true; + } else { + return CALENDAROBJECTVALID_INVALIDFORMAT; + } + + } + + if (ObjectName[SeekCount] == "END" && + ObjectData[SeekCount] == "VFREEBUSY" && + 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 END:VFREEBUSY. + + for (vector::iterator iter = ObjectName.begin(); + iter != ObjectName.end(); iter++){ + + if (ObjectName[SeekCount] == "END" && + ObjectData[SeekCount] == "VFREEBUSY"){ + + 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 CalendarFreeBusyObject::ProcessData(){ + + // Process the data. + + multimap DataReceived; + map PropertyData; + string *PropertyNameData = nullptr; + int ObjectSeekCount = 0; + +} \ No newline at end of file diff --git a/source/objects/calendarfreebusy/CalendarFreeBusy.h b/source/objects/calendarfreebusy/CalendarFreeBusy.h new file mode 100644 index 0000000..3906e9c --- /dev/null +++ b/source/objects/calendarfreebusy/CalendarFreeBusy.h @@ -0,0 +1,16 @@ +#ifndef __OBJECTS_CALENDARFREEBUSY_CALENDARFREEBUSY_H__ +#define __OBJECTS_CALENDARFREEBUSY_CALENDARFREEBUSY_H__ + +#include "../calendarobject/CalendarObject.h" + +class CalendarFreeBusyObject: public CalendarObject{ + + CalendarObjectValidResult ValidObject(); + + private: + + void ProcessData(); + +}; + +#endif \ No newline at end of file