From: Steve Brokenshire Date: Tue, 7 Jun 2016 20:15:42 +0000 (+0100) Subject: Added VALARM properties for saving data from a CalendarTaskObject. X-Git-Tag: release-0.02~144 X-Git-Url: http://Server1/repobrowser/?a=commitdiff_plain;h=f474eabb6d4363823d87ddbd169f529dbf919221;p=xestiacalendar%2F.git Added VALARM properties for saving data from a CalendarTaskObject. Added the code and unit tests for the VALARM properties. --- diff --git a/source/objects/calendartask/CalendarTask-Save.cpp b/source/objects/calendartask/CalendarTask-Save.cpp index 3eac545..63b57fc 100644 --- a/source/objects/calendartask/CalendarTask-Save.cpp +++ b/source/objects/calendartask/CalendarTask-Save.cpp @@ -1185,6 +1185,406 @@ void CalendarTaskObject::SaveObjectData(string *SaveData){ } + // Process the VALARMS. + + if (CalendarAlarmData.size() > 0){ + + for (int CalendarAlarmDataSeek = 0; CalendarAlarmDataSeek < CalendarAlarmData.size(); + CalendarAlarmDataSeek++){ + + *SaveData += "BEGIN:VALARM\n"; + + // Process the ACTION VALARM value. + + DataLine += "ACTION"; + + if (CalendarAlarmData[CalendarAlarmDataSeek].AlarmActionTokens.size() > 0){ + + DataLine += ";"; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].AlarmActionTokens; + + } + + DataLine += ":"; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].AlarmAction; + DataLine += "\n"; + + DataLineProcessed = OutputText(&DataLine); + + *SaveData += DataLineProcessed; + + DataLine.clear(); + DataLineProcessed.clear(); + + // Process the TRIGGER VALARM value. + + if (CalendarAlarmData[CalendarAlarmDataSeek].TriggerData.size() > 0){ + + DataLine += "TRIGGER"; + + if (CalendarAlarmData[CalendarAlarmDataSeek].TriggerRelated.size() > 0){ + + DataLine += ";RELATED="; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].TriggerRelated; + + } + + if (CalendarAlarmData[CalendarAlarmDataSeek].TriggerValue.size() > 0){ + + DataLine += ";VALUE="; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].TriggerValue; + + } + + if (CalendarAlarmData[CalendarAlarmDataSeek].TriggerTokens.size() > 0){ + + DataLine += ";"; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].TriggerTokens; + + } + + DataLine += ":"; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].TriggerData; + DataLine += "\n"; + + DataLineProcessed = OutputText(&DataLine); + + *SaveData += DataLineProcessed; + + DataLine.clear(); + DataLineProcessed.clear(); + + } + + // Process the DURATION VALARM value. + + if (CalendarAlarmData[CalendarAlarmDataSeek].DurationData.size() > 0){ + + DataLine += "DURATION"; + + if (CalendarAlarmData[CalendarAlarmDataSeek].DurationTokens.size() > 0){ + + DataLine += ";"; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].DurationTokens; + + } + + DataLine += ":"; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].DurationData; + DataLine += "\n"; + + DataLineProcessed = OutputText(&DataLine); + + *SaveData += DataLineProcessed; + + DataLine.clear(); + DataLineProcessed.clear(); + + } + + // Process the DESCRIPTION VALARM value. + + if (CalendarAlarmData[CalendarAlarmDataSeek].DescriptionData.size() > 0){ + + DataLine += "DESCRIPTION"; + + if (CalendarAlarmData[CalendarAlarmDataSeek].DescriptionAltRep.size() > 0){ + + DataLine += ";ALTREP=\""; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].DescriptionAltRep; + DataLine += "\""; + + } + + if (CalendarAlarmData[CalendarAlarmDataSeek].DescriptionLanguage.size() > 0){ + + DataLine += ";LANGUAGE="; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].DescriptionLanguage; + + } + + if (CalendarAlarmData[CalendarAlarmDataSeek].DescriptionTokens.size() > 0){ + + DataLine += ";"; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].DescriptionTokens; + + } + + DataLine += ":"; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].DescriptionData; + DataLine += "\n"; + + DataLineProcessed = OutputText(&DataLine); + + *SaveData += DataLineProcessed; + + DataLine.clear(); + DataLineProcessed.clear(); + + } + + // Process the SUMMARY VALARM value. + + if (CalendarAlarmData[CalendarAlarmDataSeek].SummaryData.size() > 0){ + + DataLine += "SUMMARY"; + + if (CalendarAlarmData[CalendarAlarmDataSeek].SummaryAltRep.size() > 0){ + + DataLine += ";ALTREP=\""; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].SummaryAltRep; + DataLine += "\""; + + } + + if (CalendarAlarmData[CalendarAlarmDataSeek].SummaryLanguage.size() > 0){ + + DataLine += ";LANGUAGE="; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].SummaryLanguage; + + } + + if (CalendarAlarmData[CalendarAlarmDataSeek].SummaryTokens.size() > 0){ + + DataLine += ";"; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].SummaryTokens; + + } + + DataLine += ":"; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].SummaryData; + DataLine += "\n"; + + DataLineProcessed = OutputText(&DataLine); + + *SaveData += DataLineProcessed; + + DataLine.clear(); + DataLineProcessed.clear(); + + } + + // Process the REPEAT VALARM value. + + if (CalendarAlarmData[CalendarAlarmDataSeek].RepeatData.size() > 0){ + + DataLine += "REPEAT"; + + if (CalendarAlarmData[CalendarAlarmDataSeek].RepeatTokens.size() > 0){ + + DataLine += ";"; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].RepeatTokens; + + } + + DataLine += ":"; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].RepeatData; + DataLine += "\n"; + + DataLineProcessed = OutputText(&DataLine); + + *SaveData += DataLineProcessed; + + DataLine.clear(); + DataLineProcessed.clear(); + + } + + // Process the ATTENDEE VALARM values. + + if (CalendarAlarmData[CalendarAlarmDataSeek].AttendeeList.size() > 0){ + + for (int AttendeeListSeek = 0; AttendeeListSeek < CalendarAlarmData[CalendarAlarmDataSeek].AttendeeList.size(); + AttendeeListSeek++){ + + DataLine += "ATTENDEE"; + + if (CalendarAlarmData[CalendarAlarmDataSeek].AttendeeListMember[AttendeeListSeek].size() > 0){ + + DataLine += ";MEMBER=\""; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].AttendeeListMember[AttendeeListSeek]; + DataLine += "\""; + + } + + if (CalendarAlarmData[CalendarAlarmDataSeek].AttendeeListDelegatedFrom[AttendeeListSeek].size() > 0){ + + DataLine += ";DELEGATED-FROM=\""; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].AttendeeListDelegatedFrom[AttendeeListSeek]; + DataLine += "\""; + + } + + if (CalendarAlarmData[CalendarAlarmDataSeek].AttendeeListDelegatedTo[AttendeeListSeek].size() > 0){ + + DataLine += ";DELEGATED-TO=\""; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].AttendeeListDelegatedTo[AttendeeListSeek]; + DataLine += "\""; + + } + + if (CalendarAlarmData[CalendarAlarmDataSeek].AttendeeListRole[AttendeeListSeek].size() > 0){ + + DataLine += ";ROLE="; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].AttendeeListRole[AttendeeListSeek]; + + } + + if (CalendarAlarmData[CalendarAlarmDataSeek].AttendeeListRSVP[AttendeeListSeek].size() > 0){ + + DataLine += ";RSVP="; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].AttendeeListRSVP[AttendeeListSeek]; + + } + + if (CalendarAlarmData[CalendarAlarmDataSeek].AttendeeListDirectoryEntry[AttendeeListSeek].size() > 0){ + + DataLine += ";DIR=\""; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].AttendeeListDirectoryEntry[AttendeeListSeek]; + DataLine += "\""; + + } + + if (CalendarAlarmData[CalendarAlarmDataSeek].AttendeeListSentBy[AttendeeListSeek].size() > 0){ + + DataLine += ";SENT-BY=\""; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].AttendeeListSentBy[AttendeeListSeek]; + DataLine += "\""; + + } + + if (CalendarAlarmData[CalendarAlarmDataSeek].AttendeeListCommonName[AttendeeListSeek].size() > 0){ + + DataLine += ";CN=\""; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].AttendeeListCommonName[AttendeeListSeek]; + DataLine += "\""; + + } + + if (CalendarAlarmData[CalendarAlarmDataSeek].AttendeeListCalendarUserType[AttendeeListSeek].size() > 0){ + + DataLine += ";CUTYPE="; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].AttendeeListCalendarUserType[AttendeeListSeek]; + + } + + if (CalendarAlarmData[CalendarAlarmDataSeek].AttendeeListParticipationStatus[AttendeeListSeek].size() > 0){ + + DataLine += ";PARTSTAT="; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].AttendeeListParticipationStatus[AttendeeListSeek]; + + } + + if (CalendarAlarmData[CalendarAlarmDataSeek].AttendeeListLanguage[AttendeeListSeek].size() > 0){ + + DataLine += ";LANGUAGE="; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].AttendeeListLanguage[AttendeeListSeek]; + + } + + if (CalendarAlarmData[CalendarAlarmDataSeek].AttendeeListTokens[AttendeeListSeek].size() > 0){ + + DataLine += ";"; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].AttendeeListTokens[AttendeeListSeek]; + + } + + DataLine += ":"; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].AttendeeList[AttendeeListSeek]; + DataLine += "\n"; + + DataLineProcessed = OutputText(&DataLine); + + *SaveData += DataLineProcessed; + + DataLine.clear(); + DataLineProcessed.clear(); + + } + + } + + // Process the ATTACH VALARM values. + + if (CalendarAlarmData[CalendarAlarmDataSeek].AttachList.size() > 0){ + + for (int AttachListSeek = 0; AttachListSeek < CalendarAlarmData[CalendarAlarmDataSeek].AttachList.size(); + AttachListSeek++){ + + DataLine += "ATTACH"; + + if (CalendarAlarmData[CalendarAlarmDataSeek].AttachListFormatType[AttachListSeek].size() > 0){ + + DataLine += ";FMTTYPE="; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].AttachListFormatType[AttachListSeek]; + + } + + if (CalendarAlarmData[CalendarAlarmDataSeek].AttachListValue[AttachListSeek].size() > 0){ + + DataLine += ";VALUE="; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].AttachListValue[AttachListSeek]; + + } + + if (CalendarAlarmData[CalendarAlarmDataSeek].AttachListEncoding[AttachListSeek].size() > 0){ + + DataLine += ";ENCODING="; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].AttachListEncoding[AttachListSeek]; + + } + + if (CalendarAlarmData[CalendarAlarmDataSeek].AttachListTokens[AttachListSeek].size() > 0){ + + DataLine += ";"; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].AttachListTokens[AttachListSeek]; + + } + + DataLine += ":"; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].AttachList[AttachListSeek]; + DataLine += "\n"; + + DataLineProcessed = OutputText(&DataLine); + + *SaveData += DataLineProcessed; + + DataLine.clear(); + DataLineProcessed.clear(); + + } + + } + + // Process the X-Token VALARM values. + + if (CalendarAlarmData[CalendarAlarmDataSeek].XTokensData.size() > 0){ + + for (int XTokenSeek = 0; XTokenSeek < CalendarAlarmData[CalendarAlarmDataSeek].XTokensData.size(); + XTokenSeek++){ + + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].XTokensDataTokens[XTokenSeek]; + DataLine += ":"; + DataLine += CalendarAlarmData[CalendarAlarmDataSeek].XTokensData[XTokenSeek]; + DataLine += "\n"; + + DataLineProcessed = OutputText(&DataLine); + + *SaveData += DataLineProcessed; + + DataLine.clear(); + DataLineProcessed.clear(); + + } + + } + + *SaveData += "END:VALARM\n"; + + } + + } + *SaveData += "END:VTODO\n"; } \ No newline at end of file diff --git a/source/tests/xestiacalendar_icaltasksave.h b/source/tests/xestiacalendar_icaltasksave.h index 54c5ea9..64176e4 100644 --- a/source/tests/xestiacalendar_icaltasksave.h +++ b/source/tests/xestiacalendar_icaltasksave.h @@ -119,6 +119,55 @@ TEST(iCalendarSaveTask, SaveTaskTests){ "RDATE:20160120\n" "RDATE;VALUE=DATE;TZID=Europe/Truro:20160121\n" "RDATE;ZILCH=DATA:20160520\n" + "BEGIN:VALARM\n" + "ACTION;FUNKY=SOUNDS:AUDIO\n" + "TRIGGER;RELATED=END;VALUE=DATE-TIME;PUSH=BUTTON:20160220T160000Z\n" + "DURATION;FLYING=NO:PT5H\n" + "REPEAT;NEVER=SLEEP:PT5M\n" + "ATTACH;FMTTYPE=application/internet-shortcut:http://www.example.com/\n" + "ATTACH;FMTTYPE=application/internet-shortcut:http://www.example.com/page2.htm\n" + " l\n" + "ATTACH;FMTTYPE=text/plain;VALUE=BINARY;ENCODING=BASE64;STUPID=EXAMPLE:VGhpcyB\n" + " pcyBhbiBleGFtcGxlIGZpbGU=\n" + "X-EXAMPLE1;YAY=YES:Example Data 1\n" + "X-EXAMPLE2;NOPE=YEP:Example Data 2\n" + "X-EXAMPLE3;WORLD=NO:Example Data 3\n" + "END:VALARM\n" + "BEGIN:VALARM\n" + "ACTION;FLASHING=LIGHTS:DISPLAY\n" + "TRIGGER;RELATED=END;VALUE=DATE-TIME;PUSH=BUTTON:20160230T110000Z\n" + "DURATION;FLYING=YES:PT7H\n" + "DESCRIPTION;ALTREP=\"null:nodata\";LANGUAGE=kw;TERRIBLE=TOKEN:This is the secon\n" + " d alarm.\n" + "REPEAT;SLEEP=ALWAYS:PT3M\n" + "X-EXAMPLE1;YAY=YES:Example Data 1\n" + "X-EXAMPLE2;NOPE=YEP:Example Data 2\n" + "X-EXAMPLE3;WORLD=NO:Example Data 3\n" + "END:VALARM\n" + "BEGIN:VALARM\n" + "ACTION;FLASHING=LIGHTS:EMAIL\n" + "TRIGGER;RELATED=END;VALUE=DATE-TIME;PUSH=BUTTON:20160230T120000Z\n" + "DURATION;FLYING=YES:PT7H\n" + "DESCRIPTION;ALTREP=\"null:nodata\";LANGUAGE=kw;TERRIBLE=TOKEN:This is the third\n" + " alarm.\n" + "SUMMARY;ALTREP=\"null:nodata\";LANGUAGE=en;MEEP=MOOP:This is the summary of the\n" + " third alarm.\n" + "REPEAT;SLEEP=ALWAYS:PT3M\n" + "ATTENDEE:Attendee One\n" + "ATTENDEE;DELEGATED-FROM=\"mailto:delegated.from@example.com\";DELEGATED-TO=\"mai\n" + " lto:delegated.to@example.com\";ROLE=CHAIR;RSVP=TRUE:Attendee Two\n" + "ATTENDEE;DIR=\"null:nodata\";SENT-BY=\"mailto:sent.by@example.com\";CN=\"Attendee \n" + " The Third\";CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED;LANGUAGE=kw;EXAMPLE=DATA:Atte\n" + " ndee Three\n" + "ATTACH;FMTTYPE=application/internet-shortcut:http://www.example.com/\n" + "ATTACH;FMTTYPE=application/internet-shortcut:http://www.example.com/page2.htm\n" + " l\n" + "ATTACH;FMTTYPE=text/plain;VALUE=BINARY;ENCODING=BASE64;STUPID=EXAMPLE:VGhpcyB\n" + " pcyBhbiBleGFtcGxlIGZpbGU=\n" + "X-EXAMPLE1;YAY=YES:Example Data 1\n" + "X-EXAMPLE2;NOPE=YEP:Example Data 2\n" + "X-EXAMPLE3;WORLD=NO:Example Data 3\n" + "END:VALARM\n" "END:VTODO\n" "END:VCALENDAR";