Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added initial VALARM processing in CalendarEventObject.
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sat, 13 Feb 2016 16:14:01 +0000 (16:14 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sat, 13 Feb 2016 16:14:01 +0000 (16:14 +0000)
source/objects/calendarevent/CalendarEvent.cpp
source/objects/calendarevent/CalendarEvent.h
source/objects/calendarobject/CalendarObject.h
source/tests/xestiacalendar_icaleventload.h

index 62a347b..ab88fe4 100644 (file)
@@ -1454,6 +1454,85 @@ void CalendarEventObject::ProcessData(){
                
        }
        
+       // Process Alarm section.
+       
+       ProcessAlarms();
+       
+       int SeekCount = 0;
+       
+       bool AlarmActionFound = false;
+       
+       for (vector<vector<string>>::iterator iter = EventAlarmName.begin();
+               iter != EventAlarmName.end(); iter++){
+                       
+               CalendarAlarmDataStruct NewAlarmData;
+                       
+               // Process the data from ACTION.
+       
+               bool AlarmActionFound = false;
+               bool AlarmTriggerFound = false;
+                       
+               DataReceived = ProcessTextVectors(&EventAlarmName[SeekCount], 
+                               &EventAlarmData[SeekCount], false, "ACTION");
+       
+               if (DataReceived.begin() != DataReceived.end()){
+       
+                       try {
+                               NewAlarmData.AlarmActionTokens = DataReceived.begin()->first.substr(7);
+                       }
+               
+                       catch(const out_of_range &oor){
+                               // Do nothing as there is no data.
+                       }
+               
+                       NewAlarmData.AlarmAction = DataReceived.begin()->second;
+                       AlarmActionFound = true;
+               
+               }
+               
+               // Check if a value was set for AlarmAction, otherwise
+               // process the next VALARM section.
+               
+               if (NewAlarmData.AlarmAction.size() < 1){
+                       
+                       SeekCount++;
+                       continue;
+                       
+               }
+               
+               // Check if AlarmAction is DISPLAY, AUDIO or EMAIL.
+               // Process the next VALARM section if not.
+               
+               if (NewAlarmData.AlarmAction == "AUDIO"){
+                       
+                       NewAlarmData.AlarmType = CALENDARALARM_AUDIO;
+                       
+               } else if (NewAlarmData.AlarmAction == "DISPLAY"){
+                       
+                       NewAlarmData.AlarmType = CALENDARALARM_DISPLAY;
+                       
+               } else if (NewAlarmData.AlarmAction == "EMAIL"){
+                       
+                       NewAlarmData.AlarmType = CALENDARALARM_EMAIL;
+                       
+               } else {
+               
+                       SeekCount++;
+                       continue;
+                       
+               }
+               
+               if (NewAlarmData.AlarmType == CALENDARALARM_AUDIO &&
+                       AlarmActionFound == true){
+               
+                       CalendarAlarmData.push_back(NewAlarmData);
+                       
+               }
+                       
+               SeekCount++;
+                       
+       }
+       
        ObjectSeekCount = 0;
        
        // Process data from X-*
@@ -1477,3 +1556,64 @@ void CalendarEventObject::ProcessData(){
        }
        
 }
+
+void CalendarEventObject::ProcessAlarms(){
+
+       int SeekCount = 0;
+       
+       bool TZMode = false; // False = STANDARD, True = DAYLIGHT.
+       bool ValidBegin = false;
+       vector<string> EventObjectName;
+       vector<string> EventObjectData;
+       
+       for (vector<string>::iterator iter = ObjectName.begin();
+               iter != ObjectName.end(); iter++){      
+       
+               // Check if the current name is BEGIN and
+               // data is either STANDARD or DAYLIGHT.
+                       
+               if (ObjectName[SeekCount] == "BEGIN" &&
+                       ObjectData[SeekCount] == "VALARM"){
+                       
+                       if (ValidBegin == false){
+                               ValidBegin = true;
+                               EventObjectName.clear();
+                               EventObjectData.clear();
+                       } else {
+                               
+                       }
+                       
+                       SeekCount++;
+                       continue;
+                       
+               }
+               
+               // Check if current name is END and
+               // data is either STANDARD or DAYLIGHT.
+               
+               if (ObjectName[SeekCount] == "END" &&
+                       ObjectData[SeekCount] == "VALARM" && 
+                       ValidBegin == true){
+                               
+                       EventAlarmName.push_back(EventObjectName);
+                       EventAlarmData.push_back(EventObjectData);
+                       
+                       EventObjectName.clear();
+                       EventObjectData.clear();
+                       
+                       ValidBegin = false;
+                               
+               }
+               
+               if (ValidBegin == true){
+                       
+                       EventObjectName.push_back(ObjectName[SeekCount]);
+                       EventObjectData.push_back(ObjectData[SeekCount]);
+                       
+               }
+               
+               SeekCount++;
+                       
+       }
+                       
+}
\ No newline at end of file
index e2bdf0d..99c708d 100644 (file)
@@ -10,6 +10,7 @@ class CalendarEventObject: public CalendarObject{
        private:
        
        void ProcessData();
+       void ProcessAlarms();
        
 };
 
index 1c700c4..2b450fc 100644 (file)
 using namespace std;
 
 enum CalendarObjectLoadResult {
-    CALENDAROBJECTLOAD_UNITTESTFAIL = -1,
-    CALENDAROBJECTLOAD_OK,
-    CALENDAROBJECTLOAD_MISSING,
-    CALENDAROBJECTLOAD_INVALIDFORMAT,
-    CALENDAROBJECTLOAD_CANNOTOPEN
+       CALENDAROBJECTLOAD_UNITTESTFAIL = -1,
+       CALENDAROBJECTLOAD_OK,
+       CALENDAROBJECTLOAD_MISSING,
+       CALENDAROBJECTLOAD_INVALIDFORMAT,
+       CALENDAROBJECTLOAD_CANNOTOPEN
 };
 
 enum CalendarObjectValidResult{
-    CALENDAROBJECTVALID_UNITTESTFAIL = -1,
-    CALENDAROBJECTVALID_OK,
-    CALENDAROBJECTVALID_INVALIDFORMAT
+       CALENDAROBJECTVALID_UNITTESTFAIL = -1,
+       CALENDAROBJECTVALID_OK,
+       CALENDAROBJECTVALID_INVALIDFORMAT
+};
+
+enum CalendarAlarmAction{
+       CALENDARALARM_UNSPECIFIED = -1,
+       CALENDARALARM_AUDIO,
+       CALENDARALARM_DISPLAY,
+       CALENDARALARM_EMAIL
+};
+
+struct CalendarAlarmDataStruct{
+       
+       CalendarAlarmAction AlarmType = CALENDARALARM_UNSPECIFIED;
+       
+       string AlarmAction;
+       string AlarmActionTokens;
+       
+       string TriggerData;
+       string TriggerValue;
+       string TriggerTokens;
+       
+       string DescriptionData;
+       string DescriptionAltRep;
+       string DescriptionLanguage;
+       string DescriptionTokens;
+       
+       string RepeatData;
+       string RepeatTokens;
+       
+       string SummaryData;
+       string SummaryAltRep;
+       string SummaryLanguage;
+       string SummaryTokens;
+       
+       vector<string> AttendeeList;
+       vector<string> AttendeeListMember;
+       vector<string> AttendeeListDelegatedFrom;
+       vector<string> AttendeeListDelegatedTo;
+       vector<string> AttendeeListRole;
+       vector<string> AttendeeListRSVP;
+       vector<string> AttendeeListDirectoryEntry;
+       vector<string> AttendeeListSentBy;
+       vector<string> AttendeeListCommonName;
+       vector<string> AttendeeListCalendarUserType;
+       vector<string> AttendeeListParticipationStatus;
+       vector<string> AttendeeListLanguage;
+       vector<string> AttendeeListTokens;
+       
+       string DurationData;
+       string DurationTokens;
+       
+       vector<string> AttachList;
+       vector<string> AttachListTokens;
+       vector<string> AttachListEncoding;
+       vector<string> AttachListFormatType;
+       vector<string> AttachListValue;
+       
+       vector<string> XTokensData;
+       vector<string> XTokensDataTokens;
+       
 };
 
 class CalendarObject{
@@ -223,11 +282,16 @@ class CalendarObject{
        vector<string> RequestStatusLanguage;
        vector<string> RequestStatusTokens;
        
+       vector<CalendarAlarmDataStruct> CalendarAlarmData;
+       
        protected:
        // Initial Loading Data.
        vector<string> ObjectName;
        vector<string> ObjectData;
-
+       
+       vector<vector<string>> EventAlarmName;
+       vector<vector<string>> EventAlarmData;
+       
        private:
        virtual void ProcessData() {};
   
index d82f687..3085676 100644 (file)
@@ -1069,5 +1069,27 @@ TEST(iCalendarEvent, ObjectDataTests){
        
        ASSERT_EQ("None", XTokenData);
        ASSERT_EQ("X-PHANTOM-STATUS;HELP=NONE", XTokenName);
+
+       // Tests for the first VALARM property.
+       
+       std::string ActionData;
+       std::string ActionDataTokens;
+       
+       if (TestEvent.CalendarAlarmData.size() > 0){
+       
+               ActionData = TestEvent.CalendarAlarmData[0].AlarmAction;
+               
+       }
+
+       if (TestEvent.CalendarAlarmData.size() > 0){
+       
+               ActionDataTokens = TestEvent.CalendarAlarmData[0].AlarmActionTokens;
+               
+       }
+       
+       ASSERT_EQ("AUDIO", ActionData);
+       ASSERT_EQ("FUNKY=SOUNDS", ActionDataTokens);
+       
+       
        
 }
\ 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