Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added ADR to the SaveString function of ContactDataObject
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Wed, 29 Jun 2016 17:02:09 +0000 (18:02 +0100)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Wed, 29 Jun 2016 17:02:09 +0000 (18:02 +0100)
source/contacteditor/cdo/ContactDataObject-Save.cpp
source/contacteditor/cdo/ContactDataObject.h
source/tests/xestiaab_contactsave.h

index 5fbc386..c8a394a 100644 (file)
@@ -255,6 +255,33 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){
                &BusinessTZListMediatype, &BusinessTZListPref, 
                &BusinessTZListTokens, SaveData, "work");
 
+       // Process ADR.
+       
+       SaveAddress(&GeneralAddressList, &GeneralAddressListTown,
+               &GeneralAddressListCounty, &GeneralAddressListPostCode,
+               &GeneralAddressListCountry, &GeneralAddressListLabel,
+               &GeneralAddressListLang, &GeneralAddressListAltID,
+               &GeneralAddressListPID, &GeneralAddressListGeo, 
+               &GeneralAddressListTimezone, &GeneralAddressListType, 
+               &GeneralAddressListMediatype, &GeneralAddressListPref,
+               &GeneralAddressListTokens, SaveData, "");
+       SaveAddress(&HomeAddressList, &HomeAddressListTown,
+               &HomeAddressListCounty, &HomeAddressListPostCode,
+               &HomeAddressListCountry, &HomeAddressListLabel,
+               &HomeAddressListLang, &HomeAddressListAltID,
+               &HomeAddressListPID, &HomeAddressListGeo, 
+               &HomeAddressListTimezone, &HomeAddressListType, 
+               &HomeAddressListMediatype, &HomeAddressListPref,
+               &HomeAddressListTokens, SaveData, "home");
+       SaveAddress(&BusinessAddressList, &BusinessAddressListTown,
+               &BusinessAddressListCounty, &BusinessAddressListPostCode,
+               &BusinessAddressListCountry, &BusinessAddressListLabel,
+               &BusinessAddressListLang, &BusinessAddressListAltID,
+               &BusinessAddressListPID, &BusinessAddressListGeo, 
+               &BusinessAddressListTimezone, &BusinessAddressListType, 
+               &BusinessAddressListMediatype, &BusinessAddressListPref,
+               &BusinessAddressListTokens, SaveData, "work");
+
        // Write the end part of the vCard data file.
        
        SaveData->Append("END:VCARD");
@@ -579,4 +606,139 @@ void ContactDataObject::SaveTimezone(map<int, wxString> *TZList, map<int, wxStri
                        
        }
                
+}
+
+void ContactDataObject::SaveAddress(map<int, wxString> *AddressList, map<int, wxString> *AddressListTown,
+               map<int, wxString> *AddressListCounty, map<int, wxString> *AddressListPostCode,
+               map<int, wxString> *AddressListCountry, map<int, wxString> *AddressListLabel,
+               map<int, wxString> *AddressListLang, map<int, wxString> *AddressListAltID,
+               map<int, wxString> *AddressListPID, map<int, wxString> *AddressListGeo, 
+               map<int, wxString> *AddressListTimezone, map<int, wxString> *AddressListType, 
+               map<int, wxString> *AddressListMediatype, map<int, int> *AddressListPref, 
+               map<int, wxString> *AddressListTokens, wxString *SaveData, wxString DataType){
+
+       wxString ProcessData = "";
+                       
+       for (std::map<int, wxString>::iterator AddressIter = AddressList->begin();
+               AddressIter != AddressList->end(); AddressIter++){
+                       
+               ProcessData.Append("ADR");
+                       
+               // 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 ((*AddressListAltID)[AddressIter->first].size() > 0){
+               
+                       ProcessData.Append(";ALTID=");
+                       ProcessData.Append((*AddressListAltID)[AddressIter->first]);
+                       
+               }
+
+               // Check if there is a value for GEO.
+               
+               if ((*AddressListGeo)[AddressIter->first].size() > 0){
+               
+                       ProcessData.Append(";GEO=\"");
+                       ProcessData.Append((*AddressListGeo)[AddressIter->first]);
+                       ProcessData.Append("\"");
+                       
+               }
+
+               // Check if there is a value for LABEL.
+
+               if ((*AddressListLabel)[AddressIter->first].size() > 0){
+               
+                       wxString AddressProcessed = "";
+                       AddressProcessed = (*AddressListLabel)[AddressIter->first];
+                       
+                       AddressProcessed.Replace("\n", "\\n", true);
+                       
+                       ProcessData.Append(";LABEL=");
+                       ProcessData.Append(AddressProcessed);
+                       
+               }
+               
+               // Check if there is a value for LANGUAGE.
+               
+               if ((*AddressListLang)[AddressIter->first].size() > 0){
+               
+                       ProcessData.Append(";LANGUAGE=");
+                       ProcessData.Append((*AddressListLang)[AddressIter->first]);
+                       
+               }
+               
+               // Check if there is a value for MEDIATYPE.
+               
+               if ((*AddressListMediatype)[AddressIter->first].size() > 0){
+               
+                       ProcessData.Append(";MEDIATYPE=");
+                       ProcessData.Append((*AddressListMediatype)[AddressIter->first]);
+                       
+               }
+               
+               // Check if there is a value for PID.
+
+               if ((*AddressListPID)[AddressIter->first].size() > 0){
+               
+                       ProcessData.Append(";PID=");
+                       ProcessData.Append((*AddressListPID)[AddressIter->first]);
+                       
+               }
+
+               // Check if there is a value for PREF.
+
+               if ((*AddressListPref)[AddressIter->first] > 0){
+               
+                       ProcessData.Append(";PREF=");
+                       ProcessData.Append(wxString::Format("%i", (*AddressListPref)[AddressIter->first]));
+                       
+               }
+
+               // Check if there is a value for TZ.
+
+               if ((*AddressListTimezone)[AddressIter->first].size() > 0){
+               
+                       ProcessData.Append(";TZ=");
+                       ProcessData.Append((*AddressListTimezone)[AddressIter->first]);
+                       
+               }
+               
+               // Check if there is a value for tokens.
+
+               if ((*AddressListTokens)[AddressIter->first].size() > 0){
+               
+                       ProcessData.Append(";");
+                       ProcessData.Append((*AddressListTokens)[AddressIter->first]);
+                       
+               }
+               
+               // Build the address.
+               
+               ProcessData.Append(":;;");
+               ProcessData.Append((*AddressList)[AddressIter->first]);
+               ProcessData.Append(";");
+               ProcessData.Append((*AddressListTown)[AddressIter->first]);
+               ProcessData.Append(";");
+               ProcessData.Append((*AddressListCounty)[AddressIter->first]);
+               ProcessData.Append(";");
+               ProcessData.Append((*AddressListPostCode)[AddressIter->first]);
+               ProcessData.Append(";");
+               ProcessData.Append((*AddressListCountry)[AddressIter->first]);
+               ProcessData.Append("\n");
+               
+               ProcessData = OutputText(&ProcessData);
+                       
+               SaveData->Append(ProcessData);
+               ProcessData.clear();
+                       
+       }
+                       
 }
\ No newline at end of file
index 3fa2658..f12c17a 100644 (file)
@@ -114,6 +114,14 @@ class ContactDataObject{
                map<int, wxString> *TZListPID, map<int, wxString> *TZListType,
                map<int, wxString> *TZListMediatype, map<int, int> *TZListPref, 
                map<int, wxString> *TZListTokens, wxString *SaveData, wxString DataType);
+       void SaveAddress(map<int, wxString> *AddressList, map<int, wxString> *AddressListTown,
+               map<int, wxString> *AddressListCounty, map<int, wxString> *AddressListPostCode,
+               map<int, wxString> *AddressListCountry, map<int, wxString> *AddressListLabel,
+               map<int, wxString> *AddressListLang, map<int, wxString> *AddressListAltID,
+               map<int, wxString> *AddressListPID, map<int, wxString> *AddressListGeo, 
+               map<int, wxString> *AddressListTimezone, map<int, wxString> *AddressListType, 
+               map<int, wxString> *AddressListMediatype, map<int, int> *AddressListPref, 
+               map<int, wxString> *AddressListTokens, wxString *SaveData, wxString DataType);
 
        public:
 
index 8420e63..5afdb83 100644 (file)
@@ -95,6 +95,18 @@ TEST(ContactSave, ContactSaveTests){
        " nzance\n"
        "TZ;TYPE=work;ALTID=45;MEDIATYPE=text/plain;PID=70;PREF=80;MAYBE=yes:Europe/St\n"
        "  Austell\n"
+       "ADR;ALTID=15;GEO=\"geo:1.0, 1.0\";LABEL=\"1 Lovely Lane\\nRodney\\nCornwall\\nPL99 \n"
+       " 1AA\\nCornwall\\nUnited Kingdom\";LANGUAGE=kw;MEDIATYPE=text/plain;PID=81;PREF=\n"
+       " 98;TZ=Europe/Truro;MAKES=Moo;ANIMAL=Cow:;;1 Lovely Lane;Rodney;Cornwall;PL99\n"
+       "  1AA;United Kingdom\n"
+       "ADR;TYPE=home;ALTID=40;GEO=\"geo:4.0, 4.0\";LABEL=\"3 Working Plaice\\nRoger\\nCor\n"
+       " nwall\\nPL75 4ZZ\\nCornwall\\nUnited Kingdom\";LANGUAGE=en;MEDIATYPE=text/plain;\n"
+       " PID=13;PREF=10;TZ=Europe/St Ives;TOAST=Butter:;;3 Working Plaice;Roger;Cornw\n"
+       " all;PL75 4ZZ;United Kingdom\n"
+       "ADR;TYPE=work;ALTID=45;GEO=\"geo:7.0, 7.0\";LABEL=\"7 Flyby Drive\\nElaine\\nCornw\n"
+       " all\\nPL84 9YE\\nCornwall\\nUnited Kingdom\";LANGUAGE=en-GB;MEDIATYPE=text/plain\n"
+       " ;PID=28;PREF=10;TZ=Europe/Newquay;JAM=Red:;;7 Flyby Drive;Elaine;Cornwall;PL\n"
+       " 84 9YE;United Kingdom\n"
        "END:VCARD";
 
        ASSERT_EQ(CONTACTLOAD_OK, TestFile3.LoadFile("LoadCheck-Load4.vcf"));
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy