From ee7d19886f132bfc0fb391677234e534ef3a7643 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sat, 2 Jul 2016 17:13:38 +0100 Subject: [PATCH] Added PHOTO to the SaveString function of ContactDataObject --- .../cdo/ContactDataObject-Save.cpp | 96 +++++++++++++++++++ source/contacteditor/cdo/ContactDataObject.h | 5 + source/tests/xestiaab_contactsave.h | 9 ++ 3 files changed, 110 insertions(+) diff --git a/source/contacteditor/cdo/ContactDataObject-Save.cpp b/source/contacteditor/cdo/ContactDataObject-Save.cpp index 2334177..82b0c11 100644 --- a/source/contacteditor/cdo/ContactDataObject-Save.cpp +++ b/source/contacteditor/cdo/ContactDataObject-Save.cpp @@ -567,6 +567,18 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){ &CategoriesListType, &CategoriesListPref, &CategoriesListTokens, SaveData); + // Process PHOTO. + + SavePhoto(&PicturesList, &PicturesListAltID, + &PicturesListPID, &PicturesListType, + &PicturesListPicEncType, &PicturesListPictureType, + &PicturesListMediatype, &PicturesListPref, + &PicturesListTokens, SaveData); + + // Process LOGO. + + // Process SOUND. + // Write the end part of the vCard data file. SaveData->Append("END:VCARD"); @@ -1655,4 +1667,88 @@ void ContactDataObject::SaveCategory(map *CategoryList, map *PicturesList, map *PicturesListAltID, + map *PicturesListPID, map *PicturesListType, + map *PicturesListPicEncType, map *PicturesListPictureType, + map *PicturesListMediatype, map *PicturesListPref, + map *PicturesListTokens, wxString *SaveData){ + + wxString ProcessData = ""; + + for (std::map::iterator PicturesIter = PicturesList->begin(); + PicturesIter != PicturesList->end(); PicturesIter++){ + + ProcessData.Append("PHOTO"); + + // Check if there is a value for TYPE. + + if ((*PicturesListType)[PicturesIter->first].size() > 0){ + + ProcessData.Append(";TYPE="); + ProcessData.Append((*PicturesListType)[PicturesIter->first]); + + } + + // Check if there is a value for ALTID. + + if ((*PicturesListAltID)[PicturesIter->first].size() > 0){ + + ProcessData.Append(";ALTID="); + ProcessData.Append((*PicturesListAltID)[PicturesIter->first]); + + } + + // Check if there is a value for MEDIATYPE.. + + if ((*PicturesListMediatype)[PicturesIter->first].size() > 0){ + + ProcessData.Append(";MEDIATYPE="); + ProcessData.Append((*PicturesListMediatype)[PicturesIter->first]); + + } + + // Check if there is a value for PID. + + if ((*PicturesListPID)[PicturesIter->first].size() > 0){ + + ProcessData.Append(";PID="); + ProcessData.Append((*PicturesListPID)[PicturesIter->first]); + + } + + // Check if there is a value for PREF. + + if ((*PicturesListPref)[PicturesIter->first] > 0){ + + ProcessData.Append(";PREF="); + ProcessData.Append(wxString::Format("%i", (*PicturesListPref)[PicturesIter->first])); + + } + + // Check if there is a value for tokens. + + if ((*PicturesListTokens)[PicturesIter->first].size() > 0){ + + ProcessData.Append(";"); + ProcessData.Append((*PicturesListTokens)[PicturesIter->first]); + + } + + ProcessData.Append(":data:"); + ProcessData.Append((*PicturesListPictureType)[PicturesIter->first]); + ProcessData.Append(";"); + ProcessData.Append((*PicturesListPicEncType)[PicturesIter->first]); + ProcessData.Append(","); + ProcessData.Append(PicturesIter->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 a7f4939..a0cf5d5 100644 --- a/source/contacteditor/cdo/ContactDataObject.h +++ b/source/contacteditor/cdo/ContactDataObject.h @@ -156,6 +156,11 @@ class ContactDataObject{ map *CategoryListAltID, map *CategoryListPID, map *CategoryListType, map *CategoryListPref, map *CategoryListTokens, wxString *SaveData); + void SavePhoto(map *PicturesList, map *PicturesListAltID, + map *PicturesListPID, map *PicturesListType, + map *PicturesListPicEncType, map *PicturesListPictureType, + map *PicturesListMediatype, map *PicturesListPref, + map *PicturesListTokens, wxString *SaveData); public: diff --git a/source/tests/xestiaab_contactsave.h b/source/tests/xestiaab_contactsave.h index d07aabf..0547eb2 100644 --- a/source/tests/xestiaab_contactsave.h +++ b/source/tests/xestiaab_contactsave.h @@ -151,6 +151,15 @@ TEST(ContactSave, ContactSaveTests){ "CATEGORIES;TYPE=work;ALTID=84;LANGUAGE=kw;PID=86;PREF=88;AAA=BBB:Category Fiv\n" " e\n" "CATEGORIES;TYPE=work;ALTID=84;LANGUAGE=kw;PID=86;PREF=88;AAA=BBB:Category Six\n" + "PHOTO;ALTID=70;MEDIATYPE=image/png;PID=71;PREF=72;MEEP=MOO:data:image/png;bas\n" + " e64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAKCAIAAADdHiL1AAAAJUlEQVQoz2NkwAb+//8PYTAy\n" + " MmLKMjGQDuilhxHudBrbM8zCDQCxHQkPeaUvawAAAABJRU5ErkJggg==\n" + "PHOTO;TYPE=home;ALTID=20;MEDIATYPE=image/png;PID=21;PREF=22;BEEP=BOOP:data:im\n" + " age/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAKCAIAAADdHiL1AAAAHklEQVQoz2NkY\n" + " PjPgAr+owkwMqIpYGIgHYzqGdx6AAKNAxMN5P6+AAAAAElFTkSuQmCC\n" + "PHOTO;TYPE=work;ALTID=90;MEDIATYPE=image/png;PID=91;PREF=92;PHOTO=YUP:data:im\n" + " age/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAKCAIAAADdHiL1AAAAIElEQVQoz2MUm\n" + " 53EgApepsxF4XfaoylgYiAdjOoZ3HoAeuQD2WdxRzcAAAAASUVORK5CYII=\n" "END:VCARD"; ASSERT_EQ(CONTACTLOAD_OK, TestFile3.LoadFile("LoadCheck-Load4.vcf")); -- 2.39.5