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

index 6276454..426f3f2 100644 (file)
@@ -496,7 +496,22 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){
                ProcessData.clear();
                        
        }
-
+       
+       // Process URL.
+       
+       SaveURL(&GeneralWebsiteList, &GeneralWebsiteListAltID, 
+               &GeneralWebsiteListPID, &GeneralWebsiteListType,
+               &GeneralWebsiteListMediatype, &GeneralWebsiteListPref, 
+               &GeneralWebsiteListTokens, SaveData, "");
+       SaveURL(&HomeWebsiteList, &HomeWebsiteListAltID, 
+               &HomeWebsiteListPID, &HomeWebsiteListType,
+               &HomeWebsiteListMediatype, &HomeWebsiteListPref, 
+               &HomeWebsiteListTokens, SaveData, "home");
+       SaveURL(&BusinessWebsiteList, &BusinessWebsiteListAltID, 
+               &BusinessWebsiteListPID, &BusinessWebsiteListType,
+               &BusinessWebsiteListMediatype, &BusinessWebsiteListPref, 
+               &BusinessWebsiteListTokens, SaveData, "work");
+       
        // Write the end part of the vCard data file.
        
        SaveData->Append("END:VCARD");
@@ -1178,4 +1193,83 @@ void ContactDataObject::SaveGeoposition(map<int, wxString> *GeographyList, map<i
                        
        }
                
+}
+
+void ContactDataObject::SaveURL(map<int, wxString> *WebsiteList, map<int, wxString> *WebsiteListAltID, 
+               map<int, wxString> *WebsiteListPID, map<int, wxString> *WebsiteListType,
+               map<int, wxString> *WebsiteListMediatype, map<int, int> *WebsiteListPref, 
+               map<int, wxString> *WebsiteListTokens, wxString *SaveData, wxString DataType){
+
+       wxString ProcessData = "";
+       
+       for (std::map<int, wxString>::iterator WebsiteIter = WebsiteList->begin();
+               WebsiteIter != WebsiteList->end(); WebsiteIter++){
+
+               ProcessData.Append("URL");
+                       
+               // 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 ((*WebsiteListAltID)[WebsiteIter->first].size() > 0){
+               
+                       ProcessData.Append(";ALTID=");
+                       ProcessData.Append((*WebsiteListAltID)[WebsiteIter->first]);
+                       
+               }
+               
+               // Check if there is a value for MEDIATYPE.
+               
+               if ((*WebsiteListMediatype)[WebsiteIter->first].size() > 0){
+               
+                       ProcessData.Append(";MEDIATYPE=");
+                       ProcessData.Append((*WebsiteListMediatype)[WebsiteIter->first]);
+                       
+               }
+               
+               // Check if there is a value for PID.
+
+               if ((*WebsiteListPID)[WebsiteIter->first].size() > 0){
+               
+                       ProcessData.Append(";PID=");
+                       ProcessData.Append((*WebsiteListPID)[WebsiteIter->first]);
+                       
+               }
+
+               // Check if there is a value for PREF.
+
+               if ((*WebsiteListPref)[WebsiteIter->first] > 0){
+               
+                       ProcessData.Append(";PREF=");
+                       ProcessData.Append(wxString::Format("%i", (*WebsiteListPref)[WebsiteIter->first]));
+                       
+               }
+
+               // Check if there is a value for tokens.
+
+               if ((*WebsiteListTokens)[WebsiteIter->first].size() > 0){
+               
+                       ProcessData.Append(";");
+                       ProcessData.Append((*WebsiteListTokens)[WebsiteIter->first]);
+                       
+               }
+                       
+               ProcessData.Append(":");
+               ProcessData.Append(WebsiteIter->second);
+               ProcessData.Append("\n");
+
+               ProcessData = OutputText(&ProcessData);
+                       
+               SaveData->Append(ProcessData);
+               ProcessData.clear();
+                       
+       }
+                       
 }
\ No newline at end of file
index ecb58c3..2cf736b 100644 (file)
@@ -135,6 +135,10 @@ class ContactDataObject{
                map<int, wxString> *GeographyListMediatype, map<int, wxString> *GeographyListDataType,
                map<int, int> *GeographyListPref, map<int, wxString> *GeographyListTokens, 
                wxString *SaveData, wxString DataType);
+       void SaveURL(map<int, wxString> *WebsiteList, map<int, wxString> *WebsiteListAltID, 
+               map<int, wxString> *WebsiteListPID, map<int, wxString> *WebsiteListType,
+               map<int, wxString> *WebsiteListMediatype, map<int, int> *WebsiteListPref, 
+               map<int, wxString> *WebsiteListTokens, wxString *SaveData, wxString DataType);
 
        public:
 
index 9f7a587..b0842da 100644 (file)
@@ -121,6 +121,11 @@ TEST(ContactSave, ContactSaveTests){
        "RELATED;TYPE=kin;ALTID=5;PID=10;PREF=20;OPTION=Yes:Friend Test\n"
        "RELATED;TYPE=spouse;ALTID=1;PID=2;PREF=3;OPTION=No:Friend Test Two\n"
        "RELATED;TYPE=muse;ALTID=4;PID=5;PREF=6;OPTION=Maybe:Friend Test Three\n"
+       "URL;ALTID=0;MEDIATYPE=text/plain;PID=1;PREF=2;MEEP=Moo:http://example.com/\n"
+       "URL;TYPE=home;ALTID=10;MEDIATYPE=grass/soggy;PID=11;PREF=12;BON=Bon:http://ex\n"
+       " ample.com/home/\n"
+       "URL;TYPE=work;ALTID=20;MEDIATYPE=chocolate/yummy;PID=21;PREF=22;YES=No:http:/\n"
+       " /example.com/business/\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