From a0bae18cb9a8af26a332066d3e74403d0f1aad45 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Wed, 29 Jun 2016 19:13:47 +0100 Subject: [PATCH] Added GEO to the SaveString function of ContactDataObject --- .../cdo/ContactDataObject-Save.cpp | 100 ++++++++++++++++++ source/contacteditor/cdo/ContactDataObject.h | 5 + source/tests/xestiaab_contactsave.h | 5 + 3 files changed, 110 insertions(+) diff --git a/source/contacteditor/cdo/ContactDataObject-Save.cpp b/source/contacteditor/cdo/ContactDataObject-Save.cpp index fbcfc1c..b7d2688 100644 --- a/source/contacteditor/cdo/ContactDataObject-Save.cpp +++ b/source/contacteditor/cdo/ContactDataObject-Save.cpp @@ -316,6 +316,24 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){ &BusinessLanguageListPref, &BusinessLanguageListTokens, SaveData, "work"); + // Process GEO. + + SaveGeoposition(&GeneralGeographyList, &GeneralGeographyListAltID, + &GeneralGeographyListPID, &GeneralGeographyListType, + &GeneralGeographyListMediatype, &GeneralGeographyListDataType, + &GeneralGeographyListPref, &GeneralGeographyListTokens, + SaveData, ""); + SaveGeoposition(&HomeGeographyList, &HomeGeographyListAltID, + &HomeGeographyListPID, &HomeGeographyListType, + &HomeGeographyListMediatype, &HomeGeographyListDataType, + &HomeGeographyListPref, &HomeGeographyListTokens, + SaveData, "home"); + SaveGeoposition(&BusinessGeographyList, &BusinessGeographyListAltID, + &BusinessGeographyListPID, &BusinessGeographyListType, + &BusinessGeographyListMediatype, &BusinessGeographyListDataType, + &BusinessGeographyListPref, &BusinessGeographyListTokens, + SaveData, "work"); + // Write the end part of the vCard data file. SaveData->Append("END:VCARD"); @@ -915,4 +933,86 @@ void ContactDataObject::SaveLanguage(map *LanguageList, map *GeographyList, map *GeographyListAltID, + map *GeographyListPID, map *GeographyListType, + map *GeographyListMediatype, map *GeographyListDataType, + map *GeographyListPref, map *GeographyListTokens, + wxString *SaveData, wxString DataType){ + + wxString ProcessData = ""; + + for (std::map::iterator GeographyIter = GeographyList->begin(); + GeographyIter != GeographyList->end(); GeographyIter++){ + + ProcessData.Append("GEO"); + + // 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 ((*GeographyListAltID)[GeographyIter->first].size() > 0){ + + ProcessData.Append(";ALTID="); + ProcessData.Append((*GeographyListAltID)[GeographyIter->first]); + + } + + // Check if there is a value for MEDIATYPE. + + if ((*GeographyListMediatype)[GeographyIter->first].size() > 0){ + + ProcessData.Append(";MEDIATYPE="); + ProcessData.Append((*GeographyListMediatype)[GeographyIter->first]); + + } + + // Check if there is a value for PID. + + if ((*GeographyListPID)[GeographyIter->first].size() > 0){ + + ProcessData.Append(";PID="); + ProcessData.Append((*GeographyListPID)[GeographyIter->first]); + + } + + // Check if there is a value for PREF. + + if ((*GeographyListPref)[GeographyIter->first] > 0){ + + ProcessData.Append(";PREF="); + ProcessData.Append(wxString::Format("%i", (*GeographyListPref)[GeographyIter->first])); + + } + + // Check if there is a value for tokens. + + if ((*GeographyListTokens)[GeographyIter->first].size() > 0){ + + ProcessData.Append(";"); + ProcessData.Append((*GeographyListTokens)[GeographyIter->first]); + + } + + ProcessData.Append(":"); + ProcessData.Append((*GeographyListDataType)[GeographyIter->first]); + ProcessData.Append(":"); + ProcessData.Append(GeographyIter->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 5cc94c9..ecb58c3 100644 --- a/source/contacteditor/cdo/ContactDataObject.h +++ b/source/contacteditor/cdo/ContactDataObject.h @@ -130,6 +130,11 @@ class ContactDataObject{ map *LanguageListPID, map *LanguageListType, map *LangaugeListPref, map *LanguageListTokens, wxString *SaveData, wxString DataType); + void SaveGeoposition(map *GeographyList, map *GeographyListAltID, + map *GeographyListPID, map *GeographyListType, + map *GeographyListMediatype, map *GeographyListDataType, + map *GeographyListPref, map *GeographyListTokens, + wxString *SaveData, wxString DataType); public: diff --git a/source/tests/xestiaab_contactsave.h b/source/tests/xestiaab_contactsave.h index baf9441..ab44064 100644 --- a/source/tests/xestiaab_contactsave.h +++ b/source/tests/xestiaab_contactsave.h @@ -113,6 +113,11 @@ TEST(ContactSave, ContactSaveTests){ "LANG;ALTID=20;PID=40;PREF=80;GELFORN=Great:kw\n" "LANG;TYPE=home;ALTID=22;PID=45;PREF=90;LANGUAGE=yes:en\n" "LANG;TYPE=work;ALTID=10;PID=15;PREF=20;FFENSTRI=ie:cy\n" + "GEO;ALTID=13;MEDIATYPE=text/plain;PID=26;PREF=39;POS=Yep:geo:3.5,3.5\n" + "GEO;TYPE=home;ALTID=140;MEDIATYPE=text/ratherplain;PID=70;PREF=1;POS=Nope:geo\n" + " :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" "END:VCARD"; ASSERT_EQ(CONTACTLOAD_OK, TestFile3.LoadFile("LoadCheck-Load4.vcf")); -- 2.39.2