Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Reimplemented BDAY. Simplified implementation.
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 10 Jan 2016 20:56:27 +0000 (20:56 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 10 Jan 2016 20:56:27 +0000 (20:56 +0000)
source/contacteditor/frmContactEditor-Save.cpp

index 9148b98..e23bbd9 100644 (file)
@@ -387,91 +387,89 @@ void frmContactEditor::SaveContact( wxCommandEvent& event )
         
     }
     
-    strValue.Clear();
-    strValue2.Clear();
-    strValue3.Clear();
+    ResetSaveProcessData();
     
-    boolValue = FALSE;
-    boolValue2 = FALSE;
-    intValue2 = 0;
-    intValue  = 0;
+    // Build the values for the BDAY property.
+
+    // ALTID
+
+    if (!ContactEditorData.BirthdayAltID.IsEmpty()){
     
-    // Process Label.
+       wxString DataValue;
+       DataValue = ContactEditorData.BirthdayAltID;
     
-    strValue3 = ContactEditorData.BirthdayAltID;
+       EscapeString(&DataValue, FALSE);
+    
+       strValue3.Append("ALTID=");
+       strValue3.Append(DataValue);
+    
+       boolValue2 = TRUE;
     
-    if (!strValue3.IsEmpty()){
-        
-        strValue3.Trim();
-        strValue3.Trim();
-        boolValue2 = TRUE;
-        strValue2.Append(wxT("ALTID=\"") + strValue3 + wxT("\""));
-        
-        boolValue = TRUE;
-        
     }
     
-    //strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
-    //strValue2 =
+    // CALSCALE.
     
-    // Process Language.
+    if (!ContactEditorData.BirthdayCalScale.IsEmpty()){
     
-    strValue3 = ContactEditorData.BirthdayCalScale;
+       wxString DataValue;
+       DataValue = ContactEditorData.BirthdayCalScale;
     
-    if (!strValue3.IsEmpty()){
-        
-        strValue3.Trim();
-        strValue3.Trim();
-        
-        if (boolValue2 == TRUE){
-            
-            strValue2.Append(wxT(";"));
-            
-        } else {
-            
-            boolValue2 = TRUE;
-            
-        }
-        
-        strValue2.Append(wxT("CALSCALE=") + strValue3);
-        
-        boolValue = TRUE;
-        
-    }
+       EscapeString(&DataValue, FALSE);
     
-    // Process Tokens.
+       if (boolValue2 == TRUE){
+       
+               strValue3.Append(";");
+       
+       }
+       
+       strValue3.Append("CALSCALE=");
+       strValue3.Append(DataValue);
+       
+       boolValue2 = TRUE;
     
-    strValue2 = ContactEditorData.BirthdayTokens;
+    }
     
-    // Get the birthday and write it.
+    // Extra tokens.
     
-    ResetSaveProcessData();
+    if (!ContactEditorData.BirthdayTokens.IsEmpty()){
+    
+       wxString DataValue;
+       DataValue = ContactEditorData.BirthdayTokens;
+       
+       EscapeString(&DataValue, FALSE);
+       
+       if (boolValue2 == TRUE){
+       
+               strValue3.Append(";");
+       
+       }
+       
+       strValue3.Append(DataValue);
     
+    }
+
+    // Write the BDAY property.
+
     if (!txtBirthday->IsEmpty()){
-        
-        strValue = txtBirthday->GetValue();
-        
-        if (!strValue.IsEmpty() || !strValue2.IsEmpty()){
-            
-            if (!strValue2.IsEmpty()){
-                
-                EscapeString(&strValue2, FALSE);
-                EscapeString(&strValue, FALSE);
-                
-                ContactData.AddRaw(wxT("BDAY;VALUE=text;") + strValue2 + wxT(";"), strValue);
-                
-            } else {
-                
-                EscapeString(&strValue, FALSE);
-                
-                ContactData.AddRaw(wxT("BDAY;VALUE=text"), strValue);
-                
-            }
-            
-        }
-        
+       
+       if (!txtBirthday->GetValue().IsEmpty()){
+       
+           strValue = txtBirthday->GetValue();
+       
+           if (!strValue3.IsEmpty()){
+           
+               ContactData.AddRaw("BDAY;VALUE=text;" + strValue3, strValue);
+           
+           } else {
+
+               ContactData.AddRaw("BDAY;VALUE=text", strValue);
+           
+           }
+           
+       }
+    
     } else {
-        
+    
         // Deal with date.
         
         // Get Day, Month & Year.
@@ -559,14 +557,14 @@ void frmContactEditor::SaveContact( wxCommandEvent& event )
                 
             }
             
-            if (!FinalBirthdayString.IsEmpty() || !strValue2.IsEmpty()){
+            if (!FinalBirthdayString.IsEmpty() || !strValue3.IsEmpty()){
                 
-                if (!strValue2.IsEmpty()){
+                if (!strValue3.IsEmpty()){
                     
                     EscapeString(&strValue2, FALSE);
                     EscapeString(&strValue, FALSE);
                     
-                    ContactData.AddRaw(wxT("BDAY") + strValue2 + wxT(";"), FinalBirthdayString);
+                    ContactData.AddRaw(wxT("BDAY;") + strValue3, FinalBirthdayString);
                     
                 } else {
                     
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