From b9a352b6f763186a361ae152e9d1e48913bdb1e3 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Wed, 29 Jun 2016 21:47:47 +0100 Subject: [PATCH] Added URL to the SaveString function of ContactDataObject --- .../cdo/ContactDataObject-Save.cpp | 96 ++++++++++++++++++- source/contacteditor/cdo/ContactDataObject.h | 4 + source/tests/xestiaab_contactsave.h | 5 + 3 files changed, 104 insertions(+), 1 deletion(-) diff --git a/source/contacteditor/cdo/ContactDataObject-Save.cpp b/source/contacteditor/cdo/ContactDataObject-Save.cpp index 6276454..426f3f2 100644 --- a/source/contacteditor/cdo/ContactDataObject-Save.cpp +++ b/source/contacteditor/cdo/ContactDataObject-Save.cpp @@ -496,7 +496,22 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){ ProcessData.clear(); } - + + // Process URL. + + SaveURL(&GeneralWebsiteList, &GeneralWebsiteListAltID, + &GeneralWebsiteListPID, &GeneralWebsiteListType, + &GeneralWebsiteListMediatype, &GeneralWebsiteListPref, + &GeneralWebsiteListTokens, SaveData, ""); + SaveURL(&HomeWebsiteList, &HomeWebsiteListAltID, + &HomeWebsiteListPID, &HomeWebsiteListType, + &HomeWebsiteListMediatype, &HomeWebsiteListPref, + &HomeWebsiteListTokens, SaveData, "home"); + SaveURL(&BusinessWebsiteList, &BusinessWebsiteListAltID, + &BusinessWebsiteListPID, &BusinessWebsiteListType, + &BusinessWebsiteListMediatype, &BusinessWebsiteListPref, + &BusinessWebsiteListTokens, SaveData, "work"); + // Write the end part of the vCard data file. SaveData->Append("END:VCARD"); @@ -1178,4 +1193,83 @@ void ContactDataObject::SaveGeoposition(map *GeographyList, map *WebsiteList, map *WebsiteListAltID, + map *WebsiteListPID, map *WebsiteListType, + map *WebsiteListMediatype, map *WebsiteListPref, + map *WebsiteListTokens, wxString *SaveData, wxString DataType){ + + wxString ProcessData = ""; + + for (std::map::iterator WebsiteIter = WebsiteList->begin(); + WebsiteIter != WebsiteList->end(); WebsiteIter++){ + + ProcessData.Append("URL"); + + // 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 ((*WebsiteListAltID)[WebsiteIter->first].size() > 0){ + + ProcessData.Append(";ALTID="); + ProcessData.Append((*WebsiteListAltID)[WebsiteIter->first]); + + } + + // Check if there is a value for MEDIATYPE. + + if ((*WebsiteListMediatype)[WebsiteIter->first].size() > 0){ + + ProcessData.Append(";MEDIATYPE="); + ProcessData.Append((*WebsiteListMediatype)[WebsiteIter->first]); + + } + + // Check if there is a value for PID. + + if ((*WebsiteListPID)[WebsiteIter->first].size() > 0){ + + ProcessData.Append(";PID="); + ProcessData.Append((*WebsiteListPID)[WebsiteIter->first]); + + } + + // Check if there is a value for PREF. + + if ((*WebsiteListPref)[WebsiteIter->first] > 0){ + + ProcessData.Append(";PREF="); + ProcessData.Append(wxString::Format("%i", (*WebsiteListPref)[WebsiteIter->first])); + + } + + // Check if there is a value for tokens. + + if ((*WebsiteListTokens)[WebsiteIter->first].size() > 0){ + + ProcessData.Append(";"); + ProcessData.Append((*WebsiteListTokens)[WebsiteIter->first]); + + } + + ProcessData.Append(":"); + ProcessData.Append(WebsiteIter->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 ecb58c3..2cf736b 100644 --- a/source/contacteditor/cdo/ContactDataObject.h +++ b/source/contacteditor/cdo/ContactDataObject.h @@ -135,6 +135,10 @@ class ContactDataObject{ map *GeographyListMediatype, map *GeographyListDataType, map *GeographyListPref, map *GeographyListTokens, wxString *SaveData, wxString DataType); + void SaveURL(map *WebsiteList, map *WebsiteListAltID, + map *WebsiteListPID, map *WebsiteListType, + map *WebsiteListMediatype, map *WebsiteListPref, + map *WebsiteListTokens, wxString *SaveData, wxString DataType); public: diff --git a/source/tests/xestiaab_contactsave.h b/source/tests/xestiaab_contactsave.h index 9f7a587..b0842da 100644 --- a/source/tests/xestiaab_contactsave.h +++ b/source/tests/xestiaab_contactsave.h @@ -121,6 +121,11 @@ TEST(ContactSave, ContactSaveTests){ "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" + "URL;ALTID=0;MEDIATYPE=text/plain;PID=1;PREF=2;MEEP=Moo:http://example.com/\n" + "URL;TYPE=home;ALTID=10;MEDIATYPE=grass/soggy;PID=11;PREF=12;BON=Bon:http://ex\n" + " ample.com/home/\n" + "URL;TYPE=work;ALTID=20;MEDIATYPE=chocolate/yummy;PID=21;PREF=22;YES=No:http:/\n" + " /example.com/business/\n" "END:VCARD"; ASSERT_EQ(CONTACTLOAD_OK, TestFile3.LoadFile("LoadCheck-Load4.vcf")); -- 2.39.2