From: Steve Brokenshire Date: Sun, 3 Jul 2016 13:08:15 +0000 (+0100) Subject: Added TEL to the SaveString function of ContactDataObject X-Git-Tag: release-0.14~21 X-Git-Url: http://Server1/repobrowser/?a=commitdiff_plain;h=622c4c58d84d8d0718aa5b32ff44d33f669c2c69;p=xestiaab%2F.git Added TEL to the SaveString function of ContactDataObject --- diff --git a/source/contacteditor/cdo/ContactDataObject-Save.cpp b/source/contacteditor/cdo/ContactDataObject-Save.cpp index 59b67ad..d14240b 100644 --- a/source/contacteditor/cdo/ContactDataObject-Save.cpp +++ b/source/contacteditor/cdo/ContactDataObject-Save.cpp @@ -373,10 +373,24 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){ &BusinessIMListPref, &BusinessIMListTokens, SaveData, "work"); - // TODO: Process TEL. - - + // Process TEL. + SaveTelephone(&GeneralTelephoneList, &GeneralTelephoneListAltID, + &GeneralTelephoneListPID, &GeneralTelephoneListType, + &GeneralTelephoneListTypeInfo, &GeneralTelephoneListDataType, + &GeneralTelephoneListPref, &GeneralTelephoneListTokens, + SaveData, ""); + SaveTelephone(&HomeTelephoneList, &HomeTelephoneListAltID, + &HomeTelephoneListPID, &HomeTelephoneListType, + &HomeTelephoneListTypeInfo, &HomeTelephoneListDataType, + &HomeTelephoneListPref, &HomeTelephoneListTokens, + SaveData, "home"); + SaveTelephone(&BusinessTelephoneList, &BusinessTelephoneListAltID, + &BusinessTelephoneListPID, &BusinessTelephoneListType, + &BusinessTelephoneListTypeInfo, &BusinessTelephoneListDataType, + &BusinessTelephoneListPref, &BusinessTelephoneListTokens, + SaveData, "work"); + // Process LANG. SaveLanguage(&GeneralLanguageList, &GeneralLanguageListAltID, @@ -1399,6 +1413,98 @@ void ContactDataObject::SaveIMPP(map *IMList, map } +void ContactDataObject::SaveTelephone(map *TelephoneList, map *TelephoneListAltID, + map *TelephoneListPID, map *TelephoneListType, + map *TelephoneListTypeInfo, map *TelephoneListDataType, + map *TelephoneListPref, map *TelephoneListTokens, + wxString *SaveData, wxString DataType){ + + wxString ProcessData = ""; + + for (std::map::iterator TelephoneIter = TelephoneList->begin(); + TelephoneIter != TelephoneList->end(); TelephoneIter++){ + + ProcessData.Append("TEL"); + + // Check if there is a value for TYPE. + + if (DataType.size() > 0 || (*TelephoneListAltID)[TelephoneIter->first].size() > 0){ + + ProcessData.Append(";TYPE=\""); + + bool ProcessedType = false; + + if (DataType.size() > 0){ + + ProcessData.Append(DataType); + ProcessedType = true; + + } + + if ((*TelephoneListAltID)[TelephoneIter->first].size() > 0){ + + if (ProcessedType == true){ + ProcessData.Append(","); + } + ProcessData.Append((*TelephoneListTypeInfo)[TelephoneIter->first]); + + } + + ProcessData.Append("\""); + + } + + // Check if there is a value for ALTID. + + if ((*TelephoneListAltID)[TelephoneIter->first].size() > 0){ + + ProcessData.Append(";ALTID="); + ProcessData.Append((*TelephoneListAltID)[TelephoneIter->first]); + + } + + // Check if there is a value for PID. + + if ((*TelephoneListPID)[TelephoneIter->first].size() > 0){ + + ProcessData.Append(";PID="); + ProcessData.Append((*TelephoneListPID)[TelephoneIter->first]); + + } + + // Check if there is a value for PREF. + + if ((*TelephoneListPref)[TelephoneIter->first] > 0){ + + ProcessData.Append(";PREF="); + ProcessData.Append(wxString::Format("%i", (*TelephoneListPref)[TelephoneIter->first])); + + } + + // Check if there is a value for tokens. + + if ((*TelephoneListTokens)[TelephoneIter->first].size() > 0){ + + ProcessData.Append(";"); + ProcessData.Append((*TelephoneListTokens)[TelephoneIter->first]); + + } + + ProcessData.Append(":"); + ProcessData.Append((*TelephoneListDataType)[TelephoneIter->first]); + ProcessData.Append(":"); + ProcessData.Append(TelephoneIter->second); + ProcessData.Append("\n"); + + ProcessData = OutputText(&ProcessData); + + SaveData->Append(ProcessData); + ProcessData.clear(); + + } + +} + void ContactDataObject::SaveLanguage(map *LanguageList, map *LanguageListAltID, map *LanguageListPID, map *LanguageListType, map *LangaugeListPref, map *LanguageListTokens, diff --git a/source/contacteditor/cdo/ContactDataObject.h b/source/contacteditor/cdo/ContactDataObject.h index df84a2a..5942425 100644 --- a/source/contacteditor/cdo/ContactDataObject.h +++ b/source/contacteditor/cdo/ContactDataObject.h @@ -132,9 +132,14 @@ class ContactDataObject{ wxString *SaveData, wxString DataType); void SaveIMPP(map *IMList, map *IMListAltID, map *IMListPID, map *IMListType, - map *IMListTypeInfo, map *IMListMediatype, + map *IMListTypeInfo, map *IMListDataType, map *IMListPref, map *IMListTokens, wxString *SaveData, wxString DataType); + void SaveTelephone(map *TelephoneList, map *TelephoneListAltID, + map *TelephoneListPID, map *TelephoneListType, + map *TelephoneListTypeInfo, map *TelephoneListMediatype, + map *TelephoneListPref, map *TelephoneListTokens, + wxString *SaveData, wxString DataType); void SaveLanguage(map *LanguageList, map *LanguageListAltID, map *LanguageListPID, map *LanguageListType, map *LangaugeListPref, map *LanguageListTokens, diff --git a/source/tests/xestiaab_contactsave.h b/source/tests/xestiaab_contactsave.h index f92659b..26b38e6 100644 --- a/source/tests/xestiaab_contactsave.h +++ b/source/tests/xestiaab_contactsave.h @@ -119,6 +119,9 @@ TEST(ContactSave, ContactSaveTests){ " :msn:moo.home@example.com\n" "IMPP;TYPE=work;ALTID=98;MEDIATYPE=text/superplain;PID=99;PREF=50;BUSINESS=Mon\n" " ey:xmpp:moo.business@example.com\n" + "TEL;TYPE=\"fax,cell\";ALTID=10;PID=20;PREF=40;WONDERFUL=Colour:tel:00000000\n" + "TEL;TYPE=\"home,fax\";ALTID=10;PID=20;PREF=40;BUSINESS=Money:tel:00001111\n" + "TEL;TYPE=\"work,voice\";ALTID=25;PID=50;PREF=75;BEEP=Boop:tel:22221111\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"