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

index b422160..5fbc386 100644 (file)
@@ -240,6 +240,21 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){
                &BusinessTitleListType, &BusinessTitleListPref,
                &BusinessTitleListTokens, SaveData, "work");
        
+       // Process TZ.
+       
+       SaveTimezone(&GeneralTZList, &GeneralTZListAltID, 
+               &GeneralTZListPID, &GeneralTZListType,
+               &GeneralTZListMediatype, &GeneralTZListPref, 
+               &GeneralTZListTokens, SaveData, "");
+       SaveTimezone(&HomeTZList, &HomeTZListAltID, 
+               &HomeTZListPID, &HomeTZListType,
+               &HomeTZListMediatype, &HomeTZListPref, 
+               &HomeTZListTokens, SaveData, "home");
+       SaveTimezone(&BusinessTZList, &BusinessTZListAltID, 
+               &BusinessTZListPID, &BusinessTZListType,
+               &BusinessTZListMediatype, &BusinessTZListPref, 
+               &BusinessTZListTokens, SaveData, "work");
+
        // Write the end part of the vCard data file.
        
        SaveData->Append("END:VCARD");
@@ -485,4 +500,83 @@ void ContactDataObject::SaveNickname(map<int, wxString> *NicknameList, map<int,
                        
        }
                
+}
+
+void ContactDataObject::SaveTimezone(map<int, wxString> *TZList, map<int, wxString> *TZListAltID, 
+       map<int, wxString> *TZListPID, map<int, wxString> *TZListType,
+       map<int, wxString> *TZListMediatype, map<int, int> *TZListPref, 
+       map<int, wxString> *TZListTokens, wxString *SaveData, wxString DataType){
+
+       wxString ProcessData = "";
+       
+       for (std::map<int, wxString>::iterator TZIter = TZList->begin();
+               TZIter != TZList->end(); TZIter++){
+
+               ProcessData.Append("TZ");
+                       
+               // 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 ((*TZListAltID)[TZIter->first].size() > 0){
+               
+                       ProcessData.Append(";ALTID=");
+                       ProcessData.Append((*TZListAltID)[TZIter->first]);
+                       
+               }
+
+               // Check if there is a value for MEDIATYPE.
+               
+               if ((*TZListMediatype)[TZIter->first].size() > 0){
+               
+                       ProcessData.Append(";MEDIATYPE=");
+                       ProcessData.Append((*TZListMediatype)[TZIter->first]);
+                       
+               }
+               
+               // Check if there is a value for PID.
+
+               if ((*TZListPID)[TZIter->first].size() > 0){
+               
+                       ProcessData.Append(";PID=");
+                       ProcessData.Append((*TZListPID)[TZIter->first]);
+                       
+               }
+
+               // Check if there is a value for PREF.
+
+               if ((*TZListPref)[TZIter->first] > 0){
+               
+                       ProcessData.Append(";PREF=");
+                       ProcessData.Append(wxString::Format("%i", (*TZListPref)[TZIter->first]));
+                       
+               }
+
+               // Check if there is a value for tokens.
+
+               if ((*TZListTokens)[TZIter->first].size() > 0){
+               
+                       ProcessData.Append(";");
+                       ProcessData.Append((*TZListTokens)[TZIter->first]);
+                       
+               }
+                       
+               ProcessData.Append(":");
+               ProcessData.Append(TZIter->second);
+               ProcessData.Append("\n");
+
+               ProcessData = OutputText(&ProcessData);
+                       
+               SaveData->Append(ProcessData);
+               ProcessData.clear();
+                       
+       }
+               
 }
\ No newline at end of file
index e0df47f..3fa2658 100644 (file)
@@ -110,6 +110,10 @@ class ContactDataObject{
                map<int, wxString> *NicknameListPID, map<int, wxString> *NicknameListType,
                map<int, wxString> *NicknameListLanguage, map<int, int> *NicknameListPref, 
                map<int, wxString> *NicknameListTokens, wxString *SaveData, wxString DataType);
+       void SaveTimezone(map<int, wxString> *TZList, map<int, wxString> *TZListAltID, 
+               map<int, wxString> *TZListPID, map<int, wxString> *TZListType,
+               map<int, wxString> *TZListMediatype, map<int, int> *TZListPref, 
+               map<int, wxString> *TZListTokens, wxString *SaveData, wxString DataType);
 
        public:
 
index 74a9206..8420e63 100644 (file)
@@ -89,6 +89,12 @@ TEST(ContactSave, ContactSaveTests){
        " arkness\n"
        "TITLE;TYPE=work;ALTID=40;LANGUAGE=moths/eew;PID=41;PREF=42;EEP=BOTH:Master of\n"
        "  the Light & Darkness\n"
+       "TZ;ALTID=35;MEDIATYPE=text/plain;PID=60;PREF=20;WHATS=This;A=Potato:Europe/Tr\n"
+       " uro\n"
+       "TZ;TYPE=home;ALTID=15;MEDIATYPE=text/plain;PID=20;PREF=40;MAYBE=not:Europe/Pe\n"
+       " nzance\n"
+       "TZ;TYPE=work;ALTID=45;MEDIATYPE=text/plain;PID=70;PREF=80;MAYBE=yes:Europe/St\n"
+       "  Austell\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