From: Steve Brokenshire Date: Wed, 29 Jun 2016 17:39:17 +0000 (+0100) Subject: Added LANG to the SaveString function of ContactDataObject X-Git-Tag: release-0.14~42 X-Git-Url: http://Server1/repobrowser/?a=commitdiff_plain;h=7195b19cb9b6bac69a55acdffabaec237dc67e78;p=xestiaab%2F.git Added LANG to the SaveString function of ContactDataObject --- diff --git a/source/contacteditor/cdo/ContactDataObject-Save.cpp b/source/contacteditor/cdo/ContactDataObject-Save.cpp index 61acdc0..fbcfc1c 100644 --- a/source/contacteditor/cdo/ContactDataObject-Save.cpp +++ b/source/contacteditor/cdo/ContactDataObject-Save.cpp @@ -297,6 +297,25 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){ &BusinessEmailListPref, &BusinessEmailListTokens, SaveData, "work"); + // TODO: Process IMPP. + + // TODO: Process TEL. + + // Process LANG. + + SaveLanguage(&GeneralLanguageList, &GeneralLanguageListAltID, + &GeneralLanguageListPID, &GeneralLanguageListType, + &GeneralLanguageListPref, &GeneralLanguageListTokens, + SaveData, ""); + SaveLanguage(&HomeLanguageList, &HomeLanguageListAltID, + &HomeLanguageListPID, &HomeLanguageListType, + &HomeLanguageListPref, &HomeLanguageListTokens, + SaveData, "home"); + SaveLanguage(&BusinessLanguageList, &BusinessLanguageListAltID, + &BusinessLanguageListPID, &BusinessLanguageListType, + &BusinessLanguageListPref, &BusinessLanguageListTokens, + SaveData, "work"); + // Write the end part of the vCard data file. SaveData->Append("END:VCARD"); @@ -826,4 +845,74 @@ void ContactDataObject::SaveEmail(map *EmailList, map *LanguageList, map *LanguageListAltID, + map *LanguageListPID, map *LanguageListType, + map *LangaugeListPref, map *LanguageListTokens, + wxString *SaveData, wxString DataType){ + + wxString ProcessData = ""; + + for (std::map::iterator LanguageIter = LanguageList->begin(); + LanguageIter != LanguageList->end(); LanguageIter++){ + + ProcessData.Append("LANG"); + + // 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 ((*LanguageListAltID)[LanguageIter->first].size() > 0){ + + ProcessData.Append(";ALTID="); + ProcessData.Append((*LanguageListAltID)[LanguageIter->first]); + + } + + // Check if there is a value for PID. + + if ((*LanguageListPID)[LanguageIter->first].size() > 0){ + + ProcessData.Append(";PID="); + ProcessData.Append((*LanguageListPID)[LanguageIter->first]); + + } + + // Check if there is a value for PREF. + + if ((*LangaugeListPref)[LanguageIter->first] > 0){ + + ProcessData.Append(";PREF="); + ProcessData.Append(wxString::Format("%i", (*LangaugeListPref)[LanguageIter->first])); + + } + + // Check if there is a value for tokens. + + if ((*LanguageListTokens)[LanguageIter->first].size() > 0){ + + ProcessData.Append(";"); + ProcessData.Append((*LanguageListTokens)[LanguageIter->first]); + + } + + ProcessData.Append(":"); + ProcessData.Append(LanguageIter->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 99b8fc9..5cc94c9 100644 --- a/source/contacteditor/cdo/ContactDataObject.h +++ b/source/contacteditor/cdo/ContactDataObject.h @@ -126,6 +126,10 @@ class ContactDataObject{ map *EmailListPID, map *EmailListType, map *EmailListPref, map *EmailListTokens, wxString *SaveData, wxString DataType); + void SaveLanguage(map *LanguageList, map *LanguageListAltID, + map *LanguageListPID, map *LanguageListType, + map *LangaugeListPref, map *LanguageListTokens, + wxString *SaveData, wxString DataType); public: diff --git a/source/tests/xestiaab_contactsave.h b/source/tests/xestiaab_contactsave.h index 30d4960..baf9441 100644 --- a/source/tests/xestiaab_contactsave.h +++ b/source/tests/xestiaab_contactsave.h @@ -110,6 +110,9 @@ TEST(ContactSave, ContactSaveTests){ "EMAIL;ALTID=10;PID=20;PREF=40;WONDERFUL=Colour:moo@example.com\n" "EMAIL;TYPE=home;ALTID=5;PID=10;PREF=20;PEACE=quiet:moo.home@example.com\n" "EMAIL;TYPE=work;ALTID=1;PID=2;PREF=3;BUSINESS=Money:moo.business@example.com\n" + "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" "END:VCARD"; ASSERT_EQ(CONTACTLOAD_OK, TestFile3.LoadFile("LoadCheck-Load4.vcf"));