From 63dac73eaf34576dd6bfb5251307ae61ed1d94f3 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 5 Jun 2016 14:57:36 +0100 Subject: [PATCH] Added CONTACT property for saving data from a CalendarFreeBusyObject. Added the code and unit tests for the CONTACT property. --- .../CalendarFreeBusy-Save.cpp | 45 +++++++++++++++++++ .../tests/xestiacalendar_icalfreebusysave.h | 20 +++++++++ 2 files changed, 65 insertions(+) diff --git a/source/objects/calendarfreebusy/CalendarFreeBusy-Save.cpp b/source/objects/calendarfreebusy/CalendarFreeBusy-Save.cpp index aed39d8..f59de19 100644 --- a/source/objects/calendarfreebusy/CalendarFreeBusy-Save.cpp +++ b/source/objects/calendarfreebusy/CalendarFreeBusy-Save.cpp @@ -65,6 +65,51 @@ void CalendarFreeBusyObject::SaveObjectData(string *SaveData){ } + // Process the CONTACT value. + + if (ContactList.size() > 0){ + + if (ContactList[0].size() > 0){ + + DataLine += "CONTACT"; + + if (ContactListAltRep[0].size() > 0){ + + DataLine += ";ALTREP=\""; + DataLine += ContactListAltRep[0]; + DataLine += "\""; + + } + + if (ContactListLanguage[0].size() > 0){ + + DataLine += ";LANGUAGE="; + DataLine += ContactListLanguage[0]; + + } + + if (ContactListTokens[0].size() > 0){ + + DataLine += ";"; + DataLine += ContactListTokens[0]; + + } + + DataLine += ":"; + DataLine += ContactList[0]; + DataLine += "\n"; + + DataLineProcessed = OutputText(&DataLine); + + *SaveData += DataLineProcessed; + + DataLine.clear(); + DataLineProcessed.clear(); + + } + + } + *SaveData += "END:VFREEBUSY\n"; } \ No newline at end of file diff --git a/source/tests/xestiacalendar_icalfreebusysave.h b/source/tests/xestiacalendar_icalfreebusysave.h index 6b30f1a..849b8d0 100644 --- a/source/tests/xestiacalendar_icalfreebusysave.h +++ b/source/tests/xestiacalendar_icalfreebusysave.h @@ -21,6 +21,7 @@ TEST(iCalendarSaveFreeBusy, SaveFreeBusyTests){ CalendarFreeBusyObject TestFreeBusy; + CalendarFreeBusyObject TestFreeBusy2; // Load the test free/busy information. @@ -46,4 +47,23 @@ TEST(iCalendarSaveFreeBusy, SaveFreeBusyTests){ ASSERT_EQ(SaveDataComparison, SaveData); + SaveData.clear(); + + ASSERT_EQ(CALENDAROBJECTLOAD_OK, TestFreeBusy2.LoadFile("iCalendarFreeBusy-Load2.vcf")); + ASSERT_EQ(CALENDAROBJECTVALID_OK, TestFreeBusy2.ValidBaseObject()); + + SaveDataComparison = "BEGIN:VCALENDAR\n" + "VERSION:2.0\n" + "PRODID:-//Xestia//Calendar Unit Testing//KW\n" + "BEGIN:VFREEBUSY\n" + "UID;UNIQUEPARAM=CERTAINLY;OKAY=MAYBENOT:b3a16392-ad86-4061-be53-c215af2306ff\n" + "DTSTAMP;OTHER=PARAM:20160131T173000Z\n" + "CONTACT;ALTREP=\"null:nodata\";LANGUAGE=en-GB;EXAMPLE=TOKEN:Contact Person\n" + "END:VFREEBUSY\n" + "END:VCALENDAR"; + + TestFreeBusy2.SaveString(&SaveData); + + ASSERT_EQ(SaveDataComparison, SaveData); + } \ No newline at end of file -- 2.39.5