From 8b388e04b48d97072d2efabdd08fa72c7e30ce9c Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sat, 2 Jul 2016 18:04:58 +0100 Subject: [PATCH] Added LOGO to the SaveString function of ContactDataObject --- .../cdo/ContactDataObject-Save.cpp | 90 +++++++++++++++++++ source/contacteditor/cdo/ContactDataObject.h | 5 ++ source/tests/xestiaab_contactsave.h | 9 ++ 3 files changed, 104 insertions(+) diff --git a/source/contacteditor/cdo/ContactDataObject-Save.cpp b/source/contacteditor/cdo/ContactDataObject-Save.cpp index 82b0c11..7fdb87c 100644 --- a/source/contacteditor/cdo/ContactDataObject-Save.cpp +++ b/source/contacteditor/cdo/ContactDataObject-Save.cpp @@ -577,6 +577,12 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){ // Process LOGO. + SaveLogo(&LogosList, &LogosListAltID, + &LogosListPID, &LogosListType, + &LogosListPicEncType, &LogosListPictureType, + &LogosListMediatype, &LogosListPref, + &LogosListTokens, SaveData); + // Process SOUND. // Write the end part of the vCard data file. @@ -1751,4 +1757,88 @@ void ContactDataObject::SavePhoto(map *PicturesList, map *LogosList, map *LogosListAltID, + map *LogosListPID, map *LogosListType, + map *LogosListPicEncType, map *LogosListPictureType, + map *LogosListMediatype, map *LogosListPref, + map *LogosListTokens, wxString *SaveData){ + + wxString ProcessData = ""; + + for (std::map::iterator LogosIter = LogosList->begin(); + LogosIter != LogosList->end(); LogosIter++){ + + ProcessData.Append("LOGO"); + + // Check if there is a value for TYPE. + + if ((*LogosListType)[LogosIter->first].size() > 0){ + + ProcessData.Append(";TYPE="); + ProcessData.Append((*LogosListType)[LogosIter->first]); + + } + + // Check if there is a value for ALTID. + + if ((*LogosListAltID)[LogosIter->first].size() > 0){ + + ProcessData.Append(";ALTID="); + ProcessData.Append((*LogosListAltID)[LogosIter->first]); + + } + + // Check if there is a value for MEDIATYPE.. + + if ((*LogosListMediatype)[LogosIter->first].size() > 0){ + + ProcessData.Append(";MEDIATYPE="); + ProcessData.Append((*LogosListMediatype)[LogosIter->first]); + + } + + // Check if there is a value for PID. + + if ((*LogosListPID)[LogosIter->first].size() > 0){ + + ProcessData.Append(";PID="); + ProcessData.Append((*LogosListPID)[LogosIter->first]); + + } + + // Check if there is a value for PREF. + + if ((*LogosListPref)[LogosIter->first] > 0){ + + ProcessData.Append(";PREF="); + ProcessData.Append(wxString::Format("%i", (*LogosListPref)[LogosIter->first])); + + } + + // Check if there is a value for tokens. + + if ((*LogosListTokens)[LogosIter->first].size() > 0){ + + ProcessData.Append(";"); + ProcessData.Append((*LogosListTokens)[LogosIter->first]); + + } + + ProcessData.Append(":data:"); + ProcessData.Append((*LogosListPictureType)[LogosIter->first]); + ProcessData.Append(";"); + ProcessData.Append((*LogosListPicEncType)[LogosIter->first]); + ProcessData.Append(","); + ProcessData.Append(LogosIter->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 a0cf5d5..66d7976 100644 --- a/source/contacteditor/cdo/ContactDataObject.h +++ b/source/contacteditor/cdo/ContactDataObject.h @@ -161,6 +161,11 @@ class ContactDataObject{ map *PicturesListPicEncType, map *PicturesListPictureType, map *PicturesListMediatype, map *PicturesListPref, map *PicturesListTokens, wxString *SaveData); + void SaveLogo(map *LogosList, map *LogosListAltID, + map *LogosListPID, map *LogosListType, + map *LogosListPicEncType, map *LogosListPictureType, + map *LogosListMediatype, map *LogosListPref, + map *LogosListTokens, wxString *SaveData); public: diff --git a/source/tests/xestiaab_contactsave.h b/source/tests/xestiaab_contactsave.h index 0547eb2..7a3fb37 100644 --- a/source/tests/xestiaab_contactsave.h +++ b/source/tests/xestiaab_contactsave.h @@ -160,6 +160,15 @@ TEST(ContactSave, ContactSaveTests){ "PHOTO;TYPE=work;ALTID=90;MEDIATYPE=image/png;PID=91;PREF=92;PHOTO=YUP:data:im\n" " age/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAKCAIAAADdHiL1AAAAIElEQVQoz2MUm\n" " 53EgApepsxF4XfaoylgYiAdjOoZ3HoAeuQD2WdxRzcAAAAASUVORK5CYII=\n" + "LOGO;ALTID=70;MEDIATYPE=image/png;PID=71;PREF=72;MEEP=MOO:data:image/png;base\n" + " 64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAKCAIAAADdHiL1AAAAJUlEQVQoz2NkwAb+//8PYTAyM\n" + " mLKMjGQDuilhxHudBrbM8zCDQCxHQkPeaUvawAAAABJRU5ErkJggg==\n" + "LOGO;TYPE=home;ALTID=20;MEDIATYPE=image/png;PID=21;PREF=22;BEEP=BOOP:data:ima\n" + " ge/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAKCAIAAADdHiL1AAAAHklEQVQoz2NkYP\n" + " jPgAr+owkwMqIpYGIgHYzqGdx6AAKNAxMN5P6+AAAAAElFTkSuQmCC\n" + "LOGO;TYPE=work;ALTID=90;MEDIATYPE=image/png;PID=91;PREF=92;LOGO=YUP:data:imag\n" + " e/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAKCAIAAADdHiL1AAAAIElEQVQoz2MUm53\n" + " EgApepsxF4XfaoylgYiAdjOoZ3HoAeuQD2WdxRzcAAAAASUVORK5CYII=\n" "END:VCARD"; ASSERT_EQ(CONTACTLOAD_OK, TestFile3.LoadFile("LoadCheck-Load4.vcf")); -- 2.39.5