From 03165a86aeabb5be5b9663a4703fc16d8dacecec Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Wed, 29 Jun 2016 11:04:38 +0100 Subject: [PATCH] Added TZ to the SaveString function of ContactDataObject --- .../cdo/ContactDataObject-Save.cpp | 94 +++++++++++++++++++ source/contacteditor/cdo/ContactDataObject.h | 4 + source/tests/xestiaab_contactsave.h | 6 ++ 3 files changed, 104 insertions(+) diff --git a/source/contacteditor/cdo/ContactDataObject-Save.cpp b/source/contacteditor/cdo/ContactDataObject-Save.cpp index b422160..5fbc386 100644 --- a/source/contacteditor/cdo/ContactDataObject-Save.cpp +++ b/source/contacteditor/cdo/ContactDataObject-Save.cpp @@ -240,6 +240,21 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){ &BusinessTitleListType, &BusinessTitleListPref, &BusinessTitleListTokens, SaveData, "work"); + // Process TZ. + + SaveTimezone(&GeneralTZList, &GeneralTZListAltID, + &GeneralTZListPID, &GeneralTZListType, + &GeneralTZListMediatype, &GeneralTZListPref, + &GeneralTZListTokens, SaveData, ""); + SaveTimezone(&HomeTZList, &HomeTZListAltID, + &HomeTZListPID, &HomeTZListType, + &HomeTZListMediatype, &HomeTZListPref, + &HomeTZListTokens, SaveData, "home"); + SaveTimezone(&BusinessTZList, &BusinessTZListAltID, + &BusinessTZListPID, &BusinessTZListType, + &BusinessTZListMediatype, &BusinessTZListPref, + &BusinessTZListTokens, SaveData, "work"); + // Write the end part of the vCard data file. SaveData->Append("END:VCARD"); @@ -485,4 +500,83 @@ void ContactDataObject::SaveNickname(map *NicknameList, map *TZList, map *TZListAltID, + map *TZListPID, map *TZListType, + map *TZListMediatype, map *TZListPref, + map *TZListTokens, wxString *SaveData, wxString DataType){ + + wxString ProcessData = ""; + + for (std::map::iterator TZIter = TZList->begin(); + TZIter != TZList->end(); TZIter++){ + + ProcessData.Append("TZ"); + + // Check if there is a value for TYPE. + + if (DataType.size() > 0){ + + ProcessData.Append(";TYPE="); + ProcessData.Append(DataType); + + } + + // Check if there is a value for ALTID. + + if ((*TZListAltID)[TZIter->first].size() > 0){ + + ProcessData.Append(";ALTID="); + ProcessData.Append((*TZListAltID)[TZIter->first]); + + } + + // Check if there is a value for MEDIATYPE. + + if ((*TZListMediatype)[TZIter->first].size() > 0){ + + ProcessData.Append(";MEDIATYPE="); + ProcessData.Append((*TZListMediatype)[TZIter->first]); + + } + + // Check if there is a value for PID. + + if ((*TZListPID)[TZIter->first].size() > 0){ + + ProcessData.Append(";PID="); + ProcessData.Append((*TZListPID)[TZIter->first]); + + } + + // Check if there is a value for PREF. + + if ((*TZListPref)[TZIter->first] > 0){ + + ProcessData.Append(";PREF="); + ProcessData.Append(wxString::Format("%i", (*TZListPref)[TZIter->first])); + + } + + // Check if there is a value for tokens. + + if ((*TZListTokens)[TZIter->first].size() > 0){ + + ProcessData.Append(";"); + ProcessData.Append((*TZListTokens)[TZIter->first]); + + } + + ProcessData.Append(":"); + ProcessData.Append(TZIter->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 e0df47f..3fa2658 100644 --- a/source/contacteditor/cdo/ContactDataObject.h +++ b/source/contacteditor/cdo/ContactDataObject.h @@ -110,6 +110,10 @@ class ContactDataObject{ map *NicknameListPID, map *NicknameListType, map *NicknameListLanguage, map *NicknameListPref, map *NicknameListTokens, wxString *SaveData, wxString DataType); + void SaveTimezone(map *TZList, map *TZListAltID, + map *TZListPID, map *TZListType, + map *TZListMediatype, map *TZListPref, + map *TZListTokens, wxString *SaveData, wxString DataType); public: diff --git a/source/tests/xestiaab_contactsave.h b/source/tests/xestiaab_contactsave.h index 74a9206..8420e63 100644 --- a/source/tests/xestiaab_contactsave.h +++ b/source/tests/xestiaab_contactsave.h @@ -89,6 +89,12 @@ TEST(ContactSave, ContactSaveTests){ " arkness\n" "TITLE;TYPE=work;ALTID=40;LANGUAGE=moths/eew;PID=41;PREF=42;EEP=BOTH:Master of\n" " the Light & Darkness\n" + "TZ;ALTID=35;MEDIATYPE=text/plain;PID=60;PREF=20;WHATS=This;A=Potato:Europe/Tr\n" + " uro\n" + "TZ;TYPE=home;ALTID=15;MEDIATYPE=text/plain;PID=20;PREF=40;MAYBE=not:Europe/Pe\n" + " nzance\n" + "TZ;TYPE=work;ALTID=45;MEDIATYPE=text/plain;PID=70;PREF=80;MAYBE=yes:Europe/St\n" + " Austell\n" "END:VCARD"; ASSERT_EQ(CONTACTLOAD_OK, TestFile3.LoadFile("LoadCheck-Load4.vcf")); -- 2.39.5