// 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 #include "frmContactEditor.h" #include "../enums.h" #include "../version.h" #include "../vcard/vcard.h" #include "../vcard/vcard34conv.h" #include "../common/textprocessing.h" #include "../common/preferences.h" #include "../common/uuid.h" #include "../common/dirs.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(); if (cmbDisplayAsValue.IsEmpty()){ wxMessageBox(_("Display As value cannot be left blank."), _("Display As value empty"), wxICON_ERROR); return; } // Save the updated contact data. vCard ContactData; wxString FilenameFinal; bool ReplaceContact = FALSE; if (StartupEditMode == TRUE){ if (cmbType->GetCurrentSelection() == 1 || cmbType->GetCurrentSelection() == 3 || cmbType->GetCurrentSelection() == 4){ if (IsGroup == TRUE){ // Mark contact for replacing. ReplaceContact = TRUE; IsGroup = FALSE; } } else if (cmbType->GetCurrentSelection() == 2){ if (IsGroup == FALSE){ // Mark contact for replacing. ReplaceContact = TRUE; IsGroup = TRUE; } } if (ReplaceContact == TRUE){ wxString wxDelSplitFilename; wxString wxDelFinalFilename; wxString wxSDelDataURL; wxStringTokenizer wSTDelFilename(wxSContactFilename, wxT("/")); while(wSTDelFilename.HasMoreTokens()){ wxDelSplitFilename = wSTDelFilename.GetNextToken(); } wxSDelDataURL = wxDelSplitFilename; // 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("")); // Clear the filename so the trigger to recreate the UID is done. wxSContactFilename.Clear(); EditMode = FALSE; } } if (wxSContactFilename.IsEmpty()){ // Generate a random UUID. ContactEditorData.UIDToken = GenerateUUID(); ContactEditorData.UIDToken = ContactEditorData.UIDToken.MakeUpper(); // Setup the filename. FilenameFinal = GetAccountDir(wxSContactAccount, FALSE); #if defined(__HAIKU__) //preffilename = wxT("noo"); #elif defined(__WIN32__) FilenameFinal = GetAccountDir(wxSContactAccount, FALSE); FilenameFinal.Append(ContactEditorData.UIDToken); FilenameFinal.Append(wxT(".vcf")); wxSContactFilename = FilenameFinal; #else FilenameFinal = GetAccountDir(wxSContactAccount, FALSE); FilenameFinal.Append(ContactEditorData.UIDToken); FilenameFinal.Append(wxT(".vcf")); wxSContactFilename = FilenameFinal; #endif } else { if (ContactEditorData.UIDToken.IsEmpty()){ // UID Token is empty. (Shouldn't be). // Generate a new UID Token. ContactEditorData.UIDToken = GenerateUUID(); ContactEditorData.UIDToken = ContactEditorData.UIDToken.MakeUpper(); } FilenameFinal = wxSContactFilename; } // Setup the data and write it into the account folder. // Begin preperations to write the contact to a file. bool FNFirst = TRUE; bool NNGeneralFirst = TRUE; bool NNHomeFirst = TRUE; bool NNWorkFirst = TRUE; int intFNCount = 0; std::map::iterator intiter; std::map::iterator striter; ContactData.Add(wxT("BEGIN"), wxT("VCARD"), FALSE); ContactData.Add(wxT("VERSION"), wxT("4.0"), FALSE); // Setup the version string. strValue.Append(wxT("-//Xestia//Address Book Version ")); strValue.Append(wxT(XSDAB_VERSION)); strValue.Append(wxT("//KW")); ContactData.Add(wxT("PRODID"), strValue, FALSE); // Process the REV property. wxDateTime DateTimeSave; DateTimeSave = DateTimeSave.SetToCurrent(); wxString DateTimeSaveValue; DateTimeSaveValue += wxString::Format("%04i", DateTimeSave.GetYear()); DateTimeSaveValue += wxString::Format("%02i", (DateTimeSave.GetMonth() + 1)); DateTimeSaveValue += wxString::Format("%02i", DateTimeSave.GetDay()); DateTimeSaveValue += "T"; DateTimeSaveValue += wxString::Format("%02i", DateTimeSave.GetHour()); DateTimeSaveValue += wxString::Format("%02i", DateTimeSave.GetMinute()); DateTimeSaveValue += wxString::Format("%02i", DateTimeSave.GetSecond()); if (!ContactEditorData.RevisionTokens.IsEmpty()){ ContactData.AddRaw("REV;" + ContactEditorData.RevisionTokens, DateTimeSaveValue); } else { ContactData.AddRaw("REV", DateTimeSaveValue); } // Process the XML properties. for (std::map::iterator iter = ContactEditorData.XMLList.begin(); iter != ContactEditorData.XMLList.end(); ++iter){ wxString strOrigValue; strOrigValue = ContactEditorData.XMLList.find(iter->first)->second; ResetUnusedString(&strOrigValue); ProcessSaveData(wxT("XML"), &strValue2, &boolValue2, &boolValue, &iter, &strOrigValue, &ContactData, wxT("ALTID"), &ContactEditorData.XMLListAltID ); ResetSaveProcessData(); } // Process the CLIENTPIDMAP properties. for (std::map::iterator iter = ContactEditorData.ClientPIDList.begin(); iter != ContactEditorData.ClientPIDList.end(); ++iter){ wxString strOrigValue; strOrigValue = ContactEditorData.ClientPIDList.find(iter->first)->second; ResetUnusedString(&strOrigValue); ProcessSaveData(wxT("CLIENTPIDMAP"), &strValue2, &boolValue2, &boolValue, &iter, &strOrigValue, &ContactData, wxT(""), &ContactEditorData.ClientPIDListTokens ); ResetSaveProcessData(); } // Process the SOURCE properties. for (std::map::iterator iter = ContactEditorData.SourceList.begin(); iter != ContactEditorData.SourceList.end(); ++iter){ wxString strOrigValue; strOrigValue = ContactEditorData.SourceList.find(iter->first)->second; ResetUnusedString(&strOrigValue); ProcessSaveData(wxT("SOURCE"), &strValue2, &boolValue2, &boolValue, &iter, &strOrigValue, &ContactData, wxT("ALTID"), &ContactEditorData.SourceListAltID, wxT("PID"), &ContactEditorData.SourceListPID, wxT("TYPE"), &ContactEditorData.SourceListType, wxT("PREF"), &ContactEditorData.SourceListPref, wxT("MEDIATYPE"), &ContactEditorData.SourceListMediatype, wxT(""), &ContactEditorData.SourceListTokens ); ResetSaveProcessData(); } // Setup the name. strValue.Clear(); // 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 (ContactEditorData.NameTokens.IsEmpty()){ ContactData.Add(wxT("N;SORT-AS=\"") + strValue2 + wxT("\""), strValue, FALSE); } else { ContactData.Add(wxT("N;SORT-AS=\"") + strValue2 + wxT("\";") + ContactEditorData.NameTokens, strValue, FALSE); } if (cmbType->GetCurrentSelection() == 1){ ContactData.AddRaw(wxT("KIND"), wxT("individual")); } else if (cmbType->GetCurrentSelection() == 2){ ContactData.AddRaw(wxT("KIND"), wxT("group")); // Go through each of the members and write them out. for (std::map::iterator itemiter = ContactEditorData.GroupsList.begin(); itemiter != ContactEditorData.GroupsList.end(); ++itemiter){ ContactData.Add(wxT("MEMBER:urn:uuid"), itemiter->second, FALSE); } } 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: strValue = wxT("O"); break; case 4: strValue = wxT("N"); break; case 5: strValue = wxT("U"); break; } } if (!txtGenderDescription->IsEmpty()){ strValue2 = txtGenderDescription->GetValue(); } if (!strValue.IsEmpty() || !strValue2.IsEmpty()){ EscapeString(&strValue2, FALSE); if (!ContactEditorData.GenderTokens.IsEmpty()){ if (!strValue2.IsEmpty()){ ContactData.AddRaw(wxT("GENDER;") + ContactEditorData.GenderTokens, strValue + wxT(";") + strValue2); } else { ContactData.AddRaw(wxT("GENDER;") + ContactEditorData.GenderTokens, strValue); } } else { if (!strValue2.IsEmpty()){ ContactData.AddRaw(wxT("GENDER"), strValue + wxT(";") + strValue2); } else { ContactData.AddRaw(wxT("GENDER"), strValue); } } } ResetSaveProcessData(); // Build the values for the BDAY property. // ALTID if (!ContactEditorData.BirthdayAltID.IsEmpty()){ wxString DataValue; DataValue = ContactEditorData.BirthdayAltID; EscapeString(&DataValue, FALSE); strValue3.Append("ALTID="); strValue3.Append(DataValue); boolValue2 = TRUE; } // CALSCALE. if (!ContactEditorData.BirthdayCalScale.IsEmpty()){ wxString DataValue; DataValue = ContactEditorData.BirthdayCalScale; EscapeString(&DataValue, FALSE); if (boolValue2 == TRUE){ strValue3.Append(";"); } strValue3.Append("CALSCALE="); strValue3.Append(DataValue); boolValue2 = TRUE; } // Extra tokens. if (!ContactEditorData.BirthdayTokens.IsEmpty()){ wxString DataValue; DataValue = ContactEditorData.BirthdayTokens; EscapeString(&DataValue, FALSE); if (boolValue2 == TRUE){ strValue3.Append(";"); } strValue3.Append(DataValue); } // Write the BDAY property. if (!txtBirthday->IsEmpty()){ if (!txtBirthday->GetValue().IsEmpty()){ strValue = txtBirthday->GetValue(); if (!strValue3.IsEmpty()){ ContactData.AddRaw("BDAY;VALUE=text;" + strValue3, strValue); } else { ContactData.AddRaw("BDAY;VALUE=text", strValue); } } } else { // Deal with date. // Get Day, Month & Year. wxDateTime BirthdayDate; wxDateTime::Month BirthdayMonth; int BirthdayDay; int BirthdayYear; wxString DataBeforeT; wxString DataAfterT; wxString FinalBirthdayString; bool ProcessDataAfterT = FALSE; BirthdayDate = dapBirthday->GetValue(); if (BirthdayDate.IsValid()){ BirthdayDay = BirthdayDate.GetDay(); BirthdayMonth = BirthdayDate.GetMonth(); BirthdayYear = BirthdayDate.GetYear(); // Look for T and replace data before this. wxStringTokenizer wSTDate(ContactEditorData.Birthday, wxT("T")); while (wSTDate.HasMoreTokens()){ if (ProcessDataAfterT == FALSE){ DataBeforeT = wSTDate.GetNextToken(); ProcessDataAfterT = TRUE; } else { DataAfterT = wSTDate.GetNextToken(); break; } } // If there is not T then replace altogether. wxString FinalBirthdayDay; wxString FinalBirthdayMonth; wxString FinalBirthdayYear; if (BirthdayDay < 10){ FinalBirthdayDay = wxT("0") + wxString::Format(wxT("%i"), BirthdayDay); } else { FinalBirthdayDay = wxString::Format(wxT("%i"), BirthdayDay); } if (((int)BirthdayMonth + 1) < 10){ FinalBirthdayMonth = wxT("0") + wxString::Format(wxT("%i"), ((int)BirthdayMonth + 1)); } else { FinalBirthdayMonth = wxString::Format(wxT("%i"), ((int)BirthdayMonth + 1)); } if (BirthdayYear == 0){ FinalBirthdayYear = wxT("--"); } else { FinalBirthdayYear = wxString::Format(wxT("%i"), BirthdayYear); } if (!DataAfterT.IsEmpty()){ FinalBirthdayString = FinalBirthdayYear + FinalBirthdayMonth + FinalBirthdayDay + wxT("T") + DataAfterT; } else { FinalBirthdayString = FinalBirthdayYear + FinalBirthdayMonth + FinalBirthdayDay; } if (!FinalBirthdayString.IsEmpty() || !strValue3.IsEmpty()){ if (!strValue3.IsEmpty()){ EscapeString(&strValue2, FALSE); EscapeString(&strValue, FALSE); ContactData.AddRaw(wxT("BDAY;") + strValue3, FinalBirthdayString); } else { EscapeString(&strValue, FALSE); ContactData.AddRaw(wxT("BDAY"), FinalBirthdayString); } } } } ResetSaveProcessData(); // Build the values for the ANNIVERSARY property. // ALTID if (!ContactEditorData.AnniversaryAltID.IsEmpty()){ wxString DataValue; DataValue = ContactEditorData.AnniversaryAltID; EscapeString(&DataValue, FALSE); strValue3.Append("ALTID="); strValue3.Append(DataValue); boolValue2 = TRUE; } // CALSCALE. if (!ContactEditorData.AnniversaryCalScale.IsEmpty()){ wxString DataValue; DataValue = ContactEditorData.AnniversaryCalScale; EscapeString(&DataValue, FALSE); if (boolValue2 == TRUE){ strValue3.Append(";"); } strValue3.Append("CALSCALE="); strValue3.Append(DataValue); boolValue2 = TRUE; } // Extra tokens. if (!ContactEditorData.AnniversaryTokens.IsEmpty()){ wxString DataValue; DataValue = ContactEditorData.AnniversaryTokens; EscapeString(&DataValue, FALSE); if (boolValue2 == TRUE){ strValue3.Append(";"); } strValue3.Append(DataValue); } // Write the ANNIVERSARY property. if (!txtAnniversary->IsEmpty()){ if (!txtAnniversary->GetValue().IsEmpty()){ strValue = txtAnniversary->GetValue(); if (!strValue3.IsEmpty()){ ContactData.AddRaw("ANNIVERSARY;VALUE=text;" + strValue3, strValue); } else { ContactData.AddRaw("ANNIVERSARY;VALUE=text", strValue); } } } else { // Look for T and replace data before this. // Get Day, Month & Year. wxDateTime AnniversaryDate; wxDateTime::Month AnniversaryMonth; int AnniversaryDay; int AnniversaryYear; wxString DataBeforeT; wxString DataAfterT; wxString FinalAnniversaryString; bool ProcessDataAfterT = FALSE; AnniversaryDate = dapAnniversary->GetValue(); if (AnniversaryDate.IsValid()){ AnniversaryDay = AnniversaryDate.GetDay(); AnniversaryMonth = AnniversaryDate.GetMonth(); AnniversaryYear = AnniversaryDate.GetYear(); // Look for T and replace data before this. wxStringTokenizer wSTDate(ContactEditorData.Anniversary, wxT("T")); while (wSTDate.HasMoreTokens()){ if (ProcessDataAfterT == FALSE){ DataBeforeT = wSTDate.GetNextToken(); ProcessDataAfterT = TRUE; } else { DataAfterT = wSTDate.GetNextToken(); break; } } // If there is not T then replace altogether. wxString FinalAnniversaryDay; wxString FinalAnniversaryMonth; wxString FinalAnniversaryYear; if (AnniversaryDay < 10){ FinalAnniversaryDay = wxT("0") + wxString::Format(wxT("%i"), AnniversaryDay); } else { FinalAnniversaryDay = wxString::Format(wxT("%i"), AnniversaryDay); } if (((int)AnniversaryMonth + 1) < 10){ FinalAnniversaryMonth = wxT("0") + wxString::Format(wxT("%i"), ((int)AnniversaryMonth + 1)); } else { FinalAnniversaryMonth = wxString::Format(wxT("%i"), ((int)AnniversaryMonth + 1)); } if (AnniversaryYear == 0){ FinalAnniversaryYear = wxT("--"); } else { FinalAnniversaryYear = wxString::Format(wxT("%i"), AnniversaryYear); } if (!DataAfterT.IsEmpty()){ FinalAnniversaryString = FinalAnniversaryYear + FinalAnniversaryMonth + FinalAnniversaryDay + wxT("T") + DataAfterT; } else { FinalAnniversaryString = FinalAnniversaryYear + FinalAnniversaryMonth + FinalAnniversaryDay; } if (!FinalAnniversaryString.IsEmpty() || !strValue3.IsEmpty()){ if (!strValue3.IsEmpty()){ EscapeString(&strValue2, FALSE); EscapeString(&strValue, FALSE); ContactData.AddRaw(wxT("ANNIVERSARY;") + strValue3, FinalAnniversaryString); } else { EscapeString(&strValue, FALSE); ContactData.AddRaw(wxT("ANNIVERSARY"), FinalAnniversaryString); } } } } // Setup the addresses (General, Home, Business). ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.GeneralAddressList.begin(); iter != ContactEditorData.GeneralAddressList.end(); ++iter){ int intSeekValue = iter->first; wxString strAddressString; wxString strAddressFinalValue; std::map::iterator iterValue; strAddressString.Append(wxT(";;")); // Get Address iterValue = ContactEditorData.GeneralAddressList.find(intSeekValue); strAddressFinalValue = iterValue->second; ProcessCaptureStrings(&strAddressFinalValue); strAddressString.Append(strAddressFinalValue + wxT(";")); strAddressFinalValue.Clear(); // Get Town iterValue = ContactEditorData.GeneralAddressListTown.find(intSeekValue); strAddressFinalValue = iterValue->second; ProcessCaptureStrings(&strAddressFinalValue); strAddressString.Append(strAddressFinalValue + wxT(";")); strAddressFinalValue.Clear(); // Get County iterValue = ContactEditorData.GeneralAddressListCounty.find(intSeekValue); strAddressFinalValue = iterValue->second; ProcessCaptureStrings(&strAddressFinalValue); strAddressString.Append(strAddressFinalValue + wxT(";")); strAddressFinalValue.Clear(); // Get Post Code iterValue = ContactEditorData.GeneralAddressListPostCode.find(intSeekValue); strAddressFinalValue = iterValue->second; ProcessCaptureStrings(&strAddressFinalValue); strAddressString.Append(strAddressFinalValue + wxT(";")); strAddressFinalValue.Clear(); // Get Country iterValue = ContactEditorData.GeneralAddressListCountry.find(intSeekValue); strAddressFinalValue = iterValue->second; ProcessCaptureStrings(&strAddressFinalValue); strAddressString.Append(strAddressFinalValue); strAddressFinalValue.Clear(); ProcessSaveData(wxT("ADR"), &strValue2, &boolValue2, &boolValue, &iter, &strAddressString, &ContactData, wxT("LABEL"), &ContactEditorData.GeneralAddressListLabel, wxT("LANGUAGE"), &ContactEditorData.GeneralAddressListLang, wxT("ALTID"), &ContactEditorData.GeneralAddressListAltID, wxT("PID"), &ContactEditorData.GeneralAddressListPID, wxT("GEO"), &ContactEditorData.GeneralAddressListGeo, wxT("TZ"), &ContactEditorData.GeneralAddressListTimezone, wxT("MEDIATYPE"), &ContactEditorData.GeneralAddressListMediatype, wxT("PREF"), &ContactEditorData.GeneralAddressListPref, wxT(""), &ContactEditorData.GeneralAddressListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.HomeAddressList.begin(); iter != ContactEditorData.HomeAddressList.end(); ++iter){ int intSeekValue = iter->first; wxString strAddressString; wxString strAddressFinalValue; std::map::iterator iterValue; strAddressString.Append(wxT(";;")); // Get Address iterValue = ContactEditorData.HomeAddressList.find(intSeekValue); strAddressFinalValue = iterValue->second; ProcessCaptureStrings(&strAddressFinalValue); strAddressString.Append(strAddressFinalValue + wxT(";")); // Get Town iterValue = ContactEditorData.HomeAddressListTown.find(intSeekValue); strAddressFinalValue = iterValue->second; ProcessCaptureStrings(&strAddressFinalValue); strAddressString.Append(strAddressFinalValue + wxT(";")); // Get County iterValue = ContactEditorData.HomeAddressListCounty.find(intSeekValue); strAddressFinalValue = iterValue->second; ProcessCaptureStrings(&strAddressFinalValue); strAddressString.Append(strAddressFinalValue + wxT(";")); // Get Post Code iterValue = ContactEditorData.HomeAddressListPostCode.find(intSeekValue); strAddressFinalValue = iterValue->second; ProcessCaptureStrings(&strAddressFinalValue); strAddressString.Append(strAddressFinalValue + wxT(";")); // Get Country iterValue = ContactEditorData.HomeAddressListCountry.find(intSeekValue); strAddressFinalValue = iterValue->second; ProcessCaptureStrings(&strAddressFinalValue); strAddressString.Append(strAddressFinalValue); ProcessSaveData(wxT("ADR;TYPE=home"), &strValue2, &boolValue2, &boolValue, &iter, &strAddressString, &ContactData, wxT("LABEL"), &ContactEditorData.HomeAddressListLabel, wxT("LANGUAGE"), &ContactEditorData.HomeAddressListLang, wxT("ALTID"), &ContactEditorData.HomeAddressListAltID, wxT("PID"), &ContactEditorData.HomeAddressListPID, wxT("GEO"), &ContactEditorData.HomeAddressListGeo, wxT("TZ"), &ContactEditorData.HomeAddressListTimezone, wxT("MEDIATYPE"), &ContactEditorData.HomeAddressListMediatype, wxT("PREF"), &ContactEditorData.HomeAddressListPref, wxT(""), &ContactEditorData.HomeAddressListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.BusinessAddressList.begin(); iter != ContactEditorData.BusinessAddressList.end(); ++iter){ int intSeekValue = iter->first; wxString strAddressString; wxString strAddressFinalValue; std::map::iterator iterValue; strAddressString.Append(wxT(";;")); // Get Address iterValue = ContactEditorData.BusinessAddressList.find(intSeekValue); strAddressFinalValue = iterValue->second; ProcessCaptureStrings(&strAddressFinalValue); strAddressString.Append(strAddressFinalValue + wxT(";")); // Get Town iterValue = ContactEditorData.BusinessAddressListTown.find(intSeekValue); strAddressFinalValue = iterValue->second; ProcessCaptureStrings(&strAddressFinalValue); strAddressString.Append(strAddressFinalValue + wxT(";")); // Get County iterValue = ContactEditorData.BusinessAddressListCounty.find(intSeekValue); strAddressFinalValue = iterValue->second; ProcessCaptureStrings(&strAddressFinalValue); strAddressString.Append(strAddressFinalValue + wxT(";")); // Get Post Code iterValue = ContactEditorData.BusinessAddressListPostCode.find(intSeekValue); strAddressFinalValue = iterValue->second; ProcessCaptureStrings(&strAddressFinalValue); strAddressString.Append(strAddressFinalValue + wxT(";")); // Get Country iterValue = ContactEditorData.BusinessAddressListCountry.find(intSeekValue); strAddressFinalValue = iterValue->second; ProcessCaptureStrings(&strAddressFinalValue); strAddressString.Append(strAddressFinalValue); ProcessSaveData(wxT("ADR;TYPE=work"), &strValue2, &boolValue2, &boolValue, &iter, &strAddressString, &ContactData, wxT("LABEL"), &ContactEditorData.BusinessAddressListLabel, wxT("LANGUAGE"), &ContactEditorData.BusinessAddressListLang, wxT("ALTID"), &ContactEditorData.BusinessAddressListAltID, wxT("PID"), &ContactEditorData.BusinessAddressListPID, wxT("GEO"), &ContactEditorData.BusinessAddressListGeo, wxT("TZ"), &ContactEditorData.BusinessAddressListTimezone, wxT("MEDIATYPE"), &ContactEditorData.BusinessAddressListMediatype, wxT("PREF"), &ContactEditorData.BusinessAddressListPref, wxT(""), &ContactEditorData.BusinessAddressListTokens ); ResetSaveProcessData(); } // Sort out nicknames (if any). for (std::map::iterator iter = ContactEditorData.GeneralNicknamesList.begin(); iter != ContactEditorData.GeneralNicknamesList.end(); ++iter){ intValue2 = iter->first; // Process Alternative ID. ProcessSaveData(wxT("NICKNAME"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.GeneralNicknamesList, &ContactData, wxT("LANGUAGE"), &ContactEditorData.GeneralNicknamesListLanguage, wxT("ALTID"), &ContactEditorData.GeneralNicknamesListAltID, wxT("PID"), &ContactEditorData.GeneralNicknamesListPID, wxT("PREF"), &ContactEditorData.GeneralNicknamesListPref, wxT(""), &ContactEditorData.GeneralNicknamesListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.HomeNicknamesList.begin(); iter != ContactEditorData.HomeNicknamesList.end(); ++iter){ ProcessSaveData(wxT("NICKNAME;TYPE=home"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.HomeNicknamesList, &ContactData, wxT("LANGUAGE"), &ContactEditorData.HomeNicknamesListLanguage, wxT("ALTID"), &ContactEditorData.HomeNicknamesListAltID, wxT("PID"), &ContactEditorData.HomeNicknamesListPID, wxT("PREF"), &ContactEditorData.HomeNicknamesListPref, wxT(""), &ContactEditorData.HomeNicknamesListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.BusinessNicknamesList.begin(); iter != ContactEditorData.BusinessNicknamesList.end(); ++iter){ ProcessSaveData(wxT("NICKNAME;TYPE=work"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.BusinessNicknamesList, &ContactData, wxT("LANGUAGE"), &ContactEditorData.BusinessNicknamesListLanguage, wxT("ALTID"), &ContactEditorData.BusinessNicknamesListAltID, wxT("PID"), &ContactEditorData.BusinessNicknamesListPID, wxT("PREF"), &ContactEditorData.BusinessNicknamesListPref, wxT(""), &ContactEditorData.BusinessNicknamesListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); // Sort out email (general, home and business). for (std::map::iterator iter = ContactEditorData.GeneralEmailList.begin(); iter != ContactEditorData.GeneralEmailList.end(); ++iter){ //strValue3 = ContactData.Convert(GeneralAddressList, FALSE); //strValue2 = wxString strAddressFinalValue; std::map::iterator iterValue; ProcessSaveData(wxT("EMAIL"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.GeneralEmailList, &ContactData, wxT("ALTID"), &ContactEditorData.GeneralEmailListAltID, wxT("PID"), &ContactEditorData.GeneralEmailListPID, wxT("PREF"), &ContactEditorData.GeneralEmailListPref, wxT(""), &ContactEditorData.GeneralEmailListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.HomeEmailList.begin(); iter != ContactEditorData.HomeEmailList.end(); ++iter){ //strValue3 = ContactData.Convert(GeneralAddressList, FALSE); //strValue2 = ProcessSaveData(wxT("EMAIL;TYPE=home"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.HomeEmailList, &ContactData, wxT("ALTID"), &ContactEditorData.HomeEmailListAltID, wxT("PID"), &ContactEditorData.HomeEmailListPID, wxT("PREF"), &ContactEditorData.HomeEmailListPref, wxT(""), &ContactEditorData.HomeEmailListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.BusinessEmailList.begin(); iter != ContactEditorData.BusinessEmailList.end(); ++iter){ //strValue3 = ContactData.Convert(GeneralAddressList, FALSE); //strValue2 = ProcessSaveData(wxT("EMAIL;TYPE=work"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.BusinessEmailList, &ContactData, wxT("ALTID"), &ContactEditorData.BusinessEmailListAltID, wxT("PID"), &ContactEditorData.BusinessEmailListPID, wxT("PREF"), &ContactEditorData.BusinessEmailListPref, wxT(""), &ContactEditorData.BusinessEmailListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.GeneralIMList.begin(); iter != ContactEditorData.GeneralIMList.end(); ++iter){ intValue2 = iter->first; // Process Alternative ID. ProcessSaveData(wxT("IMPP"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.GeneralIMList, &ContactData, wxT("ALTID"), &ContactEditorData.GeneralIMListAltID, wxT("PID"), &ContactEditorData.GeneralIMListPID, wxT("MEDIATYPE"), &ContactEditorData.GeneralIMListMediatype, wxT("PREF"), &ContactEditorData.GeneralIMListPref, wxT(""), &ContactEditorData.GeneralIMListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.HomeIMList.begin(); iter != ContactEditorData.HomeIMList.end(); ++iter){ ProcessSaveData(wxT("IMPP;TYPE=home"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.HomeIMList, &ContactData, wxT("ALTID"), &ContactEditorData.HomeIMListAltID, wxT("PID"), &ContactEditorData.HomeIMListPID, wxT("MEDIATYPE"), &ContactEditorData.HomeIMListMediatype, wxT("PREF"), &ContactEditorData.HomeIMListPref, wxT(""), &ContactEditorData.HomeIMListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.BusinessIMList.begin(); iter != ContactEditorData.BusinessIMList.end(); ++iter){ ProcessSaveData(wxT("IMPP;TYPE=work"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.BusinessIMList, &ContactData, wxT("ALTID"), &ContactEditorData.BusinessIMListAltID, wxT("PID"), &ContactEditorData.BusinessIMListPID, wxT("MEDIATYPE"), &ContactEditorData.BusinessIMListMediatype, wxT("PREF"), &ContactEditorData.BusinessIMListPref, wxT(""), &ContactEditorData.BusinessIMListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.GeneralTelephoneList.begin(); iter != ContactEditorData.GeneralTelephoneList.end(); ++iter){ wxString strAddressFinalValue = iter->second; ProcessCaptureStrings(&strAddressFinalValue); if (ContactEditorData.GeneralTelephoneListDataType.find(iter->first) != ContactEditorData.GeneralTelephoneListDataType.end()){ std::map::iterator DataTypeIter = ContactEditorData.GeneralTelephoneListDataType.find(iter->first); strAddressFinalValue.insert(0, ":"); strAddressFinalValue.insert(0, DataTypeIter->second); } else { strAddressFinalValue.insert(0, "tel:"); } ProcessSaveData(wxT("TEL"), &strValue2, &boolValue2, &boolValue, &iter, &strAddressFinalValue, &ContactData, wxT("ALTID"), &ContactEditorData.GeneralTelephoneListAltID, wxT("PID"), &ContactEditorData.GeneralTelephoneListPID, wxT("TYPE"), &ContactEditorData.GeneralTelephoneListType, wxT("PREF"), &ContactEditorData.GeneralTelephoneListPref, wxT(""), &ContactEditorData.GeneralTelephoneListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.HomeTelephoneList.begin(); iter != ContactEditorData.HomeTelephoneList.end(); ++iter){ wxString strAddressFinalValue = iter->second; ProcessCaptureStrings(&strAddressFinalValue); if (ContactEditorData.HomeTelephoneListDataType.find(iter->first) != ContactEditorData.HomeTelephoneListDataType.end()){ std::map::iterator DataTypeIter = ContactEditorData.HomeTelephoneListDataType.find(iter->first); strAddressFinalValue.insert(0, ":"); strAddressFinalValue.insert(0, DataTypeIter->second); } else { strAddressFinalValue.insert(0, "tel:"); } ProcessSaveData(wxT("TEL"), &strValue2, &boolValue2, &boolValue, &iter, &strAddressFinalValue, &ContactData, wxT("ALTID"), &ContactEditorData.HomeTelephoneListAltID, wxT("PID"), &ContactEditorData.HomeTelephoneListPID, wxT("TYPE"), &ContactEditorData.HomeTelephoneListType, wxT("PREF"), &ContactEditorData.HomeTelephoneListPref, wxT(""), &ContactEditorData.HomeTelephoneListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.BusinessTelephoneList.begin(); iter != ContactEditorData.BusinessTelephoneList.end(); ++iter){ wxString strAddressFinalValue = iter->second; ProcessCaptureStrings(&strAddressFinalValue); if (ContactEditorData.BusinessTelephoneListDataType.find(iter->first) != ContactEditorData.BusinessTelephoneListDataType.end()){ std::map::iterator DataTypeIter = ContactEditorData.BusinessTelephoneListDataType.find(iter->first); strAddressFinalValue.insert(0, ":"); strAddressFinalValue.insert(0, DataTypeIter->second); } else { strAddressFinalValue.insert(0, "tel:"); } ProcessSaveData(wxT("TEL"), &strValue2, &boolValue2, &boolValue, &iter, &strAddressFinalValue, &ContactData, wxT("ALTID"), &ContactEditorData.BusinessTelephoneListAltID, wxT("PID"), &ContactEditorData.BusinessTelephoneListPID, wxT("TYPE"), &ContactEditorData.BusinessTelephoneListType, wxT("PREF"), &ContactEditorData.BusinessTelephoneListPref, wxT(""), &ContactEditorData.BusinessTelephoneListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.GeneralLanguageList.begin(); iter != ContactEditorData.GeneralLanguageList.end(); ++iter){ intValue2 = iter->first; ProcessSaveData(wxT("LANG"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.GeneralLanguageList, &ContactData, wxT("ALTID"), &ContactEditorData.GeneralLanguageListAltID, wxT("PID"), &ContactEditorData.GeneralLanguageListPID, wxT("PREF"), &ContactEditorData.GeneralLanguageListPref, wxT(""), &ContactEditorData.GeneralLanguageListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.HomeLanguageList.begin(); iter != ContactEditorData.HomeLanguageList.end(); ++iter){ ProcessSaveData(wxT("LANG;TYPE=home"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.HomeLanguageList, &ContactData, wxT("ALTID"), &ContactEditorData.HomeLanguageListAltID, wxT("PID"), &ContactEditorData.HomeLanguageListPID, wxT("PREF"), &ContactEditorData.HomeLanguageListPref, wxT(""), &ContactEditorData.HomeLanguageListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.BusinessLanguageList.begin(); iter != ContactEditorData.BusinessLanguageList.end(); ++iter){ ProcessSaveData(wxT("LANG;TYPE=work"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.BusinessLanguageList, &ContactData, wxT("ALTID"), &ContactEditorData.BusinessLanguageListAltID, wxT("PID"), &ContactEditorData.BusinessLanguageListPID, wxT("PREF"), &ContactEditorData.BusinessLanguageListPref, wxT(""), &ContactEditorData.BusinessLanguageListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.GeneralTZList.begin(); iter != ContactEditorData.GeneralTZList.end(); ++iter){ ProcessSaveData(wxT("TZ"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.GeneralTZList, &ContactData, wxT("ALTID"), &ContactEditorData.GeneralTZListAltID, wxT("PID"), &ContactEditorData.GeneralTZListPID, wxT("MEDIATYPE"), &ContactEditorData.GeneralTZListMediatype, wxT("PREF"), &ContactEditorData.GeneralTZListPref, wxT(""), &ContactEditorData.GeneralTZListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.HomeTZList.begin(); iter != ContactEditorData.HomeTZList.end(); ++iter){ ProcessSaveData(wxT("TZ;TYPE=home"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.HomeTZList, &ContactData, wxT("ALTID"), &ContactEditorData.HomeTZListAltID, wxT("PID"), &ContactEditorData.HomeTZListPID, wxT("MEDIATYPE"), &ContactEditorData.HomeTZListMediatype, wxT("PREF"), &ContactEditorData.HomeTZListPref, wxT(""), &ContactEditorData.HomeTZListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.BusinessTZList.begin(); iter != ContactEditorData.BusinessTZList.end(); ++iter){ ProcessSaveData(wxT("TZ;TYPE=work"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.BusinessTZList, &ContactData, wxT("ALTID"), &ContactEditorData.BusinessTZListAltID, wxT("PID"), &ContactEditorData.BusinessTZListPID, wxT("MEDIATYPE"), &ContactEditorData.BusinessTZListMediatype, wxT("PREF"), &ContactEditorData.BusinessTZListPref, wxT(""), &ContactEditorData.BusinessTZListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.GeneralGeographyList.begin(); iter != ContactEditorData.GeneralGeographyList.end(); ++iter){ wxString strGeoFinalValue = iter->second; ProcessCaptureStrings(&strGeoFinalValue); if (ContactEditorData.GeneralGeographyListDataType.find(iter->first) != ContactEditorData.GeneralGeographyListDataType.end()){ std::map::iterator DataTypeIter = ContactEditorData.GeneralGeographyListDataType.find(iter->first); strGeoFinalValue.insert(0, ":"); strGeoFinalValue.insert(0, DataTypeIter->second); } else { strGeoFinalValue.insert(0, "geo:"); } ProcessSaveData(wxT("GEO"), &strValue2, &boolValue2, &boolValue, &iter, &strGeoFinalValue, &ContactData, wxT("ALTID"), &ContactEditorData.GeneralGeographyListAltID, wxT("PID"), &ContactEditorData.GeneralGeographyListPID, wxT("MEDIATYPE"), &ContactEditorData.GeneralGeographyListMediatype, wxT("PREF"), &ContactEditorData.GeneralGeographyListPref, wxT(""), &ContactEditorData.GeneralGeographyListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.HomeGeographyList.begin(); iter != ContactEditorData.HomeGeographyList.end(); ++iter){ wxString strGeoFinalValue = iter->second; ProcessCaptureStrings(&strGeoFinalValue); if (ContactEditorData.HomeGeographyListDataType.find(iter->first) != ContactEditorData.HomeGeographyListDataType.end()){ std::map::iterator DataTypeIter = ContactEditorData.HomeGeographyListDataType.find(iter->first); strGeoFinalValue.insert(0, ":"); strGeoFinalValue.insert(0, DataTypeIter->second); } else { strGeoFinalValue.insert(0, "geo:"); } ProcessSaveData(wxT("GEO;TYPE=home"), &strValue2, &boolValue2, &boolValue, &iter, &strGeoFinalValue, &ContactData, wxT("ALTID"), &ContactEditorData.HomeGeographyListAltID, wxT("PID"), &ContactEditorData.HomeGeographyListPID, wxT("MEDIATYPE"), &ContactEditorData.HomeGeographyListMediatype, wxT("PREF"), &ContactEditorData.HomeGeographyListPref, wxT(""), &ContactEditorData.HomeGeographyListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.BusinessGeographyList.begin(); iter != ContactEditorData.BusinessGeographyList.end(); ++iter){ wxString strGeoFinalValue = iter->second; ProcessCaptureStrings(&strGeoFinalValue); if (ContactEditorData.BusinessGeographyListDataType.find(iter->first) != ContactEditorData.BusinessGeographyListDataType.end()){ std::map::iterator DataTypeIter = ContactEditorData.BusinessGeographyListDataType.find(iter->first); strGeoFinalValue.insert(0, ":"); strGeoFinalValue.insert(0, DataTypeIter->second); } else { strGeoFinalValue.insert(0, "geo:"); } ProcessSaveData(wxT("GEO;TYPE=work"), &strValue2, &boolValue2, &boolValue, &iter, &strGeoFinalValue, &ContactData, wxT("ALTID"), &ContactEditorData.BusinessGeographyListAltID, wxT("PID"), &ContactEditorData.BusinessGeographyListPID, wxT("MEDIATYPE"), &ContactEditorData.BusinessGeographyListMediatype, wxT("PREF"), &ContactEditorData.BusinessGeographyListPref, wxT(""), &ContactEditorData.BusinessGeographyListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.GeneralRelatedList.begin(); iter != ContactEditorData.GeneralRelatedList.end(); ++iter){ ProcessSaveData(wxT("RELATED"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.GeneralRelatedList, &ContactData, wxT("ALTID"), &ContactEditorData.GeneralRelatedListAltID, wxT("PID"), &ContactEditorData.GeneralRelatedListPID, wxT("LANGUAGE"), &ContactEditorData.GeneralRelatedListLanguage, wxT("TYPE"), &ContactEditorData.GeneralRelatedListRelType, wxT("PREF"), &ContactEditorData.GeneralRelatedListPref, wxT(""), &ContactEditorData.GeneralRelatedListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.GeneralWebsiteList.begin(); iter != ContactEditorData.GeneralWebsiteList.end(); ++iter){ ProcessSaveData(wxT("URL"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.GeneralWebsiteList, &ContactData, wxT("ALTID"), &ContactEditorData.GeneralWebsiteListAltID, wxT("PID"), &ContactEditorData.GeneralWebsiteListPID, wxT("MEDIATYPE"), &ContactEditorData.GeneralWebsiteListMediatype, wxT("PREF"), &ContactEditorData.GeneralWebsiteListPref, wxT(""), &ContactEditorData.GeneralWebsiteListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.HomeWebsiteList.begin(); iter != ContactEditorData.HomeWebsiteList.end(); ++iter){ ProcessSaveData(wxT("URL;TYPE=home"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.HomeWebsiteList, &ContactData, wxT("ALTID"), &ContactEditorData.HomeWebsiteListAltID, wxT("PID"), &ContactEditorData.HomeWebsiteListPID, wxT("MEDIATYPE"), &ContactEditorData.HomeWebsiteListMediatype, wxT("PREF"), &ContactEditorData.HomeWebsiteListPref, wxT(""), &ContactEditorData.HomeWebsiteListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.BusinessWebsiteList.begin(); iter != ContactEditorData.BusinessWebsiteList.end(); ++iter){ ProcessSaveData(wxT("URL;TYPE=work"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.BusinessWebsiteList, &ContactData, wxT("ALTID"), &ContactEditorData.BusinessWebsiteListAltID, wxT("PID"), &ContactEditorData.BusinessWebsiteListPID, wxT("MEDIATYPE"), &ContactEditorData.BusinessWebsiteListMediatype, wxT("PREF"), &ContactEditorData.BusinessWebsiteListPref, wxT(""), &ContactEditorData.BusinessWebsiteListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.GeneralTitleList.begin(); iter != ContactEditorData.GeneralTitleList.end(); ++iter){ ProcessSaveData(wxT("TITLE"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.GeneralTitleList, &ContactData, wxT("ALTID"), &ContactEditorData.GeneralTitleListAltID, wxT("PID"), &ContactEditorData.GeneralTitleListPID, wxT("LANGUAGE"), &ContactEditorData.GeneralTitleListLanguage, wxT("PREF"), &ContactEditorData.GeneralTitleListPref, wxT(""), &ContactEditorData.GeneralTitleListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.HomeTitleList.begin(); iter != ContactEditorData.HomeTitleList.end(); ++iter){ ProcessSaveData(wxT("TITLE;TYPE=home"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.HomeTitleList, &ContactData, wxT("ALTID"), &ContactEditorData.HomeTitleListAltID, wxT("PID"), &ContactEditorData.HomeTitleListPID, wxT("LANGUAGE"), &ContactEditorData.HomeTitleListLanguage, wxT("PREF"), &ContactEditorData.HomeTitleListPref, wxT(""), &ContactEditorData.HomeTitleListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.BusinessTitleList.begin(); iter != ContactEditorData.BusinessTitleList.end(); ++iter){ ProcessSaveData(wxT("TITLE;TYPE=work"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.BusinessTitleList, &ContactData, wxT("ALTID"), &ContactEditorData.BusinessTitleListAltID, wxT("PID"), &ContactEditorData.BusinessTitleListPID, wxT("LANGUAGE"), &ContactEditorData.BusinessTitleListLanguage, wxT("PREF"), &ContactEditorData.BusinessTitleListPref, wxT(""), &ContactEditorData.BusinessTitleListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.GeneralRoleList.begin(); iter != ContactEditorData.GeneralRoleList.end(); ++iter){ ProcessSaveData(wxT("ROLE"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.GeneralRoleList, &ContactData, wxT("ALTID"), &ContactEditorData.GeneralRoleListAltID, wxT("PID"), &ContactEditorData.GeneralRoleListPID, wxT("LANGUAGE"), &ContactEditorData.GeneralRoleListLanguage, wxT("PREF"), &ContactEditorData.GeneralRoleListPref, wxT(""), &ContactEditorData.GeneralRoleListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.HomeRoleList.begin(); iter != ContactEditorData.HomeRoleList.end(); ++iter){ ProcessSaveData(wxT("ROLE;TYPE=home"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.HomeRoleList, &ContactData, wxT("ALTID"), &ContactEditorData.HomeRoleListAltID, wxT("PID"), &ContactEditorData.HomeRoleListPID, wxT("LANGUAGE"), &ContactEditorData.HomeRoleListLanguage, wxT("PREF"), &ContactEditorData.HomeRoleListPref, wxT(""), &ContactEditorData.HomeRoleListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.BusinessRoleList.begin(); iter != ContactEditorData.BusinessRoleList.end(); ++iter){ ProcessSaveData(wxT("ROLE;TYPE=work"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.BusinessRoleList, &ContactData, wxT("ALTID"), &ContactEditorData.BusinessRoleListAltID, wxT("PID"), &ContactEditorData.BusinessRoleListPID, wxT("LANGUAGE"), &ContactEditorData.BusinessRoleListLanguage, wxT("PREF"), &ContactEditorData.BusinessRoleListPref, wxT(""), &ContactEditorData.BusinessRoleListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.GeneralOrganisationsList.begin(); iter != ContactEditorData.GeneralOrganisationsList.end(); ++iter){ ProcessSaveData(wxT("ORG"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.GeneralOrganisationsList, &ContactData, wxT("ALTID"), &ContactEditorData.GeneralOrganisationsListAltID, wxT("PID"), &ContactEditorData.GeneralOrganisationsListPID, wxT("LANGUAGE"), &ContactEditorData.GeneralOrganisationsListLanguage, wxT("SORT-AS"), &ContactEditorData.GeneralOrganisationsListSortAs, wxT("PREF"), &ContactEditorData.GeneralOrganisationsListPref, wxT(""), &ContactEditorData.GeneralOrganisationsListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.HomeOrganisationsList.begin(); iter != ContactEditorData.HomeOrganisationsList.end(); ++iter){ ProcessSaveData(wxT("ORG;TYPE=home"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.HomeOrganisationsList, &ContactData, wxT("ALTID"), &ContactEditorData.HomeOrganisationsListAltID, wxT("PID"), &ContactEditorData.HomeOrganisationsListPID, wxT("LANGUAGE"), &ContactEditorData.HomeOrganisationsListLanguage, wxT("SORT-AS"), &ContactEditorData.HomeOrganisationsListSortAs, wxT("PREF"), &ContactEditorData.HomeOrganisationsListPref, wxT(""), &ContactEditorData.HomeOrganisationsListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.BusinessOrganisationsList.begin(); iter != ContactEditorData.BusinessOrganisationsList.end(); ++iter){ ProcessSaveData(wxT("ORG;TYPE=work"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.BusinessOrganisationsList, &ContactData, wxT("ALTID"), &ContactEditorData.BusinessOrganisationsListAltID, wxT("PID"), &ContactEditorData.BusinessOrganisationsListPID, wxT("LANGUAGE"), &ContactEditorData.BusinessOrganisationsListLanguage, wxT("SORT-AS"), &ContactEditorData.BusinessOrganisationsListSortAs, wxT("PREF"), &ContactEditorData.BusinessOrganisationsListPref, wxT(""), &ContactEditorData.BusinessOrganisationsListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.GeneralNoteList.begin(); iter != ContactEditorData.GeneralNoteList.end(); ++iter){ ProcessSaveData(wxT("NOTE"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.GeneralNoteList, &ContactData, wxT("ALTID"), &ContactEditorData.GeneralNoteListAltID, wxT("PID"), &ContactEditorData.GeneralNoteListPID, wxT("LANGUAGE"), &ContactEditorData.GeneralNoteListLanguage, wxT("PREF"), &ContactEditorData.GeneralNoteListPref, wxT(""), &ContactEditorData.GeneralNoteListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.HomeNoteList.begin(); iter != ContactEditorData.HomeNoteList.end(); ++iter){ ProcessSaveData(wxT("NOTE;TYPE=home"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.HomeNoteList, &ContactData, wxT("ALTID"), &ContactEditorData.HomeNoteListAltID, wxT("PID"), &ContactEditorData.HomeNoteListPID, wxT("LANGUAGE"), &ContactEditorData.HomeNoteListLanguage, wxT("PREF"), &ContactEditorData.HomeNoteListPref, wxT(""), &ContactEditorData.HomeNoteListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.BusinessNoteList.begin(); iter != ContactEditorData.BusinessNoteList.end(); ++iter){ ProcessSaveData(wxT("NOTE;TYPE=work"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.BusinessNoteList, &ContactData, wxT("ALTID"), &ContactEditorData.BusinessNoteListAltID, wxT("PID"), &ContactEditorData.BusinessNoteListPID, wxT("LANGUAGE"), &ContactEditorData.BusinessNoteListLanguage, wxT("PREF"), &ContactEditorData.BusinessNoteListPref, wxT(""), &ContactEditorData.BusinessNoteListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.CategoriesList.begin(); iter != ContactEditorData.CategoriesList.end(); ++iter){ ProcessSaveData(wxT("CATEGORIES"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.CategoriesList, &ContactData, wxT("ALTID"), &ContactEditorData.CategoriesListAltID, wxT("PID"), &ContactEditorData.CategoriesListPID, wxT("TYPE"), &ContactEditorData.CategoriesListType, wxT("PREF"), &ContactEditorData.CategoriesListPref, wxT(""), &ContactEditorData.CategoriesListTokens ); ResetSaveProcessData(); } // Pictures. for (std::map::iterator iter = ContactEditorData.PicturesList.begin(); iter != ContactEditorData.PicturesList.end(); ++iter){ int intValueIndex = iter->first; std::map::iterator stdstriter; std::map::iterator enciter; striter = ContactEditorData.PicturesListPictureType.find(intValueIndex); enciter = ContactEditorData.PicturesListPicEncType.find(intValueIndex); ProcessSaveData(wxT("PHOTO"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.PicturesList, &striter, &enciter, &ContactData, wxT("ALTID"), &ContactEditorData.PicturesListAltID, wxT("PID"), &ContactEditorData.PicturesListPID, wxT("TYPE"), &ContactEditorData.PicturesListType, wxT("PREF"), &ContactEditorData.PicturesListPref, wxT(""), &ContactEditorData.PicturesListTokens); ResetSaveProcessData(); } ResetSaveProcessData(); // Logos. for (std::map::iterator iter = ContactEditorData.LogosList.begin(); iter != ContactEditorData.LogosList.end(); ++iter){ int intValueIndex = iter->first; std::map::iterator stdstriter; std::map::iterator enciter; striter = ContactEditorData.LogosListPictureType.find(intValueIndex); enciter = ContactEditorData.LogosListPicEncType.find(intValueIndex); ProcessSaveData(wxT("LOGO"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.LogosList, &striter, &enciter, &ContactData, wxT("ALTID"), &ContactEditorData.LogosListAltID, wxT("PID"), &ContactEditorData.LogosListPID, wxT("TYPE"), &ContactEditorData.LogosListType, wxT("PREF"), &ContactEditorData.LogosListPref, wxT(""), &ContactEditorData.LogosListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); // Sounds. for (std::map::iterator iter = ContactEditorData.SoundsList.begin(); iter != ContactEditorData.SoundsList.end(); ++iter){ int intValueIndex = iter->first; std::map::iterator stdstriter; std::map::iterator enciter; striter = ContactEditorData.SoundsListAudioType.find(intValueIndex); enciter = ContactEditorData.SoundsListAudioEncType.find(intValueIndex); ProcessSaveData(wxT("SOUND"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.SoundsList, &striter, &enciter, &ContactData, wxT("ALTID"), &ContactEditorData.SoundsListAltID, wxT("PID"), &ContactEditorData.SoundsListPID, wxT("TYPE"), &ContactEditorData.SoundsListType, wxT("PREF"), &ContactEditorData.SoundsListPref, wxT(""), &ContactEditorData.SoundsListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.CalendarList.begin(); iter != ContactEditorData.CalendarList.end(); ++iter){ ProcessSaveData(wxT("CALURI"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.CalendarList, &ContactData, wxT("ALTID"), &ContactEditorData.CalendarListAltID, wxT("PID"), &ContactEditorData.CalendarListPID, wxT("MEDIATYPE"), &ContactEditorData.CalendarListMediatype, wxT("TYPE"), &ContactEditorData.CalendarListType, wxT("PREF"), &ContactEditorData.CalendarListPref, wxT(""), &ContactEditorData.CalendarListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.CalendarRequestList.begin(); iter != ContactEditorData.CalendarRequestList.end(); ++iter){ ProcessSaveData(wxT("CALADRURI"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.CalendarRequestList, &ContactData, wxT("ALTID"), &ContactEditorData.CalendarRequestListAltID, wxT("PID"), &ContactEditorData.CalendarRequestListPID, wxT("MEDIATYPE"), &ContactEditorData.CalendarRequestListMediatype, wxT("TYPE"), &ContactEditorData.CalendarRequestListType, wxT("PREF"), &ContactEditorData.CalendarRequestListPref, wxT(""), &ContactEditorData.CalendarRequestListTokens ); ResetSaveProcessData(); } ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.FreeBusyList.begin(); iter != ContactEditorData.FreeBusyList.end(); ++iter){ ProcessSaveData(wxT("FBURL"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.FreeBusyList, &ContactData, wxT("ALTID"), &ContactEditorData.FreeBusyListAltID, wxT("PID"), &ContactEditorData.FreeBusyListPID, wxT("MEDIATYPE"), &ContactEditorData.FreeBusyListMediatype, wxT("TYPE"), &ContactEditorData.FreeBusyListType, wxT("PREF"), &ContactEditorData.FreeBusyListPref, wxT(""), &ContactEditorData.FreeBusyListTokens ); ResetSaveProcessData(); } for (std::map::iterator iter = ContactEditorData.KeyList.begin(); iter != ContactEditorData.KeyList.end(); ++iter){ intValue2 = iter->first; // Get the key information. std::map::iterator enciter; striter = ContactEditorData.KeyListDataType.find(intValue2); //enciter = KeyListAudioEncType.find(intValue2); wxString strValueData; strValueData = iter->second; strValueData.insert(0, wxT("data:") + striter->second + wxT(";base64,")); ProcessSaveData(wxT("KEY"), &strValue2, &boolValue2, &boolValue, &iter, &strValueData, &ContactData, wxT("ALTID"), &ContactEditorData.KeyListAltID, wxT("PID"), &ContactEditorData.KeyListPID, wxT("TYPE"), &ContactEditorData.KeyListType, wxT("PREF"), &ContactEditorData.KeyListPref, wxT(""), &ContactEditorData.KeyListTokens ); ResetSaveProcessData(); } // Vendor specific items. ResetSaveProcessData(); for (std::map::iterator iter = ContactEditorData.VendorList.begin(); iter != ContactEditorData.VendorList.end(); ++iter){ intValue2 = iter->first; // Get the IANA PEN number. striter = ContactEditorData.VendorListPEN.find(intValue2); if (striter->first == intValue2){ strValue2 = striter->second; } // Get the element name. striter = ContactEditorData.VendorListElement.find(intValue2); if (striter->first == intValue2){ strValue3 = striter->second; } // Get the address. striter = ContactEditorData.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::iterator iter = ContactEditorData.XTokenList.begin(); iter != ContactEditorData.XTokenList.end(); ++iter){ intValue2 = iter->first; // Get the element name. striter = ContactEditorData.XTokenListTokens.find(intValue2); if (striter->first == intValue2){ strValue2 = striter->second; } // Get the address. striter = ContactEditorData.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 (ContactEditorData.FullNamesList.size() == 0){ wxString FullName = cmbDisplayAs->GetValue(); ContactEditorData.FullNamesList.insert(std::make_pair(0, FullName)); 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(""))); FNFirst = FALSE; } for (std::map::iterator iter = ContactEditorData.FullNamesList.begin(); iter != ContactEditorData.FullNamesList.end(); ++iter){ if (FNFirst == TRUE){ iter->second = cmbDisplayAs->GetValue(); FNFirst = FALSE; } std::map::iterator mapS; mapS = ContactEditorData.FullNamesListTokens.find(iter->first); ProcessSaveData(wxT("FN"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.FullNamesList, &ContactData, wxT("ALTID"), &ContactEditorData.FullNamesListAltID, wxT("PID"), &ContactEditorData.FullNamesListPID, wxT("TYPE"), &ContactEditorData.FullNamesListType, wxT("LANGUAGE"), &ContactEditorData.FullNamesListLanguage, wxT("PREF"), &ContactEditorData.FullNamesListPref, wxT(""), &ContactEditorData.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"), ContactEditorData.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::iterator gniter = ContactEditorData.GeneralNicknamesList.begin(); gniter != ContactEditorData.GeneralNicknamesList.end(); gniter++){ ucd->ContactNickname = gniter->second; break; } wxCommandEvent event2(CE_UPDATECONTACTLIST); event2.SetClientData(ucd); wxPostEvent(MainPtr, event2); } void frmContactEditor::SaveCloseContact( wxCommandEvent& event ) { // Save the updated contact data and close the form. wxCommandEvent NullEvent; this->SaveContact(NullEvent); this->Close(); }