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

index fbcfc1c..b7d2688 100644 (file)
@@ -316,6 +316,24 @@ ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){
                &BusinessLanguageListPref, &BusinessLanguageListTokens, 
                SaveData, "work");
 
+       // Process GEO.
+       
+       SaveGeoposition(&GeneralGeographyList, &GeneralGeographyListAltID, 
+               &GeneralGeographyListPID, &GeneralGeographyListType,
+               &GeneralGeographyListMediatype, &GeneralGeographyListDataType,
+               &GeneralGeographyListPref, &GeneralGeographyListTokens, 
+               SaveData, "");
+       SaveGeoposition(&HomeGeographyList, &HomeGeographyListAltID, 
+               &HomeGeographyListPID, &HomeGeographyListType,
+               &HomeGeographyListMediatype, &HomeGeographyListDataType,
+               &HomeGeographyListPref, &HomeGeographyListTokens, 
+               SaveData, "home");
+       SaveGeoposition(&BusinessGeographyList, &BusinessGeographyListAltID, 
+               &BusinessGeographyListPID, &BusinessGeographyListType,
+               &BusinessGeographyListMediatype, &BusinessGeographyListDataType,
+               &BusinessGeographyListPref, &BusinessGeographyListTokens, 
+               SaveData, "work");
+
        // Write the end part of the vCard data file.
        
        SaveData->Append("END:VCARD");
@@ -915,4 +933,86 @@ void ContactDataObject::SaveLanguage(map<int, wxString> *LanguageList, map<int,
                        
        }
                
+}
+
+void ContactDataObject::SaveGeoposition(map<int, wxString> *GeographyList, map<int, wxString> *GeographyListAltID, 
+       map<int, wxString> *GeographyListPID, map<int, wxString> *GeographyListType,
+       map<int, wxString> *GeographyListMediatype, map<int, wxString> *GeographyListDataType,
+       map<int, int> *GeographyListPref, map<int, wxString> *GeographyListTokens, 
+       wxString *SaveData, wxString DataType){
+
+       wxString ProcessData = "";
+       
+       for (std::map<int, wxString>::iterator GeographyIter = GeographyList->begin();
+               GeographyIter != GeographyList->end(); GeographyIter++){
+
+               ProcessData.Append("GEO");
+                       
+               // 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 ((*GeographyListAltID)[GeographyIter->first].size() > 0){
+               
+                       ProcessData.Append(";ALTID=");
+                       ProcessData.Append((*GeographyListAltID)[GeographyIter->first]);
+                       
+               }
+               
+               // Check if there is a value for MEDIATYPE.
+               
+               if ((*GeographyListMediatype)[GeographyIter->first].size() > 0){
+               
+                       ProcessData.Append(";MEDIATYPE=");
+                       ProcessData.Append((*GeographyListMediatype)[GeographyIter->first]);
+                       
+               }
+               
+               // Check if there is a value for PID.
+
+               if ((*GeographyListPID)[GeographyIter->first].size() > 0){
+               
+                       ProcessData.Append(";PID=");
+                       ProcessData.Append((*GeographyListPID)[GeographyIter->first]);
+                       
+               }
+
+               // Check if there is a value for PREF.
+
+               if ((*GeographyListPref)[GeographyIter->first] > 0){
+               
+                       ProcessData.Append(";PREF=");
+                       ProcessData.Append(wxString::Format("%i", (*GeographyListPref)[GeographyIter->first]));
+                       
+               }
+
+               // Check if there is a value for tokens.
+
+               if ((*GeographyListTokens)[GeographyIter->first].size() > 0){
+               
+                       ProcessData.Append(";");
+                       ProcessData.Append((*GeographyListTokens)[GeographyIter->first]);
+                       
+               }
+                       
+               ProcessData.Append(":");
+               ProcessData.Append((*GeographyListDataType)[GeographyIter->first]);
+               ProcessData.Append(":");
+               ProcessData.Append(GeographyIter->second);
+               ProcessData.Append("\n");
+
+               ProcessData = OutputText(&ProcessData);
+                       
+               SaveData->Append(ProcessData);
+               ProcessData.clear();
+                       
+       }
+               
 }
\ No newline at end of file
index 5cc94c9..ecb58c3 100644 (file)
@@ -130,6 +130,11 @@ class ContactDataObject{
                map<int, wxString> *LanguageListPID, map<int, wxString> *LanguageListType,
                map<int, int> *LangaugeListPref, map<int, wxString> *LanguageListTokens, 
                wxString *SaveData, wxString DataType);
+       void SaveGeoposition(map<int, wxString> *GeographyList, map<int, wxString> *GeographyListAltID, 
+               map<int, wxString> *GeographyListPID, map<int, wxString> *GeographyListType,
+               map<int, wxString> *GeographyListMediatype, map<int, wxString> *GeographyListDataType,
+               map<int, int> *GeographyListPref, map<int, wxString> *GeographyListTokens, 
+               wxString *SaveData, wxString DataType);
 
        public:
 
index baf9441..ab44064 100644 (file)
@@ -113,6 +113,11 @@ TEST(ContactSave, ContactSaveTests){
        "LANG;ALTID=20;PID=40;PREF=80;GELFORN=Great:kw\n"
        "LANG;TYPE=home;ALTID=22;PID=45;PREF=90;LANGUAGE=yes:en\n"
        "LANG;TYPE=work;ALTID=10;PID=15;PREF=20;FFENSTRI=ie:cy\n"
+       "GEO;ALTID=13;MEDIATYPE=text/plain;PID=26;PREF=39;POS=Yep:geo:3.5,3.5\n"
+       "GEO;TYPE=home;ALTID=140;MEDIATYPE=text/ratherplain;PID=70;PREF=1;POS=Nope:geo\n"
+       " :7.0,7.0\n"
+       "GEO;TYPE=work;ALTID=75;MEDIATYPE=text/greenplain;PID=32;PREF=4;POS=Money:geo:\n"
+       " 14.0,14.0\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