From bf5c917b72bf832a7d7858cdf81f88ad8c1c0146 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 24 Jan 2016 09:12:59 +0000 Subject: [PATCH 01/16] Check for quotes in SplitNameValue and remove them if needed. --- source/common/text.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/common/text.cpp b/source/common/text.cpp index 8237440..df64411 100644 --- a/source/common/text.cpp +++ b/source/common/text.cpp @@ -172,6 +172,17 @@ PropertyNameValue SplitNameValue(string InputData){ } + // Check if the value has quotes at the start and end. + // Remove them if this is the case. + + if (FinalNameValue.Value.front() == '\"' && + FinalNameValue.Value.back() == '\"'){ + + FinalNameValue.Value.erase(0, 1); + FinalNameValue.Value.erase((FinalNameValue.Value.size() - 1), 1); + + } + return FinalNameValue; } \ No newline at end of file -- 2.39.5 From 2fa80b58ada02ff544438efa8385affcaf675007 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 24 Jan 2016 09:22:12 +0000 Subject: [PATCH 02/16] Added code to process DESCRIPTION and GEO in CalendarEventObject. --- .../objects/calendarevent/CalendarEvent.cpp | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/source/objects/calendarevent/CalendarEvent.cpp b/source/objects/calendarevent/CalendarEvent.cpp index b35f7c1..823edce 100644 --- a/source/objects/calendarevent/CalendarEvent.cpp +++ b/source/objects/calendarevent/CalendarEvent.cpp @@ -307,4 +307,74 @@ void CalendarEventObject::ProcessData(){ } + // Process the data from DESCRIPTION. + + DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "DESCRIPTION"); + + if (DataReceived.begin() != DataReceived.end()){ + + bool TokenData = false; + string PropertyTokens; + + PropertyNameData = (string*)&DataReceived.begin()->first; + + PropertyData = SplitValues(*PropertyNameData); + + for(map::iterator iter = PropertyData.begin(); + iter != PropertyData.end(); iter++){ + + if (iter->first == "ALTREP"){ + + DescriptionListAltRep.clear(); + DescriptionListAltRep.push_back(iter->second); + + } else if (iter->first == "LANGUAGE"){ + + DescriptionListLanguage.clear(); + DescriptionListLanguage.push_back(iter->second); + + } else { + + if (TokenData == false){ + TokenData = true; + } else { + PropertyTokens += ";"; + } + + PropertyTokens += iter->first; + PropertyTokens += "="; + PropertyTokens += iter->second; + + } + + } + + if (PropertyTokens.size() > 0){ + DescriptionListTokens.clear(); + DescriptionListTokens.push_back(PropertyTokens); + } + + DescriptionList.clear(); + DescriptionList.push_back(DataReceived.begin()->second); + + } + + // Process the data from GEO. + + DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "GEO"); + + if (DataReceived.begin() != DataReceived.end()){ + + try { + GeographicTokens = DataReceived.begin()->first.substr(4); + } + + catch(const out_of_range &oor){ + // Do nothing as there is no data. + } + + GeographicData = DataReceived.begin()->second; + + } + } -- 2.39.5 From 88a5b0d1ed4ffe6e7bfb2e7c41d651eb8745bcc6 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 24 Jan 2016 09:23:34 +0000 Subject: [PATCH 03/16] Check for quote and go in and out of Quote mode as needed. --- .../objects/calendarobject/CalendarObject.cpp | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/source/objects/calendarobject/CalendarObject.cpp b/source/objects/calendarobject/CalendarObject.cpp index aecb136..ab21f14 100644 --- a/source/objects/calendarobject/CalendarObject.cpp +++ b/source/objects/calendarobject/CalendarObject.cpp @@ -52,6 +52,7 @@ CalendarObjectLoadResult CalendarObject::LoadString(std::string *LoadStringData) bool NewLine = false; bool SkipMode = false; bool ColonFound = false; + bool QuoteMode = false; char BufferChar = 0; int StringDataSize = LoadStringData->size(); int SeekCount = 0; @@ -73,6 +74,22 @@ CalendarObjectLoadResult CalendarObject::LoadString(std::string *LoadStringData) NewLine = false; + } else if ((*LoadStringData)[SeekCount] == '\"'){ + + if (QuoteMode == false){ + QuoteMode = true; + } else { + QuoteMode = false; + } + + BufferChar = (*LoadStringData)[SeekCount]; + + if (ColonFound == false){ + PropertyName += BufferChar; + } else { + PropertyValue += BufferChar; + } + } else if (NewLine == true){ // Character is on a new line but not a space or @@ -100,7 +117,8 @@ CalendarObjectLoadResult CalendarObject::LoadString(std::string *LoadStringData) NewLine = true; - } else if ((*LoadStringData)[SeekCount] == ':'){ + } else if ((*LoadStringData)[SeekCount] == ':' && + QuoteMode == false){ // Character is the colon. Set the colon // found boolen to true. -- 2.39.5 From ec8bfe7e1e3536f2fadbbb2d305122120e2c3471 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 24 Jan 2016 09:23:47 +0000 Subject: [PATCH 04/16] Renamed DescriptionListAltID to DescriptionListAltRep. --- source/objects/calendarobject/CalendarObject.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/objects/calendarobject/CalendarObject.h b/source/objects/calendarobject/CalendarObject.h index 005bb56..c85a3a7 100644 --- a/source/objects/calendarobject/CalendarObject.h +++ b/source/objects/calendarobject/CalendarObject.h @@ -67,7 +67,7 @@ class CalendarObject{ vector CommentListTokens; vector DescriptionList; - vector DescriptionListAltID; + vector DescriptionListAltRep; vector DescriptionListLanguage; vector DescriptionListTokens; -- 2.39.5 From 892653e5e2c5eeee9fb2eeb172c17cd11567a640 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 24 Jan 2016 09:29:25 +0000 Subject: [PATCH 05/16] Added code to process LAST-MODIFIED in CalendarEventObject. --- source/objects/calendarevent/CalendarEvent.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/source/objects/calendarevent/CalendarEvent.cpp b/source/objects/calendarevent/CalendarEvent.cpp index 823edce..655d7de 100644 --- a/source/objects/calendarevent/CalendarEvent.cpp +++ b/source/objects/calendarevent/CalendarEvent.cpp @@ -377,4 +377,22 @@ void CalendarEventObject::ProcessData(){ } + // Process the data from LAST-MODIFIED. + + DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "LAST-MODIFIED"); + + if (DataReceived.begin() != DataReceived.end()){ + + try { + LastModifiedTokens = DataReceived.begin()->first.substr(14); + } + + catch(const out_of_range &oor){ + // Do nothing as there is no data. + } + + LastModifiedData = DataReceived.begin()->second; + + } + } -- 2.39.5 From 4029e945ac7f6d6a8ce565fdfb2bb0da5f530b0d Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 24 Jan 2016 09:29:56 +0000 Subject: [PATCH 06/16] Added the LAST-MODIFIED property to iCalendarEvent-Load2.vcf --- source/tests/iCalendarEvent-Load2.vcf | 1 + 1 file changed, 1 insertion(+) diff --git a/source/tests/iCalendarEvent-Load2.vcf b/source/tests/iCalendarEvent-Load2.vcf index 5b9c5a8..ede7c9b 100644 --- a/source/tests/iCalendarEvent-Load2.vcf +++ b/source/tests/iCalendarEvent-Load2.vcf @@ -10,5 +10,6 @@ CREATED;CARAMEL=PLEASE:20160123T081100Z DESCRIPTION;ALTREP="null:nodata";EXAMPLE=TOKEN;MOREDATA=YES;LANGUAGE=kw:This is a description of the event. GEO;EXAMPLE=MEEP:5.0;5.0 +LAST-MODIFIED;FUTURE=ODD:20160124T093000Z END:VEVENT END:VCALENDAR \ No newline at end of file -- 2.39.5 From bc4101e33e39ade01665e0580e172930d6e5cde4 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 24 Jan 2016 09:30:14 +0000 Subject: [PATCH 07/16] Added unit tests for LAST-MODIFIED in iCalendarEvent/ObjectDataTests. --- source/tests/xestiacalendar_icaleventload.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/tests/xestiacalendar_icaleventload.h b/source/tests/xestiacalendar_icaleventload.h index 96d40db..534f47e 100644 --- a/source/tests/xestiacalendar_icaleventload.h +++ b/source/tests/xestiacalendar_icaleventload.h @@ -112,4 +112,9 @@ TEST(iCalendarEvent, ObjectDataTests){ ASSERT_EQ("5.0;5.0", TestEvent.GeographicData); ASSERT_EQ("EXAMPLE=MEEP", TestEvent.GeographicTokens); + // Test for LAST-MODIFIED. + + ASSERT_EQ("20160124T093000Z", TestEvent.LastModifiedData); + ASSERT_EQ("FUTURE=ODD", TestEvent.LastModifiedTokens); + } \ No newline at end of file -- 2.39.5 From 0b0f3e646240d19797c0d480d2419a058b1c8574 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 24 Jan 2016 09:49:16 +0000 Subject: [PATCH 08/16] Added code to process LOCATION in CalendarEventObject. --- .../objects/calendarevent/CalendarEvent.cpp | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/source/objects/calendarevent/CalendarEvent.cpp b/source/objects/calendarevent/CalendarEvent.cpp index 655d7de..5331fb3 100644 --- a/source/objects/calendarevent/CalendarEvent.cpp +++ b/source/objects/calendarevent/CalendarEvent.cpp @@ -395,4 +395,54 @@ void CalendarEventObject::ProcessData(){ } + // Process the data from LOCATION. + + DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "LOCATION"); + + if (DataReceived.begin() != DataReceived.end()){ + + bool TokenData = false; + string PropertyTokens; + + PropertyNameData = (string*)&DataReceived.begin()->first; + + PropertyData = SplitValues(*PropertyNameData); + + for(map::iterator iter = PropertyData.begin(); + iter != PropertyData.end(); iter++){ + + if (iter->first == "ALTREP"){ + + LocationDataAltRep = iter->second; + + } else if (iter->first == "LANGUAGE"){ + + LocationDataLanguage = iter->second; + + } else { + + if (TokenData == false){ + TokenData = true; + } else { + PropertyTokens += ";"; + } + + PropertyTokens += iter->first; + PropertyTokens += "="; + PropertyTokens += iter->second; + + } + + } + + if (PropertyTokens.size() > 0){ + + LocationDataTokens = PropertyTokens; + + } + + LocationData = DataReceived.begin()->second; + + } + } -- 2.39.5 From 5fc0ae868330aad63fd420dafb6db0a221848971 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 24 Jan 2016 09:50:19 +0000 Subject: [PATCH 09/16] Added unit tests for LOCATION in iCalendarEvent/ObjectDataTests. --- source/tests/xestiacalendar_icaleventload.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/tests/xestiacalendar_icaleventload.h b/source/tests/xestiacalendar_icaleventload.h index 534f47e..ffa5a91 100644 --- a/source/tests/xestiacalendar_icaleventload.h +++ b/source/tests/xestiacalendar_icaleventload.h @@ -116,5 +116,12 @@ TEST(iCalendarEvent, ObjectDataTests){ ASSERT_EQ("20160124T093000Z", TestEvent.LastModifiedData); ASSERT_EQ("FUTURE=ODD", TestEvent.LastModifiedTokens); + + // Test for LOCATION. + + ASSERT_EQ("The Basement, Truro", TestEvent.LocationData); + ASSERT_EQ("null:nodata", TestEvent.LocationDataAltRep); + ASSERT_EQ("kw", TestEvent.LocationDataLanguage); + ASSERT_EQ("EXACT=NO", TestEvent.LocationDataTokens); } \ No newline at end of file -- 2.39.5 From ba857afa2a20dba434ea46c2ce08d79afe19bc6d Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 24 Jan 2016 09:52:22 +0000 Subject: [PATCH 10/16] Added the LOCATION property to iCalendarEvent-Load2.vcf --- source/tests/iCalendarEvent-Load2.vcf | 1 + 1 file changed, 1 insertion(+) diff --git a/source/tests/iCalendarEvent-Load2.vcf b/source/tests/iCalendarEvent-Load2.vcf index ede7c9b..1dd12b0 100644 --- a/source/tests/iCalendarEvent-Load2.vcf +++ b/source/tests/iCalendarEvent-Load2.vcf @@ -11,5 +11,6 @@ DESCRIPTION;ALTREP="null:nodata";EXAMPLE=TOKEN;MOREDATA=YES;LANGUAGE=kw:This is a description of the event. GEO;EXAMPLE=MEEP:5.0;5.0 LAST-MODIFIED;FUTURE=ODD:20160124T093000Z +LOCATION;ALTREP="null:nodata";LANGUAGE=kw;EXACT=NO:The Basement, Truro END:VEVENT END:VCALENDAR \ No newline at end of file -- 2.39.5 From 316fac98668b1a2a371b406944a3bbdb2fc353b8 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 24 Jan 2016 09:53:59 +0000 Subject: [PATCH 11/16] Added LocationDataAltRep, LocationDataLanguage, LocationDataTokens to CalendarObject. --- source/objects/calendarobject/CalendarObject.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/objects/calendarobject/CalendarObject.h b/source/objects/calendarobject/CalendarObject.h index c85a3a7..1f1f8a6 100644 --- a/source/objects/calendarobject/CalendarObject.h +++ b/source/objects/calendarobject/CalendarObject.h @@ -75,7 +75,9 @@ class CalendarObject{ std::string GeographicTokens; std::string LocationData; - std::string LocationDataAltID; + std::string LocationDataAltRep; + std::string LocationDataLanguage; + std::string LocationDataTokens; std::string PercentCompleteData; std::string PercentCompleteTokens; -- 2.39.5 From 903ba10af41804e3f0737a39b5a63b28e9de3d69 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 24 Jan 2016 10:21:13 +0000 Subject: [PATCH 12/16] If more colons are found after the first, add to the property value. --- source/objects/calendarobject/CalendarObject.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/objects/calendarobject/CalendarObject.cpp b/source/objects/calendarobject/CalendarObject.cpp index ab21f14..e094bc2 100644 --- a/source/objects/calendarobject/CalendarObject.cpp +++ b/source/objects/calendarobject/CalendarObject.cpp @@ -123,7 +123,13 @@ CalendarObjectLoadResult CalendarObject::LoadString(std::string *LoadStringData) // Character is the colon. Set the colon // found boolen to true. - ColonFound = true; + BufferChar = (*LoadStringData)[SeekCount]; + + if (ColonFound == true){ + PropertyValue += BufferChar; + } else { + ColonFound = true; + } } else { -- 2.39.5 From 779e0466c771b6a3f3b9a448ecf13d0483555100 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 24 Jan 2016 10:21:30 +0000 Subject: [PATCH 13/16] Added code to process ORGANIZER in CalendarEventObject. --- .../objects/calendarevent/CalendarEvent.cpp | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/source/objects/calendarevent/CalendarEvent.cpp b/source/objects/calendarevent/CalendarEvent.cpp index 5331fb3..c6d7a0d 100644 --- a/source/objects/calendarevent/CalendarEvent.cpp +++ b/source/objects/calendarevent/CalendarEvent.cpp @@ -445,4 +445,62 @@ void CalendarEventObject::ProcessData(){ } + // Process the data from ORGANIZER. + + DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "ORGANIZER"); + + if (DataReceived.begin() != DataReceived.end()){ + + bool TokenData = false; + string PropertyTokens; + + PropertyNameData = (string*)&DataReceived.begin()->first; + + PropertyData = SplitValues(*PropertyNameData); + + for(map::iterator iter = PropertyData.begin(); + iter != PropertyData.end(); iter++){ + + if (iter->first == "CN"){ + + OrganiserDataCommonName = iter->second; + + } else if (iter->first == "DIR"){ + + OrganiserDataDirectoryEntry = iter->second; + + } else if (iter->first == "SENT-BY"){ + + OrganiserDataSentByParam = iter->second; + + } else if (iter->first == "LANGUAGE"){ + + OrganiserDataLanguage = iter->second; + + } else { + + if (TokenData == false){ + TokenData = true; + } else { + PropertyTokens += ";"; + } + + PropertyTokens += iter->first; + PropertyTokens += "="; + PropertyTokens += iter->second; + + } + + } + + if (PropertyTokens.size() > 0){ + + OrganiserDataTokens = PropertyTokens; + + } + + OrganiserData = DataReceived.begin()->second; + + } + } -- 2.39.5 From 35b20f5007385c1f1e9b762865dd228ed785f374 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 24 Jan 2016 10:21:45 +0000 Subject: [PATCH 14/16] Added the ORGANIZER property to iCalendarEvent-Load2.vcf --- source/tests/iCalendarEvent-Load2.vcf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/tests/iCalendarEvent-Load2.vcf b/source/tests/iCalendarEvent-Load2.vcf index 1dd12b0..b35755e 100644 --- a/source/tests/iCalendarEvent-Load2.vcf +++ b/source/tests/iCalendarEvent-Load2.vcf @@ -12,5 +12,7 @@ DESCRIPTION;ALTREP="null:nodata";EXAMPLE=TOKEN;MOREDATA=YES;LANGUAGE=kw:This GEO;EXAMPLE=MEEP:5.0;5.0 LAST-MODIFIED;FUTURE=ODD:20160124T093000Z LOCATION;ALTREP="null:nodata";LANGUAGE=kw;EXACT=NO:The Basement, Truro +ORGANIZER;CN=ExampleOrganiser;DIR="null:nodata";SENT-BY="mailto:organiser.no + reply@example.com";LANGUAGE=kw;HAPPY=DAYS:mailto:organiser@example.com END:VEVENT END:VCALENDAR \ No newline at end of file -- 2.39.5 From ba6e2ab69cd3df23489b56d0455020dc30889112 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 24 Jan 2016 10:22:02 +0000 Subject: [PATCH 15/16] Added unit tests for ORGANIZER in iCalendarEvent/ObjectDataTests. --- source/tests/xestiacalendar_icaleventload.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/source/tests/xestiacalendar_icaleventload.h b/source/tests/xestiacalendar_icaleventload.h index ffa5a91..68c7339 100644 --- a/source/tests/xestiacalendar_icaleventload.h +++ b/source/tests/xestiacalendar_icaleventload.h @@ -112,16 +112,25 @@ TEST(iCalendarEvent, ObjectDataTests){ ASSERT_EQ("5.0;5.0", TestEvent.GeographicData); ASSERT_EQ("EXAMPLE=MEEP", TestEvent.GeographicTokens); - // Test for LAST-MODIFIED. + // Tests for LAST-MODIFIED. ASSERT_EQ("20160124T093000Z", TestEvent.LastModifiedData); ASSERT_EQ("FUTURE=ODD", TestEvent.LastModifiedTokens); - // Test for LOCATION. + // Tests for LOCATION. ASSERT_EQ("The Basement, Truro", TestEvent.LocationData); ASSERT_EQ("null:nodata", TestEvent.LocationDataAltRep); ASSERT_EQ("kw", TestEvent.LocationDataLanguage); ASSERT_EQ("EXACT=NO", TestEvent.LocationDataTokens); + // Tests for ORGANIZER. + + ASSERT_EQ("mailto:organiser@example.com", TestEvent.OrganiserData); + ASSERT_EQ("ExampleOrganiser", TestEvent.OrganiserDataCommonName); + ASSERT_EQ("null:nodata", TestEvent.OrganiserDataDirectoryEntry); + ASSERT_EQ("mailto:organiser.noreply@example.com", TestEvent.OrganiserDataSentByParam); + ASSERT_EQ("kw", TestEvent.OrganiserDataLanguage); + ASSERT_EQ("HAPPY=DAYS", TestEvent.OrganiserDataTokens); + } \ No newline at end of file -- 2.39.5 From 3f22254f20bf168d14bd431af1f6d8a18416357d Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 24 Jan 2016 10:36:12 +0000 Subject: [PATCH 16/16] Added code to process PRIORITY in CalendarEventObject. --- .../objects/calendarevent/CalendarEvent.cpp | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/source/objects/calendarevent/CalendarEvent.cpp b/source/objects/calendarevent/CalendarEvent.cpp index c6d7a0d..6e96575 100644 --- a/source/objects/calendarevent/CalendarEvent.cpp +++ b/source/objects/calendarevent/CalendarEvent.cpp @@ -502,5 +502,29 @@ void CalendarEventObject::ProcessData(){ OrganiserData = DataReceived.begin()->second; } + + // Process the data from PRIORITY. + + DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "PRIORITY"); + + if (DataReceived.begin() != DataReceived.end()){ + + try { + PriorityTokens = DataReceived.begin()->first.substr(9); + } + + catch(const out_of_range &oor){ + // Do nothing as there is no data. + } + + try { + PriorityData = stoi(DataReceived.begin()->second); + } + + catch(const invalid_argument &oor){ + PriorityTokens.clear(); + } + + } } -- 2.39.5