Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Now insert 'geo:' with value if no data type is given for GEO.
[xestiaab/.git] / source / contacteditor / frmContactEditor-Save.cpp
index 65e8715..9148b98 100644 (file)
@@ -154,8 +154,6 @@ void frmContactEditor::SaveContact( wxCommandEvent& event )
     
     // Begin preperations to write the contact to a file.
     
-    bool boolValue = FALSE;
-    bool boolValue2 = FALSE;
     bool FNFirst = TRUE;
     bool NNGeneralFirst = TRUE;
     bool NNHomeFirst = TRUE;
@@ -175,6 +173,87 @@ void frmContactEditor::SaveContact( wxCommandEvent& event )
     
     ContactData.Add(wxT("PRODID"), strValue, FALSE);
     
+    // Process the REV property.
+    
+    wxDateTime DateTimeSave;
+    DateTimeSave = DateTimeSave.SetToCurrent();
+    wxString DateTimeSaveValue;
+    
+    DateTimeSaveValue += wxString::Format("%04i", DateTimeSave.GetYear());
+    DateTimeSaveValue += wxString::Format("%02i", (DateTimeSave.GetMonth() + 1));
+    DateTimeSaveValue += wxString::Format("%02i", DateTimeSave.GetDay());
+    DateTimeSaveValue += "T";
+    DateTimeSaveValue += wxString::Format("%02i", DateTimeSave.GetHour());
+    DateTimeSaveValue += wxString::Format("%02i", DateTimeSave.GetMinute());
+    DateTimeSaveValue += wxString::Format("%02i", DateTimeSave.GetSecond());    
+    
+    if (!ContactEditorData.RevisionTokens.IsEmpty()){
+       ContactData.AddRaw("REV;" + ContactEditorData.RevisionTokens, DateTimeSaveValue);
+    } else {
+       ContactData.AddRaw("REV", DateTimeSaveValue);
+    }
+    // Process the XML properties.
+    
+    for (std::map<int,wxString>::iterator iter = ContactEditorData.XMLList.begin();
+         iter != ContactEditorData.XMLList.end(); ++iter){
+    
+       wxString strOrigValue;
+    
+       strOrigValue = ContactEditorData.XMLList.find(iter->first)->second;
+    
+       ResetUnusedString(&strOrigValue);
+    
+        ProcessSaveData(wxT("XML"), &strValue2, &boolValue2, &boolValue,
+                        &iter, &strOrigValue, &ContactData,
+                        wxT("ALTID"), &ContactEditorData.XMLListAltID );
+        
+        ResetSaveProcessData();
+        
+    }
+    
+    // Process the CLIENTPIDMAP properties.
+    
+    for (std::map<int,wxString>::iterator iter = ContactEditorData.ClientPIDList.begin();
+         iter != ContactEditorData.ClientPIDList.end(); ++iter){
+        
+       wxString strOrigValue;
+    
+       strOrigValue = ContactEditorData.ClientPIDList.find(iter->first)->second;
+    
+       ResetUnusedString(&strOrigValue);
+        
+       ProcessSaveData(wxT("CLIENTPIDMAP"), &strValue2, &boolValue2, &boolValue,
+                        &iter, &strOrigValue, &ContactData,
+                        wxT(""), &ContactEditorData.ClientPIDListTokens );
+        
+        ResetSaveProcessData();
+        
+    } 
+    
+    // Process the SOURCE properties.
+    
+    for (std::map<int,wxString>::iterator iter = ContactEditorData.SourceList.begin();
+         iter != ContactEditorData.SourceList.end(); ++iter){
+        
+       wxString strOrigValue;
+    
+       strOrigValue = ContactEditorData.SourceList.find(iter->first)->second;
+    
+       ResetUnusedString(&strOrigValue);
+        
+       ProcessSaveData(wxT("SOURCE"), &strValue2, &boolValue2, &boolValue,
+                        &iter, &strOrigValue, &ContactData,
+                       wxT("ALTID"), &ContactEditorData.SourceListAltID,
+                       wxT("PID"), &ContactEditorData.SourceListPID,
+                       wxT("TYPE"), &ContactEditorData.SourceListType,
+                       wxT("PREF"), &ContactEditorData.SourceListPref,
+                       wxT("MEDIATYPE"), &ContactEditorData.SourceListMediatype,
+                        wxT(""), &ContactEditorData.SourceListTokens );
+        
+        ResetSaveProcessData();
+       
+    }
+    
     // Setup the name.
     
     strValue.Clear();
@@ -1075,8 +1154,20 @@ void frmContactEditor::SaveContact( wxCommandEvent& event )
         
         ProcessCaptureStrings(&strAddressFinalValue);
         
-        strAddressFinalValue.insert(0, wxT("tel:"));
-        
+       if (ContactEditorData.GeneralTelephoneListDataType.find(iter->first) != 
+               ContactEditorData.GeneralTelephoneListDataType.end()){
+       
+               std::map<int,wxString>::iterator DataTypeIter = ContactEditorData.GeneralTelephoneListDataType.find(iter->first);
+
+               strAddressFinalValue.insert(0, ":");    
+               strAddressFinalValue.insert(0, DataTypeIter->second);
+       
+       } else {
+
+               strAddressFinalValue.insert(0, "tel:");
+       
+       }
+               
         ProcessSaveData(wxT("TEL"), &strValue2, &boolValue2, &boolValue,
                         &iter, &strAddressFinalValue, &ContactData,
                         wxT("ALTID"), &ContactEditorData.GeneralTelephoneListAltID,
@@ -1098,7 +1189,19 @@ void frmContactEditor::SaveContact( wxCommandEvent& event )
         
         ProcessCaptureStrings(&strAddressFinalValue);
         
-        strAddressFinalValue.insert(0, wxT("tel:"));
+       if (ContactEditorData.HomeTelephoneListDataType.find(iter->first) != 
+               ContactEditorData.HomeTelephoneListDataType.end()){
+       
+               std::map<int,wxString>::iterator DataTypeIter = ContactEditorData.HomeTelephoneListDataType.find(iter->first);
+
+               strAddressFinalValue.insert(0, ":");    
+               strAddressFinalValue.insert(0, DataTypeIter->second);
+       
+       } else {
+
+               strAddressFinalValue.insert(0, "tel:");
+       
+       }
         
         ProcessSaveData(wxT("TEL"), &strValue2, &boolValue2, &boolValue,
                         &iter, &strAddressFinalValue, &ContactData,
@@ -1121,7 +1224,19 @@ void frmContactEditor::SaveContact( wxCommandEvent& event )
         
         ProcessCaptureStrings(&strAddressFinalValue);
         
-        strAddressFinalValue.insert(0, wxT("tel:"));
+       if (ContactEditorData.BusinessTelephoneListDataType.find(iter->first) != 
+               ContactEditorData.BusinessTelephoneListDataType.end()){
+       
+               std::map<int,wxString>::iterator DataTypeIter = ContactEditorData.BusinessTelephoneListDataType.find(iter->first);
+
+               strAddressFinalValue.insert(0, ":");    
+               strAddressFinalValue.insert(0, DataTypeIter->second);
+       
+       } else {
+
+               strAddressFinalValue.insert(0, "tel:");
+       
+       }
         
         ProcessSaveData(wxT("TEL"), &strValue2, &boolValue2, &boolValue,
                         &iter, &strAddressFinalValue, &ContactData,
@@ -1241,14 +1356,26 @@ void frmContactEditor::SaveContact( wxCommandEvent& event )
     for (std::map<int,wxString>::iterator iter = ContactEditorData.GeneralGeographyList.begin();
          iter != ContactEditorData.GeneralGeographyList.end(); ++iter){
         
-        wxString strAddressFinalValue = iter->second;
+        wxString strGeoFinalValue = iter->second;
         
-        ProcessCaptureStrings(&strAddressFinalValue);
+        ProcessCaptureStrings(&strGeoFinalValue);
         
-        strAddressFinalValue.insert(0, wxT("geo:"));
+       if (ContactEditorData.GeneralGeographyListDataType.find(iter->first) != 
+               ContactEditorData.GeneralGeographyListDataType.end()){
+       
+               std::map<int,wxString>::iterator DataTypeIter = ContactEditorData.GeneralGeographyListDataType.find(iter->first);
+
+               strGeoFinalValue.insert(0, ":");        
+               strGeoFinalValue.insert(0, DataTypeIter->second);
+       
+       } else {
+
+               strGeoFinalValue.insert(0, "geo:");
+       
+       }
         
         ProcessSaveData(wxT("GEO"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &strAddressFinalValue, &ContactData,
+                        &iter, &strGeoFinalValue, &ContactData,
                         wxT("ALTID"), &ContactEditorData.GeneralGeographyListAltID,
                         wxT("PID"), &ContactEditorData.GeneralGeographyListPID,
                         wxT("MEDIATYPE"), &ContactEditorData.GeneralGeographyListMediatype,
@@ -1264,14 +1391,26 @@ void frmContactEditor::SaveContact( wxCommandEvent& event )
     for (std::map<int,wxString>::iterator iter = ContactEditorData.HomeGeographyList.begin();
          iter != ContactEditorData.HomeGeographyList.end(); ++iter){
         
-        wxString strAddressFinalValue = iter->second;
+        wxString strGeoFinalValue = iter->second;
         
-        ProcessCaptureStrings(&strAddressFinalValue);
+        ProcessCaptureStrings(&strGeoFinalValue);
         
-        strAddressFinalValue.insert(0, wxT("geo:"));
+       if (ContactEditorData.HomeGeographyListDataType.find(iter->first) != 
+               ContactEditorData.HomeGeographyListDataType.end()){
+       
+               std::map<int,wxString>::iterator DataTypeIter = ContactEditorData.HomeGeographyListDataType.find(iter->first);
+
+               strGeoFinalValue.insert(0, ":");        
+               strGeoFinalValue.insert(0, DataTypeIter->second);
+       
+       } else {
+
+               strGeoFinalValue.insert(0, "geo:");
+       
+       }
         
         ProcessSaveData(wxT("GEO;TYPE=home"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &ContactEditorData.HomeGeographyList, &ContactData,
+                        &iter, &strGeoFinalValue, &ContactData,
                         wxT("ALTID"), &ContactEditorData.HomeGeographyListAltID,
                         wxT("PID"), &ContactEditorData.HomeGeographyListPID,
                         wxT("MEDIATYPE"), &ContactEditorData.HomeGeographyListMediatype,
@@ -1287,14 +1426,26 @@ void frmContactEditor::SaveContact( wxCommandEvent& event )
     for (std::map<int,wxString>::iterator iter = ContactEditorData.BusinessGeographyList.begin();
          iter != ContactEditorData.BusinessGeographyList.end(); ++iter){
         
-        wxString strAddressFinalValue = iter->second;
+        wxString strGeoFinalValue = iter->second;
         
-        ProcessCaptureStrings(&strAddressFinalValue);
+        ProcessCaptureStrings(&strGeoFinalValue);
         
-        strAddressFinalValue.insert(0, wxT("geo:"));
+       if (ContactEditorData.BusinessGeographyListDataType.find(iter->first) != 
+               ContactEditorData.BusinessGeographyListDataType.end()){
+       
+               std::map<int,wxString>::iterator DataTypeIter = ContactEditorData.BusinessGeographyListDataType.find(iter->first);
+
+               strGeoFinalValue.insert(0, ":");        
+               strGeoFinalValue.insert(0, DataTypeIter->second);
+       
+       } else {
+
+               strGeoFinalValue.insert(0, "geo:");
+       
+       }
         
         ProcessSaveData(wxT("GEO;TYPE=work"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &ContactEditorData.BusinessGeographyList, &ContactData,
+                        &iter, &strGeoFinalValue, &ContactData,
                         wxT("ALTID"), &ContactEditorData.BusinessGeographyListAltID,
                         wxT("PID"), &ContactEditorData.BusinessGeographyListPID,
                         wxT("MEDIATYPE"), &ContactEditorData.BusinessGeographyListMediatype,
@@ -1738,157 +1889,7 @@ void frmContactEditor::SaveContact( wxCommandEvent& event )
          iter != ContactEditorData.KeyList.end(); ++iter){
         
         intValue2 = iter->first;
-        
-        // Process Alternative ID.
-        
-        striter = ContactEditorData.KeyListAltID.find(intValue2);
-        
-        if (striter->first == intValue2){
-            
-            strValue3 = striter->second;
-            
-            if (!strValue3.IsEmpty()){
-                
-                strValue3.Trim();
-                strValue3.Trim();
-                
-                if (boolValue2 == TRUE){
-                    
-                    strValue2.Append(wxT(";"));
-                    
-                } else {
-                    
-                    boolValue2 = TRUE;
-                    
-                }
-                
-                strValue2.Append(wxT("ALTID=") + strValue3);
-                
-                boolValue = TRUE;
-                
-            }
-            
-        }
-        
-        // Process PID.
-        
-        striter = ContactEditorData.KeyListPID.find(intValue2);
-        
-        if (striter->first == intValue2){
-            
-            strValue3 = striter->second;
-            
-            if (!strValue3.IsEmpty()){
-                
-                strValue3.Trim();
-                strValue3.Trim();
-                
-                if (boolValue2 == TRUE){
-                    
-                    strValue2.Append(wxT(";"));
-                    
-                } else {
-                    
-                    boolValue2 = TRUE;
-                    
-                }
-                
-                strValue2.Append(wxT("PID=") + strValue3);
-                
-                boolValue = TRUE;
-                
-            }
-            
-        }
-        
-        // Process Type.
-        
-        striter = ContactEditorData.KeyListType.find(intValue2);
-        
-        if (striter->first == intValue2){
-            
-            strValue3 = striter->second;
-            
-            if (!strValue3.IsEmpty()){
-                
-                strValue3.Trim();
-                strValue3.Trim();
-                
-                if (boolValue2 == TRUE){
-                    
-                    strValue2.Append(wxT(";"));
-                    
-                } else {
-                    
-                    boolValue2 = TRUE;
-                    
-                }
-                
-                strValue2.Append(wxT("TYPE=") + strValue3);
-                
-                boolValue = TRUE;
-                
-            }
-            
-        }
-        
-        intiter = ContactEditorData.KeyListPref.find(intValue2);
-        
-        if (intiter->first == intValue2){
-            
-            intValue3 = intiter->second;
-            
-            if (intValue3){
-                
-                if (boolValue2 == TRUE){
-                    
-                    strValue2.Append(wxT(";"));
-                    
-                } else {
-                    
-                    boolValue2 = TRUE;
-                    
-                }
-                
-                strValue2.Append(wxT("PREF=") + wxString::Format(wxT("%i"), intValue3));
-                
-                boolValue = TRUE;
-                
-            }
-            
-        }      
-        
-        // Process Tokens.
-        
-        striter = ContactEditorData.KeyListTokens.find(intValue2);
-        
-        if (striter->first == intValue2){
-            
-            strValue3 = striter->second;
-            
-            if (!strValue3.IsEmpty()){
-                
-                strValue3.Trim();
-                strValue3.Trim();
-                
-                if (boolValue2 == TRUE){
-                    
-                    strValue2.Append(wxT(";"));
-                    
-                } else {
-                    
-                    boolValue2 = TRUE;
-                    
-                }
-                
-                strValue2.Append(strValue3);
-                
-                boolValue = TRUE;
-                
-            }
-            
-        }      
-        
+       
         // Get the key information.
         
         std::map<int, wxString>::iterator enciter;
@@ -1899,23 +1900,17 @@ void frmContactEditor::SaveContact( wxCommandEvent& event )
         wxString strValueData;
         
         strValueData = iter->second;   
-        //strValueData.insert(0, wxT("data:") + striter->second + wxT(";") + enciter->second + wxT(","));
-        strValueData.insert(0, wxT("data:") + striter->second + wxT(";base64,"));      
-        
-        
-        // Add to the vCard.
-        
-        if (boolValue == TRUE){
-            
-            ContactData.AddRaw(wxT("KEY;") + strValue2, strValueData);
-            
-        } else {
-            
-            ContactData.Add(wxT("KEY"), strValueData, TRUE);
-            
-        }
+        strValueData.insert(0, wxT("data:") + striter->second + wxT(";base64,"));
+       
+        ProcessSaveData(wxT("KEY"), &strValue2, &boolValue2, &boolValue,
+                        &iter, &strValueData, &ContactData,
+                        wxT("ALTID"), &ContactEditorData.KeyListAltID,
+                        wxT("PID"), &ContactEditorData.KeyListPID,
+                        wxT("TYPE"), &ContactEditorData.KeyListType,
+                        wxT("PREF"), &ContactEditorData.KeyListPref,
+                        wxT(""), &ContactEditorData.KeyListTokens );
         
-        ResetSaveProcessData();   
+        ResetSaveProcessData();
         
     }
     
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