From: Steve Brokenshire Date: Wed, 29 Jun 2016 07:34:04 +0000 (+0100) Subject: Added SOURCE to the SaveString function of ContactDataObject X-Git-Tag: release-0.14~51 X-Git-Url: http://Server1/repobrowser/?a=commitdiff_plain;h=00ca8e98dc352e78b31b07a1194475860a47fa08;p=xestiaab%2F.git Added SOURCE to the SaveString function of ContactDataObject --- diff --git a/source/contacteditor/cdo/ContactDataObject-Save.cpp b/source/contacteditor/cdo/ContactDataObject-Save.cpp index 73fb904..4cc5a6f 100644 --- a/source/contacteditor/cdo/ContactDataObject-Save.cpp +++ b/source/contacteditor/cdo/ContactDataObject-Save.cpp @@ -78,7 +78,14 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){ break; } - + + // Process SOURCE. + + SaveSource(&SourceList, &SourceListAltID, + &SourceListPID, &SourceListType, + &SourceListMediatype, &SourceListPref, + &SourceListTokens, SaveData); + // Process FN. for (std::map::iterator FNIter = FullNamesList.begin(); @@ -253,4 +260,83 @@ void ContactDataObject::SaveTitle(map *TitleList, map *SourceList, map *SourceListAltID, + map *SourceListPID, map *SourceListType, + map *SourceListMediatype, map *SourceListPref, + map *SourceListTokens, wxString *SaveData){ + + wxString ProcessData = ""; + + for (std::map::iterator SourceIter = SourceList->begin(); + SourceIter != SourceList->end(); SourceIter++){ + + ProcessData.Append("SOURCE"); + + // Check if there is a value for TYPE. + + if ((*SourceListType)[SourceIter->first].size() > 0){ + + ProcessData.Append(";TYPE="); + ProcessData.Append((*SourceListType)[SourceIter->first]); + + } + + // Check if there is a value for ALTID. + + if ((*SourceListAltID)[SourceIter->first].size() > 0){ + + ProcessData.Append(";ALTID="); + ProcessData.Append((*SourceListAltID)[SourceIter->first]); + + } + + // Check if there is a value for LANGUAGE. + + if ((*SourceListMediatype)[SourceIter->first].size() > 0){ + + ProcessData.Append(";MEDIATYPE="); + ProcessData.Append((*SourceListMediatype)[SourceIter->first]); + + } + + // Check if there is a value for PID. + + if ((*SourceListPID)[SourceIter->first].size() > 0){ + + ProcessData.Append(";PID="); + ProcessData.Append((*SourceListPID)[SourceIter->first]); + + } + + // Check if there is a value for PREF. + + if ((*SourceListPref)[SourceIter->first] > 0){ + + ProcessData.Append(";PREF="); + ProcessData.Append(wxString::Format("%i", (*SourceListPref)[SourceIter->first])); + + } + + // Check if there is a value for tokens. + + if ((*SourceListTokens)[SourceIter->first].size() > 0){ + + ProcessData.Append(";"); + ProcessData.Append((*SourceListTokens)[SourceIter->first]); + + } + + ProcessData.Append(":"); + ProcessData.Append(SourceIter->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 b9bfdf1..5cd36f4 100644 --- a/source/contacteditor/cdo/ContactDataObject.h +++ b/source/contacteditor/cdo/ContactDataObject.h @@ -102,6 +102,10 @@ class ContactDataObject{ map *TitleListAltID, map *TitleListPID, map *TitleListType, map *TitleListPref, map *TitleListTokens, wxString *SaveData, wxString DataType); + void SaveSource(map *SourceList, map *SourceListAltID, + map *SourceListPID, map *SourceListType, + map *SourceListMediatype, map *SourceListPref, + map *SourceListTokens, wxString *SaveData); public: diff --git a/source/tests/xestiaab_contactsave.h b/source/tests/xestiaab_contactsave.h index cff2a98..6ae4698 100644 --- a/source/tests/xestiaab_contactsave.h +++ b/source/tests/xestiaab_contactsave.h @@ -62,6 +62,12 @@ TEST(ContactSave, ContactSaveTests){ "PRODID:-//Xestia//Address Book Unit Testing//KW\n" "UID:903588-9082374-989120310-AAFECDBCDF\n" "KIND:individual\n" + "SOURCE;ALTID=74;MEDIATYPE=text/plain;PID=71;PREF=72;STATUS=FEED:http://exampl\n" + " e.com/source/sourcea.vcf\n" + "SOURCE;TYPE=home;ALTID=84;MEDIATYPE=text/plainpaper;PID=81;PREF=82;STATUS=ONL\n" + " INE:http://example.com/source/sourceb.vcf\n" + "SOURCE;TYPE=work;ALTID=94;MEDIATYPE=text/sandpaper;PID=91;PREF=92;STATUS=OFFL\n" + " INE:http://example.com/source/sourcec.vcf\n" "FN;TYPE=work;LANGUAGE=kw;ALTID=500;PID=40;PREF=45;EXAMPLE=Baaa:Test Contact\n" "TITLE;ALTID=20;LANGUAGE=text/plain;PID=21;PREF=22;EEP=LIGHT:Lord of Light\n" "TITLE;TYPE=home;ALTID=30;LANGUAGE=grass/dry;PID=31;PREF=32;EEP=DARK:Lord of D\n"