Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added CATEGORIES to the SaveString function of ContactDataObject
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sat, 2 Jul 2016 07:51:53 +0000 (08:51 +0100)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sat, 2 Jul 2016 07:51:53 +0000 (08:51 +0100)
source/contacteditor/cdo/ContactDataObject-Save.cpp
source/contacteditor/cdo/ContactDataObject.h
source/tests/xestiaab_contactsave.h

index 8107ed5..2334177 100644 (file)
@@ -560,6 +560,13 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){
                &BusinessNoteListType, &BusinessNoteListPref,
                &BusinessNoteListTokens, SaveData, "work");
 
+       // Process CATEGORIES.
+       
+       SaveCategory(&CategoriesList, &CategoriesListLanguage,
+               &CategoriesListAltID, &CategoriesListPID,
+               &CategoriesListType, &CategoriesListPref,
+               &CategoriesListTokens, SaveData);
+
        // Write the end part of the vCard data file.
        
        SaveData->Append("END:VCARD");
@@ -1569,4 +1576,83 @@ void ContactDataObject::SaveNote(map<int, wxString> *NoteList, map<int, wxString
                        
        }
                
+}
+
+void ContactDataObject::SaveCategory(map<int, wxString> *CategoryList, map<int, wxString> *CategoryListLanguage,
+       map<int, wxString> *CategoryListAltID, map<int, wxString> *CategoryListPID,
+       map<int, wxString> *CategoryListType, map<int, int> *CategoryListPref,
+       map<int, wxString> *CategoryListTokens, wxString *SaveData){
+
+       wxString ProcessData = "";
+               
+       for (std::map<int, wxString>::iterator CategoryIter = CategoryList->begin();
+               CategoryIter != CategoryList->end(); CategoryIter++){
+
+               ProcessData.Append("CATEGORIES");
+                       
+               // Check if there is a value for TYPE.
+               
+               if ((*CategoryListType)[CategoryIter->first].size() > 0){
+               
+                       ProcessData.Append(";TYPE=");
+                       ProcessData.Append((*CategoryListType)[CategoryIter->first]);
+                       
+               }
+               
+               // Check if there is a value for ALTID.
+               
+               if ((*CategoryListAltID)[CategoryIter->first].size() > 0){
+               
+                       ProcessData.Append(";ALTID=");
+                       ProcessData.Append((*CategoryListAltID)[CategoryIter->first]);
+                       
+               }
+
+               // Check if there is a value for LANGUAGE.
+               
+               if ((*CategoryListLanguage)[CategoryIter->first].size() > 0){
+               
+                       ProcessData.Append(";LANGUAGE=");
+                       ProcessData.Append((*CategoryListLanguage)[CategoryIter->first]);
+                       
+               }
+               
+               // Check if there is a value for PID.
+
+               if ((*CategoryListPID)[CategoryIter->first].size() > 0){
+               
+                       ProcessData.Append(";PID=");
+                       ProcessData.Append((*CategoryListPID)[CategoryIter->first]);
+                       
+               }
+
+               // Check if there is a value for PREF.
+
+               if ((*CategoryListPref)[CategoryIter->first] > 0){
+               
+                       ProcessData.Append(";PREF=");
+                       ProcessData.Append(wxString::Format("%i", (*CategoryListPref)[CategoryIter->first]));
+                       
+               }
+
+               // Check if there is a value for tokens.
+
+               if ((*CategoryListTokens)[CategoryIter->first].size() > 0){
+               
+                       ProcessData.Append(";");
+                       ProcessData.Append((*CategoryListTokens)[CategoryIter->first]);
+                       
+               }
+                       
+               ProcessData.Append(":");
+               ProcessData.Append(CategoryIter->second);
+               ProcessData.Append("\n");
+
+               ProcessData = OutputText(&ProcessData);
+               
+               SaveData->Append(ProcessData);
+               ProcessData.clear();
+                       
+       }
+               
 }
\ No newline at end of file
index 6ffd214..a7f4939 100644 (file)
@@ -152,6 +152,10 @@ class ContactDataObject{
                map<int, wxString> *NoteListAltID, map<int, wxString> *NoteListPID,
                map<int, wxString> *NoteListType, map<int, int> *NoteListPref,
                map<int, wxString> *NoteListTokens, wxString *SaveData, wxString DataType);
+       void SaveCategory(map<int, wxString> *CategoryList, map<int, wxString> *CategoryListLanguage,
+               map<int, wxString> *CategoryListAltID, map<int, wxString> *CategoryListPID,
+               map<int, wxString> *CategoryListType, map<int, int> *CategoryListPref,
+               map<int, wxString> *CategoryListTokens, wxString *SaveData);
 
        public:
 
index 8e672c7..d07aabf 100644 (file)
@@ -142,6 +142,15 @@ TEST(ContactSave, ContactSaveTests){
        " 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"
+       "CATEGORIES;ALTID=40;LANGUAGE=en;PID=41;PREF=42;CAT=TAC:Category One\n"
+       "CATEGORIES;TYPE=home;ALTID=44;LANGUAGE=kw;PID=46;PREF=48;TAC=CAT:Category Two\n"
+       "CATEGORIES;TYPE=home;ALTID=44;LANGUAGE=kw;PID=46;PREF=48;TAC=CAT:Category Thr\n"
+       " ee\n"
+       "CATEGORIES;TYPE=work;ALTID=84;LANGUAGE=kw;PID=86;PREF=88;AAA=BBB:Category Fou\n"
+       " r\n"
+       "CATEGORIES;TYPE=work;ALTID=84;LANGUAGE=kw;PID=86;PREF=88;AAA=BBB:Category Fiv\n"
+       " e\n"
+       "CATEGORIES;TYPE=work;ALTID=84;LANGUAGE=kw;PID=86;PREF=88;AAA=BBB:Category Six\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