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

index 426f3f2..3ee868c 100644 (file)
@@ -511,6 +511,21 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){
                &BusinessWebsiteListPID, &BusinessWebsiteListType,
                &BusinessWebsiteListMediatype, &BusinessWebsiteListPref, 
                &BusinessWebsiteListTokens, SaveData, "work");
+
+       // Process ROLE.
+       
+       SaveRole(&GeneralRoleList, &GeneralRoleListLanguage,
+               &GeneralRoleListAltID, &GeneralRoleListPID,
+               &GeneralRoleListType, &GeneralRoleListPref,
+               &GeneralRoleListTokens, SaveData, "");
+       SaveRole(&HomeRoleList, &HomeRoleListLanguage,
+               &HomeRoleListAltID, &HomeRoleListPID,
+               &HomeRoleListType, &HomeRoleListPref,
+               &HomeRoleListTokens, SaveData, "home");
+       SaveRole(&BusinessRoleList, &BusinessRoleListLanguage,
+               &BusinessRoleListAltID, &BusinessRoleListPID,
+               &BusinessRoleListType, &BusinessRoleListPref,
+               &BusinessRoleListTokens, SaveData, "work");
        
        // Write the end part of the vCard data file.
        
@@ -1272,4 +1287,83 @@ void ContactDataObject::SaveURL(map<int, wxString> *WebsiteList, map<int, wxStri
                        
        }
                        
+}
+
+void ContactDataObject::SaveRole(map<int, wxString> *RoleList, map<int, wxString> *RoleListLanguage,
+       map<int, wxString> *RoleListAltID, map<int, wxString> *RoleListPID,
+       map<int, wxString> *RoleListType, map<int, int> *RoleListPref,
+       map<int, wxString> *RoleListTokens, wxString *SaveData, wxString DataType){
+
+       wxString ProcessData = "";
+               
+       for (std::map<int, wxString>::iterator RoleIter = RoleList->begin();
+               RoleIter != RoleList->end(); RoleIter++){
+
+               ProcessData.Append("ROLE");
+                       
+               // 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 ((*RoleListAltID)[RoleIter->first].size() > 0){
+               
+                       ProcessData.Append(";ALTID=");
+                       ProcessData.Append((*RoleListAltID)[RoleIter->first]);
+                       
+               }
+
+               // Check if there is a value for LANGUAGE.
+               
+               if ((*RoleListLanguage)[RoleIter->first].size() > 0){
+               
+                       ProcessData.Append(";LANGUAGE=");
+                       ProcessData.Append((*RoleListLanguage)[RoleIter->first]);
+                       
+               }
+               
+               // Check if there is a value for PID.
+
+               if ((*RoleListPID)[RoleIter->first].size() > 0){
+               
+                       ProcessData.Append(";PID=");
+                       ProcessData.Append((*RoleListPID)[RoleIter->first]);
+                       
+               }
+
+               // Check if there is a value for PREF.
+
+               if ((*RoleListPref)[RoleIter->first] > 0){
+               
+                       ProcessData.Append(";PREF=");
+                       ProcessData.Append(wxString::Format("%i", (*RoleListPref)[RoleIter->first]));
+                       
+               }
+
+               // Check if there is a value for tokens.
+
+               if ((*RoleListTokens)[RoleIter->first].size() > 0){
+               
+                       ProcessData.Append(";");
+                       ProcessData.Append((*RoleListTokens)[RoleIter->first]);
+                       
+               }
+                       
+               ProcessData.Append(":");
+               ProcessData.Append(RoleIter->second);
+               ProcessData.Append("\n");
+
+               ProcessData = OutputText(&ProcessData);
+               
+               SaveData->Append(ProcessData);
+               ProcessData.clear();
+                       
+       }
+               
 }
\ No newline at end of file
index 2cf736b..85342e4 100644 (file)
@@ -139,6 +139,10 @@ class ContactDataObject{
                map<int, wxString> *WebsiteListPID, map<int, wxString> *WebsiteListType,
                map<int, wxString> *WebsiteListMediatype, map<int, int> *WebsiteListPref, 
                map<int, wxString> *WebsiteListTokens, wxString *SaveData, wxString DataType);
+       void SaveRole(map<int, wxString> *RoleList, map<int, wxString> *RoleListLanguage,
+               map<int, wxString> *RoleListAltID, map<int, wxString> *RoleListPID,
+               map<int, wxString> *RoleListType, map<int, int> *RoleListPref,
+               map<int, wxString> *RoleListTokens, wxString *SaveData, wxString DataType);
 
        public:
 
index b0842da..ea07194 100644 (file)
@@ -126,6 +126,11 @@ TEST(ContactSave, ContactSaveTests){
        " ample.com/home/\n"
        "URL;TYPE=work;ALTID=20;MEDIATYPE=chocolate/yummy;PID=21;PREF=22;YES=No:http:/\n"
        " /example.com/business/\n"
+       "ROLE;ALTID=50;LANGUAGE=en;PID=51;PREF=52;ASTERISK=None:Ordinary Person\n"
+       "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"
+       
        "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