From ff65774611d82f2bdbb6cb5c34829cc2e922cf68 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Wed, 29 Jun 2016 20:55:43 +0100 Subject: [PATCH] Added RELATED to the SaveString function of ContactDataObject --- .../cdo/ContactDataObject-Save.cpp | 163 ++++++++++++++++++ source/tests/xestiaab_contactsave.h | 3 + 2 files changed, 166 insertions(+) diff --git a/source/contacteditor/cdo/ContactDataObject-Save.cpp b/source/contacteditor/cdo/ContactDataObject-Save.cpp index b7d2688..6276454 100644 --- a/source/contacteditor/cdo/ContactDataObject-Save.cpp +++ b/source/contacteditor/cdo/ContactDataObject-Save.cpp @@ -334,6 +334,169 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){ &BusinessGeographyListPref, &BusinessGeographyListTokens, SaveData, "work"); + // Process RELATED. + + int Moo = 0; + + for (std::map::iterator RelatedIter = GeneralRelatedList.begin(); + RelatedIter != GeneralRelatedList.end(); RelatedIter++){ + + ProcessData.Append("RELATED"); + + // Check if there is a value for TYPE. + + if (GeneralRelatedListRelType[RelatedIter->first].size() > 0){ + + wxString RelatedType = ""; + + ProcessData.Append(";TYPE="); + + if (GeneralRelatedListRelType[RelatedIter->first] == _("Contact")){ + + RelatedType = wxT("contact"); + + } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Acquaintance")){ + + RelatedType = wxT("acquaintance"); + + } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Friend")){ + + RelatedType = wxT("friend"); + + } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Met")){ + + RelatedType = wxT("met"); + + } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Co-worker")){ + + RelatedType = wxT("co-worker"); + + } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Colleague")){ + + RelatedType = wxT("colleague"); + + } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Co-resident")){ + + RelatedType = wxT("co-resident"); + + } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Neighbour")){ + + RelatedType = wxT("neighbor"); + + } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Child")){ + + RelatedType = wxT("child"); + + } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Parent")){ + + RelatedType = wxT("parent"); + + } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Sibling")){ + + RelatedType = wxT("sibling"); + + } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Spouse")){ + + RelatedType = wxT("spouse"); + + } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Kin")){ + + RelatedType = wxT("kin"); + + } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Muse")){ + + RelatedType = wxT("muse"); + + } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Crush")){ + + RelatedType = wxT("crush"); + + } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Date")){ + + RelatedType = wxT("date"); + + } else if (GeneralRelatedListRelType[RelatedIter->first]== _("Sweetheart")){ + + RelatedType = wxT("sweetheart"); + + } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Me")){ + + RelatedType = wxT("me"); + + } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Agent")){ + + RelatedType = wxT("agent"); + + } else if (GeneralRelatedListRelType[RelatedIter->first] == _("Emergency")){ + + RelatedType = wxT("emergency"); + + } else { + + RelatedType = GeneralRelatedListRelType[RelatedIter->first]; + + } + + ProcessData.Append(RelatedType); + + } + + // Check if there is a value for LANGUAGE. + + if (GeneralRelatedListLanguage[RelatedIter->first].size() > 0){ + + ProcessData.Append(";LANGUAGE="); + ProcessData.Append(GeneralRelatedListLanguage[RelatedIter->first]); + + } + + // Check if there is a value for ALTID. + + if (GeneralRelatedListAltID[RelatedIter->first].size() > 0){ + + ProcessData.Append(";ALTID="); + ProcessData.Append(GeneralRelatedListAltID[RelatedIter->first]); + + } + + // Check if there is a value for PID. + + if (GeneralRelatedListPID[RelatedIter->first].size() > 0){ + + ProcessData.Append(";PID="); + ProcessData.Append(GeneralRelatedListPID[RelatedIter->first]); + + } + + // Check if there is a value for PREF. + + if (GeneralRelatedListPref[RelatedIter->first] > 0){ + + ProcessData.Append(";PREF="); + ProcessData.Append(wxString::Format("%i", GeneralRelatedListPref[RelatedIter->first])); + + } + + // Check if there is a value for tokens. + + if (GeneralRelatedListTokens[RelatedIter->first].size() > 0){ + + ProcessData.Append(";"); + ProcessData.Append(GeneralRelatedListTokens[RelatedIter->first]); + + } + + ProcessData.Append(":"); + ProcessData.Append(RelatedIter->second); + ProcessData.Append("\n"); + + ProcessData = OutputText(&ProcessData); + + SaveData->Append(ProcessData); + ProcessData.clear(); + + } + // Write the end part of the vCard data file. SaveData->Append("END:VCARD"); diff --git a/source/tests/xestiaab_contactsave.h b/source/tests/xestiaab_contactsave.h index ab44064..9f7a587 100644 --- a/source/tests/xestiaab_contactsave.h +++ b/source/tests/xestiaab_contactsave.h @@ -118,6 +118,9 @@ TEST(ContactSave, ContactSaveTests){ " :7.0,7.0\n" "GEO;TYPE=work;ALTID=75;MEDIATYPE=text/greenplain;PID=32;PREF=4;POS=Money:geo:\n" " 14.0,14.0\n" + "RELATED;TYPE=kin;ALTID=5;PID=10;PREF=20;OPTION=Yes:Friend Test\n" + "RELATED;TYPE=spouse;ALTID=1;PID=2;PREF=3;OPTION=No:Friend Test Two\n" + "RELATED;TYPE=muse;ALTID=4;PID=5;PREF=6;OPTION=Maybe:Friend Test Three\n" "END:VCARD"; ASSERT_EQ(CONTACTLOAD_OK, TestFile3.LoadFile("LoadCheck-Load4.vcf")); -- 2.39.2