From a149bada80447804867d7a30018ca57eb6f8e863 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sat, 2 Jul 2016 23:06:47 +0100 Subject: [PATCH] Added X-* to the SaveString function of ContactDataObject --- .../cdo/ContactDataObject-Save.cpp | 28 +++++++++++++++++++ source/contacteditor/cdo/ContactDataObject.h | 2 ++ source/tests/xestiaab_contactsave.h | 9 ++++++ 3 files changed, 39 insertions(+) diff --git a/source/contacteditor/cdo/ContactDataObject-Save.cpp b/source/contacteditor/cdo/ContactDataObject-Save.cpp index 8a04c55..b78bdc0 100644 --- a/source/contacteditor/cdo/ContactDataObject-Save.cpp +++ b/source/contacteditor/cdo/ContactDataObject-Save.cpp @@ -626,6 +626,11 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){ SaveVendor(&VendorList, &VendorListPEN, &VendorListElement, SaveData); + // Process X-Tokens. + + SaveXToken(&XTokenList, &XTokenListTokens, + SaveData); + // Write the end part of the vCard data file. SaveData->Append("END:VCARD"); @@ -2313,4 +2318,27 @@ void ContactDataObject::SaveVendor(map *VendorList, map *XTokenList, map *XTokenListTokens, + wxString *SaveData){ + + wxString ProcessData = ""; + + for (std::map::iterator XTokenIter = XTokenList->begin(); + XTokenIter != XTokenList->end(); XTokenIter++){ + + ProcessData.Append("X-"); + ProcessData.Append((*XTokenListTokens)[XTokenIter->first]); + ProcessData.Append(":"); + ProcessData.Append(XTokenIter->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 6886fcd..24451f1 100644 --- a/source/contacteditor/cdo/ContactDataObject.h +++ b/source/contacteditor/cdo/ContactDataObject.h @@ -191,6 +191,8 @@ class ContactDataObject{ map *KeyListTokens, wxString *SaveData); void SaveVendor(map *VendorList, map *VendorListPEN, map *VendorListElement, wxString *SaveData); + void SaveXToken(map *XTokenList, map *XTokenListTokens, + wxString *SaveData); public: diff --git a/source/tests/xestiaab_contactsave.h b/source/tests/xestiaab_contactsave.h index 7261f8c..bab693e 100644 --- a/source/tests/xestiaab_contactsave.h +++ b/source/tests/xestiaab_contactsave.h @@ -682,6 +682,15 @@ TEST(ContactSave, ContactSaveTests){ "VND-696-CAKE:Lemon\n" "VND-696-DRINK:Orange\n" "VND-696-MUSIC:Shiena Nishizawa\n" + "X-FARM:Yard\n" + "X-FARM:Animals\n" + "X-FARM;LOCATION=Back;TYPE=Vehicles:Shed\n" + "X-DISKSERIAL:14444\n" + "X-DISKSERIAL:7555\n" + "X-DISKSERIAL;STATUS=DESTROYED;TYPE=FLASH:3250539032590\n" + "X-FOODS;STATUS=HIGH:Lemon Cake\n" + "X-FOODS;STATUS=LOW:Starrey Gazey Pie\n" + "X-FOODS;STATUS=FAVOURITE;TYPE=CHEESEANDONION:Cornish Pasties\n" "END:VCARD"; ASSERT_EQ(CONTACTLOAD_OK, TestFile3.LoadFile("LoadCheck-Load4.vcf")); -- 2.39.5