From eb3920b819b84e8a61cd21f302026379b4480a2b Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sat, 2 Jul 2016 19:51:57 +0100 Subject: [PATCH] Added CALURI to the SaveString function of ContactDataObject --- .../cdo/ContactDataObject-Save.cpp | 86 +++++++++++++++++++ source/contacteditor/cdo/ContactDataObject.h | 4 + source/tests/xestiaab_contactsave.h | 6 ++ 3 files changed, 96 insertions(+) diff --git a/source/contacteditor/cdo/ContactDataObject-Save.cpp b/source/contacteditor/cdo/ContactDataObject-Save.cpp index 540b5ec..642ea5c 100644 --- a/source/contacteditor/cdo/ContactDataObject-Save.cpp +++ b/source/contacteditor/cdo/ContactDataObject-Save.cpp @@ -592,6 +592,13 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){ &SoundsListPref, &SoundsListTokens, SaveData); + // Process CALURI. + + SaveCalendarURI(&CalendarList, &CalendarListMediatype, + &CalendarListAltID, &CalendarListPID, + &CalendarListType, &CalendarListPref, + &CalendarListTokens, SaveData); + // Write the end part of the vCard data file. SaveData->Append("END:VCARD"); @@ -1942,4 +1949,83 @@ void ContactDataObject::SaveSound(map *SoundsList, map *CalendarList, map *CalendarListMediatype, + map *CalendarListAltID, map *CalendarListPID, + map *CalendarListType, map *CalendarListPref, + map *CalendarListTokens, wxString *SaveData){ + + wxString ProcessData = ""; + + for (std::map::iterator CalendarIter = CalendarList->begin(); + CalendarIter != CalendarList->end(); CalendarIter++){ + + ProcessData.Append("CALURI"); + + // Check if there is a value for TYPE. + + if ((*CalendarListType)[CalendarIter->first].size() > 0){ + + ProcessData.Append(";TYPE="); + ProcessData.Append((*CalendarListType)[CalendarIter->first]); + + } + + // Check if there is a value for ALTID. + + if ((*CalendarListAltID)[CalendarIter->first].size() > 0){ + + ProcessData.Append(";ALTID="); + ProcessData.Append((*CalendarListAltID)[CalendarIter->first]); + + } + + // Check if there is a value for MEDIATYPE. + + if ((*CalendarListMediatype)[CalendarIter->first].size() > 0){ + + ProcessData.Append(";MEDIATYPE="); + ProcessData.Append((*CalendarListMediatype)[CalendarIter->first]); + + } + + // Check if there is a value for PID. + + if ((*CalendarListPID)[CalendarIter->first].size() > 0){ + + ProcessData.Append(";PID="); + ProcessData.Append((*CalendarListPID)[CalendarIter->first]); + + } + + // Check if there is a value for PREF. + + if ((*CalendarListPref)[CalendarIter->first] > 0){ + + ProcessData.Append(";PREF="); + ProcessData.Append(wxString::Format("%i", (*CalendarListPref)[CalendarIter->first])); + + } + + // Check if there is a value for tokens. + + if ((*CalendarListTokens)[CalendarIter->first].size() > 0){ + + ProcessData.Append(";"); + ProcessData.Append((*CalendarListTokens)[CalendarIter->first]); + + } + + ProcessData.Append(":"); + ProcessData.Append(CalendarIter->second); + ProcessData.Append("\n"); + + ProcessData = OutputText(&ProcessData); + + SaveData->Append(ProcessData); + ProcessData.clear(); + + } + } \ No newline at end of file diff --git a/source/contacteditor/cdo/ContactDataObject.h b/source/contacteditor/cdo/ContactDataObject.h index 9bb8773..1a47af9 100644 --- a/source/contacteditor/cdo/ContactDataObject.h +++ b/source/contacteditor/cdo/ContactDataObject.h @@ -172,6 +172,10 @@ class ContactDataObject{ map *SoundsListMediatype, map *SoundsListLanguage, map *SoundsListPref, map *SoundsListTokens, wxString *SaveData); + void SaveCalendarURI(std::map *CalendarList, std::map *CalendarListAltID, + std::map *CalendarListPID, std::map *CalendarListType, + std::map *CalendarListMediatype, std::map *CalendarListPref, + std::map *CalendarListTokens, wxString *SaveData); public: diff --git a/source/tests/xestiaab_contactsave.h b/source/tests/xestiaab_contactsave.h index 8a09b03..b2be408 100644 --- a/source/tests/xestiaab_contactsave.h +++ b/source/tests/xestiaab_contactsave.h @@ -544,6 +544,12 @@ TEST(ContactSave, ContactSaveTests){ " rOiaKk49EpYoqYecozQYDhT04juULDYbJn7IXeksuXpi2v2irciAXICHx2PAvM4SVoUKcberP+c9\n" " c+Pj7unVvPkyBqbwKmHWBSOj4S4e7W5oSH9nHhrW1jnyCtQZClVD86hh6E7vpEDb8Ny+AbwuSlI+\n" " b4KyFDt6/fEADBnCOeFgDID42jkBQ+wFjNEAGMJtbcK5WgAODg==\n" + "CALURI;ALTID=34;MEDIATYPE=text/plain;PID=31;PREF=32;CALENDARS=FLYING:http://e\n" + " xample.com\n" + "CALURI;TYPE=home;ALTID=44;MEDIATYPE=text/dryplain;PID=41;PREF=42;CALENDARS=GR\n" + " OUNDED:http://example.com/home\n" + "CALURI;TYPE=work;ALTID=54;MEDIATYPE=text/stillwetink;PID=51;PREF=52;CALENDARS\n" + " =CANCELLED:http://example.com/business\n" "END:VCARD"; ASSERT_EQ(CONTACTLOAD_OK, TestFile3.LoadFile("LoadCheck-Load4.vcf")); -- 2.39.5