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

index c8a394a..61acdc0 100644 (file)
@@ -282,6 +282,21 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){
                &BusinessAddressListMediatype, &BusinessAddressListPref,
                &BusinessAddressListTokens, SaveData, "work");
 
+       // Process EMAIL.
+       
+       SaveEmail(&GeneralEmailList, &GeneralEmailListAltID, 
+               &GeneralEmailListPID, &GeneralEmailListType,
+               &GeneralEmailListPref, &GeneralEmailListTokens, 
+               SaveData, "");
+       SaveEmail(&HomeEmailList, &HomeEmailListAltID, 
+               &HomeEmailListPID, &HomeEmailListType,
+               &HomeEmailListPref, &HomeEmailListTokens, 
+               SaveData, "home");
+       SaveEmail(&BusinessEmailList, &BusinessEmailListAltID, 
+               &BusinessEmailListPID, &BusinessEmailListType,
+               &BusinessEmailListPref, &BusinessEmailListTokens, 
+               SaveData, "work");
+
        // Write the end part of the vCard data file.
        
        SaveData->Append("END:VCARD");
@@ -741,4 +756,74 @@ void ContactDataObject::SaveAddress(map<int, wxString> *AddressList, map<int, wx
                        
        }
                        
+}
+
+void ContactDataObject::SaveEmail(map<int, wxString> *EmailList, map<int, wxString> *EmailListAltID, 
+       map<int, wxString> *EmailListPID, map<int, wxString> *EmailListType,
+       map<int, int> *EmailListPref, map<int, wxString> *EmailListTokens, 
+       wxString *SaveData, wxString DataType){
+
+       wxString ProcessData = "";
+       
+       for (std::map<int, wxString>::iterator EmailIter = EmailList->begin();
+               EmailIter != EmailList->end(); EmailIter++){
+
+               ProcessData.Append("EMAIL");
+                       
+               // 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 ((*EmailListAltID)[EmailIter->first].size() > 0){
+               
+                       ProcessData.Append(";ALTID=");
+                       ProcessData.Append((*EmailListAltID)[EmailIter->first]);
+                       
+               }
+               
+               // Check if there is a value for PID.
+
+               if ((*EmailListPID)[EmailIter->first].size() > 0){
+               
+                       ProcessData.Append(";PID=");
+                       ProcessData.Append((*EmailListPID)[EmailIter->first]);
+                       
+               }
+
+               // Check if there is a value for PREF.
+
+               if ((*EmailListPref)[EmailIter->first] > 0){
+               
+                       ProcessData.Append(";PREF=");
+                       ProcessData.Append(wxString::Format("%i", (*EmailListPref)[EmailIter->first]));
+                       
+               }
+
+               // Check if there is a value for tokens.
+
+               if ((*EmailListTokens)[EmailIter->first].size() > 0){
+               
+                       ProcessData.Append(";");
+                       ProcessData.Append((*EmailListTokens)[EmailIter->first]);
+                       
+               }
+                       
+               ProcessData.Append(":");
+               ProcessData.Append(EmailIter->second);
+               ProcessData.Append("\n");
+
+               ProcessData = OutputText(&ProcessData);
+                       
+               SaveData->Append(ProcessData);
+               ProcessData.clear();
+                       
+       }
+               
 }
\ No newline at end of file
index f12c17a..99b8fc9 100644 (file)
@@ -122,6 +122,10 @@ class ContactDataObject{
                map<int, wxString> *AddressListTimezone, map<int, wxString> *AddressListType, 
                map<int, wxString> *AddressListMediatype, map<int, int> *AddressListPref, 
                map<int, wxString> *AddressListTokens, wxString *SaveData, wxString DataType);
+       void SaveEmail(map<int, wxString> *EmailList, map<int, wxString> *EmailListAltID, 
+               map<int, wxString> *EmailListPID, map<int, wxString> *EmailListType,
+               map<int, int> *EmailListPref, map<int, wxString> *EmailListTokens, 
+               wxString *SaveData, wxString DataType);
 
        public:
 
index 5afdb83..30d4960 100644 (file)
@@ -107,6 +107,9 @@ TEST(ContactSave, ContactSaveTests){
        " 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"
+       "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"
        "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