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

index 3ee868c..08135bf 100644 (file)
@@ -526,7 +526,25 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){
                &BusinessRoleListAltID, &BusinessRoleListPID,
                &BusinessRoleListType, &BusinessRoleListPref,
                &BusinessRoleListTokens, SaveData, "work");
+
+       // Process ORG.
        
+       SaveOrganisation(&GeneralOrganisationsList, &GeneralOrganisationsListAltID,
+               &GeneralOrganisationsListPID, &GeneralOrganisationsListLanguage, 
+               &GeneralOrganisationsListSortAs, &GeneralOrganisationsListType, 
+               &GeneralOrganisationsListPref, &GeneralOrganisationsListTokens, 
+               SaveData, "");
+       SaveOrganisation(&HomeOrganisationsList, &HomeOrganisationsListAltID,
+               &HomeOrganisationsListPID, &HomeOrganisationsListLanguage, 
+               &HomeOrganisationsListSortAs, &HomeOrganisationsListType, 
+               &HomeOrganisationsListPref, &HomeOrganisationsListTokens, 
+               SaveData, "home");
+       SaveOrganisation(&BusinessOrganisationsList, &BusinessOrganisationsListAltID,
+               &BusinessOrganisationsListPID, &BusinessOrganisationsListLanguage, 
+               &BusinessOrganisationsListSortAs, &BusinessOrganisationsListType, 
+               &BusinessOrganisationsListPref, &BusinessOrganisationsListTokens, 
+               SaveData, "work");
+
        // Write the end part of the vCard data file.
        
        SaveData->Append("END:VCARD");
@@ -1366,4 +1384,94 @@ void ContactDataObject::SaveRole(map<int, wxString> *RoleList, map<int, wxString
                        
        }
                
+}
+
+void ContactDataObject::SaveOrganisation(map<int, wxString> *OrganisationList, map<int, wxString> *OrganisationListAltID,
+       map<int, wxString> *OrganisationListPID, map<int, wxString> *OrganisationListLanguage, 
+       map<int, wxString> *OrganisationListSortAs, map<int, wxString> *OrganisationListType, 
+       map<int, int> *OrganisationListPref, map<int, wxString> *OrganisationListTokens, 
+       wxString *SaveData, wxString DataType){
+
+       wxString ProcessData = "";
+               
+       for (std::map<int, wxString>::iterator OrganisationIter = OrganisationList->begin();
+               OrganisationIter != OrganisationList->end(); OrganisationIter++){
+
+               ProcessData.Append("ORG");
+                       
+               // 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 ((*OrganisationListAltID)[OrganisationIter->first].size() > 0){
+               
+                       ProcessData.Append(";ALTID=");
+                       ProcessData.Append((*OrganisationListAltID)[OrganisationIter->first]);
+                       
+               }
+
+               // Check if there is a value for LANGUAGE.
+               
+               if ((*OrganisationListLanguage)[OrganisationIter->first].size() > 0){
+               
+                       ProcessData.Append(";LANGUAGE=");
+                       ProcessData.Append((*OrganisationListLanguage)[OrganisationIter->first]);
+                       
+               }
+               
+               // Check if there is a value for PID.
+
+               if ((*OrganisationListPID)[OrganisationIter->first].size() > 0){
+               
+                       ProcessData.Append(";PID=");
+                       ProcessData.Append((*OrganisationListPID)[OrganisationIter->first]);
+                       
+               }
+
+               // Check if there is a value for PREF.
+
+               if ((*OrganisationListPref)[OrganisationIter->first] > 0){
+               
+                       ProcessData.Append(";PREF=");
+                       ProcessData.Append(wxString::Format("%i", (*OrganisationListPref)[OrganisationIter->first]));
+                       
+               }
+               
+               // Check if there is a value for SORT-AS.
+               
+               if ((*OrganisationListSortAs)[OrganisationIter->first].size() > 0){
+               
+                       ProcessData.Append(";SORT-AS=\"");
+                       ProcessData.Append((*OrganisationListSortAs)[OrganisationIter->first]);
+                       ProcessData.Append("\"");
+                       
+               }
+
+               // Check if there is a value for tokens.
+
+               if ((*OrganisationListTokens)[OrganisationIter->first].size() > 0){
+               
+                       ProcessData.Append(";");
+                       ProcessData.Append((*OrganisationListTokens)[OrganisationIter->first]);
+                       
+               }
+                       
+               ProcessData.Append(":");
+               ProcessData.Append(OrganisationIter->second);
+               ProcessData.Append("\n");
+
+               ProcessData = OutputText(&ProcessData);
+               
+               SaveData->Append(ProcessData);
+               ProcessData.clear();
+                       
+       }
+               
 }
\ No newline at end of file
index 85342e4..d8c199b 100644 (file)
@@ -143,6 +143,11 @@ class ContactDataObject{
                map<int, wxString> *RoleListAltID, map<int, wxString> *RoleListPID,
                map<int, wxString> *RoleListType, map<int, int> *RoleListPref,
                map<int, wxString> *RoleListTokens, wxString *SaveData, wxString DataType);
+       void SaveOrganisation(map<int, wxString> *OrganisationList, map<int, wxString> *OrganisationListLanguage,
+               map<int, wxString> *OrganisationListAltID, map<int, wxString> *OrganisationListPID,
+               map<int, wxString> *OrganisationListSortAs, map<int, wxString> *OrganisationListType,
+               map<int, int> *OrganisationListPref, map<int, wxString> *OrganisationListTokens, 
+               wxString *SaveData, wxString DataType);
 
        public:
 
index ea07194..08f9ac8 100644 (file)
@@ -130,7 +130,12 @@ TEST(ContactSave, ContactSaveTests){
        "ROLE;TYPE=home;ALTID=60;LANGUAGE=en-GB;PID=61;PREF=62;SOMEWHERE=There:Ordinar\n"
        " y Lazy Person\n"
        "ROLE;TYPE=work;ALTID=70;LANGUAGE=en-AU;PID=71;PREF=72;HERE=Nope:Company Owner\n"
-       
+       "ORG;ALTID=50;LANGUAGE=en;PID=51;PREF=52;SORT-AS=\"Organisation, Ordinary\";ASTE\n"
+       " RISK=None:Ordinary Organisation\n"
+       "ORG;TYPE=home;ALTID=60;LANGUAGE=en-GB;PID=61;PREF=62;SORT-AS=\"Person, Ordinar\n"
+       " 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"
        "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