1 #include "CalendarEvent.h"
5 CalendarObjectValidResult CalendarEventObject::ValidObject(){
7 bool ValidBegin = false;
9 bool ValidDateTimeStamp = false;
10 bool ValidUniqueID = false;
11 bool ValidDateTimeStart = false;
15 // Look for BEGIN:VEVENT.
17 for (vector<string>::iterator iter = ObjectName.begin();
18 iter != ObjectName.end(); iter++){
20 if (ObjectName[SeekCount] == "BEGIN" &&
21 ObjectData[SeekCount] == "VEVENT"){
23 if (ValidBegin == false){
26 return CALENDAROBJECTVALID_INVALIDFORMAT;
31 if (ObjectName[SeekCount] == "END" &&
32 ObjectData[SeekCount] == "VEVENT" &&
35 return CALENDAROBJECTVALID_INVALIDFORMAT;
47 for (vector<string>::iterator iter = ObjectName.begin();
48 iter != ObjectName.end(); iter++){
51 PropertyName = ObjectName[SeekCount].substr(0,7);
54 catch(const out_of_range& oor){
58 if (PropertyName == "DTSTAMP"){
60 if (ValidDateTimeStamp == false){
61 ValidDateTimeStamp = true;
63 return CALENDAROBJECTVALID_INVALIDFORMAT;
76 for (vector<string>::iterator iter = ObjectName.begin();
77 iter != ObjectName.end(); iter++){
80 PropertyName = ObjectName[SeekCount].substr(0,3);
83 catch(const out_of_range& oor){
87 if (PropertyName == "UID"){
89 if (ValidUniqueID == false){
92 return CALENDAROBJECTVALID_INVALIDFORMAT;
103 // Look for DTSTART if nothing is set for METHOD..
105 if (MethodData.size() == 0){
107 for (vector<string>::iterator iter = ObjectName.begin();
108 iter != ObjectName.end(); iter++){
111 PropertyName = ObjectName[SeekCount].substr(0,7);
114 catch(const out_of_range& oor){
118 if (PropertyName == "DTSTART"){
120 if (ValidDateTimeStart == false){
121 ValidDateTimeStart = true;
123 return CALENDAROBJECTVALID_INVALIDFORMAT;
133 ValidDateTimeStart = true;
138 // Look for END:VEVENT.
140 for (vector<string>::iterator iter = ObjectName.begin();
141 iter != ObjectName.end(); iter++){
143 if (ObjectName[SeekCount] == "END" &&
144 ObjectData[SeekCount] == "VEVENT"){
146 if (ValidEnd == false){
149 return CALENDAROBJECTVALID_INVALIDFORMAT;
158 // Check if the VEVENT is valid.
160 if (ValidBegin == true &&
162 ValidDateTimeStamp == true &&
163 ValidDateTimeStart == true &&
164 ValidUniqueID == true){
166 return CALENDAROBJECTVALID_OK;
170 return CALENDAROBJECTVALID_INVALIDFORMAT;
176 void CalendarEventObject::ProcessData(){
180 multimap<string,string> DataReceived;
181 map<string,string> PropertyData;
182 string *PropertyNameData = nullptr;
183 int ObjectSeekCount = 0;
185 // Get the Date Time Stamp (DTSTAMP).
187 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "DTSTAMP");
189 // Process the data from DTSTAMP.
191 if (DataReceived.begin() != DataReceived.end()){
194 DateTimeStampTokens = DataReceived.begin()->first.substr(8);
197 catch(const out_of_range &oor){
198 // Do nothing as there is no data.
201 DateTimeStampData = DataReceived.begin()->second;
205 // Get the Unique ID (UID).
207 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "UID");
209 // Process the data from UID.
211 if (DataReceived.begin() != DataReceived.end()){
214 UniqueIDTokens = DataReceived.begin()->first.substr(4);
217 catch(const out_of_range &oor){
218 // Do nothing as there is no data.
221 UniqueID = DataReceived.begin()->second;
225 // Get the Date Time Start value.
227 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "DTSTART");
229 // Process the data from DTSTART.
231 if (DataReceived.begin() != DataReceived.end()){
233 bool TokenData = false;
234 string PropertyTokens;
236 PropertyNameData = (string*)&DataReceived.begin()->first;
238 PropertyData = SplitValues(*PropertyNameData);
240 for(map<string,string>::iterator iter = PropertyData.begin();
241 iter != PropertyData.end(); iter++){
243 if (iter->first == "VALUE"){
245 DateTimeStartDataValue = iter->second;
247 } else if (iter->first == "TZID"){
249 DateTimeStartDataTimeZoneID = iter->second;
253 if (TokenData == false){
256 PropertyTokens += ";";
259 PropertyTokens += iter->first;
260 PropertyTokens += "=";
261 PropertyTokens += iter->second;
267 if (PropertyTokens.size() > 0){
268 DateTimeStartDataTokens = PropertyTokens;
271 DateTimeStartData = DataReceived.begin()->second;
275 // Process the data from CLASS.
277 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "CLASS");
279 if (DataReceived.begin() != DataReceived.end()){
282 ClassDataTokens = DataReceived.begin()->first.substr(6);
285 catch(const out_of_range &oor){
286 // Do nothing as there is no data.
289 ClassData = DataReceived.begin()->second;
293 // Process the data from CREATED.
295 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "CREATED");
297 if (DataReceived.begin() != DataReceived.end()){
300 DateTimeCreatedTokens = DataReceived.begin()->first.substr(8);
303 catch(const out_of_range &oor){
304 // Do nothing as there is no data.
307 DateTimeCreatedData = DataReceived.begin()->second;
311 // Process the data from DESCRIPTION.
313 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "DESCRIPTION");
315 if (DataReceived.begin() != DataReceived.end()){
317 bool TokenData = false;
318 string PropertyTokens;
320 PropertyNameData = (string*)&DataReceived.begin()->first;
322 PropertyData = SplitValues(*PropertyNameData);
324 for(map<string,string>::iterator iter = PropertyData.begin();
325 iter != PropertyData.end(); iter++){
327 if (iter->first == "ALTREP"){
329 DescriptionListAltRep.clear();
330 DescriptionListAltRep.push_back(iter->second);
332 } else if (iter->first == "LANGUAGE"){
334 DescriptionListLanguage.clear();
335 DescriptionListLanguage.push_back(iter->second);
339 if (TokenData == false){
342 PropertyTokens += ";";
345 PropertyTokens += iter->first;
346 PropertyTokens += "=";
347 PropertyTokens += iter->second;
353 if (PropertyTokens.size() > 0){
354 DescriptionListTokens.clear();
355 DescriptionListTokens.push_back(PropertyTokens);
358 DescriptionList.clear();
359 DescriptionList.push_back(DataReceived.begin()->second);
363 // Process the data from GEO.
365 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "GEO");
367 if (DataReceived.begin() != DataReceived.end()){
370 GeographicTokens = DataReceived.begin()->first.substr(4);
373 catch(const out_of_range &oor){
374 // Do nothing as there is no data.
377 GeographicData = DataReceived.begin()->second;
381 // Process the data from LAST-MODIFIED.
383 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "LAST-MODIFIED");
385 if (DataReceived.begin() != DataReceived.end()){
388 LastModifiedTokens = DataReceived.begin()->first.substr(14);
391 catch(const out_of_range &oor){
392 // Do nothing as there is no data.
395 LastModifiedData = DataReceived.begin()->second;
399 // Process the data from LOCATION.
401 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "LOCATION");
403 if (DataReceived.begin() != DataReceived.end()){
405 bool TokenData = false;
406 string PropertyTokens;
408 PropertyNameData = (string*)&DataReceived.begin()->first;
410 PropertyData = SplitValues(*PropertyNameData);
412 for(map<string,string>::iterator iter = PropertyData.begin();
413 iter != PropertyData.end(); iter++){
415 if (iter->first == "ALTREP"){
417 LocationDataAltRep = iter->second;
419 } else if (iter->first == "LANGUAGE"){
421 LocationDataLanguage = iter->second;
425 if (TokenData == false){
428 PropertyTokens += ";";
431 PropertyTokens += iter->first;
432 PropertyTokens += "=";
433 PropertyTokens += iter->second;
439 if (PropertyTokens.size() > 0){
441 LocationDataTokens = PropertyTokens;
445 LocationData = DataReceived.begin()->second;
449 // Process the data from ORGANIZER.
451 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "ORGANIZER");
453 if (DataReceived.begin() != DataReceived.end()){
455 bool TokenData = false;
456 string PropertyTokens;
458 PropertyNameData = (string*)&DataReceived.begin()->first;
460 PropertyData = SplitValues(*PropertyNameData);
462 for(map<string,string>::iterator iter = PropertyData.begin();
463 iter != PropertyData.end(); iter++){
465 if (iter->first == "CN"){
467 OrganiserDataCommonName = iter->second;
469 } else if (iter->first == "DIR"){
471 OrganiserDataDirectoryEntry = iter->second;
473 } else if (iter->first == "SENT-BY"){
475 OrganiserDataSentByParam = iter->second;
477 } else if (iter->first == "LANGUAGE"){
479 OrganiserDataLanguage = iter->second;
483 if (TokenData == false){
486 PropertyTokens += ";";
489 PropertyTokens += iter->first;
490 PropertyTokens += "=";
491 PropertyTokens += iter->second;
497 if (PropertyTokens.size() > 0){
499 OrganiserDataTokens = PropertyTokens;
503 OrganiserData = DataReceived.begin()->second;
507 // Process the data from PRIORITY.
509 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "PRIORITY");
511 if (DataReceived.begin() != DataReceived.end()){
514 PriorityTokens = DataReceived.begin()->first.substr(9);
517 catch(const out_of_range &oor){
518 // Do nothing as there is no data.
522 PriorityData = stoi(DataReceived.begin()->second);
525 catch(const invalid_argument &oor){
526 PriorityTokens.clear();
531 // Process the data from SEQUENCE.
533 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "SEQUENCE");
535 if (DataReceived.begin() != DataReceived.end()){
538 SequenceTokens = DataReceived.begin()->first.substr(9);
541 catch(const out_of_range &oor){
542 // Do nothing as there is no data.
546 SequenceData = stoi(DataReceived.begin()->second);
549 catch(const invalid_argument &oor){
550 SequenceTokens.clear();
555 // Process the data from STATUS.
557 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "STATUS");
559 if (DataReceived.begin() != DataReceived.end()){
561 bool TokenData = false;
562 string PropertyTokens;
564 PropertyNameData = (string*)&DataReceived.begin()->first;
566 PropertyData = SplitValues(*PropertyNameData);
568 for(map<string,string>::iterator iter = PropertyData.begin();
569 iter != PropertyData.end(); iter++){
571 if (iter->first == "LANGUAGE"){
573 RequestStatusLanguage = iter->second;
577 if (TokenData == false){
580 PropertyTokens += ";";
583 PropertyTokens += iter->first;
584 PropertyTokens += "=";
585 PropertyTokens += iter->second;
591 if (PropertyTokens.size() > 0){
593 RequestStatusTokens = PropertyTokens;
597 RequestStatusData = DataReceived.begin()->second;
601 // Process the data from SUMMARY.
603 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "SUMMARY");
605 if (DataReceived.begin() != DataReceived.end()){
607 bool TokenData = false;
608 string PropertyTokens;
610 PropertyNameData = (string*)&DataReceived.begin()->first;
612 PropertyData = SplitValues(*PropertyNameData);
614 for(map<string,string>::iterator iter = PropertyData.begin();
615 iter != PropertyData.end(); iter++){
617 if (iter->first == "ALTREP"){
619 SummaryDataAltRep = iter->second;
621 } else if (iter->first == "LANGUAGE"){
623 SummaryDataLanguage = iter->second;
627 if (TokenData == false){
630 PropertyTokens += ";";
633 PropertyTokens += iter->first;
634 PropertyTokens += "=";
635 PropertyTokens += iter->second;
641 if (PropertyTokens.size() > 0){
643 SummaryDataTokens = PropertyTokens;
647 SummaryData = DataReceived.begin()->second;
651 // Process the data from TRANSP.
653 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "TRANSP");
655 if (DataReceived.begin() != DataReceived.end()){
658 TimeTransparencyDataTokens = DataReceived.begin()->first.substr(7);
661 catch(const out_of_range &oor){
662 // Do nothing as there is no data.
665 TimeTransparencyData = DataReceived.begin()->second;
669 // Process the data from URL.
671 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "URL");
673 if (DataReceived.begin() != DataReceived.end()){
676 URLDataTokens = DataReceived.begin()->first.substr(4);
679 catch(const out_of_range &oor){
680 // Do nothing as there is no data.
683 URLData = DataReceived.begin()->second;
687 // Process the data from RECURRENCE-ID.
689 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "RECURRENCE-ID");
691 if (DataReceived.begin() != DataReceived.end()){
693 bool TokenData = false;
694 string PropertyTokens;
696 PropertyNameData = (string*)&DataReceived.begin()->first;
698 PropertyData = SplitValues(*PropertyNameData);
700 for(map<string,string>::iterator iter = PropertyData.begin();
701 iter != PropertyData.end(); iter++){
703 if (iter->first == "TZID"){
705 RecurranceIDDataTimeZoneParam = iter->second;
707 } else if (iter->first == "VALUE"){
709 RecurranceIDDataValue = iter->second;
711 } else if (iter->first == "RANGE"){
713 RecurranceIDDataRangeParam = iter->second;
717 if (TokenData == false){
720 PropertyTokens += ";";
723 PropertyTokens += iter->first;
724 PropertyTokens += "=";
725 PropertyTokens += iter->second;
731 if (PropertyTokens.size() > 0){
733 RecurranceIDDataTokens = PropertyTokens;
737 RecurranceIDData = DataReceived.begin()->second;
741 // Process the data from RRULE.
743 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "RRULE");
745 if (DataReceived.begin() != DataReceived.end()){
748 RecurranceRuleDataTokens = DataReceived.begin()->first.substr(6);
751 catch(const out_of_range &oor){
752 // Do nothing as there is no data.
755 RecurranceRuleData = DataReceived.begin()->second;
759 // Process the data from DTEND.
761 bool DateTimeEndProcessed = false;
763 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "DTEND");
765 if (DataReceived.begin() != DataReceived.end()){
767 bool TokenData = false;
768 string PropertyTokens;
770 PropertyNameData = (string*)&DataReceived.begin()->first;
772 PropertyData = SplitValues(*PropertyNameData);
774 for(map<string,string>::iterator iter = PropertyData.begin();
775 iter != PropertyData.end(); iter++){
777 if (iter->first == "VALUE"){
779 DateTimeEndDataValue = iter->second;
781 } else if (iter->first == "TZID"){
783 DateTimeEndDataTimeZoneID = iter->second;
787 if (TokenData == false){
790 PropertyTokens += ";";
793 PropertyTokens += iter->first;
794 PropertyTokens += "=";
795 PropertyTokens += iter->second;
801 if (PropertyTokens.size() > 0){
802 DateTimeEndDataTokens = PropertyTokens;
805 DateTimeEndData = DataReceived.begin()->second;
807 DateTimeEndProcessed = true;
811 if (DateTimeEndProcessed == false){
813 // Process the data from DURATION if DTEND
814 // hasn't already been processed.
816 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "DURATION");
818 if (DataReceived.begin() != DataReceived.end()){
821 DurationDataTokens = DataReceived.begin()->first.substr(9);
824 catch(const out_of_range &oor){
825 // Do nothing as there is no data.
828 DurationData = DataReceived.begin()->second;
834 // Process the data from ATTACH.
836 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, true, "ATTACH");
838 for(multimap<string,string>::iterator iter = DataReceived.begin();
839 iter != DataReceived.end();
842 AttachListEncoding.push_back("");
843 AttachListValue.push_back("");
844 AttachListFormatType.push_back("");
845 AttachListTokens.push_back("");
846 AttachList.push_back("");
848 bool TokenData = false;
849 string PropertyTokens;
851 PropertyNameData = (string*)&iter->first;
853 PropertyData = SplitValues(*PropertyNameData);
855 for(map<string,string>::iterator dataiter = PropertyData.begin();
856 dataiter != PropertyData.end(); dataiter++){
858 if (dataiter->first == "ENCODING"){
860 AttachListEncoding[ObjectSeekCount] = dataiter->second;
862 } else if (dataiter->first == "VALUE"){
864 AttachListValue[ObjectSeekCount] = dataiter->second;
866 } else if (dataiter->first == "FMTTYPE"){
868 AttachListFormatType[ObjectSeekCount] = dataiter->second;
872 if (TokenData == false){
875 PropertyTokens += ";";
878 PropertyTokens += dataiter->first;
879 PropertyTokens += "=";
880 PropertyTokens += dataiter->second;
886 if (PropertyTokens.size() > 0){
887 AttachListTokens[ObjectSeekCount] = PropertyTokens;
890 AttachList[ObjectSeekCount] = iter->second;
896 // Process the data from ATTENDEE.
898 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, true, "ATTENDEE");
902 for(multimap<string,string>::iterator iter = DataReceived.begin();
903 iter != DataReceived.end();
906 AttendeeListMember.push_back("");
907 AttendeeListDelegatedFrom.push_back("");
908 AttendeeListDelegatedTo.push_back("");
909 AttendeeListRole.push_back("");
910 AttendeeListRSVP.push_back("");
911 AttendeeListDirectoryEntry.push_back("");
912 AttendeeListSentBy.push_back("");
913 AttendeeListCommonName.push_back("");
914 AttendeeListCalendarUserType.push_back("");
915 AttendeeListParticipationStatus.push_back("");
916 AttendeeListLanguage.push_back("");
917 AttendeeListTokens.push_back("");
918 AttendeeList.push_back("");
920 bool TokenData = false;
921 string PropertyTokens;
923 PropertyNameData = (string*)&iter->first;
925 PropertyData = SplitValues(*PropertyNameData);
927 for(map<string,string>::iterator dataiter = PropertyData.begin();
928 dataiter != PropertyData.end(); dataiter++){
930 if (dataiter->first == "CUTYPE"){
932 AttendeeListCalendarUserType[ObjectSeekCount] = dataiter->second;
934 } else if (dataiter->first == "MEMBER"){
936 AttendeeListMember[ObjectSeekCount] = dataiter->second;
938 } else if (dataiter->first == "ROLE"){
940 AttendeeListRole[ObjectSeekCount] = dataiter->second;
942 } else if (dataiter->first == "PARTSTAT"){
944 AttendeeListParticipationStatus[ObjectSeekCount] = dataiter->second;
946 } else if (dataiter->first == "RSVP"){
948 AttendeeListRSVP[ObjectSeekCount] = dataiter->second;
950 } else if (dataiter->first == "DELEGATED-TO"){
952 AttendeeListDelegatedTo[ObjectSeekCount] = dataiter->second;
954 } else if (dataiter->first == "DELEGATED-FROM"){
956 AttendeeListDelegatedFrom[ObjectSeekCount] = dataiter->second;
958 } else if (dataiter->first == "SENT-BY"){
960 AttendeeListSentBy[ObjectSeekCount] = dataiter->second;
962 } else if (dataiter->first == "CN"){
964 AttendeeListCommonName[ObjectSeekCount] = dataiter->second;
966 } else if (dataiter->first == "DIR"){
968 AttendeeListDirectoryEntry[ObjectSeekCount] = dataiter->second;
970 } else if (dataiter->first == "LANGUAGE"){
972 AttendeeListLanguage[ObjectSeekCount] = dataiter->second;
976 if (TokenData == false){
979 PropertyTokens += ";";
982 PropertyTokens += dataiter->first;
983 PropertyTokens += "=";
984 PropertyTokens += dataiter->second;
990 if (PropertyTokens.size() > 0){
991 AttendeeListTokens[ObjectSeekCount] = PropertyTokens;
994 AttendeeList[ObjectSeekCount] = iter->second;