Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added NOTE to the SaveString function of ContactDataObject
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Thu, 30 Jun 2016 22:32:57 +0000 (23:32 +0100)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Thu, 30 Jun 2016 22:32:57 +0000 (23:32 +0100)
source/contacteditor/cdo/ContactDataObject-Save.cpp
source/contacteditor/cdo/ContactDataObject.h
source/tests/xestiaab_contactsave.h

index 08135bf..8107ed5 100644 (file)
@@ -545,6 +545,21 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){
                &BusinessOrganisationsListPref, &BusinessOrganisationsListTokens, 
                SaveData, "work");
 
+       // Process NOTE.
+       
+       SaveNote(&GeneralNoteList, &GeneralNoteListLanguage,
+               &GeneralNoteListAltID, &GeneralNoteListPID,
+               &GeneralNoteListType, &GeneralNoteListPref,
+               &GeneralNoteListTokens, SaveData, "");
+       SaveNote(&HomeNoteList, &HomeNoteListLanguage,
+               &HomeNoteListAltID, &HomeNoteListPID,
+               &HomeNoteListType, &HomeNoteListPref,
+               &HomeNoteListTokens, SaveData, "home");
+       SaveNote(&BusinessNoteList, &BusinessNoteListLanguage,
+               &BusinessNoteListAltID, &BusinessNoteListPID,
+               &BusinessNoteListType, &BusinessNoteListPref,
+               &BusinessNoteListTokens, SaveData, "work");
+
        // Write the end part of the vCard data file.
        
        SaveData->Append("END:VCARD");
@@ -1474,4 +1489,84 @@ void ContactDataObject::SaveOrganisation(map<int, wxString> *OrganisationList, m
                        
        }
                
+}
+
+void ContactDataObject::SaveNote(map<int, wxString> *NoteList, map<int, wxString> *NoteListLanguage,
+       map<int, wxString> *NoteListAltID, map<int, wxString> *NoteListPID,
+       map<int, wxString> *NoteListType, map<int, int> *NoteListPref,
+       map<int, wxString> *NoteListTokens, wxString *SaveData, wxString DataType){
+
+       wxString ProcessData = "";
+               
+       for (std::map<int, wxString>::iterator NoteIter = NoteList->begin();
+               NoteIter != NoteList->end(); NoteIter++){
+
+               ProcessData.Append("NOTE");
+                       
+               // 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 ((*NoteListAltID)[NoteIter->first].size() > 0){
+               
+                       ProcessData.Append(";ALTID=");
+                       ProcessData.Append((*NoteListAltID)[NoteIter->first]);
+                       
+               }
+
+               // Check if there is a value for LANGUAGE.
+               
+               if ((*NoteListLanguage)[NoteIter->first].size() > 0){
+               
+                       ProcessData.Append(";LANGUAGE=");
+                       ProcessData.Append((*NoteListLanguage)[NoteIter->first]);
+                       
+               }
+               
+               // Check if there is a value for PID.
+
+               if ((*NoteListPID)[NoteIter->first].size() > 0){
+               
+                       ProcessData.Append(";PID=");
+                       ProcessData.Append((*NoteListPID)[NoteIter->first]);
+                       
+               }
+
+               // Check if there is a value for PREF.
+
+               if ((*NoteListPref)[NoteIter->first] > 0){
+               
+                       ProcessData.Append(";PREF=");
+                       ProcessData.Append(wxString::Format("%i", (*NoteListPref)[NoteIter->first]));
+                       
+               }
+
+               // Check if there is a value for tokens.
+
+               if ((*NoteListTokens)[NoteIter->first].size() > 0){
+               
+                       ProcessData.Append(";");
+                       ProcessData.Append((*NoteListTokens)[NoteIter->first]);
+                       
+               }
+                       
+               ProcessData.Append(":");
+               ProcessData.Append(NoteIter->second);
+               ProcessData.Replace("\n", "\\n", true);
+               ProcessData.Append("\n");
+
+               ProcessData = OutputText(&ProcessData);
+               
+               SaveData->Append(ProcessData);
+               ProcessData.clear();
+                       
+       }
+               
 }
\ No newline at end of file
index d8c199b..6ffd214 100644 (file)
@@ -148,6 +148,10 @@ class ContactDataObject{
                map<int, wxString> *OrganisationListSortAs, map<int, wxString> *OrganisationListType,
                map<int, int> *OrganisationListPref, map<int, wxString> *OrganisationListTokens, 
                wxString *SaveData, wxString DataType);
+       void SaveNote(map<int, wxString> *NoteList, map<int, wxString> *NoteListLanguage,
+               map<int, wxString> *NoteListAltID, map<int, wxString> *NoteListPID,
+               map<int, wxString> *NoteListType, map<int, int> *NoteListPref,
+               map<int, wxString> *NoteListTokens, wxString *SaveData, wxString DataType);
 
        public:
 
index 08f9ac8..8e672c7 100644 (file)
@@ -136,6 +136,12 @@ TEST(ContactSave, ContactSaveTests){
        " y Lazy\";SOMEWHERE=There:Ordinary Lazy Person\n"
        "ORG;TYPE=work;ALTID=70;LANGUAGE=en-AU;PID=71;PREF=72;SORT-AS=\"Owner, Company\"\n"
        " ;HERE=Nope:Company Owner\n"
+       "NOTE;ALTID=90;LANGUAGE=en;PID=91;PREF=92;WOO=WOOP:Note\\n\\nLine 3\\nLine 4\\nLin\n"
+       " e 5\n"
+       "NOTE;TYPE=home;ALTID=80;LANGUAGE=kw;PID=81;PREF=82;MOO=MEEP:Note\\n\\n\\n\\nLine \n"
+       " 5\\nLine 6\\nLine 7\n"
+       "NOTE;TYPE=work;ALTID=70;LANGUAGE=fr;PID=71;PREF=72;BOING=BOOP:Note\\n\\n\\n\\nLin\n"
+       " e 8\\nLine 9\\nLine 10\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