Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added TEL to the SaveString function of ContactDataObject
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 3 Jul 2016 13:08:15 +0000 (14:08 +0100)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 3 Jul 2016 13:08:15 +0000 (14:08 +0100)
source/contacteditor/cdo/ContactDataObject-Save.cpp
source/contacteditor/cdo/ContactDataObject.h
source/tests/xestiaab_contactsave.h

index 59b67ad..d14240b 100644 (file)
@@ -373,10 +373,24 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){
                &BusinessIMListPref, &BusinessIMListTokens,
                SaveData, "work");
 
-       // TODO: Process TEL.
-       
-       
+       // Process TEL.
        
+       SaveTelephone(&GeneralTelephoneList, &GeneralTelephoneListAltID, 
+               &GeneralTelephoneListPID, &GeneralTelephoneListType,
+               &GeneralTelephoneListTypeInfo, &GeneralTelephoneListDataType, 
+               &GeneralTelephoneListPref, &GeneralTelephoneListTokens, 
+               SaveData, "");
+       SaveTelephone(&HomeTelephoneList, &HomeTelephoneListAltID, 
+               &HomeTelephoneListPID, &HomeTelephoneListType,
+               &HomeTelephoneListTypeInfo, &HomeTelephoneListDataType, 
+               &HomeTelephoneListPref, &HomeTelephoneListTokens, 
+               SaveData, "home");
+       SaveTelephone(&BusinessTelephoneList, &BusinessTelephoneListAltID, 
+               &BusinessTelephoneListPID, &BusinessTelephoneListType,
+               &BusinessTelephoneListTypeInfo, &BusinessTelephoneListDataType, 
+               &BusinessTelephoneListPref, &BusinessTelephoneListTokens, 
+               SaveData, "work");
+
        // Process LANG.
        
        SaveLanguage(&GeneralLanguageList, &GeneralLanguageListAltID, 
@@ -1399,6 +1413,98 @@ void ContactDataObject::SaveIMPP(map<int, wxString> *IMList, map<int, wxString>
                
 }
 
+void ContactDataObject::SaveTelephone(map<int, wxString> *TelephoneList, map<int, wxString> *TelephoneListAltID, 
+       map<int, wxString> *TelephoneListPID, map<int, wxString> *TelephoneListType,
+       map<int, wxString> *TelephoneListTypeInfo, map<int, wxString> *TelephoneListDataType, 
+       map<int, int> *TelephoneListPref, map<int, wxString> *TelephoneListTokens, 
+       wxString *SaveData, wxString DataType){
+
+       wxString ProcessData = "";
+       
+       for (std::map<int, wxString>::iterator TelephoneIter = TelephoneList->begin();
+               TelephoneIter != TelephoneList->end(); TelephoneIter++){
+
+               ProcessData.Append("TEL");
+                       
+               // Check if there is a value for TYPE.
+
+               if (DataType.size() > 0 || (*TelephoneListAltID)[TelephoneIter->first].size() > 0){
+
+                       ProcessData.Append(";TYPE=\"");
+                       
+                       bool ProcessedType = false;
+                       
+                       if (DataType.size() > 0){
+               
+                               ProcessData.Append(DataType);
+                               ProcessedType = true;
+                       
+                       }
+                       
+                       if ((*TelephoneListAltID)[TelephoneIter->first].size() > 0){
+                               
+                               if (ProcessedType == true){
+                                       ProcessData.Append(",");
+                               }
+                               ProcessData.Append((*TelephoneListTypeInfo)[TelephoneIter->first]);
+                               
+                       }
+                       
+                       ProcessData.Append("\"");
+               
+               }
+               
+               // Check if there is a value for ALTID.
+               
+               if ((*TelephoneListAltID)[TelephoneIter->first].size() > 0){
+               
+                       ProcessData.Append(";ALTID=");
+                       ProcessData.Append((*TelephoneListAltID)[TelephoneIter->first]);
+                       
+               }
+               
+               // Check if there is a value for PID.
+
+               if ((*TelephoneListPID)[TelephoneIter->first].size() > 0){
+               
+                       ProcessData.Append(";PID=");
+                       ProcessData.Append((*TelephoneListPID)[TelephoneIter->first]);
+                       
+               }
+
+               // Check if there is a value for PREF.
+
+               if ((*TelephoneListPref)[TelephoneIter->first] > 0){
+               
+                       ProcessData.Append(";PREF=");
+                       ProcessData.Append(wxString::Format("%i", (*TelephoneListPref)[TelephoneIter->first]));
+                       
+               }
+
+               // Check if there is a value for tokens.
+
+               if ((*TelephoneListTokens)[TelephoneIter->first].size() > 0){
+               
+                       ProcessData.Append(";");
+                       ProcessData.Append((*TelephoneListTokens)[TelephoneIter->first]);
+                       
+               }
+
+               ProcessData.Append(":");
+               ProcessData.Append((*TelephoneListDataType)[TelephoneIter->first]);
+               ProcessData.Append(":");
+               ProcessData.Append(TelephoneIter->second);
+               ProcessData.Append("\n");
+
+               ProcessData = OutputText(&ProcessData);
+                       
+               SaveData->Append(ProcessData);
+               ProcessData.clear();
+                       
+       }
+               
+}
+
 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, 
index df84a2a..5942425 100644 (file)
@@ -132,9 +132,14 @@ class ContactDataObject{
                wxString *SaveData, wxString DataType);
        void SaveIMPP(map<int, wxString> *IMList, map<int, wxString> *IMListAltID, 
                map<int, wxString> *IMListPID, map<int, wxString> *IMListType,
-               map<int, wxString> *IMListTypeInfo, map<int, wxString> *IMListMediatype, 
+               map<int, wxString> *IMListTypeInfo, map<int, wxString> *IMListDataType, 
                map<int, int> *IMListPref, map<int, wxString> *IMListTokens, 
                wxString *SaveData, wxString DataType);
+       void SaveTelephone(map<int, wxString> *TelephoneList, map<int, wxString> *TelephoneListAltID, 
+               map<int, wxString> *TelephoneListPID, map<int, wxString> *TelephoneListType,
+               map<int, wxString> *TelephoneListTypeInfo, map<int, wxString> *TelephoneListMediatype, 
+               map<int, int> *TelephoneListPref, map<int, wxString> *TelephoneListTokens, 
+               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, 
index f92659b..26b38e6 100644 (file)
@@ -119,6 +119,9 @@ TEST(ContactSave, ContactSaveTests){
        " :msn:moo.home@example.com\n"
        "IMPP;TYPE=work;ALTID=98;MEDIATYPE=text/superplain;PID=99;PREF=50;BUSINESS=Mon\n"
        " ey:xmpp:moo.business@example.com\n"
+       "TEL;TYPE=\"fax,cell\";ALTID=10;PID=20;PREF=40;WONDERFUL=Colour:tel:00000000\n"
+       "TEL;TYPE=\"home,fax\";ALTID=10;PID=20;PREF=40;BUSINESS=Money:tel:00001111\n"
+       "TEL;TYPE=\"work,voice\";ALTID=25;PID=50;PREF=75;BEEP=Boop:tel:22221111\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"
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