Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmContactEditor: Check if there is values in certain text boxes
[xestiaab/.git] / source / contacteditor / frmContactEditor-Save.cpp
index 66890df..baeeae5 100644 (file)
@@ -1,3 +1,21 @@
+// frmContactEditor-Save.cpp - frmContactEditor save contact subroutines.
+//
+// (c) 2012-2016 Xestia Software Development.
+//
+// This file is part of Xestia Address Book.
+//
+// Xestia Address Book is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by the
+// Free Software Foundation, version 3 of the license.
+//
+// Xestia Address Book is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
+
 #include "frmContactEditor.h"
 #include "../enums.h"
 #include "../version.h"
 void frmContactEditor::SaveContact( wxCommandEvent& event )
 {
     
-    // Check if Display As combo box has a value in it.
-    // Do not go any further if there is no value.
-    
-    wxString cmbDisplayAsValue = cmbDisplayAs->GetValue();
+       // Do not save if the account is an unsupported account.
+       
+       if (boolUnsupportedAccount == true){
+       
+               wxMessageBox(_("Cannot make changes to a contact from an unsupported account type."), _("Unsupported account"), wxICON_ERROR);          
+               return;
+               
+       }
+       
+       // Check if Display As combo box has a value in it.
+       // Do not go any further if there is no value.
+    
+       wxString cmbDisplayAsValue = cmbDisplayAs->GetValue();
+    
+       if (cmbDisplayAsValue.IsEmpty()){
+        
+               wxMessageBox(_("Display As value cannot be left blank."), _("Display As value empty"), wxICON_ERROR);
+               return;
+        
+       }
+    
+       // Check if a value has been entered either in the Title,
+       // Forename, Surname, Other Names and Suffix text boxes.
+       
+       if (txtTitle->IsEmpty() && txtForename->IsEmpty() && txtSurname->IsEmpty() 
+               && txtOtherNames->IsEmpty() && txtSuffix->IsEmpty())
+       {
+
+               wxMessageBox(_("A value must be as minimum eithered in either the Title, Forename, Surname, Other Names or Suffix text boxes."), _("No name information entered"), wxICON_ERROR);
+               saveSuccess = false;
+               return;
+               
+       }
     
-    if (cmbDisplayAsValue.IsEmpty()){
-        
-        wxMessageBox(_("Display As value cannot be left blank."), _("Display As value empty"), wxICON_ERROR);
-        return;
-        
-    }
+       // Save the updated contact data.
     
-    // Save the updated contact data.
+       //vCard ContactData;
+       wxString FilenameFinal;
+       bool ReplaceContact = FALSE;
     
-    vCard ContactData;
-    wxString FilenameFinal;
-    bool ReplaceContact = FALSE;
+       if (StartupEditMode == TRUE){
     
-    if (cmbType->GetCurrentSelection() == 1 ||
-        cmbType->GetCurrentSelection() == 3 ||
-        cmbType->GetCurrentSelection() == 4){
+               if (cmbType->GetCurrentSelection() == 1 ||
+                   cmbType->GetCurrentSelection() == 3 ||
+                   cmbType->GetCurrentSelection() == 4){
         
-        if (IsGroup == TRUE){
-            
-            // Mark contact for replacing.
+                       if (IsGroup == TRUE){
             
-            ReplaceContact = TRUE;
+                               // Mark contact for replacing.
             
-        }
+                               ReplaceContact = TRUE;
+                               IsGroup = FALSE;
+           
+                       }
         
-    } else if (cmbType->GetCurrentSelection() == 2){
+               } else if (cmbType->GetCurrentSelection() == 2){
         
-        if (IsGroup == TRUE){
-            
-            // Mark contact for replacing.
+                       if (IsGroup == FALSE){
             
-            ReplaceContact = TRUE;
+                               // Mark contact for replacing.
             
-        }
+                               ReplaceContact = TRUE;
+                               IsGroup = TRUE;
+           
+                       }
         
-    }
+               }
     
-    if (ReplaceContact == TRUE){
+               if (ReplaceContact == TRUE){
         
-        wxString wxDelSplitFilename;
-        wxString wxDelFinalFilename;
-        wxString wxSDelDataURL;
-        wxStringTokenizer wSTDelFilename(wxSContactFilename, wxT("/"));
-        while(wSTDelFilename.HasMoreTokens()){
+                       wxString wxDelSplitFilename;
+                       wxString wxDelFinalFilename;
+                       wxString wxSDelDataURL;
+                       wxStringTokenizer wSTDelFilename(wxSContactFilename, wxT("/"));
+                       
+                       while(wSTDelFilename.HasMoreTokens()){
             
-            wxDelSplitFilename = wSTDelFilename.GetNextToken();
+                               wxDelSplitFilename = wSTDelFilename.GetNextToken();
             
-        }
+                       }
         
-        wxSDelDataURL = wxDelSplitFilename;
+                       wxSDelDataURL = wxDelSplitFilename;
         
-        // Delete the contact from the server as it will be useless in certain
-        // address book clients.
+                       // Delete the contact from the server as it will be useless in certain
+                       // address book clients.
         
-        ActMgrPtr->AddTask(2, cmbDisplayAs->GetValue(), wxSContactAccount, wxSDelDataURL, wxDelSplitFilename, wxSContactFilename, wxT(""));
+                       ActMgrPtr->AddTask(2, cmbDisplayAs->GetValue(), wxSContactAccount, wxSDelDataURL, wxDelSplitFilename, wxSContactFilename, wxT(""));
         
-        // Clear the filename so the trigger to recreate the UID is done.
+                       // Clear the filename so the trigger to recreate the UID is done.
         
-        wxSContactFilename.Clear();
-        EditMode = FALSE;
+                       wxSContactFilename.Clear();
+                       EditMode = FALSE;
         
-    }
+               }
+    
+       }
     
-    if (wxSContactFilename.IsEmpty()){
+       if (wxSContactFilename.IsEmpty()){
         
-        // Generate a random UUID.
+               // Generate a random UUID.
         
-        UIDToken = GenerateUUID();
-        UIDToken = UIDToken.MakeUpper();
+               ContactEditorData.UIDToken = GenerateUUID();
+               ContactEditorData.UIDToken = ContactEditorData.UIDToken.MakeUpper();
         
-        // Setup the filename.
+               // Setup the filename.
         
-        FilenameFinal = GetAccountDir(wxSContactAccount, FALSE);
+               FilenameFinal = GetAccountDir(wxSContactAccount, FALSE);
         
 #if defined(__HAIKU__)
-        
-        //preffilename = wxT("noo");
-        
+                
 #elif defined(__WIN32__)
         
-        FilenameFinal = GetAccountDir(wxSContactAccount, FALSE);
-        FilenameFinal.Append(UIDToken);
-        FilenameFinal.Append(wxT(".vcf"));
-        wxSContactFilename = FilenameFinal;
+               FilenameFinal = GetAccountDir(wxSContactAccount, FALSE);
+               FilenameFinal.Append(ContactEditorData.UIDToken);
+               FilenameFinal.Append(wxT(".vcf"));
+               wxSContactFilename = FilenameFinal;
         
 #else
         
-        FilenameFinal = GetAccountDir(wxSContactAccount, FALSE);
-        FilenameFinal.Append(UIDToken);
-        FilenameFinal.Append(wxT(".vcf"));
-        wxSContactFilename = FilenameFinal;
+               FilenameFinal = GetAccountDir(wxSContactAccount, FALSE);
+               FilenameFinal.Append(ContactEditorData.UIDToken);
+               FilenameFinal.Append(wxT(".vcf"));
+               wxSContactFilename = FilenameFinal;
         
 #endif
         
-    } else {
+       } else {
         
-        if (UIDToken.IsEmpty()){
+               if (ContactEditorData.UIDToken.IsEmpty()){
             
-            // UID Token is empty. (Shouldn't be).
-            // Generate a new UID Token.
+                       // UID Token is empty. (Shouldn't be).
+                       // Generate a new UID Token.
             
-            /*boost::uuids::uuid ContactUUID = boost::uuids::random_generator()();
-             std::string sstContactUUID = boost::uuids::to_string(ContactUUID);
-             wxString strContactUUID(sstContactUUID.c_str(), wxConvUTF8);
-             UIDToken = strContactUUID;*/
-            UIDToken = GenerateUUID();
-            UIDToken = UIDToken.MakeUpper();
+                       ContactEditorData.UIDToken = GenerateUUID();
+                       ContactEditorData.UIDToken = ContactEditorData.UIDToken.MakeUpper();
             
-        }
-        FilenameFinal = wxSContactFilename;
+               }
+       
+               FilenameFinal = wxSContactFilename;
         
-    }
-    
-    // Setup the data and write it into the account folder.
-    
-    // Begin preperations to write the contact to a file.
-    
-    bool boolValue = FALSE;
-    bool boolValue2 = FALSE;
-    bool FNFirst = TRUE;
-    bool NNGeneralFirst = TRUE;
-    bool NNHomeFirst = TRUE;
-    bool NNWorkFirst = TRUE;
-    int intFNCount = 0;
-    std::map<int,int>::iterator intiter;
-    std::map<int,wxString>::iterator striter;
+       }
     
-    ContactData.Add(wxT("BEGIN"), wxT("VCARD"), FALSE);
-    ContactData.Add(wxT("VERSION"), wxT("4.0"), FALSE);
+       // Setup the data and write it into the account folder.
     
-    // Setup the version string.
+       // Begin preperations to write the contact to a file.
     
-    strValue.Append(wxT("-//Xestia//Address Book Version "));
-    strValue.Append(wxT(XSDAB_VERSION));
-    strValue.Append(wxT("//KW"));
+       bool FNFirst = TRUE;
+       std::map<int,int>::iterator intiter;
+       std::map<int,wxString>::iterator striter;
     
-    ContactData.Add(wxT("PRODID"), strValue, FALSE);
-    
-    // Setup the name.
-    
-    strValue.Clear();
-    
-    // Setup the name field.
-    
-    strValue = txtSurname->GetValue() + wxT(";") +
-    txtForename->GetValue() + wxT(";") +
-    txtOtherNames->GetValue() + wxT(";") +
-    txtTitle->GetValue() + wxT(";") +
-    txtSuffix->GetValue();
-    
-    strValue2 = ContactData.Convert(cmbDisplayAs->GetValue(), FALSE);
-    strValue2.Trim();
-    
-    if (NameTokens.IsEmpty()){
-        ContactData.Add(wxT("N;SORT-AS=\"") + strValue2 + wxT("\""), strValue, FALSE);
-    } else {
-        ContactData.Add(wxT("N;SORT-AS=\"") + strValue2 + wxT("\";") + NameTokens, strValue, FALSE);
-    }
-    
-    if (cmbType->GetCurrentSelection() == 1){
-        
-        ContactData.AddRaw(wxT("KIND"), wxT("individual"));
+       // Set some values for saving.
+       
+       ContactEditorData.NameForename = txtForename->GetValue();
+       ContactEditorData.NameSurname = txtSurname->GetValue();
+       ContactEditorData.NameOtherNames = txtOtherNames->GetValue();
+       ContactEditorData.NameTitle = txtTitle->GetValue();
+       ContactEditorData.NameSuffix = txtSuffix->GetValue();
+       
+       ContactEditorData.GenderDetails = txtGenderDescription->GetValue();
+       
+       // Process Birthday: Get Day, Month & Year.
         
-    } else if (cmbType->GetCurrentSelection() == 2){
+       wxDateTime BirthdayDate;
+       wxDateTime::Month BirthdayMonth;
+       int BirthdayDay;
+       int BirthdayYear;
+       wxString DataBeforeT;
+       wxString DataAfterT;
+       wxString FinalBirthdayString;
+       bool ProcessDataAfterT = FALSE;
         
-        ContactData.AddRaw(wxT("KIND"), wxT("group"));
+       BirthdayDate = dapBirthday->GetValue();
         
-        // Go through each of the members and write them out.
-        
-        for (std::map<int, wxString>::iterator itemiter = GroupsList.begin();
-             itemiter != GroupsList.end(); ++itemiter){
+       if (!txtBirthday->IsEmpty()){
+       
+               // Birthday value is text so use this.
+               
+               ContactEditorData.Birthday = txtBirthday->GetValue();
+               
+       } else if (BirthdayDate.IsValid()){
             
-            ContactData.Add(wxT("MEMBER:urn:uuid"), itemiter->second, FALSE);
+               BirthdayDay = BirthdayDate.GetDay();
+               BirthdayMonth = BirthdayDate.GetMonth();
+               BirthdayYear = BirthdayDate.GetYear();
             
-        }
-        
-    } else if (cmbType->GetCurrentSelection() == 3){
-        
-        ContactData.AddRaw(wxT("KIND"), wxT("org"));
-        
-    } else if (cmbType->GetCurrentSelection() == 4){
-        
-        ContactData.AddRaw(wxT("KIND"), wxT("location"));
-        
-    }
-    
-    
-    // Setup the nicknames (General, Home & Business).
-    
-    strValue.Clear();
-    strValue2.Clear();
-    strValue3.Clear();
-    
-    boolValue = FALSE;
-    boolValue2 = FALSE;
-    intValue2 = 0;
-    intValue  = 0;
-    
-    // Setup the gender.
-    
-    if (cmbGender->GetCurrentSelection() != 0){
-        
-        switch(cmbGender->GetCurrentSelection()){
-                
-            case 1:
-                
-                strValue = wxT("M");
-                break;
-                
-            case 2:
-                
-                strValue = wxT("F");
-                break;
-                
-            case 3:
+               // Look for T and replace data before this.
+            
+               wxStringTokenizer wSTDate(ContactEditorData.Birthday, wxT("T"));
+            
+               while (wSTDate.HasMoreTokens()){
                 
-                strValue = wxT("O");
-                break;
+                       if (ProcessDataAfterT == FALSE){
+                    
+                               DataBeforeT = wSTDate.GetNextToken();
+                               ProcessDataAfterT = TRUE;
+                    
+                       } else {
+                    
+                               DataAfterT = wSTDate.GetNextToken();
+                               break;
+                    
+                       }
                 
-            case 4:
+               }
+            
+               // If there is not T then replace altogether.
+            
+               wxString FinalBirthdayDay;
+               wxString FinalBirthdayMonth;
+               wxString FinalBirthdayYear;
+            
+               if (BirthdayDay < 10){
                 
-                strValue = wxT("N");
-                break;
+                       FinalBirthdayDay = wxT("0") + wxString::Format(wxT("%i"), BirthdayDay);
                 
-            case 5:
+               } else {
                 
-                strValue = wxT("U");
-                break;
+                       FinalBirthdayDay = wxString::Format(wxT("%i"), BirthdayDay);
                 
-        }
-        
-    }
-    
-    if (!txtGenderDescription->IsEmpty()){
-        
-        strValue2 = txtGenderDescription->GetValue();
-        
-    }
-    
-    if (!strValue.IsEmpty() || !strValue2.IsEmpty()){
-        
-        EscapeString(&strValue2, FALSE);
-        
-        if (!GenderTokens.IsEmpty()){
+               }
             
-            if (!strValue2.IsEmpty()){
+               if (((int)BirthdayMonth + 1) < 10){
                 
-                ContactData.AddRaw(wxT("GENDER;") + GenderTokens, strValue + wxT(";") + strValue2);
+                       FinalBirthdayMonth = wxT("0") + wxString::Format(wxT("%i"), ((int)BirthdayMonth + 1));
                 
-            } else {
+               } else {
                 
-                ContactData.AddRaw(wxT("GENDER;") + GenderTokens, strValue);
+                       FinalBirthdayMonth = wxString::Format(wxT("%i"), ((int)BirthdayMonth + 1));
                 
-            }
+               }
             
-        } else {
-            
-            if (!strValue2.IsEmpty()){
+               if (BirthdayYear == 0){
                 
-                ContactData.AddRaw(wxT("GENDER"), strValue + wxT(";") + strValue2);
+                       FinalBirthdayYear = wxT("--");
                 
-            } else {
+               } else {
                 
-                ContactData.AddRaw(wxT("GENDER"), strValue);
+                       FinalBirthdayYear = wxString::Format(wxT("%i"), BirthdayYear);
                 
-            }
-            
-        }
-        
-    }
-    
-    strValue.Clear();
-    strValue2.Clear();
-    strValue3.Clear();
-    
-    boolValue = FALSE;
-    boolValue2 = FALSE;
-    intValue2 = 0;
-    intValue  = 0;
-    
-    // Process Label.
-    
-    strValue3 = BirthdayAltID;
-    
-    if (!strValue3.IsEmpty()){
-        
-        strValue3.Trim();
-        strValue3.Trim();
-        boolValue2 = TRUE;
-        strValue2.Append(wxT("ALTID=\"") + strValue3 + wxT("\""));
-        
-        boolValue = TRUE;
-        
-    }
-    
-    //strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
-    //strValue2 =
-    
-    // Process Language.
-    
-    strValue3 = BirthdayCalScale;
-    
-    if (!strValue3.IsEmpty()){
-        
-        strValue3.Trim();
-        strValue3.Trim();
-        
-        if (boolValue2 == TRUE){
-            
-            strValue2.Append(wxT(";"));
-            
-        } else {
-            
-            boolValue2 = TRUE;
-            
-        }
-        
-        strValue2.Append(wxT("CALSCALE=") + strValue3);
-        
-        boolValue = TRUE;
-        
-    }
-    
-    // Process Tokens.
-    
-    strValue2 = BirthdayTokens;
-    
-    // Get the birthday and write it.
-    
-    ResetSaveProcessData();
-    
-    if (!txtBirthday->IsEmpty()){
-        
-        strValue = txtBirthday->GetValue();
-        
-        if (!strValue.IsEmpty() || !strValue2.IsEmpty()){
+               }
             
-            if (!strValue2.IsEmpty()){
-                
-                EscapeString(&strValue2, FALSE);
-                EscapeString(&strValue, FALSE);
+               if (!DataAfterT.IsEmpty()){
                 
-                ContactData.AddRaw(wxT("BDAY;VALUE=text;") + strValue2 + wxT(";"), strValue);
+                       FinalBirthdayString = FinalBirthdayYear + FinalBirthdayMonth + FinalBirthdayDay + wxT("T") + DataAfterT;
                 
-            } else {
+               } else {
                 
-                EscapeString(&strValue, FALSE);
+                       FinalBirthdayString = FinalBirthdayYear + FinalBirthdayMonth + FinalBirthdayDay;
                 
-                ContactData.AddRaw(wxT("BDAY;VALUE=text"), strValue);
-                
-            }
-            
-        }
-        
-    } else {
-        
-        // Deal with date.
-        
-        // Get Day, Month & Year.
-        
-        wxDateTime BirthdayDate;
-        wxDateTime::Month BirthdayMonth;
-        int BirthdayDay;
-        int BirthdayYear;
-        wxString DataBeforeT;
-        wxString DataAfterT;
-        wxString FinalBirthdayString;
-        bool ProcessDataAfterT = FALSE;
+               }
+               
+               if(!FinalBirthdayString.IsEmpty()){
+                       
+                       ContactEditorData.Birthday = FinalBirthdayString;
+                       
+               }
+               
+       }
+       
+       // Process Anniversary: Get Day, Month & Year.
+       
+       wxDateTime AnniversaryDate;
+       wxDateTime::Month AnniversaryMonth;
+       int AnniversaryDay;
+       int AnniversaryYear;
+       DataBeforeT = "";
+       DataAfterT = "";
+       wxString FinalAnniversaryString;
+       ProcessDataAfterT = FALSE;
         
-        BirthdayDate = dapBirthday->GetValue();
+       AnniversaryDate = dapAnniversary->GetValue();
         
-        if (BirthdayDate.IsValid()){
+       if (!txtAnniversary->IsEmpty()){
+       
+               // Birthday value is text so use this.
+               
+               ContactEditorData.Anniversary = txtAnniversary->GetValue();
+               
+       } else if (AnniversaryDate.IsValid()){
             
-            BirthdayDay = BirthdayDate.GetDay();
-            BirthdayMonth = BirthdayDate.GetMonth();
-            BirthdayYear = BirthdayDate.GetYear();
+               AnniversaryDay = AnniversaryDate.GetDay();
+               AnniversaryMonth = AnniversaryDate.GetMonth();
+               AnniversaryYear = AnniversaryDate.GetYear();
             
-            // Look for T and replace data before this.
+               // Look for T and replace data before this.
             
-            wxStringTokenizer wSTDate(Birthday, wxT("T"));
+               wxStringTokenizer wSTDate(ContactEditorData.Anniversary, wxT("T"));
             
-            while (wSTDate.HasMoreTokens()){
+               while (wSTDate.HasMoreTokens()){
                 
-                if (ProcessDataAfterT == FALSE){
+                       if (ProcessDataAfterT == FALSE){
                     
-                    DataBeforeT = wSTDate.GetNextToken();
-                    ProcessDataAfterT = TRUE;
+                               DataBeforeT = wSTDate.GetNextToken();
+                               ProcessDataAfterT = TRUE;
                     
-                } else {
+                       } else {
                     
-                    DataAfterT = wSTDate.GetNextToken();
-                    break;
+                               DataAfterT = wSTDate.GetNextToken();
+                               break;
                     
-                }
+                       }
                 
-            }
+               }
             
-            // If there is not T then replace altogether.
+               // If there is not T then replace altogether.
             
-            wxString FinalBirthdayDay;
-            wxString FinalBirthdayMonth;
-            wxString FinalBirthdayYear;
-            
-            if (BirthdayDay < 10){
+               wxString FinalAnniversaryDay;
+               wxString FinalAnniversaryMonth;
+               wxString FinalAnniversaryYear;
+           
+               if (AnniversaryDay < 10){
                 
-                FinalBirthdayDay = wxT("0") + wxString::Format(wxT("%i"), BirthdayDay);
+                       FinalAnniversaryDay = wxT("0") + wxString::Format(wxT("%i"), AnniversaryDay);
                 
-            } else {
+               } else {
                 
-                FinalBirthdayDay = wxString::Format(wxT("%i"), BirthdayDay);
+                       FinalAnniversaryDay = wxString::Format(wxT("%i"), AnniversaryDay);
                 
-            }
+               }
             
-            if (((int)BirthdayMonth + 1) < 10){
+               if (((int)AnniversaryMonth + 1) < 10){
                 
-                FinalBirthdayMonth = wxT("0") + wxString::Format(wxT("%i"), ((int)BirthdayMonth + 1));
+                       FinalAnniversaryMonth = wxT("0") + wxString::Format(wxT("%i"), ((int)AnniversaryMonth + 1));
                 
-            } else {
+               } else {
                 
-                FinalBirthdayMonth = wxString::Format(wxT("%i"), ((int)BirthdayMonth + 1));
+                       FinalAnniversaryMonth = wxString::Format(wxT("%i"), ((int)AnniversaryMonth + 1));
                 
-            }
-            
-            if (BirthdayYear == 0){
+               }
+        
+               if (AnniversaryYear == 0){
                 
-                FinalBirthdayYear = wxT("--");
+                       FinalAnniversaryYear = wxT("--");
                 
-            } else {
+               } else {
                 
-                FinalBirthdayYear = wxString::Format(wxT("%i"), BirthdayYear);
+                       FinalAnniversaryYear = wxString::Format(wxT("%i"), AnniversaryYear);
                 
-            }
+               }
             
-            if (!DataAfterT.IsEmpty()){
-                
-                FinalBirthdayString = FinalBirthdayYear + FinalBirthdayMonth + FinalBirthdayDay + wxT("T") + DataAfterT;
+               if (!DataAfterT.IsEmpty()){
                 
-            } else {
+                       FinalAnniversaryString = FinalAnniversaryYear + FinalAnniversaryMonth + FinalAnniversaryDay + wxT("T") + DataAfterT;
                 
-                FinalBirthdayString = FinalBirthdayYear + FinalBirthdayMonth + FinalBirthdayDay;
+               } else {
                 
-            }
-            
-            if (!FinalBirthdayString.IsEmpty() || !strValue2.IsEmpty()){
-                
-                if (!strValue2.IsEmpty()){
-                    
-                    EscapeString(&strValue2, FALSE);
-                    EscapeString(&strValue, FALSE);
-                    
-                    ContactData.AddRaw(wxT("BDAY") + strValue2 + wxT(";"), FinalBirthdayString);
-                    
-                } else {
-                    
-                    EscapeString(&strValue, FALSE);
-                    
-                    ContactData.AddRaw(wxT("BDAY"), FinalBirthdayString);
-                    
-                }
+                       FinalAnniversaryString = FinalAnniversaryYear + FinalAnniversaryMonth + FinalAnniversaryDay;
                 
-            }
-            
-        }
-        
-    }
+               }
+               
+               if(!FinalAnniversaryString.IsEmpty()){
+                       
+                       ContactEditorData.Birthday = FinalAnniversaryString;
+                       
+               }
+       
+       }
+       
+       // Process full name.
+       
+       if (ContactEditorData.FullNamesList.size() > 0){
+               
+               ContactEditorData.FullNamesList[0] = cmbDisplayAs->GetValue();
+               
+       } else {
+               
+               ContactEditorData.FullNamesList.insert(std::make_pair(0, cmbDisplayAs->GetValue()));
+               ContactEditorData.FullNamesListAltID.insert(std::make_pair(0, wxT("")));
+               ContactEditorData.FullNamesListPID.insert(std::make_pair(0, wxT("")));
+               ContactEditorData.FullNamesListType.insert(std::make_pair(0, wxT("")));
+               ContactEditorData.FullNamesListLanguage.insert(std::make_pair(0, wxT("")));
+               ContactEditorData.FullNamesListPref.insert(std::make_pair(0, 0));
+               ContactEditorData.FullNamesListTokens.insert(std::make_pair(0, wxT("")));
+               
+       }
     
-    ResetSaveProcessData();
+       FMTimer.Stop();
+       ContactEditorData.SaveFile(FilenameFinal);
     
-    // Process Label.
+       vCard34Conv ConvFileFun;
     
-    strValue3 = AnniversaryAltID;
+       wxString wxSData;
     
-    if (!strValue3.IsEmpty()){
-        
-        strValue3.Trim();
-        strValue3.Trim();
-        boolValue2 = TRUE;
-        strValue2.Append(wxT("ALTID=\"") + strValue3 + wxT("\""));
-        
-        boolValue = TRUE;
-        
-    }
+       ConvFileFun.ConvertToV3(FilenameFinal, &wxSData);
     
-    //strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
-    //strValue2 =
+       wxString AccountDirPrefix;
+       wxString AccountDir;
+       wxString PrefDir;
     
-    // Process Language.
+#if defined(__HAIKU__)
+
+#elif defined(__APPLE__)
     
-    strValue3 = AnniversaryCalScale;
+       PrefDir = GetUserPrefDir();
     
-    if (!strValue3.IsEmpty()){
-        
-        strValue3.Trim();
-        strValue3.Trim();
-        
-        if (boolValue2 == TRUE){
-            
-            strValue2.Append(wxT(";"));
-            
-        } else {
-            
-            boolValue2 = TRUE;
-            
-        }
-        
-        strValue2.Append(wxT("CALSCALE=") + strValue3);
-        
-        boolValue = TRUE;
-        
-    }
+       wxStringTokenizer wSTFilename(wxSContactFilename, wxT("/"));
+    
+#elif defined(__WIN32__)
+    
+       PrefDir = GetUserPrefDir();
     
-    // Process Tokens.
+       wxStringTokenizer wSTFilename(wxSContactFilename, wxT("\\"));
     
-    strValue2 = AnniversaryTokens;
+#else
+    
+       PrefDir = GetUserPrefDir();
+    
+       wxStringTokenizer wSTFilename(wxSContactFilename, wxT("/"));
+    
+#endif
+
+       XABPreferences PrefData(PrefDir);
     
-    // Deal with ANNIVERSARY.
+       wxString AccountType;
     
-    if (!txtAnniversary->IsEmpty()){
+       for (int i = 0; i < PrefData.accounts.GetCount(); i++){
         
-        strValue = txtAnniversary->GetValue();
+               AccountDir = PrefData.accounts.GetAccountDirectory(i) + wxT(".carddav");
         
-        if (!strValue.IsEmpty() || !strValue2.IsEmpty()){
+               if (AccountDir == wxSContactAccount){
             
-            if (!strValue2.IsEmpty()){
-                
-                EscapeString(&strValue2, FALSE);
-                EscapeString(&strValue, FALSE);
-                
-                ContactData.AddRaw(wxT("ANNIVERSARY;VALUE=text;") + strValue2 + wxT(";"), strValue);
-                
-            } else {
-                
-                EscapeString(&strValue, FALSE);
-                
-                ContactData.AddRaw(wxT("ANNIVERSARY;VALUE=text"), strValue);
-                
-            }
+                       AccountDirPrefix = PrefData.accounts.GetAccountDirPrefix(i);
+                       AccountDirPrefix.Trim();
+                       AccountType = PrefData.accounts.GetAccountType(i);
+                       break;
             
-        }
+               }
         
-    } else {
+       }
+    
+       wxString wxSplitFilename;
+       wxString wxSDataURL;
+    
+       while(wSTFilename.HasMoreTokens()){
         
-        // Look for T and replace data before this.
+               wxSplitFilename = wSTFilename.GetNextToken();
+        
+       }
+    
+       wxSDataURL = wxSplitFilename;
+    
+       // Find out if the filename exists in the table.
+    
+       if (AccountType == wxT("CardDAV") || AccountType == wxT("carddav")){
         
-        // Get Day, Month & Year.
+               wxString ETagResult;
+               wxString ETagOriginal;
         
-        wxDateTime AnniversaryDate;
-        wxDateTime::Month AnniversaryMonth;
-        int AnniversaryDay;
-        int AnniversaryYear;
-        wxString DataBeforeT;
-        wxString DataAfterT;
-        wxString FinalAnniversaryString;
-        bool ProcessDataAfterT = FALSE;
+               ETagDB *ETagDBPtr = NULL;
         
-        AnniversaryDate = dapAnniversary->GetValue();
+               ETagDBPtr = ETagTmrPtr->GetPointer(wxSContactAccount);
         
-        if (AnniversaryDate.IsValid()){
+               wxString wxSETag = ETagDBPtr->GetETag(wxSplitFilename);
+               wxString wxSETagOrig = ETagDBPtr->GetETagOriginal(wxSplitFilename);
+
+               if (wxSETagOrig.IsEmpty()){
             
-            AnniversaryDay = AnniversaryDate.GetDay();
-            AnniversaryMonth = AnniversaryDate.GetMonth();
-            AnniversaryYear = AnniversaryDate.GetYear();
+                       // Generate the ETag.
             
-            // Look for T and replace data before this.
+                       wxSETagOrig = wxString::Format(wxT("%X%X%X%X"), rand() % 1024, rand() % 1024, rand() % 1024, rand() % 1024);
             
-            wxStringTokenizer wSTDate(Anniversary, wxT("T"));
+               }
+        
+               if (wxSETag.IsEmpty()){
             
-            while (wSTDate.HasMoreTokens()){
-                
-                if (ProcessDataAfterT == FALSE){
-                    
-                    DataBeforeT = wSTDate.GetNextToken();
-                    ProcessDataAfterT = TRUE;
-                    
-                } else {
-                    
-                    DataAfterT = wSTDate.GetNextToken();
-                    break;
-                    
-                }
-                
-            }
+                       // Update empty ETag.
             
-            // If there is not T then replace altogether.
+                       wxSETag = wxSETagOrig;
+                       ETagDBPtr->AddETag(wxSplitFilename, wxSETag, "");
             
-            wxString FinalAnniversaryDay;
-            wxString FinalAnniversaryMonth;
-            wxString FinalAnniversaryYear;
+               } else {
             
-            if (AnniversaryDay < 10){
-                
-                FinalAnniversaryDay = wxT("0") + wxString::Format(wxT("%i"), AnniversaryDay);
-                
-            } else {
-                
-                FinalAnniversaryDay = wxString::Format(wxT("%i"), AnniversaryDay);
-                
-            }
+                       // Don't change original ETag.
             
-            if (((int)AnniversaryMonth + 1) < 10){
-                
-                FinalAnniversaryMonth = wxT("0") + wxString::Format(wxT("%i"), ((int)AnniversaryMonth + 1));
-                
-            } else {
-                
-                FinalAnniversaryMonth = wxString::Format(wxT("%i"), ((int)AnniversaryMonth + 1));
-                
-            }
+                       wxSETag = wxString::Format(wxT("%X%X%X%X"), rand() % 1024, rand() % 1024, rand() % 1024, rand() % 1024);
+                       ETagDBPtr->UpdateETag(wxSplitFilename, wxSETag);
             
-            if (AnniversaryYear == 0){
-                
-                FinalAnniversaryYear = wxT("--");
-                
-            } else {
-                
-                FinalAnniversaryYear = wxString::Format(wxT("%i"), AnniversaryYear);
-                
-            }
+               }
+        
+               if (EditMode == FALSE){
+
+                       ActMgrPtr->AddTask(0, cmbDisplayAs->GetValue(), wxSContactAccount, wxSDataURL, wxSplitFilename, FilenameFinal, wxSData);
+                       EditMode = TRUE;
+                       FMTimer.SetFilename(FilenameFinal);
+                       FMTimer.UpdateTimestamp();
+                       FMTimer.Start(10000, FALSE);
+           
+                       wxCommandEvent reloadevent(RELOADCONTACTLIST);
+                       reloadevent.SetString(wxSContactAccount);
+                       wxPostEvent(this->GetParent(), reloadevent);
             
-            if (!DataAfterT.IsEmpty()){
-                
-                FinalAnniversaryString = FinalAnniversaryYear + FinalAnniversaryMonth + FinalAnniversaryDay + wxT("T") + DataAfterT;
-                
-            } else {
-                
-                FinalAnniversaryString = FinalAnniversaryYear + FinalAnniversaryMonth + FinalAnniversaryDay;
-                
-            }
+               } else {
             
-            if (!FinalAnniversaryString.IsEmpty() || !strValue2.IsEmpty()){
-                
-                if (!strValue2.IsEmpty()){
-                    
-                    EscapeString(&strValue2, FALSE);
-                    EscapeString(&strValue, FALSE);
-                    
-                    ContactData.AddRaw(wxT("ANNIVERSARY") + strValue2 + wxT(";"), FinalAnniversaryString);
-                    
-                } else {
-                    
-                    EscapeString(&strValue, FALSE);
-                    
-                    ContactData.AddRaw(wxT("ANNIVERSARY"), FinalAnniversaryString);
-                    
-                }
-                
-            }
+                       ActMgrPtr->AddTask(1, cmbDisplayAs->GetValue(), wxSContactAccount, wxSDataURL, wxSplitFilename, FilenameFinal, wxSData);
+                       FMTimer.UpdateTimestamp();
+                       FMTimer.Start(10000, FALSE);
             
-        }
-        
-    }
-    
-    // Setup the addresses (General, Home, Business).
-    
-    //intValue = GeneralAddressList.size();
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = GeneralAddressList.begin();
-         iter != GeneralAddressList.end(); ++iter){
-        
-        int intSeekValue = iter->first;
-        
-        wxString strAddressString;
-        wxString strAddressFinalValue;
-        std::map<int, wxString>::iterator iterValue;
-        
-        strAddressString.Append(wxT(";;"));
-        
-        // Get Address
-        
-        iterValue = GeneralAddressList.find(intSeekValue);
-        strAddressFinalValue = iterValue->second;
-        ProcessCaptureStrings(&strAddressFinalValue);
-        strAddressString.Append(strAddressFinalValue + wxT(";"));
-        strAddressFinalValue.Clear();
-        
-        // Get Town
-        
-        iterValue = GeneralAddressListTown.find(intSeekValue);
-        strAddressFinalValue = iterValue->second;
-        ProcessCaptureStrings(&strAddressFinalValue);
-        strAddressString.Append(strAddressFinalValue + wxT(";"));
-        strAddressFinalValue.Clear();
+               }
         
-        // Get County
-        
-        iterValue = GeneralAddressListCounty.find(intSeekValue);
-        strAddressFinalValue = iterValue->second;
-        ProcessCaptureStrings(&strAddressFinalValue);
-        strAddressString.Append(strAddressFinalValue + wxT(";"));
-        strAddressFinalValue.Clear();
-        
-        // Get Post Code
-        
-        iterValue = GeneralAddressListPostCode.find(intSeekValue);
-        strAddressFinalValue = iterValue->second;
-        ProcessCaptureStrings(&strAddressFinalValue);
-        strAddressString.Append(strAddressFinalValue + wxT(";"));
-        strAddressFinalValue.Clear();
-        
-        // Get Country
-        
-        iterValue = GeneralAddressListCountry.find(intSeekValue);
-        strAddressFinalValue = iterValue->second;
-        ProcessCaptureStrings(&strAddressFinalValue);
-        strAddressString.Append(strAddressFinalValue);
-        strAddressFinalValue.Clear();
-        
-        ProcessSaveData(wxT("ADR"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &strAddressString, &ContactData,
-                        wxT("LABEL"), &GeneralAddressListLabel,
-                        wxT("LANGUAGE"), &GeneralAddressListLang,
-                        wxT("ALTID"), &GeneralAddressListAltID,
-                        wxT("PID"), &GeneralAddressListPID,
-                        wxT("GEO"), &GeneralAddressListGeo,
-                        wxT("TZ"), &GeneralAddressListTimezone,
-                        wxT("MEDIATYPE"), &GeneralAddressListMediatype,
-                        wxT("PREF"), &GeneralAddressListPref,
-                        wxT(""), &GeneralAddressListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = HomeAddressList.begin();
-         iter != HomeAddressList.end(); ++iter){
-        
-        int intSeekValue = iter->first;
-        
-        wxString strAddressString;
-        wxString strAddressFinalValue;
-        std::map<int, wxString>::iterator iterValue;
-        
-        strAddressString.Append(wxT(";;"));
-        
-        // Get Address
-        
-        iterValue = HomeAddressList.find(intSeekValue);
-        strAddressFinalValue = iterValue->second;
-        ProcessCaptureStrings(&strAddressFinalValue);
-        
-        strAddressString.Append(strAddressFinalValue + wxT(";"));
-        
-        // Get Town
-        
-        iterValue = HomeAddressListTown.find(intSeekValue);
-        strAddressFinalValue = iterValue->second;
-        ProcessCaptureStrings(&strAddressFinalValue);
-        
-        strAddressString.Append(strAddressFinalValue + wxT(";"));
-        
-        // Get County
-        
-        iterValue = HomeAddressListCounty.find(intSeekValue);
-        strAddressFinalValue = iterValue->second;
-        ProcessCaptureStrings(&strAddressFinalValue);
-        
-        strAddressString.Append(strAddressFinalValue + wxT(";"));
-        
-        // Get Post Code
-        
-        iterValue = HomeAddressListPostCode.find(intSeekValue);
-        strAddressFinalValue = iterValue->second;
-        ProcessCaptureStrings(&strAddressFinalValue);
-        
-        strAddressString.Append(strAddressFinalValue + wxT(";"));
-        
-        // Get Country
-        
-        iterValue = HomeAddressListCountry.find(intSeekValue);
-        strAddressFinalValue = iterValue->second;
-        ProcessCaptureStrings(&strAddressFinalValue);
-        
-        strAddressString.Append(strAddressFinalValue);
-        
-        ProcessSaveData(wxT("ADR;TYPE=home"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &strAddressString, &ContactData,
-                        wxT("LABEL"), &HomeAddressListLabel,
-                        wxT("LANGUAGE"), &HomeAddressListLang,
-                        wxT("ALTID"), &HomeAddressListAltID,
-                        wxT("PID"), &HomeAddressListPID,
-                        wxT("GEO"), &HomeAddressListGeo,
-                        wxT("TZ"), &HomeAddressListTimezone,
-                        wxT("MEDIATYPE"), &HomeAddressListMediatype,
-                        wxT("PREF"), &HomeAddressListPref,
-                        wxT(""), &HomeAddressListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
+       }
     
-    for (std::map<int,wxString>::iterator iter = BusinessAddressList.begin();
-         iter != BusinessAddressList.end(); ++iter){
-        
-        int intSeekValue = iter->first;
-        
-        wxString strAddressString;
-        wxString strAddressFinalValue;
-        std::map<int, wxString>::iterator iterValue;
-        
-        strAddressString.Append(wxT(";;"));
-        
-        // Get Address
-        
-        iterValue = BusinessAddressList.find(intSeekValue);
-        strAddressFinalValue = iterValue->second;
-        ProcessCaptureStrings(&strAddressFinalValue);
-        
-        strAddressString.Append(strAddressFinalValue + wxT(";"));
-        
-        // Get Town
-        
-        iterValue = BusinessAddressListTown.find(intSeekValue);
-        strAddressFinalValue = iterValue->second;
-        ProcessCaptureStrings(&strAddressFinalValue);
-        
-        strAddressString.Append(strAddressFinalValue + wxT(";"));
-        
-        // Get County
-        
-        iterValue = BusinessAddressListCounty.find(intSeekValue);
-        strAddressFinalValue = iterValue->second;
-        ProcessCaptureStrings(&strAddressFinalValue);
-        
-        strAddressString.Append(strAddressFinalValue + wxT(";"));
-        
-        // Get Post Code
-        
-        iterValue = BusinessAddressListPostCode.find(intSeekValue);
-        strAddressFinalValue = iterValue->second;
-        ProcessCaptureStrings(&strAddressFinalValue);
-        
-        strAddressString.Append(strAddressFinalValue + wxT(";"));
-        
-        // Get Country
-        
-        iterValue = BusinessAddressListCountry.find(intSeekValue);
-        strAddressFinalValue = iterValue->second;
-        ProcessCaptureStrings(&strAddressFinalValue);
-        
-        strAddressString.Append(strAddressFinalValue);
-        
-        ProcessSaveData(wxT("ADR;TYPE=work"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &strAddressString, &ContactData,
-                        wxT("LABEL"), &BusinessAddressListLabel,
-                        wxT("LANGUAGE"), &BusinessAddressListLang,
-                        wxT("ALTID"), &BusinessAddressListAltID,
-                        wxT("PID"), &BusinessAddressListPID,
-                        wxT("GEO"), &BusinessAddressListGeo,
-                        wxT("TZ"), &BusinessAddressListTimezone,
-                        wxT("MEDIATYPE"), &BusinessAddressListMediatype,
-                        wxT("PREF"), &BusinessAddressListPref,
-                        wxT(""), &BusinessAddressListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    // Sort out nicknames (if any).
-    
-    for (std::map<int,wxString>::iterator iter = GeneralNicknamesList.begin();
-         iter != GeneralNicknamesList.end(); ++iter){
-        
-        intValue2 = iter->first;
-        
-        // Process Alternative ID.
-        
-        ProcessSaveData(wxT("NICKNAME"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &GeneralNicknamesList, &ContactData,
-                        wxT("LANGUAGE"), &GeneralNicknamesListLanguage,
-                        wxT("ALTID"), &GeneralNicknamesListAltID,
-                        wxT("PID"), &GeneralNicknamesListPID,
-                        wxT("PREF"), &GeneralNicknamesListPref,
-                        wxT(""), &GeneralNicknamesListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
+       // Send a notification to update the main window
+       // with the new details.
     
-    ResetSaveProcessData();
+       UCNotif *ucd;
+       ucd = new UCNotif;
     
-    for (std::map<int,wxString>::iterator iter = HomeNicknamesList.begin();
-         iter != HomeNicknamesList.end(); ++iter){
-        
-        ProcessSaveData(wxT("NICKNAME;TYPE=home"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &HomeNicknamesList, &ContactData,
-                        wxT("LANGUAGE"), &HomeNicknamesListLanguage,
-                        wxT("ALTID"), &HomeNicknamesListAltID,
-                        wxT("PID"), &HomeNicknamesListPID,
-                        wxT("PREF"), &HomeNicknamesListPref,
-                        wxT(""), &HomeNicknamesListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
+       // TODO: Workout nickname settings by priority and
+       // type.
     
-    ResetSaveProcessData();
+       vCardName NameData;
+       
+       NameData.Forename = txtForename->GetValue();
+       NameData.Surname = txtSurname->GetValue();
+       NameData.OtherNames = txtOtherNames->GetValue();
+       NameData.Title = txtTitle->GetValue();
+       NameData.Suffix = txtSuffix->GetValue();
+       
+       if (this->GetParent() != nullptr)
+       {
+               ucd->ContactAccount = wxSContactAccount;
+               ucd->ContactFilename = FilenameFinal;
+               ucd->ContactName = cmbDisplayAs->GetValue();
+               ucd->ContactNameArray = NameData;
     
-    for (std::map<int,wxString>::iterator iter = BusinessNicknamesList.begin();
-         iter != BusinessNicknamesList.end(); ++iter){
-        
-        ProcessSaveData(wxT("NICKNAME;TYPE=work"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &BusinessNicknamesList, &ContactData,
-                        wxT("LANGUAGE"), &BusinessNicknamesListLanguage,
-                        wxT("ALTID"), &BusinessNicknamesListAltID,
-                        wxT("PID"), &BusinessNicknamesListPID,
-                        wxT("PREF"), &BusinessNicknamesListPref,
-                        wxT(""), &BusinessNicknamesListTokens );
+               for (std::map<int,wxString>::iterator gniter = ContactEditorData.GeneralNicknamesList.begin();
+                       gniter != ContactEditorData.GeneralNicknamesList.end(); gniter++){
         
-        ResetSaveProcessData();
+                       ucd->ContactNickname = gniter->second;
+                       break;
         
-    }
-    
-    ResetSaveProcessData();
-    
-    // Sort out email (general, home and business).
-    
-    for (std::map<int,wxString>::iterator iter = GeneralEmailList.begin();
-         iter != GeneralEmailList.end(); ++iter){
-        
-        //strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
-        //strValue2 =
-        
-        wxString strAddressFinalValue;
-        std::map<int, wxString>::iterator iterValue;
-        
-        ProcessSaveData(wxT("EMAIL"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &GeneralEmailList, &ContactData,
-                        wxT("ALTID"), &GeneralEmailListAltID,
-                        wxT("PID"), &GeneralEmailListPID,
-                        wxT("PREF"), &GeneralEmailListPref,
-                        wxT(""), &GeneralEmailListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = HomeEmailList.begin();
-         iter != HomeEmailList.end(); ++iter){
-        
-        //strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
-        //strValue2 =
-        
-        ProcessSaveData(wxT("EMAIL;TYPE=home"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &HomeEmailList, &ContactData,
-                        wxT("ALTID"), &HomeEmailListAltID,
-                        wxT("PID"), &HomeEmailListPID,
-                        wxT("PREF"), &HomeEmailListPref,
-                        wxT(""), &HomeEmailListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = BusinessEmailList.begin();
-         iter != BusinessEmailList.end(); ++iter){
-        
-        //strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
-        //strValue2 =
-        
-        ProcessSaveData(wxT("EMAIL;TYPE=work"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &BusinessEmailList, &ContactData,
-                        wxT("ALTID"), &BusinessEmailListAltID,
-                        wxT("PID"), &BusinessEmailListPID,
-                        wxT("PREF"), &BusinessEmailListPref,
-                        wxT(""), &BusinessEmailListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = GeneralIMList.begin();
-         iter != GeneralIMList.end(); ++iter){
-        
-        intValue2 = iter->first;
-        
-        // Process Alternative ID.
-        
-        ProcessSaveData(wxT("IMPP"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &GeneralIMList, &ContactData,
-                        wxT("ALTID"), &GeneralIMListAltID,
-                        wxT("PID"), &GeneralIMListPID,
-                        wxT("MEDIATYPE"), &GeneralIMListMediatype,
-                        wxT("PREF"), &GeneralIMListPref,
-                        wxT(""), &GeneralIMListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = HomeIMList.begin();
-         iter != HomeIMList.end(); ++iter){
-        
-        ProcessSaveData(wxT("IMPP;TYPE=home"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &HomeIMList, &ContactData,
-                        wxT("ALTID"), &HomeIMListAltID,
-                        wxT("PID"), &HomeIMListPID,
-                        wxT("MEDIATYPE"), &HomeIMListMediatype,
-                        wxT("PREF"), &HomeIMListPref,
-                        wxT(""), &HomeIMListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = BusinessIMList.begin();
-         iter != BusinessIMList.end(); ++iter){
-        
-        ProcessSaveData(wxT("IMPP;TYPE=work"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &BusinessIMList, &ContactData,
-                        wxT("ALTID"), &BusinessIMListAltID,
-                        wxT("PID"), &BusinessIMListPID,
-                        wxT("MEDIATYPE"), &BusinessIMListMediatype,
-                        wxT("PREF"), &BusinessIMListPref,
-                        wxT(""), &BusinessIMListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = GeneralTelephoneList.begin();
-         iter != GeneralTelephoneList.end(); ++iter){
-        
-        wxString strAddressFinalValue = iter->second;
-        
-        ProcessCaptureStrings(&strAddressFinalValue);
-        
-        strAddressFinalValue.insert(0, wxT("tel:"));
-        
-        ProcessSaveData(wxT("TEL"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &strAddressFinalValue, &ContactData,
-                        wxT("ALTID"), &GeneralTelephoneListAltID,
-                        wxT("PID"), &GeneralTelephoneListPID,
-                        wxT("TYPE"), &GeneralTelephoneListType,
-                        wxT("PREF"), &GeneralTelephoneListPref,
-                        wxT(""), &GeneralTelephoneListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = HomeTelephoneList.begin();
-         iter != HomeTelephoneList.end(); ++iter){
-        
-        wxString strAddressFinalValue = iter->second;
-        
-        ProcessCaptureStrings(&strAddressFinalValue);
-        
-        strAddressFinalValue.insert(0, wxT("tel:"));
-        
-        ProcessSaveData(wxT("TEL"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &strAddressFinalValue, &ContactData,
-                        wxT("ALTID"), &HomeTelephoneListAltID,
-                        wxT("PID"), &HomeTelephoneListPID,
-                        wxT("TYPE"), &HomeTelephoneListType,
-                        wxT("PREF"), &HomeTelephoneListPref,
-                        wxT(""), &HomeTelephoneListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = BusinessTelephoneList.begin();
-         iter != BusinessTelephoneList.end(); ++iter){
-        
-        wxString strAddressFinalValue = iter->second;
-        
-        ProcessCaptureStrings(&strAddressFinalValue);
-        
-        strAddressFinalValue.insert(0, wxT("tel:"));
-        
-        ProcessSaveData(wxT("TEL"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &strAddressFinalValue, &ContactData,
-                        wxT("ALTID"), &BusinessTelephoneListAltID,
-                        wxT("PID"), &BusinessTelephoneListPID,
-                        wxT("TYPE"), &BusinessTelephoneListType,
-                        wxT("PREF"), &BusinessTelephoneListPref,
-                        wxT(""), &BusinessTelephoneListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = GeneralLanguageList.begin();
-         iter != GeneralLanguageList.end(); ++iter){
-        
-        intValue2 = iter->first;
-        
-        ProcessSaveData(wxT("LANG"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &GeneralLanguageList, &ContactData,
-                        wxT("ALTID"), &GeneralLanguageListAltID,
-                        wxT("PID"), &GeneralLanguageListPID,
-                        wxT("PREF"), &GeneralLanguageListPref,
-                        wxT(""), &GeneralLanguageListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = HomeLanguageList.begin();
-         iter != HomeLanguageList.end(); ++iter){
-        
-        ProcessSaveData(wxT("LANG;TYPE=home"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &HomeLanguageList, &ContactData,
-                        wxT("ALTID"), &HomeLanguageListAltID,
-                        wxT("PID"), &HomeLanguageListPID,
-                        wxT("PREF"), &HomeLanguageListPref,
-                        wxT(""), &HomeLanguageListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = BusinessLanguageList.begin();
-         iter != BusinessLanguageList.end(); ++iter){
-        
-        ProcessSaveData(wxT("LANG;TYPE=work"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &BusinessLanguageList, &ContactData,
-                        wxT("ALTID"), &BusinessLanguageListAltID,
-                        wxT("PID"), &BusinessLanguageListPID,
-                        wxT("PREF"), &BusinessLanguageListPref,
-                        wxT(""), &BusinessLanguageListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = GeneralTZList.begin();
-         iter != GeneralTZList.end(); ++iter){
-        
-        ProcessSaveData(wxT("TZ"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &GeneralTZList, &ContactData,
-                        wxT("ALTID"), &GeneralTZListAltID,
-                        wxT("PID"), &GeneralTZListPID,
-                        wxT("MEDIATYPE"), &GeneralTZListMediatype,
-                        wxT("PREF"), &GeneralTZListPref,
-                        wxT(""), &GeneralTZListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = HomeTZList.begin();
-         iter != HomeTZList.end(); ++iter){
-        
-        ProcessSaveData(wxT("TZ;TYPE=home"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &HomeTZList, &ContactData,
-                        wxT("ALTID"), &HomeTZListAltID,
-                        wxT("PID"), &HomeTZListPID,
-                        wxT("MEDIATYPE"), &HomeTZListMediatype,
-                        wxT("PREF"), &HomeTZListPref,
-                        wxT(""), &HomeTZListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = BusinessTZList.begin();
-         iter != BusinessTZList.end(); ++iter){
-        
-        ProcessSaveData(wxT("TZ;TYPE=work"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &BusinessTZList, &ContactData,
-                        wxT("ALTID"), &BusinessTZListAltID,
-                        wxT("PID"), &BusinessTZListPID,
-                        wxT("MEDIATYPE"), &BusinessTZListMediatype,
-                        wxT("PREF"), &BusinessTZListPref,
-                        wxT(""), &BusinessTZListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = GeneralGeographyList.begin();
-         iter != GeneralGeographyList.end(); ++iter){
-        
-        wxString strAddressFinalValue = iter->second;
-        
-        ProcessCaptureStrings(&strAddressFinalValue);
-        
-        strAddressFinalValue.insert(0, wxT("geo:"));
-        
-        ProcessSaveData(wxT("GEO"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &strAddressFinalValue, &ContactData,
-                        wxT("ALTID"), &GeneralGeographyListAltID,
-                        wxT("PID"), &GeneralGeographyListPID,
-                        wxT("MEDIATYPE"), &GeneralGeographyListMediatype,
-                        wxT("PREF"), &GeneralGeographyListPref,
-                        wxT(""), &GeneralGeographyListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = HomeGeographyList.begin();
-         iter != HomeGeographyList.end(); ++iter){
-        
-        wxString strAddressFinalValue = iter->second;
-        
-        ProcessCaptureStrings(&strAddressFinalValue);
-        
-        strAddressFinalValue.insert(0, wxT("geo:"));
-        
-        ProcessSaveData(wxT("GEO;TYPE=home"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &HomeGeographyList, &ContactData,
-                        wxT("ALTID"), &HomeGeographyListAltID,
-                        wxT("PID"), &HomeGeographyListPID,
-                        wxT("MEDIATYPE"), &HomeGeographyListMediatype,
-                        wxT("PREF"), &HomeGeographyListPref,
-                        wxT(""), &HomeGeographyListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = BusinessGeographyList.begin();
-         iter != BusinessGeographyList.end(); ++iter){
-        
-        wxString strAddressFinalValue = iter->second;
-        
-        ProcessCaptureStrings(&strAddressFinalValue);
-        
-        strAddressFinalValue.insert(0, wxT("geo:"));
-        
-        ProcessSaveData(wxT("GEO;TYPE=work"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &BusinessGeographyList, &ContactData,
-                        wxT("ALTID"), &BusinessGeographyListAltID,
-                        wxT("PID"), &BusinessGeographyListPID,
-                        wxT("MEDIATYPE"), &BusinessGeographyListMediatype,
-                        wxT("PREF"), &BusinessGeographyListPref,
-                        wxT(""), &BusinessGeographyListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = GeneralRelatedList.begin();
-         iter != GeneralRelatedList.end(); ++iter){
-        
-        ProcessSaveData(wxT("RELATED"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &GeneralRelatedList, &ContactData,
-                        wxT("ALTID"), &GeneralRelatedListAltID,
-                        wxT("PID"), &GeneralRelatedListPID,
-                        wxT("LANGUAGE"), &GeneralRelatedListLanguage,
-                        wxT("TYPE"), &GeneralRelatedListRelType,
-                        wxT("PREF"), &GeneralRelatedListPref,
-                        wxT(""), &GeneralRelatedListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = GeneralWebsiteList.begin();
-         iter != GeneralWebsiteList.end(); ++iter){
-        
-        ProcessSaveData(wxT("URL"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &GeneralWebsiteList, &ContactData,
-                        wxT("ALTID"), &GeneralWebsiteListAltID,
-                        wxT("PID"), &GeneralWebsiteListPID,
-                        wxT("MEDIATYPE"), &GeneralWebsiteListMediatype,
-                        wxT("PREF"), &GeneralWebsiteListPref,
-                        wxT(""), &GeneralWebsiteListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = HomeWebsiteList.begin();
-         iter != HomeWebsiteList.end(); ++iter){
-        
-        ProcessSaveData(wxT("URL;TYPE=home"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &HomeWebsiteList, &ContactData,
-                        wxT("ALTID"), &HomeWebsiteListAltID,
-                        wxT("PID"), &HomeWebsiteListPID,
-                        wxT("MEDIATYPE"), &HomeWebsiteListMediatype,
-                        wxT("PREF"), &HomeWebsiteListPref,
-                        wxT(""), &HomeWebsiteListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = BusinessWebsiteList.begin();
-         iter != BusinessWebsiteList.end(); ++iter){
-        
-        ProcessSaveData(wxT("URL;TYPE=work"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &BusinessWebsiteList, &ContactData,
-                        wxT("ALTID"), &BusinessWebsiteListAltID,
-                        wxT("PID"), &BusinessWebsiteListPID,
-                        wxT("MEDIATYPE"), &BusinessWebsiteListMediatype,
-                        wxT("PREF"), &BusinessWebsiteListPref,
-                        wxT(""), &BusinessWebsiteListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = GeneralTitleList.begin();
-         iter != GeneralTitleList.end(); ++iter){
-        
-        ProcessSaveData(wxT("TITLE"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &GeneralTitleList, &ContactData,
-                        wxT("ALTID"), &GeneralTitleListAltID,
-                        wxT("PID"), &GeneralTitleListPID,
-                        wxT("LANGUAGE"), &GeneralTitleListLanguage,
-                        wxT("PREF"), &GeneralTitleListPref,
-                        wxT(""), &GeneralTitleListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = HomeTitleList.begin();
-         iter != HomeTitleList.end(); ++iter){
-        
-        ProcessSaveData(wxT("TITLE;TYPE=home"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &HomeTitleList, &ContactData,
-                        wxT("ALTID"), &HomeTitleListAltID,
-                        wxT("PID"), &HomeTitleListPID,
-                        wxT("LANGUAGE"), &HomeTitleListLanguage,
-                        wxT("PREF"), &HomeTitleListPref,
-                        wxT(""), &HomeTitleListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = BusinessTitleList.begin();
-         iter != BusinessTitleList.end(); ++iter){
-        
-        ProcessSaveData(wxT("TITLE;TYPE=work"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &BusinessTitleList, &ContactData,
-                        wxT("ALTID"), &BusinessTitleListAltID,
-                        wxT("PID"), &BusinessTitleListPID,
-                        wxT("LANGUAGE"), &BusinessTitleListLanguage,
-                        wxT("PREF"), &BusinessTitleListPref,
-                        wxT(""), &BusinessTitleListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = GeneralRoleList.begin();
-         iter != GeneralRoleList.end(); ++iter){
-        
-        ProcessSaveData(wxT("ROLE"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &GeneralRoleList, &ContactData,
-                        wxT("ALTID"), &GeneralRoleListAltID,
-                        wxT("PID"), &GeneralRoleListPID,
-                        wxT("LANGUAGE"), &GeneralRoleListLanguage,
-                        wxT("PREF"), &GeneralRoleListPref,
-                        wxT(""), &GeneralRoleListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = HomeRoleList.begin();
-         iter != HomeRoleList.end(); ++iter){
-        
-        ProcessSaveData(wxT("ROLE;TYPE=home"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &HomeRoleList, &ContactData,
-                        wxT("ALTID"), &HomeRoleListAltID,
-                        wxT("PID"), &HomeRoleListPID,
-                        wxT("LANGUAGE"), &HomeRoleListLanguage,
-                        wxT("PREF"), &HomeRoleListPref,
-                        wxT(""), &HomeRoleListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = BusinessRoleList.begin();
-         iter != BusinessRoleList.end(); ++iter){
-        
-        ProcessSaveData(wxT("ROLE;TYPE=work"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &BusinessRoleList, &ContactData,
-                        wxT("ALTID"), &BusinessRoleListAltID,
-                        wxT("PID"), &BusinessRoleListPID,
-                        wxT("LANGUAGE"), &BusinessRoleListLanguage,
-                        wxT("PREF"), &BusinessRoleListPref,
-                        wxT(""), &BusinessRoleListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = GeneralOrganisationsList.begin();
-         iter != GeneralOrganisationsList.end(); ++iter){
-        
-        ProcessSaveData(wxT("ORG"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &GeneralOrganisationsList, &ContactData,
-                        wxT("ALTID"), &GeneralOrganisationsListAltID,
-                        wxT("PID"), &GeneralOrganisationsListPID,
-                        wxT("LANGUAGE"), &GeneralOrganisationsListLanguage,
-                        wxT("SORT-AS"), &GeneralOrganisationsListSortAs,
-                        wxT("PREF"), &GeneralOrganisationsListPref,
-                        wxT(""), &GeneralOrganisationsListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = HomeOrganisationsList.begin();
-         iter != HomeOrganisationsList.end(); ++iter){
-        
-        ProcessSaveData(wxT("ORG;TYPE=home"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &HomeOrganisationsList, &ContactData,
-                        wxT("ALTID"), &HomeOrganisationsListAltID,
-                        wxT("PID"), &HomeOrganisationsListPID,
-                        wxT("LANGUAGE"), &HomeOrganisationsListLanguage,
-                        wxT("SORT-AS"), &HomeOrganisationsListSortAs,
-                        wxT("PREF"), &HomeOrganisationsListPref,
-                        wxT(""), &HomeOrganisationsListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = BusinessOrganisationsList.begin();
-         iter != BusinessOrganisationsList.end(); ++iter){
-        
-        ProcessSaveData(wxT("ORG;TYPE=work"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &BusinessOrganisationsList, &ContactData,
-                        wxT("ALTID"), &BusinessOrganisationsListAltID,
-                        wxT("PID"), &BusinessOrganisationsListPID,
-                        wxT("LANGUAGE"), &BusinessOrganisationsListLanguage,
-                        wxT("SORT-AS"), &BusinessOrganisationsListSortAs,
-                        wxT("PREF"), &BusinessOrganisationsListPref,
-                        wxT(""), &BusinessOrganisationsListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = GeneralNoteList.begin();
-         iter != GeneralNoteList.end(); ++iter){
-        
-        ProcessSaveData(wxT("NOTE"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &GeneralNoteList, &ContactData,
-                        wxT("ALTID"), &GeneralNoteListAltID,
-                        wxT("PID"), &GeneralNoteListPID,
-                        wxT("LANGUAGE"), &GeneralNoteListLanguage,
-                        wxT("PREF"), &GeneralNoteListPref,
-                        wxT(""), &GeneralNoteListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = HomeNoteList.begin();
-         iter != HomeNoteList.end(); ++iter){
-        
-        ProcessSaveData(wxT("NOTE;TYPE=home"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &HomeNoteList, &ContactData,
-                        wxT("ALTID"), &HomeNoteListAltID,
-                        wxT("PID"), &HomeNoteListPID,
-                        wxT("LANGUAGE"), &HomeNoteListLanguage,
-                        wxT("PREF"), &HomeNoteListPref,
-                        wxT(""), &HomeNoteListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = BusinessNoteList.begin();
-         iter != BusinessNoteList.end(); ++iter){
-        
-        ProcessSaveData(wxT("NOTE;TYPE=work"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &BusinessNoteList, &ContactData,
-                        wxT("ALTID"), &BusinessNoteListAltID,
-                        wxT("PID"), &BusinessNoteListPID,
-                        wxT("LANGUAGE"), &BusinessNoteListLanguage,
-                        wxT("PREF"), &BusinessNoteListPref,
-                        wxT(""), &BusinessNoteListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = CategoriesList.begin();
-         iter != CategoriesList.end(); ++iter){
-        
-        ProcessSaveData(wxT("CATEGORIES"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &CategoriesList, &ContactData,
-                        wxT("ALTID"), &CategoriesListAltID,
-                        wxT("PID"), &CategoriesListPID,
-                        wxT("TYPE"), &CategoriesListType,
-                        wxT("PREF"), &CategoriesListPref,
-                        wxT(""), &CategoriesListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    // Pictures.
-    
-    for (std::map<int, std::string>::iterator iter = PicturesList.begin();
-         iter != PicturesList.end(); ++iter){
-        
-        int intValueIndex = iter->first;
-        
-        std::map<int, std::string>::iterator stdstriter;
-        std::map<int, wxString>::iterator enciter;
-        
-        striter = PicturesListPictureType.find(intValueIndex);
-        enciter = PicturesListPicEncType.find(intValueIndex);
-        
-        ProcessSaveData(wxT("PHOTO"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &PicturesList, &striter,
-                        &enciter, &ContactData,
-                        wxT("ALTID"), &PicturesListAltID,
-                        wxT("PID"), &PicturesListPID,
-                        wxT("TYPE"), &PicturesListType,
-                        wxT("PREF"), &PicturesListPref,
-                        wxT(""), &PicturesListTokens);
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    // Logos.
-    
-    for (std::map<int, std::string>::iterator iter = LogosList.begin();
-         iter != LogosList.end(); ++iter){
-        
-        int intValueIndex = iter->first;
-        
-        std::map<int, std::string>::iterator stdstriter;
-        std::map<int, wxString>::iterator enciter;
-        
-        striter = LogosListPictureType.find(intValueIndex);
-        enciter = LogosListPicEncType.find(intValueIndex);
-        
-        ProcessSaveData(wxT("LOGO"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &LogosList, &striter,
-                        &enciter, &ContactData,
-                        wxT("ALTID"), &LogosListAltID,
-                        wxT("PID"), &LogosListPID,
-                        wxT("TYPE"), &LogosListType,
-                        wxT("PREF"), &LogosListPref,
-                        wxT(""), &LogosListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    // Sounds.
-    
-    for (std::map<int, std::string>::iterator iter = SoundsList.begin();
-         iter != SoundsList.end(); ++iter){
-        
-        int intValueIndex = iter->first;
-        
-        std::map<int, std::string>::iterator stdstriter;
-        std::map<int, wxString>::iterator enciter;
-        
-        striter = SoundsListAudioType.find(intValueIndex);
-        enciter = SoundsListAudioEncType.find(intValueIndex);
-        
-        ProcessSaveData(wxT("SOUND"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &SoundsList, &striter,
-                        &enciter, &ContactData,
-                        wxT("ALTID"), &SoundsListAltID,
-                        wxT("PID"), &SoundsListPID,
-                        wxT("TYPE"), &SoundsListType,
-                        wxT("PREF"), &SoundsListPref,
-                        wxT(""), &SoundsListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = CalendarList.begin();
-         iter != CalendarList.end(); ++iter){
-        
-        ProcessSaveData(wxT("CALURI"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &CalendarList, &ContactData,
-                        wxT("ALTID"), &CalendarListAltID,
-                        wxT("PID"), &CalendarListPID,
-                        wxT("MEDIATYPE"), &CalendarListMediatype,
-                        wxT("TYPE"), &CalendarListType,
-                        wxT("PREF"), &CalendarListPref,
-                        wxT(""), &CalendarListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = CalendarRequestList.begin();
-         iter != CalendarRequestList.end(); ++iter){
-        
-        ProcessSaveData(wxT("CALADRURI"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &CalendarRequestList, &ContactData,
-                        wxT("ALTID"), &CalendarRequestListAltID,
-                        wxT("PID"), &CalendarRequestListPID,
-                        wxT("MEDIATYPE"), &CalendarRequestListMediatype,
-                        wxT("TYPE"), &CalendarRequestListType,
-                        wxT("PREF"), &CalendarRequestListPref,
-                        wxT(""), &CalendarRequestListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    for (std::map<int,wxString>::iterator iter = FreeBusyList.begin();
-         iter != FreeBusyList.end(); ++iter){
-        
-        ProcessSaveData(wxT("FBURL"), &strValue2, &boolValue2, &boolValue,
-                        &iter, &FreeBusyList, &ContactData,
-                        wxT("ALTID"), &FreeBusyListAltID,
-                        wxT("PID"), &FreeBusyListPID,
-                        wxT("MEDIATYPE"), &FreeBusyListMediatype,
-                        wxT("TYPE"), &FreeBusyListType,
-                        wxT("PREF"), &FreeBusyListPref,
-                        wxT(""), &FreeBusyListTokens );
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    for (std::map<int, wxString>::iterator iter = KeyList.begin();
-         iter != KeyList.end(); ++iter){
-        
-        intValue2 = iter->first;
-        
-        // Process Alternative ID.
-        
-        striter = 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 = 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 = 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 = 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 = 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;
-        
-        striter = KeyListDataType.find(intValue2);     
-        //enciter = KeyListAudioEncType.find(intValue2);
-        
-        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);
-            
-        }
-        
-        ResetSaveProcessData();   
-        
-    }
-    
-    // Vendor specific items.
-    
-    ResetSaveProcessData();   
-    
-    for (std::map<int,wxString>::iterator iter = VendorList.begin();
-         iter != VendorList.end(); ++iter){
-        
-        intValue2 = iter->first;       
-        
-        // Get the IANA PEN number.
-        
-        striter = VendorListPEN.find(intValue2);
-        
-        if (striter->first == intValue2){
-            
-            strValue2 = striter->second;
-            
-        }
-        
-        // Get the element name.
-        
-        striter = VendorListElement.find(intValue2);
-        
-        if (striter->first == intValue2){
-            
-            strValue3 = striter->second;
-            
-        }
-        
-        // Get the address.
-        
-        striter = VendorList.find(intValue2);
-        
-        if (striter->first == intValue2){
-            
-            strValue = striter->second;
-            
-        }
-        
-        // Add to the vCard.
-        
-        if (boolValue == TRUE){
-            
-            ContactData.AddRaw(wxT("VND-") + strValue2 + wxT("-") + strValue3, strValue);
-            
-        } else {
-            
-            ContactData.Add(wxT("VND-") + strValue2 + wxT("-") + strValue3, strValue, FALSE);
-            
-        }
-        
-        ResetSaveProcessData();
-        
-    }              
-    
-    ResetSaveProcessData();  
-    
-    // X-Tokens.
-    
-    for (std::map<int,wxString>::iterator iter = XTokenList.begin();
-         iter != XTokenList.end(); ++iter){
-        
-        intValue2 = iter->first;       
-        
-        // Get the element name.
-        
-        striter = XTokenListTokens.find(intValue2);
-        
-        if (striter->first == intValue2){
-            
-            strValue2 = striter->second;
-            
-        }      
-        
-        // Get the address.
-        
-        striter = XTokenList.find(intValue2);
-        
-        if (striter->first == intValue2){
-            
-            strValue = striter->second;
-            
-        }
-        
-        // Add to the vCard.
-        
-        if (boolValue == TRUE){
-            
-            ContactData.AddRaw(wxT("X-") + strValue2, strValue);
-            
-        } else {
-            
-            ContactData.Add(wxT("X-") + strValue2, strValue, FALSE);
-            
-        }
-        
-        ResetSaveProcessData();
-        
-    }
-    
-    ResetSaveProcessData();
-    
-    if (FullNamesList.size() == 0){
-        
-        wxString FullName = cmbDisplayAs->GetValue();
-        FullNamesList.insert(std::make_pair(0, FullName));
-        FullNamesListAltID.insert(std::make_pair(0, wxT("")));
-        FullNamesListPID.insert(std::make_pair(0, wxT("")));
-        FullNamesListType.insert(std::make_pair(0, wxT("")));
-        FullNamesListLanguage.insert(std::make_pair(0, wxT("")));
-        FullNamesListPref.insert(std::make_pair(0, 0));
-        FullNamesListTokens.insert(std::make_pair(0, wxT("")));
-        FNFirst = FALSE;
-        
-    }
-    
-    for (std::map<int, wxString>::iterator iter = FullNamesList.begin();
-         iter != FullNamesList.end(); ++iter){
-        
-        if (FNFirst == TRUE){
-            
-            iter->second = cmbDisplayAs->GetValue();
-            FNFirst = FALSE;
-            
-        }
-        
-        std::map<int,wxString>::iterator mapS;
-        
-        mapS = FullNamesListTokens.find(iter->first);
-        
-        ProcessSaveData(wxT("FN"), &strValue2, &boolValue2, &boolValue, 
-                        &iter, &FullNamesList, &ContactData,
-                        wxT("ALTID"), &FullNamesListAltID,
-                        wxT("PID"), &FullNamesListPID,
-                        wxT("TYPE"), &FullNamesListType,
-                        wxT("LANGUAGE"), &FullNamesListLanguage,
-                        wxT("PREF"), &FullNamesListPref,
-                        wxT(""), &FullNamesListTokens );
-        
-        // Get the address.
-        
-        ResetSaveProcessData();    
-        
-    }
-    
-    //ContactData.Add(wxT("FN"), cmbDisplayAs->GetValue(), FALSE);
-    
-    // Insert revision (REV) date.
-    
-    // Get today's date and time.
-    
-    wxDateTime DateTimeNow = wxDateTime::Now();
-    
-    wxString DateRev;
-    
-    // Set year, month and date.
-    
-    int intYear = DateTimeNow.GetYear();
-    int intMonth = DateTimeNow.GetMonth();
-    int intDay = DateTimeNow.GetDay();
-    
-    DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intYear));
-    
-    if (intMonth < 10){
-        
-        DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intMonth));
-        
-    } else {
-        
-        DateRev.Append(wxString::Format(wxT("%i"), intMonth));
-        
-    }
-    
-    if (intDay < 10){
-        
-        DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intDay));
-        
-    } else {
-        
-        DateRev.Append(wxString::Format(wxT("%i"), intDay));
-        
-    }
-    
-    //DateRev.Append(wx);
-    //DateRev.Append(wx);
-    //DateRev.Append(wx);
-    DateRev.Append(wxT("T"));
-    
-    // Set hour, minute and second.
-    
-    int intHour = DateTimeNow.GetHour();
-    int intMinute = DateTimeNow.GetMinute();
-    int intSecond = DateTimeNow.GetSecond();
-    
-    if (intHour < 10){
-        
-        DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intHour));
-        
-    } else {
-        
-        DateRev.Append(wxString::Format(wxT("%i"), intHour));    
-        
-    }
-    
-    if (intMinute < 10){
-        
-        DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intMinute));
-        
-    } else {
-        
-        DateRev.Append(wxString::Format(wxT("%i"), intMinute));
-        
-    }
-    
-    if (intSecond < 10){
-        
-        DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intSecond));
-        
-    } else {
-        
-        DateRev.Append(wxString::Format(wxT("%i"), intSecond));
-        
-    }
-    
-    //   DateRev.Append(wx);
-    //   DateRev.Append(wx);
-    //   DateRev.Append(wxString DateTimeNow->);
-    DateRev.Append(wxT("Z"));    
-    
-    ContactData.Add(wxT("UID"), UIDToken, FALSE);
-    
-    // End the vCard File.
-    
-    ContactData.Add(wxT("END"), wxT("VCARD"), FALSE);
-    
-    FMTimer.Stop();
-    ContactData.WriteFile(FilenameFinal);
-    
-    vCard34Conv ConvFileFun;
-    
-    wxString wxSData;
-    
-    ConvFileFun.ConvertToV3(FilenameFinal, &wxSData);
-    
-    wxString AccountDirPrefix;
-    wxString AccountDir;
-    wxString PrefDir;
-    
-#if defined(__HAIKU__)
-    
-    //preffilename = wxT("noo");
-
-#elif defined(__APPLE__)
-    
-    PrefDir = GetUserPrefDir();
-    
-    wxStringTokenizer wSTFilename(wxSContactFilename, wxT("/"));
-    
-#elif defined(__WIN32__)
-    
-    PrefDir = GetUserPrefDir();
-    
-    wxStringTokenizer wSTFilename(wxSContactFilename, wxT("\\"));
-    
-#else
-    
-    PrefDir = GetUserPrefDir();
-    
-    wxStringTokenizer wSTFilename(wxSContactFilename, wxT("/"));
-    
-#endif
-    
-    XABPreferences PrefData(PrefDir);
-    
-    wxString AccountType;
-    
-    for (int i = 0; i < PrefData.accounts.GetCount(); i++){
-        
-        AccountDir = PrefData.accounts.GetAccountDirectory(i) + wxT(".carddav");
-        
-        if (AccountDir == wxSContactAccount){
-            
-            AccountDirPrefix = PrefData.accounts.GetAccountDirPrefix(i);
-            AccountDirPrefix.Trim();
-            AccountType = PrefData.accounts.GetAccountType(i);
-            break;
-            
-        }
-        
-    }
-    
-    wxString wxSplitFilename;
-    wxString wxSDataURL;
-    
-    while(wSTFilename.HasMoreTokens()){
-        
-        wxSplitFilename = wSTFilename.GetNextToken();
-        
-    }
-    
-    wxSDataURL = wxSplitFilename;
-    //wxSDataURL.Append(wxSplitFilename);
-    
-    // Find out if the filename exists in the table.
-    
-    if (AccountType == wxT("CardDAV") || AccountType == wxT("carddav")){
-        
-        wxString ETagResult;
-        wxString ETagOriginal;
-        
-        ETagDB *ETagDBPtr = NULL;
-        
-        ETagDBPtr = ETagTmrPtr->GetPointer(wxSContactAccount);
-        
-        wxString wxSETag = ETagDBPtr->GetETag(wxSplitFilename);
-        wxString wxSETagOrig = ETagDBPtr->GetETagOriginal(wxSplitFilename);
-        
-        if (wxSETagOrig.IsEmpty()){
-            
-            // Generate the ETag.
-            
-            wxSETagOrig = wxString::Format(wxT("%X%X%X%X"), rand() % 1024, rand() % 1024, rand() % 1024, rand() % 1024);
-            
-        }
-        
-        if (wxSETag.IsEmpty()){
-            
-            // Update empty ETag.
-            
-            wxSETag = wxSETagOrig;
-            ETagDBPtr->UpdateETag(wxSplitFilename, wxSETag, wxSETagOrig);
-            
-        }
-        else {
-            
-            // Don't change original ETag.
-            
-            wxSETag = wxString::Format(wxT("%X%X%X%X"), rand() % 1024, rand() % 1024, rand() % 1024, rand() % 1024);
-            ETagDBPtr->UpdateETag(wxSplitFilename, wxSETag);
-            
-        }
-        
-        if (EditMode == FALSE){
-            
-            ActMgrPtr->AddTask(0, cmbDisplayAs->GetValue(), wxSContactAccount, wxSDataURL, wxSplitFilename, FilenameFinal, wxSData);
-            EditMode = TRUE;
-            FMTimer.SetFilename(FilenameFinal);
-            FMTimer.UpdateTimestamp();
-            FMTimer.Start(10000, FALSE);
-           
-           wxCommandEvent reloadevent(RELOADCONTACTLIST);
-           reloadevent.SetString(wxSContactAccount);
-           wxPostEvent(this->GetParent(), reloadevent);
-            
-        }
-        else {
-            
-            ActMgrPtr->AddTask(1, cmbDisplayAs->GetValue(), wxSContactAccount, wxSDataURL, wxSplitFilename, FilenameFinal, wxSData);
-            FMTimer.UpdateTimestamp();
-            FMTimer.Start(10000, FALSE);
-            
-        }
-        
-    }
-    
-    // Send a notification to update the main window
-    // with the new details.
-    
-    UCNotif *ucd;
-    ucd = new UCNotif;
-    
-    // TODO: Workout nickname settings by priority and
-    // type.
-    
-    ucd->ContactAccount = wxSContactAccount;
-    ucd->ContactFilename = FilenameFinal;
-    ucd->ContactName = cmbDisplayAs->GetValue();
-    ucd->ContactNameArray = ContactData.GetName();
-    
-    for (std::map<int,wxString>::iterator gniter = GeneralNicknamesList.begin();
-         gniter != GeneralNicknamesList.end(); gniter++){
-        
-        ucd->ContactNickname = gniter->second;
-        break;
-        
-    }
-    
-    wxCommandEvent event2(CE_UPDATECONTACTLIST);
-    event2.SetClientData(ucd);
-    wxPostEvent(MainPtr, event2);
+               }
+       
+               wxCommandEvent event2(CE_UPDATECONTACTLIST);
+               event2.SetClientData(ucd);
+               wxPostEvent(MainPtr, event2);
+       }
     
 }
 
 void frmContactEditor::SaveCloseContact( wxCommandEvent& event )
 {
     
-    // Save the updated contact data and close the form.
+       // Save the updated contact data and close the form.
     
-    wxCommandEvent NullEvent;
-    this->SaveContact(NullEvent);
-    this->Close();
+       wxCommandEvent NullEvent;
+       this->SaveContact(NullEvent);
+       this->Close();
     
 }
\ No newline at end of file
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