From 5a8405c8cebb102a025510b3df0cb84f3e63b283 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 3 Jul 2016 12:08:52 +0100 Subject: [PATCH] Added IMPP to the SaveString function of ContactDataObject --- .../cdo/ContactDataObject-Save.cpp | 102 +++++++++++++++++- source/contacteditor/cdo/ContactDataObject.h | 5 + source/tests/xestiaab_contactsave.h | 6 ++ 3 files changed, 110 insertions(+), 3 deletions(-) diff --git a/source/contacteditor/cdo/ContactDataObject-Save.cpp b/source/contacteditor/cdo/ContactDataObject-Save.cpp index 9e14252..59b67ad 100644 --- a/source/contacteditor/cdo/ContactDataObject-Save.cpp +++ b/source/contacteditor/cdo/ContactDataObject-Save.cpp @@ -355,10 +355,24 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){ &BusinessEmailListPref, &BusinessEmailListTokens, SaveData, "work"); - // TODO: Process IMPP. - - + // Process IMPP. + SaveIMPP(&GeneralIMList, &GeneralIMListAltID, + &GeneralIMListPID, &GeneralIMListType, + &GeneralIMListTypeInfo, &GeneralIMListMediatype, + &GeneralIMListPref, &GeneralIMListTokens, + SaveData, ""); + SaveIMPP(&HomeIMList, &HomeIMListAltID, + &HomeIMListPID, &HomeIMListType, + &HomeIMListTypeInfo, &HomeIMListMediatype, + &HomeIMListPref, &HomeIMListTokens, + SaveData, "home"); + SaveIMPP(&BusinessIMList, &BusinessIMListAltID, + &BusinessIMListPID, &BusinessIMListType, + &BusinessIMListTypeInfo, &BusinessIMListMediatype, + &BusinessIMListPref, &BusinessIMListTokens, + SaveData, "work"); + // TODO: Process TEL. @@ -1303,6 +1317,88 @@ void ContactDataObject::SaveEmail(map *EmailList, map *IMList, map *IMListAltID, + map *IMListPID, map *IMListType, + map *IMListTypeInfo, map *IMListMediatype, + map *IMListPref, map *IMListTokens, + wxString *SaveData, wxString DataType){ + + wxString ProcessData = ""; + + for (std::map::iterator IMIter = IMList->begin(); + IMIter != IMList->end(); IMIter++){ + + ProcessData.Append("IMPP"); + + // 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 ((*IMListAltID)[IMIter->first].size() > 0){ + + ProcessData.Append(";ALTID="); + ProcessData.Append((*IMListAltID)[IMIter->first]); + + } + + // Check if there is a value for MEDIATYPE. + + if ((*IMListMediatype)[IMIter->first].size() > 0){ + + ProcessData.Append(";MEDIATYPE="); + ProcessData.Append((*IMListMediatype)[IMIter->first]); + + } + + // Check if there is a value for PID. + + if ((*IMListPID)[IMIter->first].size() > 0){ + + ProcessData.Append(";PID="); + ProcessData.Append((*IMListPID)[IMIter->first]); + + } + + // Check if there is a value for PREF. + + if ((*IMListPref)[IMIter->first] > 0){ + + ProcessData.Append(";PREF="); + ProcessData.Append(wxString::Format("%i", (*IMListPref)[IMIter->first])); + + } + + // Check if there is a value for tokens. + + if ((*IMListTokens)[IMIter->first].size() > 0){ + + ProcessData.Append(";"); + ProcessData.Append((*IMListTokens)[IMIter->first]); + + } + + ProcessData.Append(":"); + ProcessData.Append((*IMListTypeInfo)[IMIter->first]); + ProcessData.Append(":"); + ProcessData.Append(IMIter->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 b6ef1ba..df84a2a 100644 --- a/source/contacteditor/cdo/ContactDataObject.h +++ b/source/contacteditor/cdo/ContactDataObject.h @@ -130,6 +130,11 @@ class ContactDataObject{ map *EmailListPID, map *EmailListType, map *EmailListPref, map *EmailListTokens, wxString *SaveData, wxString DataType); + void SaveIMPP(map *IMList, map *IMListAltID, + map *IMListPID, map *IMListType, + map *IMListTypeInfo, map *IMListMediatype, + map *IMListPref, map *IMListTokens, + 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 8afffd6..f92659b 100644 --- a/source/tests/xestiaab_contactsave.h +++ b/source/tests/xestiaab_contactsave.h @@ -113,6 +113,12 @@ 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" + "IMPP;ALTID=10;MEDIATYPE=text/plain;PID=20;PREF=40;WONDERFUL=Colour:skype:moo@\n" + " example.com\n" + "IMPP;TYPE=home;ALTID=20;MEDIATYPE=text/reallyplain;PID=40;PREF=80;PEACE=quiet\n" + " :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" "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" -- 2.39.5