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

index aee2638..b422160 100644 (file)
@@ -210,6 +210,21 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){
                        
        }
        
+       // Process NICKNAME.
+       
+       SaveNickname(&GeneralNicknamesList, &GeneralNicknamesListAltID, 
+               &GeneralNicknamesListPID, &GeneralNicknamesListType,
+               &GeneralNicknamesListLanguage, &GeneralNicknamesListPref, 
+               &GeneralNicknamesListTokens, SaveData, "");
+       SaveNickname(&HomeNicknamesList, &HomeNicknamesListAltID, 
+               &HomeNicknamesListPID, &HomeNicknamesListType,
+               &HomeNicknamesListLanguage, &HomeNicknamesListPref, 
+               &HomeNicknamesListTokens, SaveData, "home");
+       SaveNickname(&BusinessNicknamesList, &BusinessNicknamesListAltID, 
+               &BusinessNicknamesListPID, &BusinessNicknamesListType,
+               &BusinessNicknamesListLanguage, &BusinessNicknamesListPref, 
+               &BusinessNicknamesListTokens, SaveData, "work");
+       
        // Process TITLE.
 
        SaveTitle(&GeneralTitleList, &GeneralTitleListLanguage,
@@ -391,4 +406,83 @@ void ContactDataObject::SaveSource(map<int, wxString> *SourceList, map<int, wxSt
                        
        }
                
+}
+
+void ContactDataObject::SaveNickname(map<int, wxString> *NicknameList, map<int, wxString> *NicknameListAltID, 
+       map<int, wxString> *NicknameListPID, map<int, wxString> *NicknameListType,
+       map<int, wxString> *NicknameListLanguage, map<int, int> *NicknameListPref, 
+       map<int, wxString> *NicknameListTokens, wxString *SaveData, wxString DataType){
+
+       wxString ProcessData = "";
+       
+       for (std::map<int, wxString>::iterator NicknameIter = NicknameList->begin();
+               NicknameIter != NicknameList->end(); NicknameIter++){
+
+               ProcessData.Append("NICKNAME");
+                       
+               // 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 ((*NicknameListAltID)[NicknameIter->first].size() > 0){
+               
+                       ProcessData.Append(";ALTID=");
+                       ProcessData.Append((*NicknameListAltID)[NicknameIter->first]);
+                       
+               }
+
+               // Check if there is a value for MEDIATYPE.
+               
+               if ((*NicknameListLanguage)[NicknameIter->first].size() > 0){
+               
+                       ProcessData.Append(";LANGUAGE=");
+                       ProcessData.Append((*NicknameListLanguage)[NicknameIter->first]);
+                       
+               }
+               
+               // Check if there is a value for PID.
+
+               if ((*NicknameListPID)[NicknameIter->first].size() > 0){
+               
+                       ProcessData.Append(";PID=");
+                       ProcessData.Append((*NicknameListPID)[NicknameIter->first]);
+                       
+               }
+
+               // Check if there is a value for PREF.
+
+               if ((*NicknameListPref)[NicknameIter->first] > 0){
+               
+                       ProcessData.Append(";PREF=");
+                       ProcessData.Append(wxString::Format("%i", (*NicknameListPref)[NicknameIter->first]));
+                       
+               }
+
+               // Check if there is a value for tokens.
+
+               if ((*NicknameListTokens)[NicknameIter->first].size() > 0){
+               
+                       ProcessData.Append(";");
+                       ProcessData.Append((*NicknameListTokens)[NicknameIter->first]);
+                       
+               }
+                       
+               ProcessData.Append(":");
+               ProcessData.Append(NicknameIter->second);
+               ProcessData.Append("\n");
+
+               ProcessData = OutputText(&ProcessData);
+                       
+               SaveData->Append(ProcessData);
+               ProcessData.clear();
+                       
+       }
+               
 }
\ No newline at end of file
index 5cd36f4..e0df47f 100644 (file)
@@ -106,6 +106,10 @@ class ContactDataObject{
                map<int, wxString> *SourceListPID, map<int, wxString> *SourceListType,
                map<int, wxString> *SourceListMediatype, map<int, int> *SourceListPref, 
                map<int, wxString> *SourceListTokens, wxString *SaveData);
+       void SaveNickname(map<int, wxString> *NicknameList, map<int, wxString> *NicknameListAltID, 
+               map<int, wxString> *NicknameListPID, map<int, wxString> *NicknameListType,
+               map<int, wxString> *NicknameListLanguage, map<int, int> *NicknameListPref, 
+               map<int, wxString> *NicknameListTokens, wxString *SaveData, wxString DataType);
 
        public:
 
index ee43235..74a9206 100644 (file)
@@ -79,6 +79,11 @@ TEST(ContactSave, ContactSaveTests){
        "CLIENTPIDMAP;MEEP=MOO;WOOP=WOO:3;urn;uuid:bbbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbb\n"
        " bb\n"
        "FN;TYPE=work;LANGUAGE=kw;ALTID=500;PID=40;PREF=45;EXAMPLE=Baaa:Test Contact\n"
+       "NICKNAME;ALTID=35;LANGUAGE=kw;PID=50;PREF=40;YAY=Nope;Beep=Boop:Tester\n"
+       "NICKNAME;TYPE=home;ALTID=17;LANGUAGE=en;PID=39;PREF=78;YAY=Yep;Beep=Boop:Test\n"
+       " y\n"
+       "NICKNAME;TYPE=work;ALTID=99;LANGUAGE=en-GB;PID=10;PREF=1;YAY=Maybe;Boop=Boing\n"
+       " :The Testing One\n"
        "TITLE;ALTID=20;LANGUAGE=text/plain;PID=21;PREF=22;EEP=LIGHT:Lord of Light\n"
        "TITLE;TYPE=home;ALTID=30;LANGUAGE=grass/dry;PID=31;PREF=32;EEP=DARK:Lord of D\n"
        " arkness\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