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

index 61acdc0..fbcfc1c 100644 (file)
@@ -297,6 +297,25 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){
                &BusinessEmailListPref, &BusinessEmailListTokens, 
                SaveData, "work");
 
                &BusinessEmailListPref, &BusinessEmailListTokens, 
                SaveData, "work");
 
+       // TODO: Process IMPP.
+       
+       // TODO: Process TEL.
+       
+       // Process LANG.
+       
+       SaveLanguage(&GeneralLanguageList, &GeneralLanguageListAltID, 
+               &GeneralLanguageListPID, &GeneralLanguageListType,
+               &GeneralLanguageListPref, &GeneralLanguageListTokens, 
+               SaveData, "");
+       SaveLanguage(&HomeLanguageList, &HomeLanguageListAltID, 
+               &HomeLanguageListPID, &HomeLanguageListType,
+               &HomeLanguageListPref, &HomeLanguageListTokens, 
+               SaveData, "home");
+       SaveLanguage(&BusinessLanguageList, &BusinessLanguageListAltID, 
+               &BusinessLanguageListPID, &BusinessLanguageListType,
+               &BusinessLanguageListPref, &BusinessLanguageListTokens, 
+               SaveData, "work");
+
        // Write the end part of the vCard data file.
        
        SaveData->Append("END:VCARD");
        // Write the end part of the vCard data file.
        
        SaveData->Append("END:VCARD");
@@ -826,4 +845,74 @@ void ContactDataObject::SaveEmail(map<int, wxString> *EmailList, map<int, wxStri
                        
        }
                
                        
        }
                
+}
+
+void ContactDataObject::SaveLanguage(map<int, wxString> *LanguageList, map<int, wxString> *LanguageListAltID, 
+       map<int, wxString> *LanguageListPID, map<int, wxString> *LanguageListType,
+       map<int, int> *LangaugeListPref, map<int, wxString> *LanguageListTokens, 
+       wxString *SaveData, wxString DataType){
+
+       wxString ProcessData = "";
+       
+       for (std::map<int, wxString>::iterator LanguageIter = LanguageList->begin();
+               LanguageIter != LanguageList->end(); LanguageIter++){
+
+               ProcessData.Append("LANG");
+                       
+               // 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 ((*LanguageListAltID)[LanguageIter->first].size() > 0){
+               
+                       ProcessData.Append(";ALTID=");
+                       ProcessData.Append((*LanguageListAltID)[LanguageIter->first]);
+                       
+               }
+               
+               // Check if there is a value for PID.
+
+               if ((*LanguageListPID)[LanguageIter->first].size() > 0){
+               
+                       ProcessData.Append(";PID=");
+                       ProcessData.Append((*LanguageListPID)[LanguageIter->first]);
+                       
+               }
+
+               // Check if there is a value for PREF.
+
+               if ((*LangaugeListPref)[LanguageIter->first] > 0){
+               
+                       ProcessData.Append(";PREF=");
+                       ProcessData.Append(wxString::Format("%i", (*LangaugeListPref)[LanguageIter->first]));
+                       
+               }
+
+               // Check if there is a value for tokens.
+
+               if ((*LanguageListTokens)[LanguageIter->first].size() > 0){
+               
+                       ProcessData.Append(";");
+                       ProcessData.Append((*LanguageListTokens)[LanguageIter->first]);
+                       
+               }
+                       
+               ProcessData.Append(":");
+               ProcessData.Append(LanguageIter->second);
+               ProcessData.Append("\n");
+
+               ProcessData = OutputText(&ProcessData);
+                       
+               SaveData->Append(ProcessData);
+               ProcessData.clear();
+                       
+       }
+               
 }
\ No newline at end of file
 }
\ No newline at end of file
index 99b8fc9..5cc94c9 100644 (file)
@@ -126,6 +126,10 @@ class ContactDataObject{
                map<int, wxString> *EmailListPID, map<int, wxString> *EmailListType,
                map<int, int> *EmailListPref, map<int, wxString> *EmailListTokens, 
                wxString *SaveData, wxString DataType);
                map<int, wxString> *EmailListPID, map<int, wxString> *EmailListType,
                map<int, int> *EmailListPref, map<int, wxString> *EmailListTokens, 
                wxString *SaveData, wxString DataType);
+       void SaveLanguage(map<int, wxString> *LanguageList, map<int, wxString> *LanguageListAltID, 
+               map<int, wxString> *LanguageListPID, map<int, wxString> *LanguageListType,
+               map<int, int> *LangaugeListPref, map<int, wxString> *LanguageListTokens, 
+               wxString *SaveData, wxString DataType);
 
        public:
 
 
        public:
 
index 30d4960..baf9441 100644 (file)
@@ -110,6 +110,9 @@ TEST(ContactSave, ContactSaveTests){
        "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"
        "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"
+       "LANG;ALTID=20;PID=40;PREF=80;GELFORN=Great:kw\n"
+       "LANG;TYPE=home;ALTID=22;PID=45;PREF=90;LANGUAGE=yes:en\n"
+       "LANG;TYPE=work;ALTID=10;PID=15;PREF=20;FFENSTRI=ie:cy\n"
        "END:VCARD";
 
        ASSERT_EQ(CONTACTLOAD_OK, TestFile3.LoadFile("LoadCheck-Load4.vcf"));
        "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