Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added ADR to the SaveString function of ContactDataObject
[xestiaab/.git] / source / contacteditor / cdo / ContactDataObject-Save.cpp
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
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